What is consensus in a blockchain?
A blockchain is a decentralized ledger that runs on a peer to peer network. In the case of a public blockchain like Bitcoin, thousands or perhaps millions of anonymous users participate in this blockchain. How do we achieve trust in such a system, or in a private blockchain? This is where the consensus comes in. The consensus assures that the participants will trust each other and the validity of the next block. A consensus ensures that the network’s rules will be followed and that there is only one truth in the blockchain environment.
Depending on the type of blockchain you have, you will need a different consensus algorithm to make sure the last block in the blockchain reflect the state of the world at each moment. In this article, we will briefly explore different consensus algorithms.
Proof of Work
Let’s start with the one from the Bitcoin and Ethereum’s blockchains. The Proof of Work algorithm requires the miners to solve a complex mathematical problem involving cryptography. It is a lottery where computing powers play a big role. Basically, you take a block’s data and encrypt it with a counter until you get a valid hash.
Pros: Difficult to find a valid hash, but very easy to control of the hash is valid. It makes it impossible to cheat the system. Scales well with a great number of nodes.
Cons: Takes a unbelievable amount of power. Not very environment-friendly. Susceptible to attacks if one party controls 51% of the computing power.
Proof of Stake
Ethereum is moving towards a Proof of Stake consensus. The miner of the next block is chosen based on various combinations of random parameters such as the amount of coin they have, how long has it been since the owner had the coin… There are different instances of this algorithm like Proof of Deposit or Proof of Burn. Very simply put, if node X has 1 coin and node Y has 2 coins, node Y would be twice as likely to be called to validate a block.
Pros: More energy efficient that Proof of Work
Cons: More security issues? There seems to not be a big punishment for working on different chains at the same time. This could create a vulnerability when trying to create and keep a single truth.
Proof of Elapsed Time (PoET)
The Proof of Elapsed Time is a consensus used in the Hyperledger’ Sawtooth project. The participants each request a wait time from a secure enclave. The participant with the shortest wait time is elected the leader, waits the amount of time it was given and proposes a block.
Pros: Leader changes all the time, the same person doesn’t choose the next block every single time.
Cons: The secure enclave is a complex technology, potentially easier to cheat than Proof of Work. There is also a tendency towards centralization because we must use third party trusted certification authority to make sure the enclave is indeed secure.
Simplified Byzantine Fault Tolerance (SBFT)
In this algorithm, the block’s validator is a known entity. It could be a regulator in a business network for example. This validator creates and proposes a new block of transactions. In a SBFT consensus, a certain number of nodes must accept the block, depending on the number of faulty nodes.
In such a system, 2f+1 nodes at minimum must accept the new block in a business network, where f is the number of faulty nodes.
For example, let’s take a system with 30 participants. There are 5 faulty nodes in the network. For the new block to be validated, 11 (25+1) nodes must accept the block. If the number of faulty nodes goes up to 10, 21 (210+1) nodes must agree on the new block.
Faulty in this sense could be malicious or non functioning nodes.
Pros: Faster than Proof of Work, better scalability.
Cons: Tendency to centralization. One validator proposes the next block.
Proof of Authority (PoA)
Suited for private networks where trust doesn’t need to be distributed. The concept is relatively simple: some individuals in the networks are recognized as validators after some conditions are met, such as identity checks. These validators are responsible for maintaining the blockchain’s data.
Pros: Well suited for private networks. Makes it very fast.
Cons: Sacrifices trust.
This was a very quick overview on some consensus algorithm used in the blockchain world. I wanted to make a short article to show some of the possibilities. Of course, there are many others possible. Overall, we can distinguish three types of consensus:
- The standard Proof of Work consensus
- Permissioned voting based consensus ( PoA, SBFT )
- Permissioned lottery based consensus ( PoET )
Which consensus is chosen in a blockchain implementation depends on the type of network and data handled.
Lottery types would be more suited for large networks. Voting types are better suited for smaller networks, and reduce the latency to a minimum.