Sign in / Join

An introduction to blockchain. Part three: Consensus algorithms

What are consensus algorithms? That’s a difficult question to answer concisely but I’ll do my best. As we discussed before, there is no central authority in a decentralised network. Therefore, networks need a decision-making mechanism to force participants to come to agreement. Blockchain networks have built consensus algorithms into their protocols to serve that purpose.

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.

 

Image result for proof of work

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:

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.

Integrated Blocks

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.

Conclusion

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.

Wrapping Up

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 roywalker03@gmail.com. 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!

Sources:

A Comparison Between 5 Major Blockchain Protocols
Satoshi Nakamoto had introduced us to Bitcoin in 2008, and that was really when the blockchain technology first…medium.com
How Does the Internet Work?
A slightly technical whitepaper explaining what makes the Internet tick.web.stanford.edu
Cryptography Explained
Many people use cryptography everyday without giving it a second thought. It is also a key part of blockchain…lisk.io
What is hashing?
or, Why cryptographers enjoy passwords with a pinch of saltmedium.com
SHA-256 Cryptographic Hash Algorithm implemented in JavaScript | Movable Type Scripts
A hash is not 'encryption' - it cannot be decrypted back to the original text (it is a 'one-way' cryptographic…www.movable-type.co.uk
Understanding the SSH Encryption and Connection Process | DigitalOcean
SSH, or secure shell, is a secure protocol and the most common way of safely administering remote servers. Using a…www.digitalocean.com
What is a Digital Signature & How Do I Create One?
What is a digital signature, and how can you create one? Free Trial Digital signatures are like electronic…www.docusign.com
The Difference Between Blockchain and Distributed Ledger Technology
A distributed ledger gives control of all its information and transactions to the users and promotes transparency. They…tradeix.com
Consensus Algorithms, Explained: What You Need To Know About Proof-of-Work, Proof-of-Stake, and…
It can be a challenge trying to wrap your head around the concept of consensus mechanisms. However, they are a key…www.investinblockchain.com
What is consensus algorithm? - Definition from WhatIs.com
A consensus algorithm is a process in computer science used to achieve agreement on a single data value among…whatis.techtarget.com
A (Short) Guide to Blockchain Consensus Protocols - CoinDesk
We hear plenty of talk of how public blockchains are going to change the world, but to function on a global scale, a…www.coindesk.com
Proof-of-Work, Explained
1. Proof-of-Work, or PoW, is the original consensus algorithm in a Blockchain network. In Blockchain, this algorithm is…cointelegraph.com
Understanding Blockchain Fundamentals, Part 2: Proof of Work & Proof of Stake
Articles in this Understanding Blockchain Fundamentals series:medium.com
How are transactions validated?
The Bitcoin network’s ingenuity is solving the double spend problem or put another way, creating a monetary system that…medium.com
Proof of Work vs Proof of Stake: Basic Mining Guide - Blockgeeks
Recently you might have heard about the idea to move from an Ethereum consensus based on the Proof of Work (PoW) system…blockgeeks.com
Taxation Of Cryptocurrency Proof Of Stake Transaction Fees
Cryptocurrency mining is the process by which transactions are verified and added to the block chain. Anyone with…www.forbes.com
What is Ethereum Casper Protocol? Crash Course - Blockgeeks
If you are interested in Ethereum or Cryptocurrency in general, then you must be aware of the terms proof-of-stake and…blockgeeks.com
What is Proof of Stake?
The proof of stake system is attracting a lot of attention these days, with Ethereum switching over to this system from…hackernoon.com

Leave a reply