6 min read
In the contents of any Bitcoin block we can find a structure that is called Merkle Tree. Although many of us are not very clear about what it is, it is a vital component for the functioning of the block chain.
That’s why today we’re going to do a general review of these trees, which, although they aren’t planted on the ground or watered, have produced a lot of good fruit. So much so, that it is even normal to see people from crypto space with a Merkle Tree stamped on their shirts, hats and laptops (mmm, maybe we could raffle one off in our Telegram group).
Merkle trees are a data structure that have been created for the purpose of making verification of large amounts of data more efficient.
To do so, they relate these data through cryptographic and information management techniques.
This tree or data structure is divided into several layers that have the purpose of relating each network node with a single root associated with them. To make this possible, each node must have a unique identifier (also called a hash).
These first nodes (leaves) are associated with a superior node or parent node (branch). This parent node, will carry a unique identifier that is a result of the hash of its previous nodes (leaves). Thus, successively the structure is repeated until arriving at the root node or merkle root whose stamp is associated with all the nodes of the tree.
In short, this is how Merkle Trees can relate large amounts of data in a single point or Merkle Root. Thanks to this, the verification or validation of any of these data becomes much faster and more efficient. Thus, it will no longer be necessary to verify the entire structure but simply to verify the root.
How does a Merkle tree work?
To understand a little better what we talked about in the previous paragraph, let’s expand on the operation of a merkle tree:
This tree is a structure that relates all the transactions and later joins them between pairs to create a Root Hash. This hash is related to all the hashes that exist in the tree.
If a hash is modified, it will cause all hashes to change until they reach the root of the tree, and this root will invalidate the authenticity of the information in the entire tree.
This feature is what gives merkle trees a very high level of security.
Merkle Tree Example
Imagine a block in the Bitcoin blockchain that has a unique and unrepeatable hash. This block is linked to a higher layer by this hash. This way, the blocks above always point to the blocks below.
And the hash of the upper blocks is the result of the sum of the information contained in the new block with the hash of the previous block. So, as you keep scaling up, the structure of the tree itself becomes intertwined and forms one big block of data
A problem or alteration in one block overrides all other blocks. This system facilitates the verification of block data and the detection of hash changes.
Ralph Merkle was the creator of this design in 1979, in order to streamline the process of verifying large amounts of data.
Characteristics of Merkle trees
Among the most important characteristics of these trees are:
– They are a very efficient way to create a distributed data structure.
– They provide great security and resistance to possible data alterations.
– They reduce the necessary amount of data and improve the level of performance in data transmission.
– They allow for “dissection” to make faster verification searches without compromising security and traceability.
– They have low computational cost and are very efficient.
– They have a great capacity to adapt to different systems and have been used for database software, public key structures, distributed peer-to-peer networks, versioning systems, etc.
Relationship between Merkle Tree and Blockchain
If you wonder what the uses of Merkle Trees are today, you’ll find that one of their main applications is block chains.
So much so, that it is a fundamental part of a blockchain since thanks to them, the client software allows you to download the complete history of the chain and verify it. It also serves to cut part of the history and reduce the weight by creating the pruned nodes.
The use of merkle trees in blockchain technology is vital. Thanks to its use, the client software can download the whole history of the blockchain and verify it hot. In fact, its use facilitates the process by allowing “pruning” (taking only a part of the history) the history and reducing the size of the download.
This does not harm the security of the client, since thanks to the merkle tree, you can download a certain “root hash” and start creating a history from that point. Since this root hash is related to all the blocks that precede it, all you have to do is check it.
For this reason, you go to the complete Bitcoin nodes that have all the transaction history and simply check that the root hash taken matches. Once this is done, the user can easily use his new Bitcoin client node.