Consensus is the foundation of any distributed network, blockchain included. Distributed networks are, in fact, a random number of random nodes that should work towards achieving a common goal. With no central authority, such networks must have a reliable method of processing transactions.

In order to agree on a certain value (whether a transaction is to be approved, whether somebody’s identity is to be confirmed, etc.) the majority of the nodes in the system should be of the same opinion. No single node is special and no node is trusted unconditionally. The trust in the system is evenly distributed between all nodes.

To make the matters worse, any distributed network always assumes that at any moment, any number of nodes may be unavailable or even malicious. At the same time, the network must be organized so that at any moment it can issue a unanimous decision, so that transaction processing continues without interruption.

Obviously, in such conditions, reaching a consensus is the only strategy that works. Distributed networks use the so-called consensus algorithms – strict mathematical rules that allow any network of any number of nodes to reach consensus. At the moment, there is a number of generally accepted consensus algorithms that are used by the most popular blockchains. However, all of them still leave something to be desired, and new algorithms appear with the promise of solving the problems of the existing ones.

Let’s look at the most popular consensus algorithms mechanisms to see their advantages and disadvantages.

Hashing and hash function

Before we dive deep into the specifics of consensus algorithms mechanisms, let’s take a brief look at the fundamental concept of the blockchain technology that is at the core of all consensus mechanisms. We are talking about the hash function that ensures the ultimate immutability of the blockchain.

The hash function generates a fixed-length output from any input. The output string obtained as the result of hashing corresponds to the only input data. What is also worth noting is that while there are several hashing mechanisms creating hashed values, the reverse process is impossible – you cannot decipher the input from the hash string.

Many blockchains use the SHA-256 hashing algorithm generating output strings of 256 bits, or 64 characters. Each new block contains the hashed value of the previous block, thus ensuring the blockchain immutability. As soon as the data of any previous block is changed, the hash no longer matches. While SHA-256 is currently the most popular hashing algorithm in crypto networks, others are also used, such as SHA-2, SHA-512 or Ethash.

How is hashing related to the blockchain consensus? The blockchain is formed by adding new blocks. Since the network is decentralized, it should arrive at the consensus algorithms on which block to add. While many nodes can calculate the correct hash, only first one is chosen. This block is added to the blockchain and the node that found it gets the reward.

The consensus algorithms are basically about the way of making the decision whether the transaction is to be added to the network.

Most popular consensus algorithms

Different blockchains use different consensus algorithms that sometimes define the overall effectiveness and performance of the network.

Proof-of-Work

Proof-of-Work, or PoW, is the best-known consensus algorithm so far. It is used by Bitcoin and Ethereum and forms the underlying concept of “mining”. The miners compete for the right to add the block to the chain by trying to find the next hash. There is no way to find it but by brute force, as each block contains a random number called “nonce” that can only be guessed.

Thus, Bitcoin or Ether miners have to use enormous computing power to win this race for the next block. This is their “Proof-of-Work”, and the first miner who produces the correct hash adds their block and gets a coin as the reward.

While each miner spends their computing power and energy on mining the blocks, their efforts may lead to nothing when their blok is not chosen. To improve their chances to get the reward, miners have begun to join in the so-called mining pools – groups of minors combining their mining power and then sharing the reward. Within the pool, the reward is shared in proportion to the power contributed by each miner.

China is known to have the largest number of mining pools. For example, for Bitcoin, the Chinese mining pools hold over 80% of the total mining power in the network. This is a matter of concern for Bitcoin, as it hides a threat of power concentration in the hands of several groups of users.

The difficulty of mining blocks is tends to increase, as there may be only 21 million of Bitcoin altogether and 18 million of Ether per year. The block generation rate is one in 10 minutes for Bitcoin and one in 2 minutes for Ether. Thus, the mining difficulty and computing power are constantly being balanced to keep this rate and to prevent mining all coins immediately and dropping their value. Mining Bitcoin or Ether translates into good old electricity which means that whoever is willing to spend more on powerful hardware and ever-rising electricity bills has a higher chance of mining more coins.

While Bitcoin keeps with its traditional PoW algorithm, Ethereum is considering a different option – the Proof-of-Stake.

Proof-of-Stake

The goal of the Proof-of-Stake, or PoS, algorithm is also to choose the node whose block is to be added to the network, however, the selection criteria are different. The nodes are selected by the amount of the cryptocurrency they are holding and the length of time they have been holding it. The node with the largest amount of cryptocurrency, or the largest stake, has higher chances to have their block selected.

However, make no mistake of thinking that the PoS algorithm favors the rich making them even richer. On the contrary, the random selection mechanism includes all nodes, however, those with higher stakes have a better probability to be chosen. Let’s say, node A holds 50 coins, node B holds 30 coins and node C holds 20 coins. If all of them take part in block mining, A will have the 50% chance to have their block selected, while B and C will have the 30% and 20% chance, respectively.

With the PoS algorithm, no coins are produced, thus the winning node is rewarded with the transaction fee. As the nodes do not need to race each other to win, as in the case of PoW, the electricity consumption is significantly lower and, consequently, the processing costs are not that high, either.

The first cryptocurrency to use the PoS algorithm was Peercoin. As we mentioned, Ethereum is currently considering to switch to PoS as a more cost-effective option.

Delegated Proof-of-Stake

The Delegated Proof-of-Stake, or DPoS, concept appeared in an attempt to prevent the danger of centralization that, if allowed, will kill the very idea of blockchain. Indeed, the PoW and PoS approaches have the risk of consensus algorithms consolidating in the hands of a certain group that holds either the largest amount of computing power or the biggest stake of coins.

Thus, in 2014, the idea of DPoS was proposed. This algorithm is a shot at establishing democracy in a blockchain. In DPoS, each node holding coins can vote for representatives who then will reach consensus among themselves. This way, the hardware power or the coin wealth no longer matter.

In addition to its potential to resolve the centralization problem, DPoS can dramatically increase the network performance. Compared to Bitcoin that is agonizingly slow due to its ever-increasing processing difficulty and prohibitively expensive for the same reason, DPoS looks lightning fast and extremely affordable. Despite the resistance of the PoW community that sensed the impending losses, the DPoS is spreading and is now used by Steem and Bitshares with the number of processed transactions increasing.

The DPoS has become the underlying concept of EOS, a decentralized system that is going to work with no huge electricity waste and no transaction fees. EOS is a whole ecosystem with an own cryptocoin, a platform for building distributed applications, and an operating system.

Right now, EOS is in public beta. Well, let’s wait and see, as the idea seems rather ambitious and aspiring.

Proof-of-Elapsed-Time

This principle of reaching consensus is used in permissioned networks where all users need authorization to participate. With Proof-of-Elapsed-Time, or PoET, the nodes are to wait for a random period of time and the one with the shortest waiting time gets to add the block to the chain.

The PoET algorithm is very effective at solving the power waste problem that is the greatest downside of PoW. In fact, the nodes go to sleep for the waiting period and wake up upon its expiration. This way, the energy consumption is reduced and the computing resources can be used for other tasks.

The PoET mechanism is a brainchild of the Intel team who also developed the way to ensure that the waiting time is, indeed, random and that the nodes actually wait for that time. Today, the PoET algorithm is used in Hyperledger Sawtooth, the technology often used to build enterprise blockchains.

Delegated Byzantine Fault Tolerance

The name refers to the Byzantine Generals Problem that is actually in the core of any consensus algorithm. In short, a decentralized network must find a way to reach consensus in the conditions when any node can be assumed malfunctioning or malicious and the communication between nodes may fail.

The Delegated Byzantine Fault Tolerance algorithm, or dBFT, is designed to take care of this problem and to ensure consensus no matter how many nodes are malicious or improperly functioning.

With dBFT, all nodes in the network vote for the so-called consensus nodes from among which a speaker node is chosen randomly. The speaker creates and verifies a new block in the chain and passes it on to the consensus nodes for validation. When the consensus nodes reach consensus on the block, it is added to the chain.

The algorithm protects the network from the dishonest behavior of the speaker, a consensus node, or both. In all cases, since all nodes have the same data, they can conclude whether the block is actually valid or invalid and reach consensus. Whenever the speaker or any consensus node is found malicious, they are replaced.

This algorithm is applied by NEO claiming that dBFT is capable of reducing the power consumption required for the block processing. While this seems to be a fair advantage of the dBFT algorithm, it still has a certain risk of centralization.

Proof-of-Authority

Proof-of-Authority, or PoA, is an improved version of the Proof-of-Stake algorithm. PoA is intended to resolve the problem that the PoS-based network may face – the problem of the stake value to its holder. While stakes of two holders may be equal in their amount, they may correspond to a different share of their total holdings. Thus, a holder whose stake is only 1% of their holdings is less motivated than the holder for whom the same amount of tokens represents 50% of the holdings.

In blockchains using the PoA algorithm, users stake their identity rather than tokens. The consensus is reached by a small group of users who disclose their true identities with a formal procedure, such as the submission of a notarized document.

The users are motivated to behave honestly by the knowledge that their reputation may be easily ruined and that the fact of their dishonesty will be circulated widely across the network and beyond. However, for fairness’ sake, we have to note that when known individuals are responsible for such important decisions as reaching consensus for the whole network, the risk of plain bribery gets rather high.

Obviously, the PoA-based networks consume much less energy than those using PoW and are thus less costly. Besides, no continuous communication between the nodes is needed to reach the consensus. At the same time, the PoA algorithm is the most effective in private, permissioned networks rather than public ones where users are mostly anonymous.

Currently, the most notable use case of PoA is, quite logically, POA Network, a platform for building smart contracts. The network verifies the user identities through the notary database which ensures that no identities can be falsified.

Proof-of-Reputation

We may say that the Proof-of-Reputation algorithm, or PoR, is a variety of PoA. In PoR, the consensus is reached by entities who stake their reputation. Mostly, these are well-known companies and corporations whose good name is going to be damaged if they abuse their right to verify the blocks in the chain.

According to its creators, PoR is supposed to resolve the drawbacks of as many as three other algorithms. It is not as energy greedy as PoW, it performs better than PoS, and it prevents bribery that is the risk in PoA.

By its nature, the PoR algorithm is best suited for enterprise solutions, as it requires certain authentication and identity verification. At the moment, PoR is used by its creators, GoChain, the environment for deploying distributed applications and smart contracts. GoChain rewards the companies that agree to take part in maintaining consensus in the network with its native tokens.

Proof-of-Importance

The last consensus algorithm we are going to discuss is Proof-of-Importance, or PoI. Similarly to the Proof-of-Stake algorithm, it is based on the number of coins that the user holds, however, there are differences.

PoI gives more weight to coins that are actually spent within a certain period of time, with the most recent transactions being more important. This way, those who actively use the coins get preference over those who just accumulate them.

The Proof-of-Importance algorithm was invented by NEM, a platform for building decentralized applications for various purposes. To do that, NEM offers the so-called “smart assets”, a sort of building blocks that a business can use to deploy an application. Quite expectedly, NEM uses the PoI algorithm in its blockchains.

Is there an algorithm that is “the best”?

All consensus algorithms have their pros and cons. Moreover, each new one is made with the idea of improving something in the ones before it. In view of this, we are safe to say that there will be more, as there is still no consensus algorithm that has no drawbacks at all.

At the same time, choosing the algorithm for your blockchain is a part of a larger, more complex task. Your business idea dictates the type of blockchain that it the most optimal, the platform on which it should be developed, the technology stack that is to be used, whether the blockchain is going to be public or private – and that leads to the consensus algorithm.

We have built blockchains on different platforms using different technologies. We know their strengths and weaknesses and we know how to enhance the former and minimize the latter. We can help you turn your great startup idea into a decentralized application with the effectiveness, performance, security and scalability suiting your business goals perfectly. Contact us, and our blockchain experts will help you get your project off the ground.