Design an encrypted key-value store with login
CloudflareSoftware Engineer · Technical ScreenLast updated
This question evaluates a candidate's understanding of secure authentication, key management, and applied cryptography for encrypting data at rest within a user-scoped key–value store.
Prompt
Design a small key–value store that supports user login and ensures values are encrypted at rest using a user-provided password.
You may assume this is a standalone service/library (language-agnostic) and you can use standard cryptographic primitives from a library (you do not need to implement AES/SHA yourself).
Requirements
- Authentication / login
- Users can register and then log in with a password.
- The system must not store plaintext passwords.
- Encrypted-at-rest values
put(key, value)stores the value such that if the database/file is leaked, values are not readable without the user’s password.get(key)returns the decrypted value for an authenticated user.
- Basic API surface (suggested)
Register(username, password)Login(username, password) -> session/tokenPut(session, key, value)Get(session, key) -> value- Optional:
Delete(session, key)/ListKeys(session)
- Threat model / constraints
- Assume an attacker can obtain the underlying storage (DB/file) but not the running process memory.
- Consider common pitfalls (e.g., deterministic encryption, IV reuse, password hashing vs encryption keys).
What to provide
- A high-level design (data model + flow) showing how you would store:
- user credentials
- encrypted values
- any metadata needed for decryption
- A description of cryptographic choices and why they are safe.
- Key edge cases (password change, corruption, wrong password, multi-user isolation).
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.