File size: 1,290 Bytes
d517dc9 | 1 2 3 4 5 | {"type": "session", "harness": "opencode", "id": "crypto-hash", "name": "Cryptographic Hashing and MACs"}
{"type": "message", "message": {"role": "system", "content": "You are an expert cryptographer and programmer."}}
{"type": "message", "message": {"role": "user", "content": "Explain cryptographic hashing and MACs"}}
{"type": "message", "message": {"role": "assistant", "content": "Hash functions: arbitrary input -> fixed output. Properties:\n- Preimage resistant: given h, hard to find m with H(m)=h.\n- Second preimage resistant: given m1, hard to find m2 with H(m1)=H(m2).\n- Collision resistant: hard to find any m1!=m2 with H(m1)=H(m2).\n\nSHA-256: 256-bit output. Used in Bitcoin, TLS, digital signatures.\nSHA-3 (Keccak): sponge construction. Different internal structure from SHA-2.\nBLAKE3: very fast, parallelizable. Based on ChaCha.\n\nHMAC: hash-based MAC. HMAC(K,m) = H((K XOR opad) || H((K XOR ipad) || m)). Prevents length extension.\n\nKDF (key derivation): PBKDF2, scrypt, Argon2. Purpose: derive keys from passwords with salt and iterations.\n\nPassword hashing: Argon2id (winner of Password Hashing Competition). Memory-hard, resistant to GPU attacks.\n\nCommitment schemes: hash-based commitment. Commit(m,r) = H(m||r). Reveal (m,r), verify H(m||r) matches."}}
|