Friday 27 July 2018

Bitcoin Block Hashing Algorithm (Part II)


In our previous article (Read more here), we have illustrated the basic core hashing algorithm of Bitcoin using SHA256.  It can cryptograph input messages of any size into a unique 64-character code.  Thus, contracts or transactions could be hashed and distributed on the Blockchain network.

This article will provide an overview of the Bitcoin hashing process using real-world example.  Each Bitcoin transaction info is publicly available on the internet.  One can use the Bitcoin Block Explorer (Read more here) to view the transaction info of every block (ledger) that was registered onto the Blockchain.  For example, the first Bitcoin block was created by the Bitcoin inventor, Sathoshi.  The block info is accessible on the internet and it is commonly regarded as the Genesis Block (Read more here).



As you may have already learnt from the previous article, input message is required to generate the unique hash for this transaction block.  The input message (block header) of Bitcoin transaction comprises of
  • Version info
  • Hash of Previous Block
  • Hash of Merkle Root
  • Time
  • Bits
  • Nonce

For the Genesis block,
  • the version info is 1;
  • the hash of previous block is 0 because there was no previous block;
  • hash of merkle root is ‘4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b’, which is the hashing results of the transaction details such as someone sending some bitcoins to another party. (Read more here);
  • the time when the transaction was accepted, which was 2009-01-03 18:15:05;
  • the bits that was provided by the algorithm to adjust the difficulty of the “mining” task, depending on the number of “miners” participating in the process, for this case was 486604799; and 
  • finally the nonce, which is a guessing number that was “mined” by the miners.

The nonce is a moving target and depends on time, bits and merkle root, which are updated roughly every ten minutes.   The successful miner is the one who could guess the nonce that will produce the output hash of certain length of leading zeros.   For the Genesis block, the nonce is 2083236893.  The following diagram shows the flow of the hashing and mining process.



The hash for Genesis block is ‘000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f’.  It has 10 leading zeros.  At the time of this article was written, the target leading zero for new hash was 18.

As we can see from the above diagram, every new block incorporates the info from a previous block.  Thus, changing a small info from a block that sits in the middle of the blockchain without impacting the entire chain is impossible.  As such, once the transaction is registered on the blockchain, it is theoretically irreversible. 

1 comment:

  1. Impressive! I finally found great post here. Nice article on blockchain . It's really a nice experience to read your post. Thanks for sharing your innovative ideas to our vision.

    blockchain training in hyderabad
    blockchain course in hyderabad
    blockchain coaching in hyderabad
    blockchain training institute in hyderabad
    blockchain institute in hyderabad

    ReplyDelete