Merkle Tree Fundamentals
Merkle Tree Fundamentals
The Merkle Root is the third field in the 80-Byte Block Header. It is a single 32-byte hash that cryptographically summarizes every single transaction included in the block.
1. What is a Merkle Tree?
A Merkle Tree is a Binary Hash Tree. Instead of hashing all transactions together in one long string (which would be inefficient), Bitcoin hashes them in pairs. * Leaf Nodes: The hashes of the individual Transaction IDs (TXIDs). * Branch Nodes: The hash of the concatenation of two child hashes. * Root Node: The final hash at the top of the tree.
2. The Pairing Process
If a block has 4 transactions ($TX_A, TX_B, TX_C, TX_D$): 1. Calculate hashes: $H_A = Hash(TX_A)$, $H_B = Hash(TX_B)$, etc. 2. Pair them: $H_{AB} = Hash(H_A + H_B)$ and $H_{CD} = Hash(H_C + H_D)$. 3. Final Root: Merkle Root $= Hash(H_{AB} + H_{CD})$.
3. Cryptographic Binding
Because the Merkle Root is included in the block header, any change to a transaction—even a single satoshi or a signature bit—will change its leaf hash. This change will ripple up the tree, changing every branch hash and ultimately changing the Merkle Root. This would make the block header (and thus the block hash) invalid.
4. Efficiency for SPV
The real power of the Merkle Tree is not just security, but efficiency. It allows a user to prove that a transaction is part of a block without needing to download the entire multi-megabyte block.
| Component | Role |
|---|---|
| TXID | The unique identifier of a transaction. |
| Leaf | The base level of the tree ($Hash(TXID)$). |
| Branch | Intermediate nodes representing pairs. |
| Merkle Root | The 32-byte summary in the block header. |
A Bitcoin block can contain thousands of transactions, but the Merkle Root is always exactly 32 bytes. This constant size is what keeps the block header small and easy to process for mobile wallets.
In the next section, we will look at the Merkle Path and how proofs work.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: