Cryptopedia
Proof of Work
Proof of Work (PoW) is an important blockchain consensus mechanism that makes each node reach an agreement that one node has the right to add a new block to the blockchain. Also, it can be regarded as a way of mining; that is, the node which completes PoW has the chance to gain block reward and handling fees.
PoW works through hashing a rational value: the data of the block header will be put into the hash function and the nonce of it will be continuously tuned till a hash value that is lower or equal to Target comes out. This process requires abundant calculation, which is the principle of PoW. In short, any node that has stronger computational power gets a bigger opportunity to add a new block to the blockchain and win a bitcoin reward.
Currently, the BTC blockchain is using PoW as the consensus mechanism. The procedures are as follows:
Before hashing, the verified transactions and the coinbase transaction that yields the reward will be packed into a candidate block by the miners. All the trading history in the candidate block will be calculated by Merkle Tree algorithm and the results of it is called Merkle Root Hash. Merkle Root Hash, Version, Prev Hash, Timestamp, Bits and Nonce compose the block header.
The miners will put the block header data into SHA256, in which the nonce will be continuously tuned until a hash value that is smaller or equal to Target comes out.
SHA256(SHA256( Version + Prev_Hash + Timestamp + Bits + Nonce))<= Target
After finishing PoW, the node will propagate the hash value and the candidate block to the whole network. Once the candidate block is validated by other nodes, it will be added to the blockchain.
Hash function, Block header and Bits jointly affect the calculation of PoW:
1. Hash Function
Hash function is a formula used in PoW. The hash function applied in the BTC blockchain is SHA256 that has extremely high security. Up till now, there has not been any effective attack on SHA256. Besides, the hash function requires an immense amount of calculation during the verification procedure, whilst the hash value can be easily validated by other nodes, both of which consist of a solid network that can’t be cheated by some bad nodes.
2. Block Header
Block header, metadata and the block transactions consist of a new block. Block header records the crucial information of the entire block and also stores the data that PoW needs. Except that the node itself needs to calculate Merkle Root Hash and tune the nonce, other data has already been provided.
3. Bits
Bits decides the difficulty for the miners to mine the next legal block. Generally, the bigger the Bits is, the larger the calculation and the longer time it needs to mine and vice versa. Bits will measure the computational power of the entire network and then instruct each node to have a self-tuning, ensuring that the time to yield a new block is within a fixed range. For instance, in BTC blockchain, the time to yield a new block is approximately 10 minutes, so to make sure the time of generating new blocks stays within 10 minutes when Network Hash Rate varies, Bits have to adjust accordingly.
Target=0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
(The Biggest Bits/Bits)
The absolute decentralization of PoW brings safety and reliability. However, its substantial consumption of energy (electricity and hardware consumption) promotes the advent of other consensus algorithms. Despite that, PoW still plays a significant role in the consensus mechanisms of the blockchain.
PoW works through hashing a rational value: the data of the block header will be put into the hash function and the nonce of it will be continuously tuned till a hash value that is lower or equal to Target comes out. This process requires abundant calculation, which is the principle of PoW. In short, any node that has stronger computational power gets a bigger opportunity to add a new block to the blockchain and win a bitcoin reward.
Currently, the BTC blockchain is using PoW as the consensus mechanism. The procedures are as follows:
Before hashing, the verified transactions and the coinbase transaction that yields the reward will be packed into a candidate block by the miners. All the trading history in the candidate block will be calculated by Merkle Tree algorithm and the results of it is called Merkle Root Hash. Merkle Root Hash, Version, Prev Hash, Timestamp, Bits and Nonce compose the block header.
The miners will put the block header data into SHA256, in which the nonce will be continuously tuned until a hash value that is smaller or equal to Target comes out.
SHA256(SHA256( Version + Prev_Hash + Timestamp + Bits + Nonce))<= Target
After finishing PoW, the node will propagate the hash value and the candidate block to the whole network. Once the candidate block is validated by other nodes, it will be added to the blockchain.
Hash function, Block header and Bits jointly affect the calculation of PoW:
1. Hash Function
Hash function is a formula used in PoW. The hash function applied in the BTC blockchain is SHA256 that has extremely high security. Up till now, there has not been any effective attack on SHA256. Besides, the hash function requires an immense amount of calculation during the verification procedure, whilst the hash value can be easily validated by other nodes, both of which consist of a solid network that can’t be cheated by some bad nodes.
2. Block Header
Block header, metadata and the block transactions consist of a new block. Block header records the crucial information of the entire block and also stores the data that PoW needs. Except that the node itself needs to calculate Merkle Root Hash and tune the nonce, other data has already been provided.
3. Bits
Bits decides the difficulty for the miners to mine the next legal block. Generally, the bigger the Bits is, the larger the calculation and the longer time it needs to mine and vice versa. Bits will measure the computational power of the entire network and then instruct each node to have a self-tuning, ensuring that the time to yield a new block is within a fixed range. For instance, in BTC blockchain, the time to yield a new block is approximately 10 minutes, so to make sure the time of generating new blocks stays within 10 minutes when Network Hash Rate varies, Bits have to adjust accordingly.
Target=0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
(The Biggest Bits/Bits)
The absolute decentralization of PoW brings safety and reliability. However, its substantial consumption of energy (electricity and hardware consumption) promotes the advent of other consensus algorithms. Despite that, PoW still plays a significant role in the consensus mechanisms of the blockchain.