What is Merkle Tree

TDhendup
0

 

A Merkle tree (or binary hash tree) involves taking large amount of data and making it more manageable to process. In the case of blockchain technology, merkle trees are used to organize transactions such as “Alice sent Bob 5 BTC”, using fewer resources.

Source: mycryptopedia

 

Let us have a closer look at the above diagram.

“TA” represents a normal transaction. This transaction is hashed individually to give their corresponding hash value. For example, “TD” is put through a hash function to give its corresponding hash value of “HD”. In the case of Bitcoin, the hash function used is SHA-256 (Secure Hash Algorithm).

After each transaction has been individually hashed to produce its corresponding hash value, the new hash values are combined with an adjacent partner to be hashed once again. For example, the hash values “HC” and “HD” are combined and hashed to produce the hash “HCD”. In the above example, there are 8 transactions with their own corresponding hash values. However, if there had been an odd number of hash values, such as 7, the 7th hash is simply paired with itself and hashed to produce a new hash value i.e., “HH” and “HH” would be combined to give “HHH”.

This process is repeated until the last hash value is obtained. This value is known as the “merkle root.” In the above example, the merkle root is “HABCDEFGH”. The merkle root is 32 bytes in size and is then taken to be placed inside the block header (representing a summary of all transaction data.”

 

Advantages of using merkle tree are i) easy to check if transactions have been tampered with; ii) uses fewer resources; and iii) easy to verify if a specific transaction has been added to the block.

Source: mycryptopedia 

 

For example, in the above diagram, if a user wants to check whether the transaction “HD” had been included in a block, instead of downloading the whole blockchain and checking, the only values the user would need are, the merkle root “HEFGH”, “HAB” and “HC”. Thus, it is better to download the specific chain than downloading the whole blockchain.

Tags:

Post a Comment

0Comments

Will review your comment and get back!

Post a Comment (0)