Experimental prototype. This code has not been reviewed or audited by an independent third party. Don't store anything here you can't afford to lose or have exposed; use is entirely at your own risk. Read the source.

Your passkey is the key.

End-to-end encryption usually means asking people to look after a secret key, and they lose it. prfect borrows the one secret they already keep safe and synced, their passkey, and derives the encryption key from it. The server stores only ciphertext and keys it can't open.

The big picture

Three kinds of material move around, and the colors in every diagram below follow them.

Secret key material: exists only on your devicesPublic: safe to hand to anyoneStored by the server: wrapped keys and ciphertext
YOUR DEVICES the only place keys and plaintext exist Browser tab prfect web app WebCrypto · hpke-js Authenticator Touch ID · Secure Enclave passkey + PRF secret PRF output Other devices iPhone · iPad · … same passkey synced by your passkey provider (iCloud Keychain, Google, 1Password) prfect server SQLite metadata · wrapped keys Blob store sealed boxes · dir / S3 / R2 holds nothing that can decrypt wrapped keys sealed boxes challenge · slot ciphertext Ingest machine prfect upload public key only public key sealed boxes
Plaintext and every key that can decrypt stay inside the dashed boundary. Your passkey provider syncs the passkey, with its PRF secret, to your other devices. The prfect server and ingest machines get only things that are safe to lose.

1A passkey that can make secrets

Normally a passkey only signs. The WebAuthn PRF extension lets it also act as a keyed hash: give it a salt and it returns 32 bytes that only that passkey can produce, the same every time.

requires user verification (Touch ID) App salt hash of a fixed, versioned label Browser re-hashes with a "WebAuthn PRF" prefix Authenticator HMAC-SHA-256 with its per-passkey secret PRF output 32 bytes stays in the tab HKDF-SHA-256 info: prfect/v1/ amk-wrap/passkey KEK AES-KW key non-extractable credential secret never leaves the authenticator versioned info → rotatable
PRF is HMAC under a secret that the authenticator creates per passkey. The browser pre-hashes the salt with a "WebAuthn PRF" prefix, so values derived for one purpose can't be replayed for another. The output is turned into a key-encryption key (KEK) and never sent anywhere.

Try it: a simulated authenticator

This runs the same calculation as a real authenticator, using two random secrets generated in this tab to stand in for two passkeys. Change the salt or switch passkeys and watch which outputs repeat.

Press Evaluate.

2Key slots: many ways in, one master key

Data is never encrypted directly with a passkey's output. A random account master key (AMK) sits in the middle, and each way of unlocking stores its own wrapped copy of it, the way LUKS disk encryption uses key slots.

Passkey #1 → PRF e.g. iCloud Keychain Passkey #2 → PRF e.g. a YubiKey Recovery code 160 random bits, printed once HKDF → KEK derived on demand, never stored HKDF → KEK derived on demand, never stored HKDF → KEK + auth secret server keeps SHA-256(auth) only Slot: AES-KW(KEK, AMK) 40 bytes on the server Slot: AES-KW(KEK, AMK) 40 bytes on the server Slot: AES-KW(KEK, AMK) 40 bytes on the server Account master key (AMK) random 256-bit · only ever in memory any one unwraps it Account private key (P-256) stored AES-GCM-encrypted under the AMK Account public key given to ingest machines and senders decrypts key pair
Adding a passkey adds one 40-byte slot, and removing one deletes its slot. No file is touched either way. The server won't remove your last remaining slot. The recovery code's second derived value lets the server confirm you know the code without learning the key it unlocks.

3Sealing a file with HPKE

Files are encrypted to the account public key with HPKE (RFC 9180). Anyone holding the public key can seal a file, and only the private key can open it. That's how an ingest machine can upload files it can't read back.

SENDER: KNOWS ONLY THE PUBLIC KEY Ephemeral key pair (skE, pkE), fresh per box ECDH(skE, pkR) pkR = account public key KEM ExtractAndExpand dh, enc ‖ pkR → shared secret Key schedule info "prfect/v2/box" Plaintext len ‖ meta JSON ‖ file AES-256-GCM key + nonce from schedule Sealed box v2 02 enc = pkE · 65 B ciphertext: filename, type and contents, all hidden tag · 16 B
To open a box, the recipient computes ECDH(skR, enc), which gives the same shared secret and therefore the same key. The ciphersuite is DHKEM(P-256, HKDF-SHA-256), HKDF-SHA-256, AES-256-GCM. Go's standard crypto/hpke and the browser's hpke-js both reproduce the official RFC 9180 test vector for it. P-256 was chosen over X25519 because it's the curve Apple's Secure Enclave supports.

4Unlocking: signing in and decrypting are one Touch ID

The same navigator.credentials.get() call proves who you are to the server and asks the passkey for its PRF output. The browser sends the server the signature and keeps the PRF output.

Authenticator Browser tab prfect server ① POST /api/login/begin ② challenge + PRF salt ③ credentials.get({ prf: { eval } }) Touch ID ④ signature + PRF output ⑤ signature only (PRF results stripped) ⑥ session + wrapped slot + wrapped private key ⑦ unwrap AMK → decrypt private key cache it as a non-extractable CryptoKey
After step ⑦ the private key sits in IndexedDB as a non-extractable WebCrypto key. A reload stays unlocked, and script on the page can use the key but can't read its bytes. The master key is held in memory only, so a reload drops it.

What the server sees

Stores

  • your username and each passkey's public key
  • the account public key
  • slots: the AMK wrapped under each KEK
  • the account private key, encrypted under the AMK
  • SHA-256 of the recovery auth secret
  • sealed boxes, their sizes and upload times
  • hashes of ingest tokens and their labels

Never receives

  • PRF outputs or the KEKs derived from them
  • the account master key
  • the account private key in usable form
  • your recovery code
  • file names, types or contents

The blob store needs even less trust. Object names are random, so listing a bucket shows nothing about who owns what. A leaked bucket exposes ciphertext, sizes and timestamps. Signed in, the app's The server's view panel shows exactly what is stored for you.

Standards used

No new cryptography: every primitive is a published standard, and the code combining them is small enough to read.

StandardRole in prfect
WebAuthn Level 3 (W3C)Passkey registration and sign-in. The server verifies signatures with go-webauthn.
PRF extension (WebAuthn §10.1.4)Gets a stable, per-passkey 32-byte secret for a given salt.
CTAP 2.1 hmac-secret (FIDO Alliance)The authenticator-side HMAC that PRF is built on. Security keys support it too.
HKDF (RFC 5869)Turns PRF output and recovery codes into KEKs, with versioned info labels.
AES Key Wrap (RFC 3394)Key slots: the AMK wrapped under each KEK.
AES-GCM (NIST SP 800-38D)Encrypts the private key under the AMK, and is the AEAD inside HPKE.
HPKE (RFC 9180)Sealed boxes, via Go crypto/hpke and hpke-js.
ECDH on P-256 (NIST SP 800-56A, FIPS 186-5)The account key pair, on the same curve as the Secure Enclave.
Web Crypto API (W3C)All browser crypto, including keys marked non-extractable.
Crockford Base32Recovery codes that survive being read aloud or mistyped (O→0, I/L→1).
S3 APIBlob storage on AWS S3, Cloudflare R2, MinIO, …

Limits worth knowing

What's next

Key rotation

Every layer is versioned, so each one can rotate on its own schedule. The cost depends on how far down the stack you go:

What rotatesCostStatus
A passkey (add / remove)One ceremony, one 40-byte slotbuilt
Recovery codeRe-wrap one slotbuilt
PRF saltEvaluate old and new salts in one ceremony (first/second) and re-wrap. Each passkey upgrades the next time it's used.planned
Account key pairNew key pair. Old private keys stay in a keyring under the AMK, and boxes gain a key id. Ingest machines follow a rotation statement signed by the old key.planned
Re-encrypting old dataWith per-file keys (below), re-wrap each small key instead of re-encrypting gigabytesplanned

Sharing with another prfect user

Every account already has a public key, so sharing comes down to encrypting each file under its own random key and sealing that small key once per reader:

Your file any size AES-256-GCM under a random file key Ciphertext stored once File key (DEK) 32 random bytes Envelope → you HPKE seal, ~115 B Envelope → Bob HPKE seal, ~115 B your public key Bob's public key
Adding a reader costs one ~115-byte envelope, however large the file. Unsharing deletes Bob's envelope, but can't make him forget a file he already opened. The hard part is making sure "Bob's public key" really is Bob's: a dishonest server could substitute its own. The fixes are the same as for ingest pinning: compare fingerprints, pin keys on first use, or publish keys in a key-transparency log.

Post-quantum

A future quantum computer threatens only the public-key layer. Data sealed today could be stored and decrypted later ("harvest now, decrypt later"). Everything symmetric in prfect is already fine:

LayerAlgorithmAgainst a quantum attacker
Passkey PRFHMAC-SHA-256safe symmetric
KEKs, slots, private key at restHKDF-SHA-256, AES-256-KW, AES-256-GCMsafe 256-bit keys keep 128-bit security against Grover's algorithm
Passkey signaturesECDSA P-256sign-in only forgeable someday, but that can't decrypt data recorded earlier
TransportTLSbrowser's job current browsers already negotiate hybrid ML-KEM key exchange
Sealed boxesHPKE DHKEM(P-256)exposed this is the one piece to upgrade

The upgrade is a hybrid KEM that combines ML-KEM-768 (FIPS 203) with an elliptic curve, so a box stays safe unless both are broken. Go already ships these hybrids (hpke.MLKEM768X25519 and hpke.MLKEM768P256). The costs:

Status: deferred, but upgradable. Today the cost isn't worth it, so the groundwork is in place instead:

Adding X-Wing would be "suite 3" plus a key migration. The checklist is in POST-QUANTUM.md.