Skip to content
uencoder
TASK

Use Merkle trees for data verification

Merkle trees hash data into a tree structure, enabling efficient verification of individual elements without downloading the entire dataset.

  1. 1

    A Merkle tree hashes data blocks at the leaves, then pairs and hashes up to a single root. To verify a block, you need the block and its Merkle proof (sibling hashes along the path to the root). Verification is O(log n) instead of O(n) — you don't need all data, just the proof. Used in Bitcoin, Git, ZFS, and certificate transparency logs.

  2. 2
    Hash Calculator →

    Hash each data block to create leaf nodes. Use SHA-256 (Bitcoin) or SHA-3. Pair leaves and hash their concatenation to create parent nodes. Repeat until one node remains — the Merkle root. The root commits to all data: any change in a leaf changes the root.

  3. 3
    SHA-3 / Keccak Hash →

    Use SHA-3-256 for Merkle tree hashing. SHA-3 is resistant to length extension attacks (unlike SHA-2), making it safer for Merkle trees where hash concatenation is used. Alternatively, use SHA-256 with a domain separator (e.g., hash(0x00 || left || right) for internal nodes, hash(0x01 || data) for leaves).

Frequently asked questions

What is a Merkle proof?
A Merkle proof for a leaf consists of the sibling hashes along the path from the leaf to the root. For a tree with n leaves, the proof has log2(n) hashes. To verify: hash the leaf, combine with the proof hashes in the correct order, and check if the result equals the root. This proves the leaf is in the tree without downloading all data.
Where are Merkle trees used?
Bitcoin (transaction verification in blocks), Git (content-addressable storage), ZFS (data integrity), Apache Cassandra (anti-entropy repair), Certificate Transparency (log verification), and IPFS (content addressing). Any system that needs efficient verification of large datasets benefits from Merkle trees.

Workflows that solve this

Learn more

Want to understand why?

Related tools