What is a Merkle tree? Proving one record without revealing the rest
What is a Merkle tree? Proving one record without revealing the rest
A Merkle tree is a way of combining many hashes into a single hash, called the Merkle root. It lets you prove that one specific record belongs to a large set without showing anyone the rest of the set.
It's named after Ralph Merkle, who patented the idea in 1979. Today it sits inside Bitcoin, Ethereum, Git, and most systems that need to prove data integrity at scale.
How it actually works
Start with a list of records. Say it's a loan tape with 10,000 loans.
- Hash each loan record individually. You now have 10,000 hashes. These are the leaves of the tree.
- Pair the hashes up and hash each pair together. You now have 5,000 hashes.
- Repeat. 2,500. 1,250. And so on, halving each time.
- After about 14 rounds you're left with one hash. That's the Merkle root.
The root depends on every leaf. Change one character in one loan record and its leaf hash changes, which changes its parent, which changes every hash on the path up to the root. One root fingerprints the whole set.
The inclusion proof
Here's the clever part. Suppose a borrower, an auditor, or an investor wants to confirm that loan #4,812 is in the set behind a published root. You don't hand over all 10,000 records. You hand over:
- loan #4,812 itself
- the sibling hash at each level on its path to the root (about 14 hashes)
The checker hashes the loan, combines it with each sibling in turn, and sees whether the result equals the published root. If it does, the loan is in the set. They've learned nothing about the other 9,999 loans except that they exist.
The proof grows with the logarithm of the set size, not the set size. A tree with a million leaves needs about 20 sibling hashes. A billion, about 30.
Why it matters
Private credit has a disclosure problem. Investors want evidence that the assets they're exposed to exist and haven't changed. Borrowers and originators have a legitimate need to keep loan-level data private. Publishing the full tape satisfies the first group and breaks faith with the second.
Merkle trees split the difference. Publish the root, and anyone can later verify any individual record against it, on request, without exposing the others. The root can be recorded somewhere permanent (see Hash-then-anchor), and every future version of the tape can be compared against it.
Limits
A Merkle proof shows a record is in the set. It doesn't show the record is accurate, and it doesn't show the set is complete. Someone could leave a bad loan out before building the tree. Completeness and accuracy still come from checking the data against its sources before it's hashed. The tree only makes the result tamper-evident.