Bitcoin’s Blockchain Consensus Mechanism
This write-up is meant to give a basic understanding of how Bitcoin’s Consensus Mechanism known as Proof-of-Work, works. The notion is explained in a macro sense without in-depth technicality that might confuse beginners.
Background
In a traditional sense of money, everything is regulated by a central bank or government. People put their trust into banks and governments to take care of their money — this means that fundamentally, the current monetary system is predicated on trust. These trusts give values into our day-to-day currency such as the USD, GBP, etc.
Blockchain itself is a digital, decentralized, and public ledger that keeps record of transaction/values exchange. With the implementation of blockchain technology to create a cryptocurrency (Bitcoin), it allows people to exchange monetary values in a trust-less system without a central authority figure. The foundation that allows such a system to work is called the Consensus Mechanism.
Consensus Mechanism
Consensus Mechanism is a method to achieve a decision-making process that allows a group to reach an agreement that benefits the entire group. It promotes collaboration, cooperation and participation within a group for the method to be effective.
To understand the difficulty of reaching a consensus within a peer-to-peer decentralized currency system, there is a problem that must be explained, called the Byzantine Generals Problem (BGP). In short, it is a problem on how to ensure that, without an authority figure or a third party, the information within a system is not compromised or tampered while being transferred — aka how do one achieve a trust-less system that will enforce a positive consensus for the benefit of the population.
Proof-of-Work
To solve this problem, Bitcoin utilizes a consensus mechanism called Proof-of-Work (PoW). In a blockchain network where decentralized ledgers keep track of all the transactions data into blocks, it needs a method to confirm the legibility of these transactions and to arrange the blocks in the right manner. After all, if multiple ledgers keep track of all the transactions, how do we know that a particular ledger is true? How can we ensure that it has not been tampered by a violent actor?
This responsibility belongs to the people that are called “Miners”. Miners are essentially in charge of special nodes to ensure that the blockchain network keeps on functioning. Miners verify the legibility of a transaction and append it to the blockchain. They do this by solving a complex mathematical problem that takes a lot of a computational power to solve. Bitcoin utilizes a puzzle called Hashcash. It is an algorithm that adjust the difficulty of the puzzle based on the total power of the network.
The algorithm ensure that it will take approximately 10 minutes per block generation in order to maintain scarcity, an intrinsic element that a currency must have to work in a society. After solving the mathematical puzzle, the block is then checked/verified to see whether it belongs to the chain or not. This process is extremely simple so that all nodes are capable of checking whether the solution is correct. It is a very crucial aspect of the PoW because if not all nodes are capable of checking for the right solution, then trusts must be put into some of the nodes that are able to solve it, which means that the system is not trust-less.
How PoW Works
PoW algorithm works by first appending a nonce, which is an arbitrary number that can only be used for one time in a cryptographic setting. It will then hash the text that has been appended with the nonce to get the result. The miner that first finds the next correct hash, meaning that the hash conditions are satisfied, will be given the right to add a new block of the transaction to the blockchain.
What’s great about Bitcoin’s PoW algorithm is that it utilizes cryptographic has functions, which are one-way functions. In simple words, it forces a miner to use brute-force method to find the solution, trying every possible outcome one by one without any pattern/clue that might lead to the solution. Moreover, the algorithm adjusts the difficulty of the problem to ensure that 1 bitcoin takes around 10 minutes to mine, by adding or reducing zeros to the beginning of the output, which essentially makes them problem exponentially more difficult to solve. On the contrary, checking for the right solution is fairly simple; append the message with the correct nonce, hash it, and then check whether it matches or not.
Pros and Cons of PoW
Bitcoin’s PoW ensures that it will be safe from DoS attacks. Theoretically, it is possible to launch a DoS attack to the Bitcoin network. However, the overhead cost, time, and computational power will be extremely high up to the point that it does not make sense to launch the attack as it will not benefit the violent actor at all. Moreover, if the attack is successful, the entire system will know, and it will only plummet the price of Bitcoin, which will not benefit the attacker.
Although Bitcoin’s PoW solves the BGP, it requires an immense computational power and energy, which means that the overhead cost is extremely high as the problem gets more complex with its growing user. This large cost allows groups with greater financial ability to acquire more mining rig. This problem has caused Bitcoin’s mining to be more centralized, with more than 50% of the system controlled by 5 combined mining groups.