Double-SHA256 Linkage
Double-SHA256 Linkage
Bitcoin doesn't just use SHA-256 for its block links; it uses Double-SHA256 (also known as hash256). This means the Block Header is hashed, and then the resulting hash is hashed again.
1. The Algorithm
Mathematically, the link between blocks is calculated as: $$Block\ Hash = SHA256(SHA256(Block\ Header))$$
2. Why Hash Twice?
Satoshi Nakamoto never explicitly stated why he chose double hashing, but there are two primary technical theories:
A. Length Extension Attacks
Standard SHA-256 is vulnerable to a "length extension attack," where an attacker who knows $Hash(Message)$ can potentially calculate $Hash(Message + ExtraData)$ without knowing the original message. While this attack doesn't directly break block security, hashing twice ($Hash(Hash(M))$) completely eliminates this class of vulnerability.
B. Birthday Attack Hardening
Double-hashing provides an extra layer of protection against future cryptographic breakthroughs. If a partial weakness is found in a single round of SHA-256, the second round acts as a safety buffer.
3. Computational Efficiency
While double-hashing sounds like it would take twice as long, it is actually very efficient for SPV Nodes. Since the headers are only 80 bytes, calculating two rounds of SHA-256 takes only a fraction of a millisecond on modern hardware.
4. The Resulting Hash
The final output is a 256-bit number. For a block to be valid, this number must be lower than the current Target.
| Property | Value |
|---|---|
| Input size | 80 Bytes |
| Output size | 32 Bytes (256 bits) |
| Common Format | Hexadecimal (Big-Endian) |
The prev_hash field in a block is the exact 32-byte output of this double-SHA256 process applied to the previous header. This is the cryptographic glue that holds the entire financial history together.
Next, we will explore the Immutability Mechanics that result from this linked structure.
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: