Proof-of-Work is the algorithm that regulates the consensus process underlying Bitcoin mining: what it is and how it works.
The first use of Proof of Work dates back to 1997 when Adam Back decided to implement it in the Hashcash project. The goal was to prevent denial-of-service (DoS) attacks and email spam.
In 2004, Hal Finney, a cypherpunk and creator of PGP 2.0, introduced Reusable Proofs of Work (RPOW), which made the HashCash proof of work transferable, enabling the creation of a digital currency based on proof-of-work that could be exchanged among users for the first time. The application of this idea would be crucial for the subsequent development of Bitcoin.
Proof-of-Work requires proof that a certain amount of ‘work,’ in terms of energy and technological resources, has been performed to gain the right to add a block to the Bitcoin blockchain and thus receive a monetary reward known as a block reward. This dynamic is in stark contrast to the fiat currency system, where money can be created without any associated cost based on decisions made by central banks.
To understand in detail how to obtain the right to write a block on the blockchain, refer to the in-depth feature on mining.
How it works?
In order to add a block to the blockchain, miners compete with each other in a global challenge that can be likened to a continuous roll of dice. To write a block, it is necessary to find the correct Proof-of-Work, the solution to a mathematical problem that becomes more difficult as the computational power on the network increases.
Miners are required to find a number called a nonce, which, together with the hash of the last mined block after applying the SHA-256 mathematical function, produces a hash lower than a certain limit set by the nodes of the network. There is no mathematical formula to immediately find the solution. The only way is to make as many attempts as possible until a compatible value is found. While theoretically these attempts can be done manually (as demonstrated in this video), they are carried out with machines known as ASICs, equipped with highly specialized chips.
To calculate the required solution, ASIC machines perform functions called hashing: they try all possible combinations until a miner finds the correct value. The process repeats approximately every 10 minutes.
The more hashing functions, meaning more attempts a miner can perform in the shortest possible time, the more likely they are to find the solution before others and thus write the new block of the blockchain.
Once the solution is found, the miner transmits the block to neighboring nodes, which, in turn, share it with their peers through the gossip protocol until the block reaches all nodes in the network. The network can then cryptographically verify the work done by the miner: if the block is considered valid by the rest of the nodes on the network, it is added to the blockchain, and the miner receives the block subsidy as a reward, in addition to the fees from all transactions contained in the block.
Difficulty adjustment
The difficulty required to solve the mathematical problem is managed in such a way as to ensure that each new block is found on average every 10 minutes. Every 2,016 blocks, approximately two weeks, the difficulty parameter is adjusted by the nodes of the network based on the time taken to mine the previous 2,016 blocks. As the hashrate on the network increases, the difficulty increases proportionally, and vice versa. The variation of difficulty is called difficulty adjustment.
It is important to note that if the difficulty of the puzzle remained constant, with an increase in hashrate, the solution would be found in less time, resulting in the issuance of more bitcoin. Conversely, with a decrease in computing power, fewer blocks would be mined, and consequently, fewer bitcoin would be produced.
More computing power = more security
The Proof-of-Work represents the cryptographic proof that a miner has completed the necessary work to find a hash compatible with the difficulty established by the nodes. The winning hash becomes the hash of the just-mined block and will serve as the starting point for the subsequent verification of the Proof-of-Work for the next block. This process creates a chain, where the hash of each block is derived from the hash of the previous block, plus the nonce. This means that to modify a particular block, one would need to violate all the blocks that follow it, progressively increasing the computational power required to attack the Bitcoin network. By convention, a block is considered inviolable when it has at least five blocks in front of it (the sixth-to-last block).
The Bitcoin network is protected by the computational power used to find the Proof-of-Work of the blocks. If the difficulty required for mining each block increases, the security of the network also increases. The higher is the hashrate on the network, the greater is the security of Bitcoin.