Merkle Tree – how it improved blockchain

Blockchain is very secure and what is worth to mention, entirely transparent. Blockchain is hard to remove from the world, because if there…

Merkle Tree – how it improved blockchain

Blockchain is very secure and what is worth to mention, entirely transparent. Blockchain is hard to remove from the world, because if there is only one server which contains the copy of network, it will survive.

Downloading entire blockchain copy can be inefficient, because of the storage which is required. Bitcoin network is about 350GB for 2021.

How to manage the network and all of the transactions without downloading such an amount of bytes?

The solution is a Merkle Tree.


Agenda:

  • Intro,
  • Definition,
  • How it works.

Definition

Simply said, Merkle tree is just a data structure widely used in computer science. It was named after Ralph Merkle, who designed that and also invented cryptographic hashing.

Merkle tree was considered as a great improvement of blockchain. It is used as a binary hash tree. What it means…

Thanks to Merkle tree, it is not required anymore to download entire blockchain copy to verify few, specific transactions.


How it works

To get acquainted with above mentioned feature, it is necessary to describe how Merkle tree works in blockchain network.

Let’s use bitcoin network as an example…

Bitcoin block is added once at about every 10 minutes, it does not mean that in a block is one transaction attached. Many transactions are “compressed” inside block data.

This “compression” is made by using Merkle tree. For example, assume that block should consist 8 transactions.

Each transaction is hashed, then each pair of transactions is also hashed and it is proceeded till one hash will be left.

If there is an odd number of transactions, one of them is doubled and is concatenated with itself.

Below is represented graph, which shows above example of 8 transactions. In real usage, block can consist even 500 transactions.

Let’s assume that we want to verify transaction number 4 on this graph. Having a root H12345678, process seems to be like sudoku.

Querying network about T4 will result returning H3, H12 and H5678. The Merkle tree allows you to verify that everything is accounted for with three hashes: given H12, H3, H5678, and the root H12345678, H4 (the only missing hash) has to be present in the data.


If you like my web3 challenge, visit repo which contains all of the days.

GitHub - Kacper-Hernacki/100-days-of-web3-challenge-blockchain-free-materials: This is the repo…
This is the repo which consists 100 topics about blockchain/ decentralisation/ web3. There are links to my articles,…