Applied Cryptography in Computing: Hashing, Authenticated Encryption, Public Keys, and Zero-Knowledge Proofs
Modern computing trust—git commit hashes, TLS web security, signed software updates, encrypted cloud databases, hardware passkeys, and content-provenance manifests—rests on a small, battle-tested toolkit of mathematical cryptographic primitives. Following Auguste Kerckhoffs’s principle (security must reside strictly in secret keys, never in algorithm obscurity), applied engineers assemble systems exclusively from standardized primitives: collision-resistant Hash Functions, memory-hard Password KDFs, Authenticated Encryption with Associated Data (AEAD), Asymmetric Public-Key Signatures/KEMs, and Zero-Knowledge Proofs.
Key Highlights
- Cryptographic hashes (`SHA-256`, `SHA-3`, `BLAKE3`) are fast one-way fingerprints for file integrity, Git/Merkle trees, and HMACs—**never** use fast SHA-256 directly on user passwords (use memory-hard `Argon2id` instead!).
- Plain unauthenticated encryption (`AES-CBC` / `AES-ECB`) is vulnerable to ciphertext tampering and padding-oracle attacks; always use **Authenticated Encryption (`AES-256-GCM` or `ChaCha20-Poly1305`)**.
- Asymmetric cryptography separates a public key from a private key (`X25519` key exchange, `Ed25519` signatures, and NIST Post-Quantum `ML-KEM` / `ML-DSA`) to bootstrap shared symmetric session keys and sign artifacts.
- Zero-Knowledge Proofs (`zk-SNARKs` / `zk-STARKs`) allow a Prover to mathematically convince a Verifier that a computation or credential check succeeded without revealing the underlying secret input.
Matching Each Security Goal to the Right Modern Primitive
Most real-world cryptographic breaches come not from mathematicians cracking 256-bit AES, but from engineers picking the wrong primitive or mismanaging nonces and keys: storing passwords with unsalted `MD5`/`SHA-256` (cracked at tens of billions of guesses per second on a single GPU), reusing a 96-bit `AES-GCM` nonce twice under the same key (catastrophically leaking the authentication key and XOR of plaintexts), or pulling non-cryptographic `Math.random()` instead of OS CSPRNG entropy (`/dev/urandom` / `secrets`).
Envelope Encryption solves key rotation cleanly at cloud scale: each database record or S3 checkpoint encrypts under a unique random Data Encryption Key (DEK), and only that small DEK is wrapped by a hardware Key Management Service (HSM/KMS) root key.
| Security Objective | NEVER Use (Broken / Unsafe) | Modern Gold-Standard Choice |
|---|---|---|
| File / Model Weight Checksum | MD5, SHA-1 (collision broken) | SHA-256 or BLAKE3 (parallel SIMD/tree hash) |
| User Password Storage | Plain SHA-256, MD5, reversible encryption | Argon2id with per-user CSPRNG random salt |
| Symmetric Data Encryption | AES-ECB, unauthenticated AES-CBC | AES-256-GCM, AES-GCM-SIV, or XChaCha20-Poly1305 (192-bit random nonce) |
| API Token / Webhook Integrity | Raw `SHA256(secret + msg)` (length extension!) | HMAC-SHA256 verified in constant time (`hmac.compare_digest`) |
| Digital Signatures (Code / C2PA) | 1024-bit RSA, reused ECDSA nonces | Ed25519 (deterministic nonce) + Post-Quantum ML-DSA |
Merkle Trees and Zero-Knowledge Proofs (ZKPs) in Verifiable Computing
Ralph Merkle’s hash trees allow anyone to verify in `O(log N)` hashes whether a specific software binary, certificate (`Certificate Transparency` logs), or dataset shard belongs to a signed root commitment without downloading terabytes of sibling files. Extending commitment math further, Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge (`zk-SNARKs` and post-quantum `zk-STARKs`) let clients prove age/residency eligibility without disclosing passport numbers, or verify outsourced computation ("zkML") in milliseconds.
- Never roll custom cryptography—use high-level misuse-resistant APIs (`libsodium`, `age`, Go `crypto`, Rust `RustCrypto` / `ring`, Python `cryptography.fernet`).
- Always compare HMACs and secret tokens using constant-time comparison functions so microsecond timing side-channels cannot leak secret bytes one character at a time.
- Prefer `XChaCha20-Poly1305` (192-bit nonce) or `AES-256-GCM-SIV` whenever random nonces are generated statelessly across many servers.
FAQs
What is the difference between Hashing, Encoding (Base64), and Encryption?
**Encoding** (`Base64`, `UTF-8`) merely formats public bytes with zero secret and instant reversal; **Hashing** (`SHA-256`, `Argon2id`) is strictly one-way (irreversible) to verify integrity or passwords; **Encryption** (`AES-GCM`) is two-way confidentiality reversible *only* with the decryption key.
Why must Password Hashing be deliberately SLOW (`Argon2id`) while File Hashing (`BLAKE3` / `SHA-256`) is FAST?
Human passwords have low entropy, so if a database leaks, a fast hash lets an attacker test 50 billion passwords per second on GPUs; `Argon2id` forces ~64 MB of RAM and ~200 milliseconds per guess—unnoticeable once during legitimate user login, but crippling brute-force GPU farms.
References & Sources
- Boneh, Dan; Shoup, Victor — A Graduate Course in Applied Cryptography, Stanford University.
- Aumasson, Jean-Philippe — Serious Cryptography: A Practical Introduction to Modern Encryption (2nd ed.), No Starch Press.
- NIST FIPS 180-4 (SHA-2), FIPS 197 (AES), SP 800-38D (GCM), FIPS 203/204 (Post-Quantum ML-KEM / ML-DSA).