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.
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.
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: https://etherscan.io/tx/0xde34e2a6dc94b0fcf54a330bb3cd246764d37942317d7fa88493d0b29d24d7ed
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.
We are making crypto knowledge-sharing even more accessible to everyone by giving an avenue for Filipinos to connect about all-things crypto in Facebook. Be part of our community today.