SHA-256
The cryptographic hash function at the heart of Bitcoin mining and block creation. SHA-256 converts any input into a unique 256-bit fingerprint and is computationally irreversible, making it the foundation of Bitcoin's proof of work.
SHA-256, short for Secure Hash Algorithm 256-bit, is a cryptographic hash function that takes any input and produces a fixed-length 256-bit output, typically represented as a 64-character hexadecimal string. The function is one-directional: given an input, computing its hash is fast and deterministic, but reversing the process — finding the original input from just the hash — is computationally infeasible with current technology. Even a single character change in the input produces a completely different output, a property known as the avalanche effect.
Bitcoin uses SHA-256 in two critical ways. In mining, nodes compete to find an input value (the nonce) that, combined with the block data, produces a hash below a target threshold — a process that requires enormous computational effort but can be verified instantly by anyone. This is the core mechanism of proof of work. SHA-256 is also used to chain blocks together: each block contains the hash of the previous block, making any retroactive alteration of history detectable immediately.
SHA-256 was developed by the United States National Security Agency and published in 2001. As of today, no practical attacks against SHA-256 are known. The theoretical concern from quantum computing, specifically an algorithm called Grover's algorithm, does not apply to SHA-256 in the same way it does to asymmetric cryptography. The Bitcoin community actively monitors cryptographic research to assess whether the function's security assumptions remain valid over time.
Frequently asked questions
What is SHA-256 and why does Bitcoin use it?
SHA-256 is a cryptographic hash function that converts any input into a unique 256-bit fingerprint. Bitcoin uses it in two ways: in mining, where nodes must find an input that produces a hash below a target threshold, and in block chaining, where each block stores the hash of the previous one. SHA-256 makes Bitcoin's proof of work verifiable and its transaction history tamper-resistant.
What is the avalanche effect in SHA-256?
The avalanche effect means that even the smallest change in input — a single character, a single bit — results in a completely different and unpredictable output hash. This property is essential for security: it makes it impossible to predict what hash a slightly modified block header will produce, forcing miners to try billions of variations to find a valid one.
Is SHA-256 vulnerable to quantum computers?
The primary quantum threat to Bitcoin cryptography is against the elliptic curve signatures used to protect private keys, not against SHA-256 directly. Grover's algorithm could theoretically reduce the effective security of SHA-256, but this is a slower threat than the risk to asymmetric key cryptography. The Bitcoin community is aware of quantum computing developments and long-term mitigation strategies are actively being researched.