2021-10-11

What is Proof of Work (PoW)?


If you have read articles on blockchain technology and cryptocurrency, there is a great possibility that you have come across plenty of technical terms including consensus mechanism and proof of work. But what is proof of work? What do we proof? What work are we doing?

For beginners, blockchain technology may sound straightforward; there are blocks that keep all the data and there are chains that connects all the blocks. The blocks’ integrity and security are maintained by the nodes in the blockchain network, making the whole system decentralised. However, how does the network know which nodes are honest and which nodes are malicious?

It is possible that some nodes are dishonest and would tamper with the data in the blocks, but how does blockchain technology fends off such attack?

Such attack on a network is kept off by a byzantine fault tolerance system. The network is protected by a consensus mechanism among the honest nodes, and one of the mechanisms is proof of work. In this article, we will delve into the history of the proof of work, its underlying fundamentals, and its application in the bitcoin network.

bitcoin
 
 

History

 

Proof of work was not invented in 2008 by Satoshi Nakamoto. In fact, it has been introduced much earlier to deal with spam emails and denial of service attack (DoS attack). In spam email for example, the sender is required to do some work before the email is allowed to go through. As such, spammers will need to spend expensive computational power to send thousands of emails, but for a genuine sender, it will require them only minuscule amount of energy to send an email. Hashcash was also another proof of work system used to prevent email spam and DoS attack. It was introduced in 1997.

Bitcoin

 

In bitcoin network, the blocks are created through mining by the miners. Each block keeps all the transaction data when the respective block is mined. To mine a block, miners must solve cryptographic puzzles, in which the miners must find a particular hash value (string of letters and numbers) with certain number of zero in front of it. Once a miner has found the correct hash value, the state of the block will be announced to all miners to verify the hash value. After the verification, the block will be chained to the previous block and the miners will continue mining new blocks.

Miners must spend a lot of electrical energy to solve the cryptographic puzzles. Therefore, once the miners have successfully mined a block, they have proved that work has been done to solve the cryptographic puzzle. Successful miners are rewarded with bitcoins as an incentive for the work that they have done. Since solving such puzzles require massive computational power, the mining process take huge toll on electrical consumption. Other miners who did not manage to solve the puzzle would have wasted energy, and as such would incur losses.

btc mining
 

Tampering blockchain

 

To understand the immutability of a blockchain, we analyse from the perspective of an attacker node. Let say we want to double spend our bitcoins (transfer the same bitcoin more than once at the same time). To do so, we cannot tamper the currently mined block since other miners would notice and would nullify such transaction. So, a better approach is tampering some blocks that are already in the chain. Once we try to tamper a block in the chain, it would significantly alter the subsequent block due to the avalanche effect. Therefore, other miners would notice such change, and nullify any attempt to include that change into the blockchain. The only way we can successfully tamper the block and successfully include in the blockchain is to mine all the subsequent blocks before other nodes mine one new block. Such attempt is only possible if we control most of the nodes, which is a very expensive task.

Honest and Dishonest Nodes
 

Forking blockchain

 

It is possible that two blocks or more are mined at almost the same time. In this case, we would have a fork in the blockchain. Such forking would cause massive disruptions to the transactions in the block. To solve the forking problem, all nodes need to choose the longest chain in the fork and abandon any other chains.

There are cases where the fork is done permanently. Such situation would require some nodes to agree on the forked chain, and such fork is known as hard fork. An example of hard fork is the Bitcoin Cash (BCH).

forking
 

Confirming transaction

 

In a traditional online transaction, a buyer sends his money from his bank account to the seller’s bank account. This transaction is recorded by the banks and once the banks confirmed that the transaction has been performed, both sides can agree that the transaction has indeed been confirmed. However, in blockchain, we do not have a third party such as the bank to confirm our transaction. So, how can both the buyer and seller agree that the transaction has gone through?

This is where the Proof of Work comes into play. Once a transaction has been recorded, both parties wait for the block to be mined. Once the block has been mined, they know that their transaction has gone through. However, there is a possibility that another block has also been mined at the same time which does not record their transaction. To circumvent this problem, they can wait for more blocks to be mined and observe which chain is the longest. Since the node will continue mining the longest chain and drop any other shorter chains, both parties can agree whether their transaction has gone through or has not. The proof of work helps in ensuring that no tampering on the transaction is possible because it would require extremely large computational power to mine the subsequent blocks.

Drawbacks

 

Even though Proof of Work sounds appealing in many aspects, it has its drawbacks. The biggest is energy consumption and waste. Since all the nodes must work on mining new blocks, all of them would consume large amount of energy. However, energy is also wasted since only one block is accepted at a time.

Another imperfection in Proof of Work is that the transaction process is long. This is due to the long wait-time to confirm the transaction as mentioned previously. This leads to scalability issue. At the global scale, transaction happens at an extremely high rate and in large volume at a time.

To account for the issues with Proof of Work, blockchain developers began searching for other consensus mechanisms.