Building Zero-Knowledge Encryption for a Web App
AES-256-GCM + PBKDF2 210K iterations + group key sharing. How I built E2E encryption where the server never sees plaintext.
Why Zero-Knowledge?
Users upload photos of home interiors and financial records. Server-side encryption means a breach exposes plaintext. E2E ensures the server is zero-knowledge — even a full database dump reveals only ciphertext.
Three-Layer Architecture
Layer 1 (Key Management): AES-256 master key encrypted with owner's password via PBKDF2 (210K iterations). Layer 2 (Client-Side): Web Crypto API encrypts media before upload. Layer 3 (Hooks): 11 encryption hooks handle encrypt/decrypt transparently.
The Race Condition
Two members loading encrypted evidence simultaneously competed for key derivation. Fixed with per-member salts and idempotent PBKDF2 derivation. Validated with unit, integration, and Playwright E2E tests.