End-to-end encryption for your app, without writing cryptography
@ezpriv/crypto combines libsodium's primitives into what an app needs to keep its users' data unreadable to its own server: user keys and ways to unlock them, group keys, encrypted rows, sealed values and linking a browser by QR code. Every byte is fixed by a written spec and checked by test vectors.
npm install @ezpriv/crypto
What it gives you
Keys and ways to unlock them
A key pair per user. The private key is wrapped under a password (Argon2id), 12 recovery words, a passkey's PRF output or another device.
Group keys and encrypted rows
One random key per group, sealed to each member. Rows are encrypted and bound to their table and id, so the server can't move or alter them.
Values only the user opens
The server seals incoming data, and the sender's app seals push notifications, to a user's public key. A context label keeps one kind from passing for another.
Link a browser by QR code
A phone hands its keys to a new browser through a QR code whose secret never reaches the server.
One format, any runtime
React Native, browsers, service workers and Node through the libsodium each one has. Swift and Kotlin ports open sealed notifications.
Honest limits
It protects against a server that reads, not yet one that tampers. Every limit is written down.
Learn it from the examples
Each example animates the flow step by step: who acts, which function runs, what travels and what every party holds.
Account setup
The user signs up with an email and a password, and writes down 12 recovery words shown once.
02Unlock with a password
On a new phone, the user types the email and password they signed up with and sees their data.
03Recover with the 12 words
A user who forgot their password types the 12 recovery words, chooses a new password and is back in, with all their data.
04Unlock with a passkey (PRF)
Optional: the user adds a passkey, and later unlocks with Face ID, Touch ID or a security key instead of typing the password.
05Device and synced copies of key_A
After unlocking once, the user isn't asked for the password again on that device, and often not on their next phone either.
06Group rows
Users share a group (a trip, a flat) and add expenses that every member sees, while the server stores only ciphertexts.