The process of building bitcoin blockchain through Proof of Work.
Miners verify the authenticity of each transaction, add them into blocks and build bitcoin blockchain. This mechanism through which miners verify the transaction is known as Proof of Work.
What is Bitcoin Mining?
In our last guide on Cryptoinstitution, we learned how miners perform the act of verifying the authenticity of each transaction. Verification or authentication of a bitcoin transaction includes the following:
- If the bitcoins are not used before. i.e. bitcoins are not double spent
- If the payee actually holds the amount of bitcoin that he is transferring
- Ensuring that the transaction gets included in the bitcoin public ledger
After verifying legit transactions, miners put them into blocks. Later these blocks are added to the existing blockchain. In return, the miners receive a block containing bitcoins, as a reward. This whole process is known as Bitcoin Mining.
The protocol through which miners verify bitcoin transactions and spend computing power is called Proof of Work. As such, the procedure is automated inside the bitcoin network.
What is Proof of Work in Bitcoin?
Technically, while verifying transactions, miners solve computational mathematical problems. These problems are solved by using a cryptographic hash.
The brief of the Proof of Work process is this:
Miners compete in finding the correct or the targeted hash value (as defined by the bitcoin network). In order to find the hash value, miners have to solve computational problems. To solve computational problems, miners have to verify legit transactions.
The one miner who correctly finds the value of hash is rewarded a block of bitcoin.
Did you see how a complete circle is formed in the network with each role and rewards, in place?
Miners solve problem-verify transaction- build blockchain- receive rewards- bitcoin blockchain is maintained- new bitcoins are released.
Using Hash Function for Proof of Work
Let’s dig deeper into technical details.
A hash function takes data as input (which can be of any size) and produces a fixed-length output of the corresponding input. Meaning, a hash function can be used to compress a data, no matter what size, to produce the desired output which is known as ‘Hash’.
It is important to note that even the slightest change in the input would produce an entirely different output.
For example, we can convert this whole document into a hash and by even changing one comma, would produce an entirely different value of the hash. Also, it is impossible to have the same values for two hash, even when the inputs are slightly different.
Take a look at this graphic
You can see that the only difference in the two sentences is a question mark (?) added after Aman. However, the hash function produces an entirely different result
This characteristic of hash ensures the authenticity of the data. If any transaction is even slightly manipulated, the entire hash of that block is bound to change.
Components of a Block in Blockchain
Each block in bitcoin blockchain has a set of markers.
A block contains its own hash value, the hash of the previous block, timestamp and a nonce.
The block contains the hash of the previous block so as to tie the blocks together in a blockchain. The first block mined by Satoshi Nakamoto is known as the ‘Genesis Block’. The block succeeding it contains the hash of genesis block. The chain continues.
Another marker that this block contains is a time-stamp i.e. the exact time when the block is included to the blockchain. Additionally, it also has all the transactions that have been processed in the past 10 minutes. Lastly, with all of the input added together, produces the block’s own value of hash.
Even if a single transaction on that block is tampered with, the hash of that particular block as well as all the blocks succeeding it will entirely change.
Nonce in a Blockchain
Miners solve mathematical puzzles in order to include their block in the bitcoin blockchain and receive rewards.
Now the computational puzzle is that each miner has to produce a hash value. This hash value has to be lower than the target hash value (as decided by the bitcoin network). For producing the targeted hash value, miners combine hash of the previous block, transactions happened within past 10 minutes and nonce (a variable).
A nonce is a number which is used for producing a targeted value of the hash.
Miners need to find a specific value of nonce such that when combined with all data of the block, will produce a value of hash that meets target requirements.
Miners keep on changing the value of nonce until the correct value or the target value of hash is obtained. One miner finds this required result of hash. Consequently, that miner’s block gets added to the blockchain. In return, that miner receives the block containing bitcoins.
Once the transaction is confirmed and added to the blockchain, it is impossible to reverse, retrieve or modify the transaction. If the transaction is complete there is no way to retrieve the bitcoins back (unless the opposite party decides to return it back.