Definition
A cryptographic hash function is a mathematical algorithm that takes any input data, no matter how large or small, and turns it into a fixed-length digest. Some modern versions, called eXtendable Output Functions (XOFs), can produce outputs of a customizable length. Hash functions have several essential properties: they are deterministic, meaning the same input always gives the same output; they are preimage resistant, so it is practically impossible to reverse a hash to find the original input; they are collision resistant, making it virtually impossible to find two different inputs that produce the same hash; and they exhibit the avalanche effect, where even a tiny change in the input results in a completely different output. Bitcoin uses SHA-256 for mining and transaction hashing, while Ethereum uses Keccak-256, a variant of SHA-3. Hash functions are the foundation of blockchain security—they enable everything from proving work in mining to creating Merkle tree proofs and signing transactions.
Hash Function Properties Illustrated
SHA-256 hash examples: Input: “Hello” Output: 185f8db32271fe25f561a6fc938b2e26…
Input: “hello” (lowercase) Output: 2cf24dba5fb0a30e26e83b2ac5b9e29e… → Completely different (avalanche effect)
Input: 10MB movie file Output: Still only 64 hex characters (256 bits) → Fixed output size regardless of input size
Preimage resistance demonstration: Target: Find input that produces “0000abc…” Only method: Brute force (try billions of inputs) Bitcoin mining: Exactly this – find nonce producing hash below target At 500 exahash/second (Bitcoin network): ~500,000,000,000,000,000,000 attempts/second
Collision resistance: Goal: Find two different inputs producing same hash SHA-256: No collisions found (2^128 operations to find one) SHA-1 (deprecated): Collisions found (Google, 2017) → No longer trusted
Hash Functions Used in Crypto
| Hash Function | Output Size | Used In | Status |
| SHA-256 | 256 bits | Bitcoin (mining, transactions) | Secure |
| Keccak-256 | 256 bits | Ethereum (addresses, transactions) | Secure |
| SHA-3-256 | 256 bits | Some newer protocols | Secure |
| BLAKE2/BLAKE3 | Variable (as an XOF) | Zcash, some protocols | Secure, faster |
| SHA-1 | 160 bits | Legacy (deprecated) | BROKEN (collision found) |
| MD5 | 128 bits | Legacy (deprecated) | BROKEN (collision trivial) |
| RIPEMD-160 | 160 bits | Bitcoin address derivation | Secure (with SHA-256) |
FAQ
Q: Why can’t we reverse a hash to find the input?
Hash functions involve non-invertible mathematical operations – they deliberately discard information. You can verify that hash(input) = output, but you can’t mathematically reverse hash(output) → input. The only known general attack is brute force: try many inputs until finding one that hashes to the target. For 256-bit outputs, this requires ~2^256 attempts – more than atoms in the observable universe. This irreversibility is what makes hash functions useful for password storage, digital signatures, and proof of work.
Q: What is the “avalanche effect” and why does it matter?
The avalanche effect means that changing even one bit (one character) in the input produces a completely different hash output – typically about half the bits in the output change. This matters for blockchain security: if a block header is modified even slightly (to change a timestamp or a transaction), the hash changes completely and becomes invalid, requiring the entire proof of work to be redone. This makes blockchain transaction history effectively immutable.
Q: How are hash functions used in digital signatures?
Rather than signing a large document directly, you hash the document first (producing 256 bits regardless of document size), then sign the hash with your private key. This is efficient (signing a fixed-size hash is much faster than signing a gigabyte file) and maintains security (the signature proves you signed this specific document – any modification changes the hash and invalidates the signature). All blockchain transaction signatures follow this pattern.










