SHA-256
Technical • Cryptography • Hash Algorithms
the cryptographic engine behind Bitcoin and proof-of-work security
SHA-256 (Secure Hash Algorithm 256-bit) is a cryptographic hash function that converts any input data into a fixed 256-bit (64-character hexadecimal) output. Designed by the National Security Agency and published in 2001 as part of the SHA-2 family, it is deterministic (same input always produces the same output), irreversible (original data cannot be derived from the hash), and collision-resistant (no two different inputs have ever produced the same output). SHA-256 is the cryptographic backbone of Bitcoin. Every block header is double-hashed with SHA-256 to produce the value miners race to solve. Every transaction ID is a SHA-256 double hash of the serialized transaction data. Every Merkle tree pair is concatenated and double-hashed with SHA-256 to build the Merkle root. Every Bitcoin address includes a SHA-256 checksum to prevent typos. The algorithm processes data in 512-bit blocks through 64 rounds of bitwise operations, producing a 256-bit digest that provides 128 bits of collision resistance — a search space so vast that brute-force attacks remain physically impossible with any foreseeable technology. SHA-256 uses the Merkle–Damgård construction, which introduces a theoretical vulnerability to length-extension attacks. Bitcoin mitigates this by double hashing — applying SHA-256 twice in sequence so the intermediate state is never exposed. Not all blockchains use SHA-256. Ethereum chose Keccak-256 (SHA-3 family), which uses a sponge construction immune to length-extension attacks without requiring double hashing. Litecoin uses Scrypt for mining but SHA-256 for transaction IDs. Understanding which algorithm a chain uses is fundamental to evaluating its security model.
Use Case: A Bitcoin miner takes an 80-byte block header containing the version, previous block hash, Merkle root, timestamp, difficulty bits, and nonce — then runs SHA-256 twice. If the resulting 256-bit output falls below the network’s difficulty target, the block is valid and broadcast. If not, the miner increments the nonce and hashes again — billions of times per second.
Key Concepts:
- Keccak-256 — Ethereum’s sponge-based alternative that eliminates the length-extension weakness SHA-256 requires double hashing to mitigate
- Cryptographic Hash — The broader category of one-way functions that SHA-256 belongs to
- Single Hash — One-pass application of SHA-256 producing a single digest
- Double Hash — Bitcoin’s SHA-256(SHA-256()) method that eliminates length-extension exposure
- Collision Resistance — The property that makes SHA-256’s 2^128 collision search space infeasible to crack
- Merkle Root — Built from SHA-256 double-hashed transaction pairs
- Block Headers — 80-byte structure double-hashed with SHA-256 for mining and chain linking
- Proof of Work — Consensus mechanism where miners compete to find valid SHA-256 outputs
- Merkle–Damgård Construction — The internal architecture of SHA-256 that processes data in 512-bit blocks
- Keccak-256 — Ethereum’s alternative hash algorithm using sponge construction instead of Merkle–Damgård
- 256-Bit Output — Fixed-length digest providing 128 bits of collision resistance via the birthday bound
- Hashing Individual Transactions — Each Bitcoin TXID is produced by applying SHA-256 twice
- Block Verification — Nodes verify blocks by independently recomputing the SHA-256 double hash
- Security Model — Framework where SHA-256’s collision resistance is a foundational assumption
- Blockchain — Linked chain structure secured by SHA-256 hash dependencies at every level
Summary: SHA-256 is the specific algorithm that turns Bitcoin’s theoretical design into a functioning trustless system. It secures block headers, transaction IDs, Merkle trees, and wallet addresses through a single mathematical function that has remained unbroken for over two decades. Understanding SHA-256 is understanding why proof-of-work works.
How SHA-256 Processes Data
64 rounds of mathematical transformation
SHA-256 breaks input data into 512-bit blocks and processes each through 64 rounds of bitwise operations. The result is a 256-bit digest that is completely different even if a single bit of input changes.
Avalanche Effect: Changing one bit of input changes approximately 50% of the output bits. This property ensures that similar inputs produce completely unrelated hashes — making pattern-based attacks impossible.
Where Bitcoin Uses SHA-256
the algorithm touches every layer of the protocol
Cross-Chain Hash Algorithm Map
different chains, different algorithms, same security goal
Key Insight: SHA-256 dominance extends beyond Bitcoin. Even chains that use different mining algorithms often rely on SHA-256 for transaction IDs and address generation — it remains the most battle-tested hash function in the blockchain ecosystem.
SHA-256 Checklist
algorithm literacy — four-quadrant self-assessment
The same SHA-256 protecting Bitcoin’s chain protects your private keys — store them in Ledger or Tangem. The algorithm is only as strong as the custody around it.