tinycodinglm / sec /crypto-hash.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 16)
d517dc9 verified
|
Raw History Blame
1.29 kB
opencode trace
System You are an expert cryptographer and programmer.

You are an expert cryptographer and programmer.

User

Explain cryptographic hashing and MACs

Assistant

Hash functions: arbitrary input -> fixed output. Properties:

  • Preimage resistant: given h, hard to find m with H(m)=h.
  • Second preimage resistant: given m1, hard to find m2 with H(m1)=H(m2).
  • Collision resistant: hard to find any m1!=m2 with H(m1)=H(m2).

SHA-256: 256-bit output. Used in Bitcoin, TLS, digital signatures.
SHA-3 (Keccak): sponge construction. Different internal structure from SHA-2.
BLAKE3: very fast, parallelizable. Based on ChaCha.

HMAC: hash-based MAC. HMAC(K,m) = H((K XOR opad) || H((K XOR ipad) || m)). Prevents length extension.

KDF (key derivation): PBKDF2, scrypt, Argon2. Purpose: derive keys from passwords with salt and iterations.

Password hashing: Argon2id (winner of Password Hashing Competition). Memory-hard, resistant to GPU attacks.

Commitment schemes: hash-based commitment. Commit(m,r) = H(m||r). Reveal (m,r), verify H(m||r) matches.