We can all rely on the third-party organizations that control traditional fiat currencies like the US dollar to provide an accurate account of the truth.
This is partly what gives them their value.
So, if I send you $100 through direct debit but you say you haven’t received it, we can take a look at our bank accounts. If there’s no record of the transaction in either of our accounts, we can take our banks’ records as the truth. Unlike fiat currencies, cryptocurrencies like Bitcoin aren’t controlled by a central organization. If I send you a bitcoin and you say you don’t receive it, how do I know you’re telling the truth? There’s no centralized organization we can turn to for the facts.
This is where the consensus algorithm comes in. Without this algorithm, cryptocurrencies would be worthless, as there’d be no way to be sure our money has gone where we sent it. With it, we can be sure our transactions have gone through without the need for a centralized authority.
In this article, I’ll walk you through the different kind of consensus algorithms in use today and give a brief overview of how they each work. But first, we need to understand what consensus is and why it’s so important…
What is consensus?
If you’ve ever kept a personal record of your income and expenses, then you already know what a ledger looks like: a record of inputs and outputs.
A blockchain is a public, decentralized ledger. Anyone can access it, and there is no single entity controlling it.
When you transfer US dollars using direct debit, your bank controls a ledger that acts as an official record of the transaction. If it’s on your bank’s ledger it happened, and if it isn’t, it didn’t. Because cryptocurrencies aren’t regulated by a centralized authority, they need another way of updating the ledger and keeping an accurate and objective record of every transaction.
The solution? A consensus algorithm.
This algorithm requires all the nodes on a network to reach an agreement on the information in the blockchain in order to function. With this in place, no one can corrupt the public ledger or undermine the network’s security.
The types of consensus algorithms
Every cryptocurrency uses a different consensus algorithm. Each system has its own pros and cons, and in this section we’ll quickly run through them so you understand the facts.
Practical Byzantine Fault Tolerance Consensus
In a 1982 paper, Leslie Lamport, Robert Shostak and Marshall Pease illustrated a common failure that occurs in systems that need to reach a consensus in order to function with the Byzantine General’s Problem (BGP).
A group of Byzantine generals have surrounded a city and are deciding whether to attack its walls or retreat to safety.
Some of the generals want to attack and others want to retreat, but they know they all need to fully commit to one option, as a half-hearted attack would result in a resounding defeat for the entire army. The generals need to cast a vote to come to a consensus on what to do, and because they have to hold their positions, they need to use messengers.
But how do they make sure the vote isn’t corrupted by a traitorous general or messenger?
Left unchecked, a traitor could send a vote for attack to the generals who want to attack and a vote for retreat to those that want to retreat, dividing the army and deceiving them into defeat.
In 1999, Miguel Castro and Barbara Liskov came up with a solution to this problem: the Practical Byzantine Fault Tolerance (PBFT) algorithm. Each general compares the other generals’ votes with their internal stays, reaches a conclusion, and then sends this out to the other generals.
Once every general has sent out their conclusions, a consensus is reached based on the total number of votes either way. However, a consensus can’t be reached until every general has cast their vote. When it comes to cryptocurrencies, the generals are the nodes on the network and a “vote” is cast every time a transaction is made. Hyperledger, Ripple, and Stellar all use the PBFT algorithm.
- Among all consensus algorithms, PBFT requires the least effort.
- Promotes anonymity.
- Requires participation of all generals (nodes) before a consensus can be reached.
Proof of Work
The most popular consensus algorithm among cryptocurrencies is Proof of Work (PoW).
In a Proof of Work system, not all the coins in a currency are released at the outset. Miners compete with each other to solve a cryptographic puzzle and earn the remaining coins.
Once the puzzle is solved, a new block is added to the blockchain, and the miner who solves the puzzle is rewarded a set amount in the cryptocurrency, which is reduced as time goes by.
The PoW system uses the SHA-256 hash function to convert non-readable data into a readable form. The hash, known as a nonce, must be less difficult for the nodes on the network to solve than the cryptocurrency’s set difficulty, or else it won’t be solvable.
Ethereum began with PoW, but is planning to switch to Proof of Stake.
- Difficult to ‘hack’, because you’d have to go back and rework the entire computational quiz to make changes to the blockchain, which would take years.
- Does not require the participation of all nodes in the system before a consensus is reached.
- Mining consumes an unsustainable amount of energy.
- The equipment you need for mining is prohibitively expensive.
- Financing mining equipment and electricity means you have to convert your cryptocurrency into a fiat currency, which drags down the value of these currencies.
- Areas with cheap electricity have a big advantage when it comes to mining these cryptocurrencies, and the computational power tends to cluster there.
Proof of Stake
Most cryptocurrencies that don’t use the Proof of Work system use Proof of Stake (PoS).
In cryptocurrencies that run on this consensus algorithm, all coins are released at the offset. Rather than competing with one another to solve the next block in the chain (and use up lots of energy in the process), miners receive a transaction fee for validating transactions.
The Proof of Stake system is based on the fact it would be against the miner with the highest stake’s interest to put the system at risk, as they have the most to lose if the cryptocurrency loses value or collapses.
So, the person with the biggest share in the cryptocurrency validates the transactions, and it’s in their best interest to keep the system safe and secure.
PoS was introduced in 2011, and the first cryptocurrency to adopt it was Peercoin a year later. Nav Coin, OkCash, BlackCoin, NEO, ShadowCash, Nushares/NuBits, ReddCoin, Qora and Nxt are also using this consensus algorithm right now.
At the moment, Ethereum uses PoW, but it will be migrating to PoS sometime in 2018 with a hard fork.
- Requires a lot less computational power than PoW, so uses up a lot less energy.
- Vulnerable to the 51% attack.
Proof of Space/Capacity
Proof of Space/Capacity (PoS/C) revolves around the available disk space on a miner’s computer. Proposed by Bram Cohen, a BitTorrent developer, this system was developed to provide an alternative to the PoW system that doesn’t require an unsustainable amount of energy.
In this consensus, miners offer up disk space on their computer for the network to use to create a new block in the blockchain. The more available space a miner has, the more coins they can mine. It’s therefore a good call to invest in plenty of disk space if you want to mine a cryptocurrency using PoS/C. Storj, SpaceMint and BurstCoin all use this consensus algorithm, while File Coin, uses a variation called Proof of Replication (or Proof of Spacetime).
- Uses less computational power/energy.
- Anyone with a computer can become a miner.
- What happens when there is no more space? No one has answered that.
Proof of Burn
A Proof of Burn consensus is built on top of an existing cryptocurrency using Proof of Work. This is known as ‘bootstrapping’ coins, because they exist off the back of an original coin.
In this system, miners have to ‘burn’ coins of an existing cryptocurrency by sending them to an address they can’t be retrieved from. The more coins a miner sends to this irretrievable address, the higher their chance of being selected to mine the next block on the new currency’s blockchain.
As time goes by, the ‘burned’ coins lose their value, so miners need to constantly keep spending coins to maintain their chances of being chosen to mine the next block.
The only coin currently using Proof of Burn is Slimcoin, which is bootstrapped on Peercoin
- Requires very little computational power.
- Expensive for individuals.
- Concentrates mining power to the elite few with plenty of money to burn.
Proof of Activity
Proof of Activity (PoA) is a hybrid of Proof of Work and Proof of Stake that was created to replace the Proof of Work consensus when block rewards run out.
A miner who solves the computational puzzle to unlock a new block in a PoW system is awarded a block bounty, which currently stands at 25 bitcoins, as well as transaction fees.
Every four years, the block bounty halves. Eventually, there’ll be nothing left to halve, and miners will only be rewarded with transaction fees.
This will probably lead to a tragedy of Commons, where miners will be forced to endanger the system while looking for other means of compensation.
The Proof of Activity approach was proposed by Iddo Bentov, Charles Lee, Alex Mizrahi and Meni Rosenfeld as a solution to this inevitable outcome. This solution involves starting off mining with Proof of Work system and then transitioning to Proof of Stake.
In PoA, miners compete to solve a computational puzzle. But unlike in a traditional PoW system, the blocks being mined don’t contain any transactions except the header and the miner’s reward address.
It’s at this point that things switch to PoS.
To create a new block, a randomly chosen group of validators are chosen to sign the new block.
The more coins you hold in the header, the better your chances of being chosen to sign the block and share in the rewards.
Once the required number of validators have been chosen, they all sign and a new block is created.
Miners and signing validators all share the transaction fees from the newly created block.
Currently, the only blockchain using PoA is Decred.
- Helps the system avoid the tragedy of Commons when miner rewards dry up.
- The same disadvantages as PoW and PoS
Proof of Elapsed Time
The Proof of Elapsed Time (PoEt) system, which was created by Intel, uses a Trusted Execution Environment (TEE) like SGX to randomly create blocks on the blockchain.
This consensus creates a new block after a certain amount of time has elapsed. However, there’s a catch — miners have to put their trust in Intel to create new blocks.
One of the main reasons blockchain technology was developed was to do away with third parties, making this an unpopular consensus algorithm. However, it’s possible the solution could be developed to eliminate the need for a centralised authority..
- Doesn’t consume much energy.
- Could level the mining field, as virtually everyone can access a CPU, unlike a GPU or ASIC mining equipments.
- Requires trust in a third party.
Each of these consensus algorithms have their own strengths and weaknesses.
Until we discover one consensus to rule them all, programmers have to adopt the one that best meets their needs, and miners and investors would be well advised to stick to cryptocurrencies that run on a system they’re comfortable with.