🌳 Merkle Tree
Hash trees & proofs
root: 0000
8 leaves · depth 3
Data blocks (leaves)
Setup
Verify (Merkle proof)
Stats
Leaves
8
Tree levels
4
Proof size
Status
Ready
Info & Theory

A Merkle tree (hash tree) summarises many data blocks with a single hash, the Merkle root. Each leaf is the hash of a data block; each internal node is the hash of its two children concatenated.

How it is built

  • Hash every data block to form the leaf level.
  • Hash each adjacent pair together to form the parent level.
  • Repeat until a single node remains — the root. An odd node is duplicated (paired with itself).

Tamper evidence

Change one byte of one block and its leaf hash changes, which changes its parent, and so on up to the root. The root is a fingerprint of the entire dataset: any change is detectable from the root alone.

Merkle proof (inclusion proof)

To prove a block belongs under a known root you do not need all the data — only the sibling hash at each level on the path from the leaf to the root. That is just O(log n) hashes. The verifier rehashes upward and checks the result equals the trusted root.

Where it is used

Bitcoin and Ethereum block headers store a Merkle root so light clients can verify a transaction with a tiny proof. Git, IPFS, Certificate Transparency and many databases use the same idea for efficient, tamper-evident integrity checks.

About this simulation

For speed and clarity the hashes here use a small non-crypto mixing function (FNV-1a style) shown as short hex. Real systems use SHA-256 or Keccak, but the tree structure and proof logic are identical.

Frequently asked questions

What is a Merkle tree?

A Merkle tree is a binary tree of hashes. The leaves are hashes of data blocks and every parent is the hash of its two children, so a single root hash summarises all the data beneath it.

What is the Merkle root?

The Merkle root is the single hash at the top of the tree. It acts as a compact fingerprint of the entire dataset; if any block changes, the root changes too.

What is a Merkle proof?

A Merkle proof (or inclusion proof) is the set of sibling hashes along the path from a leaf to the root. With it you can prove a block belongs under a known root without revealing the other blocks.

Why does changing one leaf change the root?

Because each parent hash depends on its children, a change to one leaf cascades upward: its parent, grandparent and ultimately the root all change. This is what makes the tree tamper-evident.

How big is a Merkle proof?

A proof contains one sibling hash per tree level, so its size grows as O(log n) with the number of leaves n. For a million leaves that is only about twenty hashes.

Where are Merkle trees used?

They are used in Bitcoin and Ethereum block headers, Git commit history, IPFS, Certificate Transparency logs and many distributed databases for efficient integrity verification.

What happens with an odd number of leaves?

When a level has an odd number of nodes, the last node is paired with a copy of itself before hashing. This keeps the tree binary at every level.

Is the hash in this simulation cryptographically secure?

No. For speed the demo uses a small FNV-1a style mixing function shown as short hex. Real systems use SHA-256 or Keccak, but the tree structure and proof logic are exactly the same.

Can a Merkle proof verify a block is absent?

A standard Merkle proof shows inclusion. Proving absence requires a sorted variant such as a Merkle Patricia trie or a sparse Merkle tree, which this simulation does not cover.

How does a light client use the root?

A light client trusts only the small block header containing the root. To check a transaction it requests just the O(log n) sibling hashes, rehashes upward and compares against the trusted root.