Checking a large set of records usually means getting all of it. You download the whole file, recompute what you were told and compare. That works for a short list. It breaks down when the set is huge, private or changes every day, and all you care about is whether your own entry is in it.
So what is a Merkle tree? It is a data structure that condenses many records into a single hash, called the Merkle root, and lets you check one record against that root with a short proof instead of the full data. You can follow the idea without any cryptography.
This piece stays vendor-neutral. It explains the data structure step by step, not any product: how the tree is built, how an inclusion proof works, why a small change shows up at the top, and what a root hash cannot tell you.
Key Takeaways
- A Merkle tree condenses many records into a single root hash that commits to the entire set.
- Change any record and every hash on its path changes, up to and including the root.
- An inclusion proof needs only the sibling hashes along one path, so it stays short even for very large sets.
- A root proves that a record belongs to a committed set, not that the set was built honestly or completely.
What a Merkle Tree Is
A Merkle tree is built from one primitive: the cryptographic hash function. A hash function takes any input, a word or a whole file, and returns a short fingerprint of fixed length. The same input always gives the same output. Change a single character and the output changes completely, with no visible link to the old one. And you cannot run it backwards. From the fingerprint alone, you cannot work out the input.
A Merkle tree stacks those fingerprints. Picture it upside down. At the bottom sit the leaves, one hash for each record. Above them sit parent nodes, each a hash of the pair below it. At the very top sits a single hash, the root. In effect, the root fingerprints the entire set, because every leaf below it has shaped its value.
Building the Tree: Leaves, Pairs, Root
Most designs build the tree with the same basic steps, even where the details differ.
First, you hash each record on its own. Those hashes are the leaves. The records themselves never appear in the tree. Only their fingerprints do.
Next, you take the leaves in pairs. For each pair, you join both hashes in a fixed order and hash the result. That gives you the next level up, which is smaller than the level of leaves.
Then you repeat. Pair the new hashes, hash each pair and move up again. You stop when a single hash is left. That hash is the Merkle root.
Order matters at every step. Joining the left hash before the right one gives a different result than the reverse, so a proof has to say on which side each hash belongs.
Real hash functions output far longer fingerprints, and real trees can hold far more records. The pattern stays the same.
Proving One Record Is Included
This is where the tree earns its keep. Say you hold a record and want to confirm it is part of a set, and all you have been given is the published root.
The holder of the full set sends you an inclusion proof, also called a Merkle proof. It contains the sibling hashes along the path from your leaf to the root: at each level, the hash your node gets paired with, plus the side it sits on.
You then do the work yourself. Hash your record to get your leaf. Join it with the first sibling and hash again. Join the result with the next sibling and hash again. Keep going until you reach the top. If your final hash equals the published root, your record is in the set. If it does not, either the record is not in the set or the proof is wrong.
Notice what you did not need. No other records. No full download. You needed your record, a short list of hashes and the root. Put simply, the proof follows a path, not the set, and that is why it stays small.
Because every level pairs up the nodes below it, the path grows very slowly as the set grows. A proof for a very large set is still a short list of hashes.
Why Changing One Record Changes the Root
The same chain of hashes works in the other direction. It makes tampering visible.
Change a single record, even by one character, and its leaf hash changes. Its parent was computed from that leaf, so the parent changes too. So does every node above it, all the way to the top. The root ends up different.
That has a practical consequence. Anyone who saved an earlier root can tell whether the set behind it has changed since, without keeping a copy of the data. A new root means something changed. The same root means nothing did, as long as the hash function holds.
It also explains why a root can be published on its own. A root does not show the records behind it, yet it commits to them. Once it is public, the holder cannot quietly swap a record and still claim the same root.
What a Merkle Root Does Not Tell You
A Merkle root is a strong commitment. It is not a guarantee about what was committed. Three limits matter when you read one.
It does not prove the set is complete. The tree only covers what went into the leaves. Whoever built it could have left records out before hashing, and the root would look exactly as valid. An inclusion proof tells you that your record is in. It cannot tell you what is missing. Absent records leave no trace.
It does not prove the records are true. A leaf is a hash of whatever data was supplied. If a record was wrong before it was hashed, the tree commits to the wrong record, faithfully. The result is valid structure around wrong data, and the math has no view on that.
It does not prove where the root came from. A proof checks your record against a root. If the root you were given is not the one that was actually published, or you cannot tell who published it, the check means little. The root has to come from a source you can check independently.
That is the core of verifying instead of trusting: a check is only as good as the anchor it checks against. CarrotFunding's documentation on transparency and on-chain proofs sets out the wallets, smart contracts and fund flows that power its protocol.
Where You Meet Merkle Trees: Proof of Reserves
One place you may meet a Merkle tree is a proof of reserves. A custodian that wants to show it holds its customers' balances can put each balance into a leaf, publish the root and give every customer an inclusion proof. Each customer can then confirm that their own balance was counted, without seeing anyone else's balance in the clear.
That covers inclusion, which is exactly what a Merkle tree does well. The limits from the previous section stay in place, and a reserves proof raises questions of its own about liabilities and timing. Our guide to what a proof of reserves can and cannot show works through those in detail.
Merkle Trees and Zero-Knowledge Proofs
Merkle trees and zero-knowledge proofs both prove something about data you cannot fully see. That makes them easy to mix up.
A Merkle proof shows that a specific record is part of a committed set. To do that, it usually reveals the record itself and the path of hashes. A zero-knowledge proof can establish a statement about data without revealing the data at all. Some systems combine the two, using a zero-knowledge proof to show something about the records under a Merkle root while keeping those records private.
Our primer on zero-knowledge proofs, in plain English explains how that works and where its guarantee ends.
Conclusion
A Merkle tree makes checking cheap and tampering loud. With a single record, a short path of hashes and a root you trust, you can confirm inclusion yourself, and any later change to the set shows up as a new root. What the tree cannot do is make the underlying claim true. It is only as honest as what went into its leaves, and only as useful as the root you check against. So when you see a published root, read it as an invitation to check, not as the proof itself. Ask who published it, when, and what went into the leaves before anything was hashed.
FAQ
Is a Merkle tree the same thing as a blockchain?
No. A blockchain is a chain of blocks, each linked to the one before it by a hash. A Merkle tree summarises a set of records under a single root. In many designs, each block carries the Merkle root of its transactions, so the block commits to all of them without listing them in its header. The two work together, but they are different structures.
What happens if a level has an odd number of nodes?
One node is left without a partner, and designs handle that differently. Some duplicate the last node and hash it with itself. Others carry it up to the next level unchanged. Duplication can let two slightly different lists produce the same root, which is a reason some designs avoid it. Either way, whoever checks a proof must follow the same rule as whoever built the tree.
How is a Merkle root different from a checksum of the whole file?
A checksum over a whole file tells you whether the file as a whole is unchanged. To check any part of it, you need all of it. A Merkle root commits to the same data in pieces. You can check a single record against it with a short proof, and when something changes, the tree shows which branch it sits in. That suits large sets that are shared in parts.
Can someone fake an inclusion proof?
Not against a sound hash function and a root you trust. Faking a proof would mean finding different inputs that hash to the same value, which a cryptographic hash function is designed to make impractical. Careful designs also hash leaves and inner nodes in distinct ways, so a pair of hashes cannot be passed off as a record. The realistic weak point is the root. A proof against the wrong root proves nothing useful.