Cryptocurrency 101: What are consensus mechanisms?

18 April, 2019

U.S. regulators were the recipients of a bit of cryptocurrency education in March 2019 when Coin Center director of research Peter Van Valkenburgh addressed the U.S. Commodity Futures Trading Commission regarding consensus mechanisms. Members of the commission's Technical Advisory Committee learned about things like proof-of-work and proof-of-stake algorithms.

Consensus mechanisms are critical to the proper functioning of decentralized blockchain applications. Without said mechanisms, there would be no way to maintain the accuracy and integrity of the information contained within. Knowing that, it is worth understanding the consensus mechanism of a given cryptocurrency before making any decisions regarding its security, data integrity, etc.

In this post you will learn exactly what a consensus mechanism is and why it is so critical to decentralized applications. Be aware that there are several different consensus mechanisms to choose from. Each cryptocurrency developer chooses that mechanism that best suits the project at hand.

Centralized decision making

We will start our discussion with an explanation of how centralized decision making is achieved in a financial environment. Understanding this will open the door to a better understanding of why cryptocurrencies require consensus mechanisms. For the purposes of illustration, imagine a commercial bank funded by contributions from a number of private investors.

That bank is run by a director. All record-keeping is maintained through a database hosted locally on the bank's computer network. Whenever a transaction takes place, a bank representative enters the associated information into the database. However, the bank director ultimately has complete authority and control over the database.

If an internal audit reveals that information in the database is incorrect, the director can simply order one of the bank's employees to go in and correct the mistake. The bank director himself can add new information, edit existing information, or delete entries as he sees fit. Absolutely no outside contributions are necessary to keep the database going.

All of this works because of the centralization of the database and its administration under the bank director. But as you know by now, decentralized cryptocurrencies do not work in the same way. The fact that they are decentralized eliminates the possibility of any one individual or entity controlling the distributed ledger that acts as a cryptocurrency's database.

How distributed ledger's work

A cryptocurrency like Bitcoin doesn't operate on a single database. Rather, it operates on a distributed ledger that can be copied and moved indefinitely. There could be thousands of copies of the ledger in circulation at any point in time. What's more, those copies can be distributed all over the world.

The thing about Bitcoin is that each copy of the distributed ledger has to agree with all the others in order to maintain blockchain integrity. So when you hear someone talk of coin mining, they are speaking of a process that directly contributes to ledger maintenance. Coin miners are the individuals and entities who process transactions and then add them to the blocks that make up the ledger.

Now, you might be wondering how making so many copies of the ledger available to so many coin miners is possible without some copies of the ledger being corrupted. That is where consensus mechanisms come into play.

How the consensus mechanism works

Let us go back to our fictional commercial bank scenario for just a minute. Let's say the bank was established in such a way as to prevent a single director from controlling the institution's database. Instead, it was a committee of 10 directors who all maintain a copy of the database for the purposes of running their respective departments. At the end of the day, all of their copies have to agree before any of the directors can go home.

Each director brings his copy to evening meeting for review. Along with the transaction data is a record of the work that each director performed in order to achieve the numbers in his database. If all the work was done correctly, the numbers in all the copies will agree. If just one copy is not in agreement, there is something wrong. The directors then have to figure it out and fix it.

This is how consensus mechanisms in cryptocurrency work. Each entity that mines Bitcoins represents a node on the Bitcoin network. When information from a transaction is broadcast across the network, every node picks it up. Contained in the encrypted information are details of the transactions along with a fault-tolerant mechanism that forces every node to agree on the transaction information before it can be finalized.

If we compare this to our fictional bank scenario, the consensus mechanism followed by the bank's 10 directors is the work they were required to do in order to arrive at their database numbers. Forcing the directors to do the work forces them to verify the accuracy of their data.

In cryptocurrency, there are different kinds of consensus mechanisms that force coin miners to actually do something that verifies the accuracy of the data they are working with. Without such a mechanism in place, anyone with a copy of the ledger could alter it for any reason. Everything from innocent mistakes to outright fraud would be possible.

3 most common consensus mechanisms

There is no single consensus mechanism that governs all cryptocurrencies. As previously stated, each crypto developer chooses the consensus mechanism best suited to that particular project. Below are descriptions of the three most common consensus mechanisms currently in use among crypto platforms:

1. Proof-of-Work

The proof-of-work mechanism is the most commonly used. Bitcoin, Litecoin, and most of the other big cryptos make use of it. It is a mechanism built on the concept of requiring computer nodes to do some sort of work that can be verified by all the other nodes on the network.

The simplest way to understand the proof-of-work concept is to imagine a long and complicated mathematical equation. The information necessary to complete that equation is automatically generated when a new transaction takes place. Each computer node on the network has to decrypt transaction data, run the mathematical equation, and then submit the result for verification. Once all of the computer nodes agree on the results of the equation, the transaction is verified.

This is essentially what happens every time you deposit bitcoins at your favorite casino. Your deposit triggers a flurry of work across a global network of Bitcoin nodes seeking to verify the trade and post the information to the current block.

Note that the proof-of-work consensus mechanism requires a tremendous amount of raw computing power and energy. This is by design. By making proof-of-work so complicated, Bitcoin's developer created a scenario in which it is extremely difficult for any single entity to take complete control of the Bitcoin network by creating more nodes.

2. Proof-of-Stake

The second consensus mechanism we want to talk about is proof-of-stake. Unlike networks powered by the proof-of-work consensus mechanism, proof-of-stake networks are not made up of multiple nodes all simultaneously competing to see who can correctly process the next block in the chain first. Instead, a proof-of-stake network relies on a single node to produce each block.

The methods for choosing who gets to process the next block vary by platform. Perhaps the most common is an algorithm in which nodes are chosen based on a combination of ownership, age, and random selection. Ownership and age give those nodes with a longer and more reliable history a better chance of being chosen while randomization still gives younger and less wealthy nodes an opportunity to participate.

The key to proof-of-stake is that all nodes still have to process transaction data in order to verify its integrity. All of the nodes not chosen to generate the next block must still vote on the data generated by the chosen node. This prevents any single entity from unilaterally altering blockchain data without any accountability.

3. Proof-of-Capacity

Finally is the proof-of-capacity mechanism. Also known as proof-of-space, this consensus mechanism is based on demonstrating that each of the nodes in a cryptocurrency network has set aside a certain amount of memory or disk space in order to solve a puzzle. The puzzle then gets solved and the solution sent back across the network for consensus.

This mechanism is similar to proof-of-work in that each of the computers on the network have to do something - usually perform a mathematical equation - in order to participate in generating the current block. Its key difference is that it does not require nearly as much computing power or energy.

The proof-of-capacity algorithm allows for puzzles that are significantly less complicated and labor-intensive. These simpler tasks offset a theoretical loss of integrity by first requiring computer nodes to prove they have set aside the proper memory or disk space necessary to complete the puzzle.

The one thing all three consensus mechanisms have in common is that they require every node on the network to agree on data before a new block is entered. That is where the term 'consensus' comes from. Regardless of the mechanism used to force consensus, a new block cannot be entered into the ledger if consensus among all of the nodes on the network is not there. That's really all there is to it.