Consensus Algorithms in Blockchain


blockchain-consensus

When we talk about the blockchain, the first thing that came up in our mind is the security and the security because of the blockchain consensus algorithm. Those who know about the blockchain know that we keep the ledger transactions synchronized across the network to ensure that ledgers only update when the appropriate participants approve transactions and that when ledgers do update, they update with the same transactions in the same order is called consensus. Here we will discuss the three different consensus algorithms.

Practical Byzantine fault tolerance

Imagine that several divisions of the Byzantine army are camped outside an enemy city, each division commanded by its own general. The generals can communicate with one another only by messenger. After observing the enemy, they must decide upon a common plan of action. However, some of the generals may be traitors, trying to prevent the loyal generals from reaching an agreement. The generals must decide on when to attack the city, but they need a strong majority of their army to attack at the same time. The generals must have an algorithm to guarantee that (a) all loyal generals decide upon the same plan of action, and (b) a small number of traitors cannot cause the loyal generals to adopt a bad plan. The loyal generals will all do what the algorithm says they should, but the traitors may do anything they wish. The algorithm must guarantee condition (a) regardless of what the traitors do. The loyal generals should not only reach an agreement but should agree upon a reasonable plan.

Above story represents the Byzantine General’s Problem. There are many solutions for this problem, but we will talk about Practical Byzantine fault tolerance (PBFT).

In 1999, Miguel Castro and Barbara Liskov introduced the “Practical Byzantine Fault Tolerance” (PBFT) algorithm, which provides high-performance Byzantine state machine replication, processing thousands of requests per second with sub-millisecond increases in latency.

We here talking about only PBFT from the number of other solution is because PBFT the only potential solution to  Byzantine General’s Problem. IBM backed Hyperledger uses this consensus algorithm. In PBFT each node maintains an internal storage. When a node receives, messages coming through the node is signed by the node to verify its format. Once enough same responses are reached, then a consensus is met that the message is a valid transaction.

Proof of Work

One of the most known algorithms of the all is Proof of Work (PoW). This algorithm is used by one of the strongest crypto-currency that is Bitcoins. This is one of the most commonly used consensuses mechanism. Unlike PBFT, PoW doesn’t require every node on the network to submit their message to reach any consensus. Instead in PoW, an individual can provide the conclusions to reach consensus.

Individual also known as miner calculates the hash of his block header and checks whether the conclusion is correct or not. If the conclusion is wrong, then the miner modify the nonce and then try again.

For example, let’s say we are going to work on a string “blockchain” and our target is to find a variation of the variation of it that SHA-256 hashes to a value beginning with ‘0000’. We vary the string by adding an integer value to the end called a nonce and incrementing it each time.

Finding a match for “blockchain” takes us 1042 tries.

Proof of Stake

And the last one is known as Proof of Stake (PoS). Here the mining is done by a stakeholder who is selected by network based on their stake. Unlike PoW, there is no reward for the block miner in the PoS system. The miners get the transaction fees instead. Crypto-currencies like Peercoin, BlackCoin, Nav Coin uses the PoS system.

So these are the well know three different consensus algorithms. Each one has their pros and cons.

References:

https://en.bitcoin.it/wiki/Proof_of_work

https://medium.com/@chrshmmmr/consensus-in-blockchain-systems-in-short-691fc7d1fefe


knoldus-advt-sticker


Advertisements

About Prabhat Kashyap

Consultant(Engineer) at Knoldus Software LLP
This entry was posted in Blockchain and tagged , , , , , , , . Bookmark the permalink.

One Response to Consensus Algorithms in Blockchain

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s