FIG. 03 · Guides

Merkle trees and verifiable logs: proving a record exists with a handful of hashes

A Merkle root is a 32-byte fingerprint of an entire log. This guide shows how to prove that one record is inside it without revealing or downloading the rest.

Published: 4 December 2026 Updated: 4 December 2026 6 min read

Suppose a company keeps an audit log of every administrative action, a public registry lists every software release it has signed, or a certificate authority records every TLS certificate it has issued. Outsiders need two guarantees from such a log: that a specific record really is in it, and that nobody has quietly rewritten history. Sending everyone the whole log is impractical. A Merkle tree solves both problems with a few kilobytes of hashes at most.

The Merkle Proof Verifier builds real trees in your browser. This guide explains what it is doing.

Hashes as fingerprints

A cryptographic hash function such as SHA-256 maps any input to a fixed 32-byte output. Three properties matter here.

  • Deterministic. The same input always gives the same hash.
  • Avalanche. Changing a single bit of the input changes about half of the output bits.
  • Collision-resistant. Nobody knows how to find two different inputs with the same SHA-256 hash.

Together they mean that a hash works as a fingerprint: if two hashes match, the inputs match.

Building the tree

Hash every record to get the leaves. Then pair the leaves from left to right and hash each pair to get the next level up. Repeat until one hash remains: the Merkle root.

                 root = H(H01 ‖ H23)
                /                    \
        H01 = H(L0 ‖ L1)       H23 = H(L2 ‖ L3)
          /        \             /        \
       L0 = H(r0) L1 = H(r1)  L2 = H(r2) L3 = H(r3)

Here ‖ means concatenation. The root depends on every byte of every record, and on their order. Publish the root, or sign it, and you have committed to the entire log in 32 bytes.

Inclusion proofs

To prove that record r2 is in the log, you do not need the other records. You only need the siblings along the path from r2 to the root: L3, then H01. The verifier recomputes:

L2   = H(r2)
H23  = H(L2 ‖ L3)     sibling on the right
root = H(H01 ‖ H23)   sibling on the left

If the result equals the published root, r2 is in the log at that position. The proof grows with the logarithm of the log size: a log with a million entries needs only 20 sibling hashes, 640 bytes, to prove any single entry.

Each sibling must be tagged with its side, because H(a ‖ b) and H(b ‖ a) are different. A careful verifier also checks that the sequence of sides matches the claimed leaf index and tree size. Otherwise a valid proof for one position could be presented as a proof for another. The verifier in the instrument performs this check and reports a position mismatch separately from a wrong root.

Domain separation: leaves are not nodes

The naïve tree above has a subtle weakness. An inner node is the hash of 64 bytes, two child hashes. If someone submits those same 64 bytes as a record, its leaf hash equals the inner node’s hash, and a forged proof can present an inner node as if it were a leaf. This is a second-preimage attack on the tree structure, not on SHA-256 itself.

RFC 6962, the specification behind Certificate Transparency, fixes this with a one-byte prefix:

leaf hash  = SHA-256(0x00 ‖ record)
inner node = SHA-256(0x01 ‖ left ‖ right)

A leaf can now never collide with an inner node, because their inputs start with different bytes. The instrument lets you switch domain separation off to see how every hash changes, but production logs should always keep it on.

The odd-node pitfall

What happens when a level has an odd number of nodes? One common historical answer was to duplicate the last node and hash it with itself. That creates a real problem: the lists [a, b, c] and [a, b, c, c] produce exactly the same root, so two different logs share one commitment. A well-known 2012 vulnerability, CVE-2012-2459, came from exactly this ambiguity in a widely deployed system.

RFC 6962 avoids it by splitting the list at the largest power of two smaller than its length, which is equivalent to promoting a lone last node to the next level unchanged. The instrument offers both rules side by side. Choose the duplicate rule with three leaves, then add a fourth leaf identical to the third: the root does not change. With the promote rule it does.

Detecting tampering

Because each inner hash depends on its children, changing one record changes exactly one path: its leaf, each ancestor and the root. Everything else stays identical. In the instrument’s tamper lab, seal a baseline, edit one leaf, and the changed path turns crimson all the way up while untouched subtrees stay green. With 16 leaves, one edit changes 5 of the 31 hashes.

This is also why the root alone is enough to detect tampering. Anyone holding yesterday’s signed root can tell that a rewritten log no longer matches it.

Where Merkle trees are used

  • Certificate Transparency. Certificate authorities submit every certificate to public append-only logs defined by RFC 6962 and its successor RFC 9162. Browsers require proof that a certificate was logged, and monitors watch the logs for certificates that nobody requested.
  • Software supply-chain transparency. Signing services record every signature in a public transparency log, so a compromised signing key or a malicious release leaves a permanent, verifiable trace.
  • Tamper-evident audit logs. Internal systems append administrative actions to a Merkle log and publish or archive the root regularly. An auditor can later prove that a record existed at a given point in time.
  • Anti-entropy in distributed databases. Replicas compare Merkle trees of their key ranges and only exchange the subtrees whose hashes differ, rather than every row.
  • Version control. Git stores content-addressed trees of hashes, a close relative of the same idea.

What a root does not prove

A Merkle proof shows that a record is in the log described by a root. It does not show that the root is the one everybody else sees. Real transparency systems therefore sign their roots, publish them widely and use consistency proofs to show that each new root extends the previous one without rewriting it. Verifiers also gossip roots with each other, so that a log cannot show different histories to different people.

Encoding matters too. Hash a precise, canonical byte representation of each record, because two serialisations of the same data produce different leaves.

Try it

Open the Merkle Proof Verifier, load the certificate transparency preset, select a leaf and send its proof to the independent verifier. Then change one character of the proof and watch the verifier reject it.