Hash Functions Compared
SHA-256, Keccak-256, Blake3, and Poseidon — which one each chain uses, why ZK systems needed a new family of 'arithmetic-friendly' hashes, and what tradeoffs each makes.
The basics
What a Hash Function Is
A hash function takes any input and produces a fixed-size output that looks random. Same input always gives the same output. Find two inputs giving the same output? You've found a collision, and most security guarantees collapse. Good cryptographic hashes are designed so finding collisions is computationally infeasible — measured in the 2^128 to 2^256 range, well beyond anything physically realisable. Hashes are everywhere in crypto: transaction IDs, block hashes, Merkle trees, signature precomputations.
The Big Four You'll Meet
SHA-256: Bitcoin's choice. Designed by the NSA in 2001, ubiquitous in TLS and general computing. Keccak-256: Ethereum's execution-layer choice (its consensus layer uses SHA-256). Designed by the team that won the SHA-3 competition. Note: Ethereum's `keccak256` is the original Keccak submission, not the slightly-different finalised SHA-3 standard. Blake3: A modern fast hash optimised for software speed, built as a Merkle tree so it parallelises across threads and SIMD lanes. Some newer proof systems include it, for example ZKsync's Airbender prover. Poseidon: A 'ZK-friendly' hash designed for efficient verification inside zero-knowledge proofs.
- SHA-256: Bitcoin, classical security, slowish
- Keccak-256: Ethereum, also slowish but with cleaner properties
- Blake3: Newest of the classics, much faster on commodity hardware
- Poseidon: ZK-friendly, used inside zk-SNARKs and zk-STARKs
Key Takeaways
- All four are cryptographic hashes; pick based on chain and context
- SHA-256 (Bitcoin) and Keccak-256 (Ethereum) are the legacy heavyweights
- Blake3 is the modern speed king for non-ZK contexts
- Poseidon exists because regular hashes are very expensive to compute inside ZK proofs
Going deeper
Why Poseidon Exists
Inside a ZK proof, every operation becomes an arithmetic circuit. SHA-256 and Keccak-256 use lots of bitwise operations (XOR, rotation, modular addition) that translate badly into circuits — a single SHA-256 evaluation is a large cost inside a proof (the Poseidon paper cites a 'huge computational penalty' for SHA-256 in Zcash's coin-ownership proof). Poseidon, MiMC, and similar 'arithmetic-friendly' hashes use only field-friendly operations (additions and powers) that translate efficiently to circuits — often far cheaper than SHA-256. They're not better in general; they're radically better in the specific context of being computed inside a ZK proof.
Hash Function Properties to Care About
Three classic properties: pre-image resistance (given a hash, hard to find an input producing it), second pre-image resistance (given one input, hard to find another producing the same hash), collision resistance (hard to find any two inputs producing the same hash). All four hashes above satisfy these against currently-known attacks. Newer properties matter in ZK contexts: 'algebraic structure' (do polynomial relations exist between inputs and outputs?) is what makes a hash 'ZK-friendly' or not.
Speed Comparison
Throughput depends heavily on the CPU and on SIMD and hardware support, so treat any figure as indicative. The BLAKE3 authors describe it as much faster than MD5, SHA-1, SHA-2, SHA-3 and BLAKE2, and its multithreaded b3sum tool as an order of magnitude faster than sha256sum on typical desktop hardware. Poseidon in a ZK circuit doesn't have a meaningful general-CPU benchmark — its win is the constraint count inside a proof, not raw throughput. In non-ZK contexts Poseidon is slower than SHA-256.
Bitcoin's Double SHA-256
Bitcoin applies SHA-256 twice in many places (e.g., for transaction IDs and block headers). This is commonly explained as a defence against 'length-extension' attacks that affect the underlying Merkle-Damgård construction of SHA-256 in some contexts. The cost is doubling the hashing work; the benefit is a clean security argument. Ethereum's Keccak-256 doesn't have this vulnerability and doesn't double.
Key Takeaways
- Poseidon is 'ZK-friendly' because it uses arithmetic operations that translate efficiently to circuits
- Classical security properties (pre-image, collision resistance) hold for all four
- Blake3 is the throughput leader on commodity hardware
- Bitcoin double-applies SHA-256; Ethereum applies Keccak-256 once — both defensible choices
Under the hood
Internal Construction Families
Hashes come from a few architectural families. Merkle-Damgård (SHA-2): build a hash from a fixed-input-size compression function applied iteratively. Vulnerable to length-extension without padding tricks. Sponge (Keccak/SHA-3): absorb input into an internal state, squeeze output. Clean construction, no length-extension issue. Tree/blockwise (Blake3): parallel chunks combined via a tree, enabling SIMD acceleration. Arithmetic (Poseidon, MiMC): repeated S-boxes and matrix multiplications over a prime field. Each family makes different tradeoffs in security analysis simplicity, hardware acceleration, and adaptability to special contexts.
Why Poseidon's Choice of Parameters Matters
Poseidon's security depends on parameter choices (number of rounds, S-box choice, MDS matrix). Each ZK system tunes Poseidon for its specific field and security level. Poseidon-128 over the BN254 field is different from Poseidon-128 over the Goldilocks field. Researchers keep scrutinising Poseidon's parameters — the Ethereum Foundation's Poseidon Cryptanalysis Initiative runs 2024-2026 — and other arithmetic-oriented hashes (Tip5, Anemoi, Rescue, Griffin) offer different tradeoffs. ZK systems that bet hard on a specific Poseidon variant face occasional re-parameterisation pressure.
Quantum Resistance
Hash function quantum resistance is via Grover's algorithm: a quantum computer can find a collision in 2^(n/3) operations or a pre-image in 2^(n/2) operations, vs 2^(n/2) and 2^n classically. This means 256-bit hashes get reduced to ~85-bit and ~128-bit security against quantum attackers. Some designs therefore choose 384-bit or 512-bit hashes for very long-lived security, but hashes are far less exposed than signatures: NIST IR 8547 says approved symmetric primitives with at least 128 bits of classical security are believed to meet at least post-quantum Category 1, and it lists SHA-256 at Category 2 for collision resistance and Category 5 for preimage resistance. STARKs that depend on hash functions (rather than ECC) are post-quantum secure precisely because the assumed quantum-Grover penalty leaves enough security margin.
What Production Chains Actually Use
Bitcoin: SHA-256 (double-applied), RIPEMD-160 (for some address types). Ethereum: Keccak-256 on the execution layer, SHA-256 on the consensus layer and for EIP-4844 blob versioned hashes. Solana: SHA-256 (matches Bitcoin choice). Cardano: Blake2b (predecessor of Blake3). Filecoin: SHA-256 + Poseidon for ZK proofs. zkSync: Keccak-256 for compatibility + Poseidon2 over the Goldilocks field in its Boojum prover. The pattern: classical hashes for Layer 1 compatibility, Poseidon when computing inside proofs.
Don't Roll Your Own Hash
Hash function design is one of the deepest specialties in cryptography. Multiple times in the field's history, 'optimised' hash functions designed by non-specialists have fallen to attacks. Use standard implementations from vetted libraries (OpenSSL for SHA-2, Keccak Team's reference for Keccak, Blake3's official crate, Poseidon implementations from major ZK frameworks). The performance gap between rolled-from-scratch and well-tuned implementations is usually small; the security gap can be catastrophic.
Key Takeaways
- Four construction families: Merkle-Damgård, Sponge, Tree/blockwise, Arithmetic — each with characteristic tradeoffs
- Poseidon parameterisation matters; newer arithmetic hashes (Anemoi, Griffin, Tip5) keep evolving
- Grover's algorithm reduces hash security in quantum settings — argues for larger output sizes long-term
- Production pattern: classical hash for Layer 1 compatibility + Poseidon when computing inside proofs
- Never roll your own hash; use vetted implementations from major libraries
Related Content
Related Coins
Key Terms
More Topics
Browse all 189 topicsECDSA vs EdDSA vs BLS
The three signature schemes you'll meet across the crypto stack — what each does well, what tradeoffs they impose, and why Ethereum uses three of them simultaneously.
zk-SNARK vs zk-STARK vs PLONK
How the three major proof-system families compare on trusted setup, proof size, prover cost, and quantum resistance — and which production rollups picked which.
Threshold Signatures and MPC
How t-of-n threshold signatures and multi-party computation let multiple parties sign together without any one holding the full key — the cryptography behind Fireblocks and modern institutional custody.
Verifiable Random Functions
How VRFs produce randomness that's both unpredictable before commitment and cryptographically verifiable after — enabling fair lotteries, leader election, and on-chain randomness without trusted parties.
Stealth Addresses and Confidential Transactions
Privacy primitives that hide who's receiving what — from Monero's foundational stealth addresses to Ethereum's ERC-5564 and the legal context post-Tornado-Cash.
CDP Lifecycle
How collateralized debt positions work end-to-end — minting DAI against ETH, paying stability fees, surviving liquidations, and the structural lessons from MakerDAO's Black Thursday and Liquity's no-fee model.
Perpetual Swap Mechanics
How perp futures actually work — funding rates that keep them pegged to spot, mark vs index price, insurance funds that backstop losses, and the liquidation cascades that wreck overleveraged accounts in seconds.
Intent-Based Architectures
Why CoW Swap, UniswapX, Across, and 1inch Fusion moved from 'sign a transaction' to 'sign an intent' — and how solver competition delivers better prices and MEV protection.
References & further reading
- secondary
- secondary
- primaryNIST - FIPS 202: SHA-3 Standard (Keccak)
Standardised SHA-3, derived from Keccak; differs from Ethereum's original Keccak-256 padding.
- primaryBLAKE3 team - BLAKE3 repository and README
Design, parallelism and speed claims for BLAKE3.
- primaryGrassi et al. - Poseidon: A New Hash Function for Zero-Knowledge Proof Systems (ePrint 2019/458)
Original Poseidon paper (USENIX Security 2021).