Search This Blog

Apr 29, 2020

Consensus Protocol for Blockchains in Cryptocurrency

Blockchain of every Cryptocurrency should be distributed in nature with the help of a consensus protocol. Even though it is distributed across thousands of computers all over the world, a Blockchain is immutable.

If an attacker tries to change the data of any existing block in the ledger, then that block's "hash" value (generated by SHA 256 Algorithm) will change. Then, this new hash will not match with the next block's "previous hash" field. So, now the attacker needs to change this block also and this process will continue till all the subsequent blocks are manipulated successfully. 

Even if the attacker successfully changed the data of blockchain, since there are thousands of copies of original blockchian around the internet, this fake blockchain will not be valid because of the Majority Rule.

Majority Rule - Whichever copy is found more number of times, then that copy of blockchain is considered to be original and valid.

So, the attacker can't achieve anything by simply modifying one or two copies of blockchain, atleast 51% of copies of blockchains needs to be modified simultaneously with same fake data all over the world. Then only the hackers can corrupt the blockchain. But this task can be considered as impossible in real world practicality. 

Consider these 2 Scenarios:

Scenario - 1:

If an attacker adds a block exactly after the current last block in Blockchain.

If attacker entered fake/malicious transactions in the block and mined it successfully, then this block will not be added to chain because before adding any block to the chain, a series of checks are performed for validating the block.

More than 20 checks are performed on each new block before adding and copying it to all the blockchains in the distributed network.

Scenario - 2:

What if 2 blocks are mined exactly at the same time and both are valid blocks.

In this case, both the blocks are copied to the copies of blockchains which are geographically nearer in the network. So one block is copied into its nearest blockchains and other block is added to its nearest copies of blockchains. This means 2 versions of Blockchains will exist and both of the versions are Valid and original. 

Both the  versions of chains will wait for the next new block to be mined and whichever version gets the new block then it is copied all over the distributed network. So, the longest chain will be valid and the previous block in the other version will be cancelled. Those transactions needs to be validated again in a new block and it has to be mined again.


Go to Next Post - SHA 256 Algorithm


Go to Previous Post - What is Cryptography and its usage in Cryptocurrency ?

No comments:

Post a Comment

Watch Naruto vs Rock Lee vs Shiikamaru vs Kiba Battle Royal