Skip to main content

This site is for educational purposes only. Nothing here constitutes financial advice.

Topic 180 of 189

Merkle Trees & Merkle Proofs

A Merkle tree condenses many items into one root hash, and a Merkle proof shows one item belongs under it; this page covers Bitcoin and Ethereum uses.

Beginner
8 min readUpdated October 2026Block Clarity Hub Editorial Team

The basics

A Receipt of Receipts

A hash is a fixed-size fingerprint of some data: change one character of the input and the fingerprint changes completely. A Merkle tree applies this idea in layers. Hash every item, join the fingerprints in pairs and hash each pair, then repeat until a single fingerprint remains, called the root. Change any item and the change travels upward, altering every fingerprint above it and the root. The Bitcoin whitepaper illustrates this with four transactions: Hash0 to Hash3 sit at the bottom, Hash01 and Hash23 above them, and one Root Hash on top.

Why a Block Carries One Root

A Bitcoin block header is only 80 bytes, yet the block can hold thousands of transactions. The header carries just the Merkle root, built from the transaction ids. According to the Bitcoin developer reference, this ensures that none of the transactions can be modified without modifying the header. When a level has an odd number of hashes, Bitcoin's rule is to pair the last hash with a copy of itself. A node that keeps the headers therefore holds a compact commitment to the transactions in every block.

Checking One Payment Without the Whole Block

A phone wallet cannot download every block. The whitepaper's answer, simplified payment verification, is to keep only the block headers of the longest chain and to obtain the Merkle branch, the handful of hashes linking one transaction to the root in its block. The wallet cannot check the transaction itself, but it can see that the transaction sits in a block of the chain and that more blocks have been added after it. The whitepaper warns that this method can be fooled by an attacker's fabricated transactions for as long as the attacker overpowers the network.

  1. Worked example with four transactions: hash each one to get Hash0, Hash1, Hash2 and Hash3.
  2. Join Hash0 with Hash1 and hash the pair to get Hash01; do the same with Hash2 and Hash3 to get Hash23.
  3. Join Hash01 with Hash23 and hash them to get the Root Hash stored in the block header.
  4. To prove the fourth transaction, send Hash2 and Hash01; the checker recomputes Hash3, Hash23 and the root, then compares the result with the header.

Key Takeaways

  • A Merkle tree turns many items into one root hash by hashing pairs repeatedly.
  • Changing any item changes the root, so a block header commits to every transaction in the block.
  • A Merkle branch lets a light wallet check that a transaction is in a block without downloading the block.
  • A branch only proves inclusion under a root; the wallet must still trust the header that holds the root.

Going deeper

Branches, Audit Paths and Hashing Rules

A Merkle proof is the list of sibling hashes along the path from a leaf to the root. RFC 6962, published in June 2013 for Certificate Transparency and since obsoleted by RFC 9162, calls it an audit path: the shortest list of additional nodes needed to recompute the root. A verifier combines the leaf with one sibling per level and compares the result with a root it already trusts. With n leaves the path holds about log2(n) hashes, so, for example, a tree of 4,096 leaves needs 12 hashes of 32 bytes each, 384 bytes, instead of 4,096 leaves. Bitcoin's documented rule joins two 32-byte hashes as 64 raw bytes, applies SHA256 twice, and pairs a last odd hash with itself.

Light Clients: From Bloom Filters to Block Filters

BIP-37, assigned in October 2012, let a light client send a Bloom filter to a full node, which answered with a merkleblock message: a block header plus part of a Merkle tree proving that the matching transactions were in the block. BIP-37 itself notes that remote peers may correlate transactions with IP addresses, and that lying through omission remains possible. BIP-157, marked Deployed as of October 2026, says BIP-37 has known flaws for security and privacy and that most implementations offer virtually 'zero privacy'. It proposes compact filters that the client downloads and tests locally.

Ethereum: Tries, eth_getProof and Airdrop Claims

Ethereum stores its state in a modified Merkle-Patricia trie whose branch nodes have up to 16 children. According to ethereum.org, a block header carries roots from the state, transactions and receipts tries. EIP-1186 defines the eth_getProof method, which returns an account's values with an accountProof of RLP-encoded trie nodes starting at the stateRoot node. The EIP says that, combined with a stateRoot from a block header, this enables offline verification of any account or storage value.

The Uniswap merkle-distributor contract, as read in October 2026, shows the pattern for token claims. It stores one immutable merkleRoot, and its claim function takes an index, account, amount and Merkle proof. The contract hashes the index, account and amount into a leaf, checks the proof against the root, reverts with InvalidProof if the check fails, and records the index in a bitmap so it cannot be claimed twice. The full recipient list is never stored in the contract.

A Proof Needs a Trusted Root

A Merkle proof shows that a leaf sits under a particular root and nothing more. An SPV wallet takes its roots from block headers on the longest chain, and the EIP-1186 text describes verifying proofs given a trusted block hash. If the root itself is wrong, a perfectly valid-looking proof is worthless, which is why light clients put so much effort into choosing which headers to believe.

Key Takeaways

  • A Merkle proof is one sibling hash per level, so its size grows with the logarithm of the item count.
  • BIP-37 returned Merkle proofs to light clients, and BIP-157 criticises its privacy and security.
  • Ethereum block headers commit to state, transaction and receipt tries, and eth_getProof exposes state proofs.
  • Airdrop contracts store only a Merkle root, and each claimant supplies a proof for their own entry.

Under the hood

Where the Construction Breaks

A comment in Bitcoin Core's source warns anyone designing a new system that its Merkle algorithm has a serious flaw related to duplicate txids, tracked as CVE-2012-2459. When a level has an odd number of hashes, the last one is duplicated before the next level is computed, so different transaction lists can produce the same root: the comment shows that the lists [1,2,3,4,5,6] and [1,2,3,4,5,6,5,6] give the same root. An attacker could send a modified block with the same root and block hash, and a node that marked it permanently invalid would refuse the unmodified version. As read in October 2026, the defence is to detect identical hashes paired at the end of a list and treat the block as having an invalid Merkle root.

Domain Separation and the Shape of the Tree

RFC 6962, published in June 2013, takes a different route. It hashes a leaf as SHA-256 of a 0x00 byte followed by the data, and an interior node as SHA-256 of a 0x01 byte followed by its two children, a domain separation it says is required to give second preimage resistance. For n leaves it splits at k, the largest power of two smaller than n, so the shape is uniquely determined by n and nothing is duplicated. The Bitcoin developer reference, read in October 2026, describes no such prefix bytes and does duplicate a trailing hash, which is why the duplicate check above exists.

Append-Only Variants: Mountain Ranges

The Grin documentation, read in October 2026, describes Merkle Mountain Ranges as an alternative to Merkle trees, which rely on perfectly balanced binary trees: a list of such trees, or one tree truncated at the top right, that is strictly append-only and adds a parent as soon as two children exist. Its illustration, read in October 2026, has 11 inserted leaves and a total size of 19.

Proof Size and the Move Away from Hexary Tries

Wider nodes cost more siblings per level. As read in October 2026, EIP-7864 (status Draft) uses a tree of 2^32 entries to show this: its formula gives 15 x 32 x log16(2^32) = 3,840 for one branch of a hexary tree. The same method for a binary tree gives 1 sibling x 32 bytes x 32 levels = 1,024 bytes, a figure calculated for this topic and not stated in the EIP. EIP-6800 (status Stagnant as of October 2026) proposed Verkle trees instead, quoting a witness close to 3 kB per account in the hexary trie against about 200 bytes for Verkle. EIP-7864 also says its hash function is not final.

Inclusion Is Not Validity or Completeness

A valid Merkle proof says only that data sits under a root. The whitepaper notes that simplified verification can be fooled by fabricated transactions while an attacker overpowers the network, and BIP-37 notes that a node can lie by omission, so a client may miss a transaction that exists. Proofs of non-existence need extra structure; EIP-1186, for example, requires the node to supply enough trie data to verify that an address or storage value is absent.

Key Takeaways

  • Bitcoin's odd-level duplication let different transaction lists share one root, tracked as CVE-2012-2459.
  • RFC 6962 uses distinct leaf and node prefixes and a power-of-two split to avoid duplication and second-preimage confusion.
  • Merkle Mountain Ranges keep an append-only list of balanced trees.
  • Hexary tries have larger proofs than binary trees; as of October 2026 the replacement EIPs are Draft and Stagnant.
  • A proof verifies inclusion under a root, not that the root, the data or the set of results is complete.

Related Content

Solana Memecoin Cycles

How the Solana memecoin ecosystem works — Pump.fun mechanics, sniper economics, the graduate-to-Raydium pattern, and the recurring boom-bust dynamics that make it one of the most active but riskiest crypto sub-ecosystems.

Prediction Markets Deep Dive

How Polymarket, Kalshi, and Augur-style prediction markets work — the mechanism design, liquidity structure, regulatory divide, election-cycle dynamics, and where these markets are and aren't reliable signals.

Liquid Restaking Tokens (LRTs)

How LRTs (ether.fi eETH, Renzo ezETH, Puffer pufETH, Kelp rsETH, and others) build on Lido-style liquid staking and EigenLayer restaking, why they emerged, their yield economics, and the specific risks that don't apply to plain liquid staking.

PBS and MEV-Boost

How Proposer-Builder Separation (PBS) and MEV-Boost restructured Ethereum's block-production supply chain, who the builders and relays are, why it matters for censorship resistance, and what enshrined PBS would change.

Rollup Security Stages & Escape Hatches

Rollup security stages rate how much users must trust a rollup's operators and council, and escape hatches are the exits that still work without them.

Running a Node & Client Diversity

Running a node means checking a blockchain's rules yourself, and client diversity means no single software bug should decide what the network accepts.

Bitcoin Upgrades: SegWit, Taproot & Soft Forks

Bitcoin upgrades by soft fork: how SegWit and Taproot changed signatures and scripts, how activation worked, and where covenant proposals stand.

When an Exchange Fails: Custodial Claims & Bankruptcy

How courts treat customer balances when a crypto exchange enters bankruptcy, with estate property, dollar claims and three real cases as of October 2026.

References & further reading