An Introduction to Merkle Trees

Seaver Choy
Feb 19, 2024

Merkle Trees are vital to blockchain technology and its development. It uses the concept of hashing and cryptography. Merkle Trees focus on ensuring that a dataset is valid without actually having to check each datapoint from the start. To further understand why, let's imagine two scenarios of blockchain where: (1) you have the Merkle Tree data structure or algorithm and (2) where you don't have it. 

Blockchain, at its core, is a ledger that keeps a record of all transactions ever made. Let's have Alice, Bob, and Charlie send multiple transactions to each other and start with a balance of 100 each. 

Note: Balances are not stored in the blockchain, and the blockchain simply stores the transaction log of the entire blockchain.

Without Merkle Trees:

To verify if Bob can accomplish the transactions in the blockchain, the computer would have to make sure that Alice did actually send Bob the 100 from Block 1. If we magnified this to one thousand blocks later, I would have to read all the transactions of these blocks just to ensure that Bob actually has that amount. Sadly, that is not efficient, and it will eventually cost too much computational power.

With Merkle Trees:

I can now choose to assign a value to each transaction on a block. By hashing these values together, I can get a Merkle Root which is basically a combination of all proofs in a specific block. In the real world, the value would be much longer and harder to read, like:

Let's say I am trying to destroy the blockchain, and I decided to tamper Block 1. I want to change the second transaction in block 1 for Charlie to send 100 to Bob instead, but wait, the Merkle Root of Block 1 will change because the Proof of the second transaction changed to F. Since the Merkle Root has changed in the record of other validators, they will reject my block 1 since it doesn't match. Merkle Root allows us to check the validity of the blocks without having to go through each and every transaction.

In essence, the Merkle Tree is used to separate the proof that the data is valid and untampered and the data itself, so that the computer does not need to spend computational resources just to check each transaction until it reaches the last block generated. The computer can check the Merkle Root of each block and ensure that no block has been tampered.

Seaver Choy
Developer, Entrepreneur, Crypto Enthusiast

Seaver Choy has been passionate about technology since he was a child, from video games as a kid, to setting up his own computer rig as a teen, and working as a software engineer as an adult. He sees blockchain as the future of the transactional world, allowing people to easily create wallets without KYC and transact with each other without a middleman, ultimately reducing cost and making the world a bit more efficient.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Recommended reads from the metaverse