The Merkle tree. To keep blockchain safe!

Gepubliceerd op 15 augustus 2021 om 13:04

In this article I will discuss the 'Merkle tree'. The Merkle tree has an important role in the technique of the blockchain. In order to get a better understanding of the blockchain, it is important to discuss the Merkle tree in a separate article.

First of all, I will talk about what exactly the Merkle tree is and I will briefly explain where it comes from. Next, I will explain how the Merkle tree works in the technique. Then I will explain the importance of the Merkle tree for the blockchain. Why do we have a Merkle tree in the blockchain? Finally, I will explain why the Merkle tree is resistant to changes that occur in the Merkle tree (e.g. hacking attacks).

The Merkle tree is an integration of a number of data or information in a single data file (the Merkle root). This file is then verified on the blockchain. For example, suppose I want to send the following sentence to person B: 'the COVID-19 Pandemic causes millions of infections in 2020'. If I try to send this sentence, I want to be able to do so safely and efficiently. The Merkle tree ensures that not every word has to be sent one by one. The Merkle tree ensures that only one file needs to be sent to person B (the Merkle root). This ensures more efficient data exchange.

The Merkle tree is named after Ralph Merkle, a computer scientist. He invented and designed the Merkle tree and was one of the founders of asymmetric encryption (part of the digital signature). In his famous paper, Merkle discusses the technical elaboration of the Merkle tree and the Merkle root. See the link to his paper ( The Merkle root is elaborated in section 6 (page 125).

The Merkle tree works as follows: first, all words are hashed. Hashing is a process in which input (e.g. the word ''pandemic'') is converted into a hash value (output). The hash value of the word ''pandemic'' is 9D51A179. This is a series of letters and numbers that always have 9D51A179 as output for the word ''pandemic''. If you change the word to ''Pandemic'', for example, this produces a completely different hash value. In my example, all the words are hashed (the word ''de'' until ''2020''). After hashing each word, I hash the hash values of the words ''de'' and ''worldwide''. I also do this for the hash values of the other words, always in pairs. Then I hash again the hash values that came out of this. You do this until one hash value remains at the top. So what you see is a 'tree' with a 'core' (root). This is why it is called a Merkle tree and root. See below for an example of the Merkle tree with its Merkle root:

The Merkle tree of the transaction/message 'the COVID-19 Pandemic causes millions of infections in 2020' looks as follows:

Why is the Merkle root important for the blockchain? A Merkle Tree can significantly reduce the amount of data that needs to be processed for verification purposes.
The Merkle Tree has four major advantages:

- They offer a way to demonstrate both the integrity and validity of the data;

- They reduce the amount of memory needed to do the above;

- Verification and management require only a small amount of information to be transmitted over the networks (1 datafile instead of 8);

- Simplified Payment Verification - a way to verify transactions in a block without downloading an entire block (efficient).

It is essential for the blockchain technology that the ledger is demonstrably complete and consistent. Merkle Trees helps to validate that later versions of a ledger contain everything from an earlier version. They also ensure that all data is recorded in chronological order and presented in the blockchain. This makes the blockchain transparent.

What if we change the transaction ‘veroorzaakt’? The figure below illustrates what happens when we change not only the details of a transaction ('veroorzaakt'), but also the hash reference that refers to the updated transaction. The updated hash reference (hash d, hash cd and hash abcd) is valid because it correctly refers to the new transaction data (the transaction ''veroorzaakt''). However, the updated hash reference is part of a Merkle tree whose root is also a hash reference. The root of the Merkle tree (root hash abcdefgh) refers to a piece of data containing the hash reference hash abcd. The latter (hash d associated with ''veroorzaakt'') has been modified to be consistent with the manipulated version of the word/transaction ''veroorzaakt''. Therefore, the hash value of hash cd and hash abcd also changes, making the root of the Merkle tree hash abcdefgh invalid. In other words: if you change a transaction (in this example ''veroorzaakt''), then the hash values (hash d, cd and abcd) also change. As a result of changes in the hash values, the hash value of the Merkle root also changes. And because the hash value of the Merkle root changes, it is clear that the transaction has been tampered with, making the Merkle root (and the entire data structure) invalid.

The Merkle tree is an indispensable link in the blockchain. The Merkle tree ensures efficient data exchange and less disk space. The Merkle tree also ensures secure data transfer. The hash technology makes this possible. If the transaction and the corresponding hash value is changed, the Merkle root (and the entire data structure) is invalid. For example, the recipient can see that the message has been tampered with. 

I published this article previously on my LinkedIn page. This article was written on July 5 2020.

BTC address: bc1q3nnm8m2vrsv8med8a38dl37g8l3mm4wa7ph7wj 

ETH address: 0x38b84E2D3B50F83A067A7488C1733180651f418A

Reactie plaatsen


Er zijn geen reacties geplaatst.