Cheat sheet of the cryptographic hashes powering BitcoinCheat sheet of the cryptographic hashes powering Bitcoin
1- Core Bitcoin Hashes1- Core Bitcoin Hashes
SHA-256SHA-256
- Mining (Proof of Work): miners hash block headers
- Transaction IDs (txid): each transaction gets a unique SHA-256 hash
- Merkle tree construction (organizing transactions in blocks)
SHA-256d (Double SHA-256)SHA-256d (Double SHA-256)
- Block hashes (each block header hashed twice)
- Extra security against length extension attacks
- Checksums in addresses
RIPEMD-160RIPEMD-160
- Address generation:
RIPEMD160(SHA256(pubkey)) - Shortens 256-bit SHA-256 into 160-bit hash
HASH-160 (SHA-256 + RIPEMD-160)HASH-160 (SHA-256 + RIPEMD-160)
- Used in P2PKH & P2SH addresses
2- Wallet & Key Management Hashes2- Wallet & Key Management Hashes
HMAC-SHA256 / SHA512HMAC-SHA256 / SHA512
- Key derivation in BIP32 (HD wallets)
- Secure key stretching
HKDFHKDF
- BIP-324 encrypted P2P transport
- Secure key expansion from master keys
- Advanced key derivation
3- Networking & Protocol3- Networking & Protocol
SipHash-2-4SipHash-2-4
- Short IDs in Compact Block relay (BIP-152)
- DoS protection
- Fast hash for hash tables
- Prevents hash collision attacks
MuHash MuHash
- Accumulators for UTXO set commitments (useful for AssumeUTXO, UTXO snapshots)
4- Encryption (Not Core Bitcoin)4- Encryption (Not Core Bitcoin)
ChaCha20ChaCha20
- Stream cipher for encrypting data
- Used in BIP324 (v2 P2P transport encryption)
Poly1305Poly1305
- Works with ChaCha20 for authenticated encryption
- Ensures data integrity
SHA-3 (SHA3-256)SHA-3 (SHA3-256)
- Not used in Bitcoin itself. It’s only needed for Tor v3 onion addresses (ed25519 → onion domain)
what about bip 324 ?