Bitcoin Magic
Bitcoin

Bitcoin Magic

Here are some of the innovations and concepts brought by Bitcoin (I will omit the details and change a bit the terminology to try to make it more approachable). It’s meant for people who know the basics of Bitcoin but want to know how it works underneath.

  1. Let’s start from bitcoin transactions: basically as you know there is some chain of nodes called a “blockchain” and when a transaction is made it’s supposed to somehow be added to the blockchain. So how is it done? Each node in the blockchain contains more than one transaction, so when a transaction is made and its transmitted to the bitcoin network, the transaction details together with other pending transactions are transformed into the desired form and a random number is added to the output and now there is another transformation which takes all this as input and returns as a result a number which is supposed to start with let’s say 20 zeroes. If it does not start with 20 zeroes then another random number is taken and the transformation with the new number is tried again and once again the result should start with 20 zeroes and if it doesn’t then the process continues with other random numbers until finally the result will start with 20 zeroes. How long will it take to find the correct random number? A lot of time. What do you get for finding the correct number? 12.5 bitcoins! That’s called mining. If the demand is increased from 20 zeroes to lets say 30 zeroes then the time to find the correct number will increase. The bitcoin network maintains the zeroes length (mining difficulty) in a way so that to mine a new node into the blockchain will keep taking the same number of hours even if the technology used by the miners gets improved (see: https://bitcoinwisdom.com/bitcoin/difficulty ). This leads to a race and these days only a specific hardware designed for mining (ASIC) can be fast enough to have a good chance of succeeding, see: https://en.bitcoin.it/wiki/Mining_hardware_comparison.
  2. After the mining succeeds the node is added to the blockchain and all the bitcoin network is informed about the new node. The new node includes the “address” of the previous node. Modifying a node requires again finding the magic number which gives the result with the zeroes and thus it takes a lot of time to modify a node and also a modified node “address”(=hash) changes. Thus if a node is modified and it has a child then to keep the blockchain valid the parent address inside the child needs to be modified which requires modifying the child and calculating the magic number for the son and if the son has a son of its own then it needs to be modified too and so on for all the chain under the modified node. This makes it practically impossible to modify a node once it has enough children. This is the first magic of the bitcoin. When a transaction is added to a node in the blockchain it is considered to have 1 confirmation and each son added to the chain under the transaction node is adding to the confirmation number of the transaction. Thus when you make a transaction you usually need to wait for about 6 confirmations before the sent money can be used by the receiver because as I explained after 6 layers, the chance the transaction will be manipulated are too slim.
  3. What is a bitcoin address and why do you need to keep your wallet safe? The bitcoin blockchain is based on public key cryptography. What does it mean? There are pairs of public key and private key where the bitcoin address is derived from the public key and can be publicly displayed, while the private key is a secret which is saved inside your wallet and which is used to get access to your coins. How can you have many addresses in your wallet? your wallet just generated a new pair of private and public keys for each address and saves them. One would think that the different addresses point to the same “balance” but its not actually right. Each address is independent and your wallet and the bitcoin network can perform a calculation which can calculate how much coins each address has and then the wallet sums it up and it can display the total sum of coins from all addresses in your wallet.
  4. How is a bitcoin address balance being calculated? Each transaction is specifying how coins move from previous transaction to a target address or addresses. That’s right, previous transaction! Not source address. That’s another “trick” of the bitcoin concept. If you look at previous transaction, it has the current sender address as the destination address which proves that the sender actually has the money he wants to send since he received them in the previous transaction! But to actually prove that the previous transaction is to his address and not to someone else he uses the magic of public key cryptography and he must have his private key. That’s why you must have your private key to send coins. You don’t need it to receive coins.

Leave your thought here