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 ?

Apr 13, 2020

What is Cryptography and its usage for Cryptocurrency ?

Cryptography is the science of keeping data secure from unwanted or untrusted entities. Main goal of cryptography is to make a public open channel into a virtual secure channel such that it satisfies the following 3 properties:

  1. Privacy
  2. Authenticity
  3. Integrity
Cryptographic mechanisms can vaguely be divided into two types: 
  1. Symmetric Key Cryptography
  2. Asymmetric Key Cryptography.

In Cryptocurrencies, Asymmetric Key Cryptography is used. So, we will try to understand that in this post.
Asymmetrical cryptography follows Public Key Mechanism meaning that - one key is publicly displayed and it is sharable to anyone. However the Private key should be kept secret. (Know more about private keys and how to store securely in this article)

Some attributes of Asymmetric Key Cryptography:
  • Public Key Cryptography
  • One key will be in public domain and the other will be Private
  • Different Keys are present on both Parties (sender and receiver)
  • No need of prior key agreement
  • Computationally a little bit heavier.

In Blockchain, all the blocks are linked cryptographically. For every block, a hash is generated using SHA 256 Algorithm. Then, that hash is stored in that block and copied to next new block as well. In this way every block will contain two hashes : one is its own hash and other one is that of previous block.


Go to Next Post - Consensus Protocol for Blockchain


Go to Previous Post - Technologies behind BTC & Cryptocurrency

Watch Naruto vs Rock Lee vs Shiikamaru vs Kiba Battle Royal