Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

12 End-to-end encryption (optional)

Gives each user an identity key pair that the server cannot read. The application builds on it.

  • The identity key is sealed once for each passkey, with the WebAuthn PRF output, and once for the recovery key.
  • The PRF input is fixed: <namespace>/passkey-prf. Each credential has its own PRF secret, so outputs differ. One prompt signs and gives the output.
  • The envelope has a random salt, so that two envelopes never share a wrapping key.
  • PRF output never leaves the client. A client removes it from what it sends.
  • A user device gets the identity key sealed to its own key by the approving client, after both sides compared fingerprints.
  • Replacing the identity key is signed by the old one, needs a passkey assertion, and runs application writes in the same commit, because the application must seal its data again.
  • With e2ee, recovery by email, by a link and by owners cannot restore the key, so the server refuses it. Only a passkey, the recovery key or a user device can.

In the routes

Each envelope is in the commit that adds, uses or removes its passkey. A request without its envelope, or with one when the mode is off, is refused.

  • Signup stores the passkey’s envelope, the recovery envelope and the recovery key’s verifier.
  • Login returns the envelope of the passkey that was used.
  • Adding a passkey stores its envelope; removing it deletes the envelope.
  • A new recovery key replaces the recovery envelope and the verifier together.
  • Recovery with the key returns the recovery envelope before the proof. For an unknown name it returns a decoy that has the same shape and is the same each time, so the answer does not show which names exist. Finishing stores the new passkey’s envelope.
  • Undoing a recovery deletes the envelopes sealed since the recovery.

In a browser

The identity key is kept for the life of the session, encrypted with a non-extractable key. This protects a copy of the browser profile that lacks that key. It does not protect against a script on the origin. See THREATS.md.