Examples

Every use case, end to end

Thirteen runnable examples from an expense-sharing app: users, groups, expenses, bank movements, receipt tables, a phone app and a web version. Each page explains the feature, animates who holds what at every step, and shows the code. Everything outside the library (server, keychain, WebAuthn, camera, push) is simulated in-process.

01

Account setup

The user signs up with an email and a password, and writes down 12 recovery words shown once.

DEFAULT_PASSWORD_PARAMS, createUserKeys, keyFromWords, newRecoveryWords, newSalt, passwordKeys, wrapKey
02

Unlock with a password

On a new phone, the user types the email and password they signed up with and sees their data.

openSealed, passwordKeys, sealForUser, unwrapKey
03

Recover 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.

keyFromWords, newSalt, openSealed, passwordKeys, sealForUser, unwrapKey, wrapKey
04

Unlock 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.

keyFromPrf, unwrapKey, wrapKey
05

Device 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.

06

Group rows

Users share a group (a trip, a flat) and add expenses that every member sees, while the server stores only ciphertexts.

decryptRow, encryptRow, newGroupKey, openGroupKey, sealGroupKey
07

Invite link

A member shares a link to the group.

decryptRow, encryptRow, sealGroupKey
08

Removing a member

A member leaves the group or is removed, and from then on can't read what the group adds.

decryptRow, encryptRow, newGroupKey, openGroupKey, sealGroupKey
09

Sealed ingest

The user forwards their bank's notification emails to the app, and the movements show up in the app ready to split.

openSealed, sealForUser
10

Push notifications

When Ben adds an expense, Ana and Carla get a push that reads "Ben added Dinner, 42.00", while the server, Apple and Google only ever see "New activity".

openSealed, sealForUser
11

Sign in on a computer by QR code

On the web version, the user scans a QR code with the phone, confirms, and the computer is signed in with all their data, without typing a password.

newLinkRequest, openLink, sealForLink
12

Live receipt table by link

At a restaurant, one person scans the receipt and shares a link.

decryptRow, encryptRow, newGroupKey
13

Migrating existing plain rows

An app that already has groups with plain data ships end-to-end encryption, and existing groups switch over without losing a row.

createUserKeys, decryptRow, encryptRow, newGroupKey, openGroupKey, sealGroupKey

Run them

git clone https://github.com/ezpriv/crypto.git && cd crypto
pnpm install && pnpm build
pnpm examples   # all of them, in order, stopping at the first failure

Each example ends with node:assert checks and runs in CI, so they stay in step with the library. Read the limits first: most "Cons and limits" sections come back to them.