Blockchain technology continues to grip the hearts and minds of many bank boardrooms, but in order for this growing technology to really reach its true potential more effort needs to go into understanding it and educating the future economic and financial leaders of tomorrow. As such, it is important to explore the pivotal role that consensus mechanisms play within distributed ledger technology.
As always, it is first worth noting that we are talking about distributed ledger technologies as a whole, not just the bitcoin blockchain, but the term ‘blockchain’ will be used here to denote these collectively. A blockchain network is a distributed collection of nodes which can submit transactions to be added to a chain of blocks.
Transactions are grouped together in these blocks and miners race against each other to verify the block and thus have it added to the blockchain – an immutable chain of all previous the transactions. For their effort, the miners are rewarded with tokens – bitcoins, in the case of the bitcoin blockchain, and ether for the ethereum blockchain.
However, in order to verify the block, the miners must satisfy a consensus algorithm. The difficulty of this cryptographic function ensures that miners must expel a significant amount of energy in order to compete to verify the block and as such, this dissuades nefarious nodes from trying to dupe the system by introducing fraudulent transactions.
Furthermore, the consensus mechanism also allows other nodes to check the verified block and ensure a solution was found, thus helping the entire network reach a consensus about the state of the blockchain.
There are some important technical terms to understand the technology:
- Hash: A hash is a large amount of data represented as a smaller numeric value, usually written as a hexadecimal.
- Hash algorithm: This turns an arbitrarily large amount of data into a fixed-length hash. The same input will always produce the same hash but even a tiny change will create a vastly different output. This allows the cryptography to be one-way only, and non-deterministic.
- Nonce: A nonce is an arbitrary number.
- Block header: This is essentially the title of the block – a summary of the transactions included.
- Merkle tree: This is an iterative hash of block pairs which connects all previous blocks together and forms a complete chain of all blocks in the blockchain.
- Difficulty: The ‘difficulty’ represents the number of leading zeroes the hash result must have in order to be considered correct.
Proof of Work
Proof of work is the most common consensus mechanism and the one employed by the bitcoin blockchain. It is based on an algorithm and required miners to compete to find a nonce which produced a hash of specified difficulty.
Firstly, the miner must group transactions together into a candidate block – a typical block has approximately 2000 transactions in and is currently limited at 1MB in size. A debate rages on about whether this block size should be increased in order to meet the growing demands of transaction volumes.
However many argue that this violates the initial conditions as set out by blockchain creator Santoshi Nakamoto – a pseudonym for the mysterious creator who went into hiding in 2009 and whose identity has never been revealed.
Once the miner has a candidate block they take a hash from the block header, the hash of the previous block, the current time, the difficulty requirement and the roothash of the merkle tree and try adding different nonces until the output has the required difficulty.
It is worth noting that the current difficulty within the bitcoin blockchain is 392,963, 262, 344 therefore, on average, miners have to try 16 to the power of 392,963,262,344 nonces before they are successful.
As evident from the above very, very large number, searching for the current nonce takes a lot of computational power. This helps with the security of the network and ensures that miners very rarely confirm two concurrent blocks, thus reducing the likelihood of their ability to enter fraudulent transactions.
However, as mentioned in our second blockchain edition, the chance of a 51% attack is still possible – especially with the growing number of Chinese miners. This further increases as bitcoin rewards decrease over time (a hard coded requirement within the network) and therefore miners have less motivation to help maintain the network thus increasing network vulnerability.
We should also note that proof of work is exceptionally data hungry – the bitcoin blockchain consumes as much energy as the country of Ireland and due to the competitive nature of the mechanism, currently takes around 8 minutes for a block to be verified, thus introducing latency in the system.
However, for a completely untrusted, open network such as bitcoin, this consensus mechanism allows high security and confidence in the mining process. But we do have other options and the Ethereum network (another distributed ledger) has set its end goal on implementing Proof of Stake consensus.
Proof of Stake
It is first worth noting that only a handful of cryptocurrencies employ PoS consensus. Peercoin was the first and this was then followed by ShadowCash, Nxt, BlackCoin, NuShares, Quora and NavCoin.
Proof of Stake consensus differs from PoW in that miners do not need to compete against each other to solve the same computational problem, thus reducing energy inefficiencies within the network. Within PoS, miners must demonstrate they have a stake in the network and then can mint a comparable amount of transactions. For example, a miner with 3% of ether could mint 3% of the proof of stake blocks within the ethereum network.
Note here that blocks created using PoS are referred to as ‘minted’ not ‘mined’. In addition to this, and unlike PoW, miners are not rewarded but instead only receive the transaction fees, however as mining costs are comparably lower this does not disincentivise miners.
There are also two selection methods which help identify the next miner within the network. The first is a randomised block selector which operates similarly to a lottery and the second is a coin age-based selection in which the ‘coinage’ is derived from the number of coins times the number of days the coins have been held.
As such, when a miner submits their bid to mine the next block, they become part of a waiting list and their chance of being chosen increases with the length of time they have been waiting. The PoS consensus mechanism is purported to be more secure than PoW in that the cost of attacking the network would be significantly higher.
Where it’s estimated that a 51% attack on a PoW blockchain would cost $10m in rigging equipment, a PoS 51% attack would cost approximately $20m in cryptocurrency ownership. However, should the nefarious node then attack the network, confident in the cryptocurrency will fall, transaction volumes will decrease and they will undoubtedly reduce the value of their own cryptocurrency holdings?
Therefore damaging the network, in a PoS environment, damages the individual significantly. The potential use cases for this mechanism reach outside of the cryptocurrency world and include a modification of the identity verification system CAPTCHA in which users are required to send a specific amount of cryptocurrency to themselves, similar to SMS verification used to verify handset ownership.
For example, the user may be asked to send 0.00062735 BTC to themselves and this transaction can be publically viewed in the blockchain to ensure the sender’s wallet matches the details on record.
Ripple Consensus Mechanism
A third consensus method is within the Ripple distributed ledger, the third biggest cryptocurrency by market cap. This works by each node first selecting a list of validators which it believes will not collude together. This list is called the Unique Node List and is recommended to be at least 1,000 validators from five different continents, spread across a number of industries.
Owing to the fact that there are pairs of enemies, the likelihood of collision is low and thus if they can all reach consensus the probability of the transactions being valid is high.
This can be an arbitrary choice as if a validator is found to be nefarious, it can be easily spotted and removed from the UNL. Thus any future attestations from that validator can be ignored.
The node then creates a candidate set of transactions which it will check against other candidate lists (called proposals) which are received from the network. Any proposals received from a validator, not on the node’s UNL are automatically rejected but those from verified validators are checked to see whether they are from the candidate set.
Those which are, have an increased probability that they are valid. The node then takes in further proposals and checks to see whether they match with their candidate set. This process is timed and those which have reached 50% probability in the first iteration are broadcast to the network for validation. The process then begins again but with transactions requiring 60%, then 70% then 80% probability.
What the Future Holds
As nodes broadcast their candidate sets to the network, the sets propagated become more and more similar until the network reaches consensus and those within the candidate list can be validated onto the ledger. Those transactions not confirmed are kept within the candidate set and the process begins again with the addition of new transactions into the candidate set.
As distributed ledger technology advances and both mathematicians and coders set their minds to increasing the efficiency of consensus mechanisms, we should start to see improved algorithms which reduce computational power requirements whilst still maintaining the security of the trustless network. The hybrid PoS and PoW models may become the norm or networks such as ethereum might finally reach their utopia and migrate to a PoS mechanism.