The graphical representation of the Merkle tree looks like this:
In the diagram, the initial leaves are the base blocks, then above them are their hashes. At a higher level, branches are spliced together — hashes are summed. This sequential folding occurs until a single hash is calculated – the root of the Merkle tree.
This principle of building a blockchain was proposed long before the emergence of the first blockchain platform. The author of the idea is Ralph Merkle, an American cryptographer, who patented the hash tree principle back in 1979.
Merkle tree in a decentralized network
Modern multi-blockchains with millions of transactions need an efficient yet simple way to verify and store information. And here you cannot do without the Merkle tree, which makes it as easy as possible to verify the authenticity of blocks.
It is a data structure in which huge amounts of information are hashed step by step into one light root hash. This hash has all the properties of a usual one: it does not disclose the data of its components, but at the same time it provides verification of the validity of a transaction written in a tree block.
Merkle tree validation is performed using Merkle proof. The correctness of the block is confirmed or denied when a check is run from the root hash to the required block. In this case, it is not necessary to know all the data, the Merkle root and the data to be checked are enough.
Hash tree with a simple example:
If you compare a Merkle tree with a family tree, then the ancestors are the original leaves, and the final descendant is the root. The root code is the genetic code of the descendant. And the leaf code is the genetic codes of its ancestors. Harry declares to his friend Jack that he is the heir of Genghis Khan and shows the genetic code – his and the famous ancestor. This makes it possible to verify if Genghis Khan is one of Harry’s ancestors, ignoring all the other generations that came between them. Similarly, in a Merkle tree, you do not need to know the rest of the values and the number of branches in order to check the validity of a particular tree block.
The Merkle tree makes it possible to significantly lighten the load on the network, since when proving the correctness of a block, it only needs to go through the branch with the required block. There is no need to recheck absolutely all blocks from a subset. Simplified inspection saves energy and time. This is a decisive advantage of hash trees over other hash schemes. It allows for increased scaling by speeding up validation processes.
For multi-blockchains like Free TON, Merkle trees provide high-quality scalability and ease of use even for low-power nodes. The nodes, relying on the Merkle proof, use only the Merkle roots, which drastically simplifies the storage and system bandwidth requirements. Thus, the Merkle Tree facilitates scalability, increases privacy and at the same time transparency of processes.