What Is a Merkle Tree?
A Merkle tree is a binary tree where every non-leaf node stores the cryptographic hash of its two children. The root hash therefore summarises all leaves. Any change to a single leaf ripples upward, altering the root and exposing tampering.
Applications
- Blockchains: transaction integrity and efficient SPV proofs.
- Git: commit trees ensure repository history integrity.
- P2P protocols such as BitTorrent for piece verification.
Demo Instructions
- Press "Generate" to create a random batch of leaves (random data strings).
- The visual shows hash values at every level.
- Observe how changing any leaf re-hashes the path to the top.
The code relies on SHA-256
via the Web Crypto API and lives in games/js/demos.js
.