Proof of work is one of the most important consensus mechanisms. It was first ideated in 1993 to help combat service abuse such as spam and was officially termed as Proof of Work in 1997. It was still heavily unused till Satoshi Nakamoto invented Bitcoin which used the mechanism to create consensus between peers on the network and used it as a way to secure the Bitcoin blockchain. This mechanism functions by measuring the work generated to determine the probability of receiving a reward. The larger the work output the larger the chances of getting a reward. It is understood as proof of a certain amount of work is done and can be easily verified by checking the end results.

Under this mechanism, the miners can add the block to the blockchain by winning the race to solve a rigorous cryptographic puzzle. The most common puzzle used is to find that the hash of the block is lesser than a certain target hash value. The difficulty to add the block depends upon this value. Hash of the addition of previous block hash, current block hash, timestamp, the nonce (the random number we discussed earlier in the architecture), and the transactions is required to be lesser than the target hash value. The probability of solving the puzzle increases with the number of times the block is hashed with different nonce values, but it doesn’t affect the probability of solving future puzzles. Thus, computational power and difficulty to solve each block are independent and almost the same. There may be conflicts when multiple miners will create blocks at the same time. Under these circumstances, the Bitcoin’s blockchain follows the ‘Longest Chain Rule’. If a user refuses to accept the addition of the new block, this means he is not complying with the ‘longest chain rule’. If there is any block that doesn’t agree to the solution of this puzzle, that block will be straightly rejected. Each and every time the block is added to the blockchain, the current state of the entire blockchain is verified since all blocks are connected to each other.

Below is an example to demonstrate the PoW mechanism. Let’s consider a text string ‘WhooshUTD’ which is affixed with a nonce value. Let’s consider the puzzle wants us to have the hash function ‘WhooshUTD(Nonce)’ to start with 5 0s.

SHA256(“CoinDCXisbest” + Nonce) = Hash Value starting with “00000”

To make this puzzle easy, we are considering the nonce value (which is a random number) to increase linearly.

SHA256(“Cosmexisbest0”) = 0x97ypt8m8o7wo8p1wwyzbxm15jobh4n04l4jkjvix8kbmfj91ne2aqtlgomnygtsr (not solved)

SHA256(“CosmexX1”) =

0xi5sd6acdjsdaeehnsoib8l5h89d2q8pe3oyfo0jxymd3q1g8v5ptglhu0kmwji1s (not solved)

SHA256(“Cosmexisbest21025484”) =

0x00000ec6582390c1203c157614bc8ca60bb6be1a8c805777c604bc5403a264c8 (solved)

This puzzle was solved in 21,025,484 attempts.

It is clearly evident that solving the puzzle is extremely difficult but verifying the solution is easy since only a single hash needs to be generated to see if it solves the puzzle. This feature helps all the mining nodes to participate in the consensus process. This means there is no single node that has more power or authority than other nodes to add a block. All nodes are equal in this system and this makes PoW mechanism extremely decentralized.  It is also evident that the process to provide consensus is extremely repetitive, therefore, the cost and difficulty to mine the block increases with time and participants in the network. If malicious users want to hack/infect the blockchain, they need to consensus to the attack by affecting at least 51% of the blockchain, making the attack greatly expensive. This makes the mechanism extremely secure and irrefutable.

The probability of the miner being chosen to update the next block is determined by the computing power a miner controls. For example. If a miner controls 20% of the network power, the probability of him winning is 20%. The more computing power the more the chances of obtaining a new Bitcoin.

But this leads to a situation where people started building larger and larger mining farms. POW gives more rewards to people with better and more mining equipment. The higher the hash rate, the more the chance that you will get to create the next block and get a reward. To increase their chances, miners are coming together and form mining pools. They combine their hashing power and distribute the reward amongst them equally.