At a high level, consensus algorithms are how network participants agree on a “single version of the truth”. Network participants use consensus algorithms to confirm that proposed transactions are valid and that a person that is sending an asset actually owns that asset in the first place. For bitcoin, that means that if somebody is trying to send 10 bitcoin, the network participants use consensus algorithms to agree that the person owned those 10 bitcoin in the first place.
These mechanisms are important because they are how blockchain networks solve the double spend problem. I covered this in a little more detail in my prior post but the double spend problem essentially refers to the idea that digital assets are easy to replicate so there’s a chance that somebody could try to copy a digital asset and use it twice. The double spend problem is the reason that we have historically needed trusted third parties to confirm that the digital assets we are exchanging (currency, property, etc.) have not already been spent elsewhere. Consensus algorithms allow decentralised networks to validate that transactions are legitimate without requiring a trusted third party.
So how do they work? There are a number of different consensus algorithms so I’m going to cover the two most popular ones here and then provide a link to a few others that are interesting.
Proof of Work:
The first consensus algorithm to be implemented in a blockchain protocol was the proof-of-work algorithm. It is the algorithm that powers a number of the top blockchain networks, including bitcoin and ethereum.
The proof-of-work algorithm requires network participants to verify transactions through a computationally complex math puzzle and incentives them to verify transactions by providing a reward to the node that successfully completes that problem. This idea of computational complexity provides additional security to the system because it requires an enormous amount of time and energy to make any changes to the blockchain after consensus has been reached. Essentially, a hacker would need to have enough computing power to compete with the entire existing blockchain network if they wanted to make any retroactive changes.
As always, I think it’s easiest to understand how the concept works by walking through an example. Let’s say that a number of bitcoin transactions have occurred and need to be validated. All of the nodes that are connected to the network (known as miners) will then compete to “mine” the block of transactions. They do this by taking a hash of a few different inputs, including (i) all of the transactions in the block, (ii) the timestamp of when the block was hashed, (iii) the difficulty of the block (don’t worry about this for now), (iv) the hash of the previous block of transactions, and (v) an extra number called a “nonce” (more on this later).
So what mathematical problem do miners have to solve? The problem that bitcoin forces miners to solve is to take all of those hash inputs and find a specific hash output. The only way to do this is to guess a nonce and hash the inputs. If those inputs don’t lead to the correct output, the miner has to guess a different nonce and re-hash the inputs. The miner then does this over and over until they arrive at the correct output. Said another way, the math problem is a guess and check problem where the nonce is the variable that can be manipulated. The first miner to guess the right nonce, wins the competition and is awarded a pre-set number of bitcoin. After this occurs, all of the other nodes on the network check the transactions and the nonce to make sure that the transactions are valid and create the correct output. Then, the nodes move onto the next block and start the process all over again.
This method requires a ton of computational resources because the only way to solve the puzzle is through brute force guess and check. As we discussed above, the computational intensity of proof-of-work networks provides additional security and mitigates the threat of a DOS attack. However, this computational intensity also presents a problem. As proof-of-work networks have scaled, they have begun to consume monstrous amounts of energy. This has led to criticisms from sustainability groups, as well as from people who are worried that mining has become concentrated among a few players that can either afford the best equipment or operate in areas with the cheapest electricity. The latter argument is particularly interesting because if mining operations begin to concentrate among a few players, it could effectively centralise the decentralized network. The final argument against proof-of-work networks is that they are slow and people are beginning to demand faster transaction speeds. That leads us to our next consensus algorithm: proof-of-stake.
Proof-of-stake (“POS”) was first used by Peercoin in 2012 and has since gained in popularity. In fact, even Ethereum will be switching to it in the near-term. The benefit of using a proof-of-stake system is that it reduces the amount of energy and expensive hardware required to validate transactions. That makes it more environmentally friendly and further decentralises the network as there are lower barriers to entry for becoming a validating node.
Let’s break down how it works. In a proof-of-stake system, there is no math puzzle for nodes to compete to solve. Instead, validating nodes (known as “forgers”) are selected in a semi-random way, where the probability of being selected is based on a combination of the number of network tokens the forger owns and the amount of time he / she has owned those coins for. For a good description of these selection methods, check out this article.
So how do you make sure that these forgers don’t validate fraudulent transactions? Proof-of-stake protocols solve this potential issue by forcing forgers to lock up their “stake” (aka their network tokens) in an escrow of sorts. If a forger validates a fraudulent transaction, it will lose the coins in the escrow account and will not be allowed to partake in the forging process in the future.
Another key difference between POW and POS consensus mechanisms is how they financially incentivize network participants to validate transactions. Unlike proof-of-work, there are no block rewards in a proof-of-stake system. Instead, nodes receive transaction fees for validating transactions. What’s interesting is that the transaction fees are actually a way for proof-of-stake networks to regulate the number of forgers (aka validating nodes). If a network wants to encourage more forgers, it can increase the value of transaction fees and vice versa.
This is a very high level overview of proof-of-stake; however, the key takeaways are that (i) POS systems choose validating nodes based on their ownership in the network, (ii) POS systems reduce the amount of electricity / computational power required to validate transactions making them more energy efficient and scalable, and (iii) POS systems may improve decentralisation by reducing the barriers to entry for validating nodes. However, this method is still relatively new and has drawn criticism for being less secure than proof of work.
While these are by far the two most popular consensus algorithms, they certainly aren’t the only ones. Other consensus algorithms include delayed proof of work, delegated proof of stake, proof of authority, proof of weight, and many more. If you want to do a little more digging on these, you can find an awesome article published in Hacker Noon that details 30 of them here.
I know this has been a dense post but stay with me, we’re almost there. The final differentiating component of a blockchain protocol is how blocks of transactions are integrated to create an “immutable ledger”. This integration is done through hashing. The best way to understand how this works is to look at how blockchain networks initially get off the ground.
The first block in a blockchain is known as the “genesis block”. The genesis block differs from other blocks because it is hardcoded into the network and details the initial parameters of the blockchain. When the transactions from this genesis block are validated, they are hashed to generate a unique value that identifies the block. When the second block is validated, the transactions from the second block, as well as the hash value of the first block, are used as inputs to create the second block’s unique hash value. This is then done for each subsequent block in the blockchain, effectively linking the blocks together. This linking feature is what makes the blockchain “immutable” because hackers cannot just hack one block. If a hacker tries to change the data stored in a validated block, it will change the hash of each subsequent block and cause a ripple effect throughout the rest of the chain. This will instantly be spotted by every other node, providing an additional level of security to the network.
Additionally, by linking blocks in this manner, the hash of the most recent block incorporates every single transaction that has occurred on the chain up to that point. Therefore, by agreeing on the most recent hash value, miners can easily come to consensus on the “current state of the chain”. That integration represents the final piece of the blockchain puzzle so it’s time to wrap this post up.
I know this piece covers a ton of dense information so thanks for taking the time to read it! Just to quickly sum it up (or…re-hash it if you will), blockchain protocols are an innovative way of sending information across a network. They sit on top of the TCP / IP protocol stack and incorporate several elements that make them a much more secure method for sending information and transferring value. These elements include distributed ledgers, encryption, consensus mechanisms, and integrated blocks.
That wraps up my post on blockchain protocols, I hope you found it interesting! If you enjoyed this post and would like future posts sent directly to your email, please reach out to me at firstname.lastname@example.org. My next post will break down how ICOs, DApps and DAOs work.
If you have an interest in venture capital and want to read VC-related content, please subscribe to my publication “All Things Venture Capital” or follow it on twitter. Additionally, please reach out to me if you are interested in adding to the publication! My goal is to continue to add high quality content (articles, podcasts, videos, etc.) from aspiring and current venture capitalists that want to share their perspective. Thanks for reading!