Design a Zero-Knowledge Password Manager
Build a 1Password-style vault with Argon2id plus Secret Key derivation, AEAD per-item AAD binding, SRP/OPAQUE login, and emergency recovery.
In this lesson (4 bite-sized sections)
The zero-knowledge security boundary
A zero-knowledge password manager (1Password, Bitwarden) syncs a user's vaults across laptops and phones while upholding one strict guarantee: even if attackers steal the entire cloud database and compromise the API servers, they still cannot decrypt a single stored credential.
Every encryption and decryption step executes strictly inside the client application. The cloud backend stores only opaque ciphertexts, public keys, KDF parameters, and an authentication verifier. Designing a vault that holds up under scrutiny means getting three pieces right: an offline-resistant key hierarchy, per-item AEAD with context binding, and a login protocol that never transmits the master password.
Key hierarchy and two-secret key derivation
Never encrypt vault entries directly with the user's master password. Doing so forces re-encrypting every record whenever the password changes and makes shared team vaults impossible. Instead, layer keys cleanly:
- Master Password + Secret Keyhuman secret plus 128-bit device-only Secret Key (2SKD)
- Argon2id KDFmemory-hard derivation yields Master Unlock Key (MUK)
- Account Key (256-bit)random key wrapped by MUK; rotate password by re-wrapping once
- Vault Keys (per vault)random 256-bit keys wrapped with member public keys for sharing
- Per-Item AEADAES-256-GCM or XChaCha20-Poly1305 encrypts each login item
First, stretch the master password client-side with a memory-hard KDF (Argon2id, or high-iteration PBKDF2-HMAC-SHA256) plus a unique per-user salt to derive the Master Unlock Key (MUK). Because human passwords often have low entropy, 1Password introduces 2SKD (Two-Secret Key Derivation): combine the password with a locally generated 128-bit Secret Key that never leaves the user's devices. Next, generate a random 256-bit Account Key wrapped by the MUK so changing the master password only re-wraps one 32-byte key. Finally, each personal or shared Vault gets its own random 256-bit Vault Key, wrapped under each authorized member's public key (RSA-OAEP or X25519) so teams can share credentials without sharing master passwords.
Per-item AEAD with AAD binding
Encrypting the entire vault as one monolithic blob makes syncing painful: editing one login re-uploads megabytes and causes whole-vault merge conflicts across devices. Encrypt each item individually using AEAD (AES-256-GCM or XChaCha20-Poly1305) with a fresh random nonce per edit.
The subtle vulnerability interviewers probe is ciphertext transplantation. Suppose a malicious server cannot decrypt your bank login, so it copies that encrypted blob into a shared marketing vault or overwrites an item with an older version. Stop this by passing structural context (vault_id, item_id, version) as Associated Authenticated Data (AAD) into the AEAD cipher. AAD is not encrypted, yet it is cryptographically bound into the authentication tag.
Zero-knowledge login and recovery
Sending the raw master password to POST /login breaks zero-knowledge even over TLS because a compromised server can log it in RAM. Better designs either derive a separate domain-separated authentication hash client-side or, stronger, run an augmented PAKE protocol such as SRP-6a (1Password) or OPAQUE (RFC 9807). Both let the client prove password knowledge and establish a mutually authenticated session key without ever sending the password or a replayable password-equivalent hash.
| Login Protocol | Server Sees Raw Password | Replayable Auth Hash | Mutual Server Auth |
|---|---|---|---|
| Plain password over TLS | Yes (in app RAM) | N/A | TLS cert only |
| Client-derived auth hash | No | Yes if TLS terminates early | TLS cert only |
| SRP-6a / OPAQUE (aPAKE) | No | No (challenge-response proof) | Yes (both sides prove key) |
Because the server truly cannot reset a forgotten master password, recovery is an explicit product feature: issue an offline Emergency Kit PDF holding the Secret Key and a printed recovery code at signup, and in enterprise tiers wrap a secondary copy of each employee's vault key under an organization recovery key controlled by quorum admins.
Sources: 1Password Security Design whitepaper · Bitwarden Security Whitepaper · RFC 9106, Argon2 memory-hard KDF · NIST SP 800-38D, AES-GCM
Apply
Your turn
The task this lesson builds to.
Architect a zero-knowledge password manager supporting multi-device sync, shared team vaults, master-password rotation without full re-encryption, and offline breach resistance.
Think about
- How do the Master Unlock Key, Account Key, and per-vault keys decouple password changes and team sharing?
- Why does per-item AEAD require AAD binding item and vault IDs?
- How do SRP/OPAQUE login and emergency recovery keep the server zero-knowledge end to end?
Draft your design answer here Save your draft, compare against the model answer, and track progress.
Practice
Make it stick
A second problem on the same idea, so it survives past today.
Specify the key rotation and revocation protocol when an employee leaves a company that uses shared zero-knowledge vaults, explaining why deleting their account row alone is not enough.
Think about
- Why can a departed employee still decrypt future items added to a shared vault if the Vault Key does not rotate?
- How do you rotate a shared Vault Key without requiring an admin server to ever see plaintext secrets?
- What credentials inside the vault must still be rotated externally even after the Vault Key changes?
Draft your design answer here Save your draft, compare against the model answer, and track progress.