Files
2026-11-05 09:05:13 +01:00

12 KiB
Raw Permalink Blame History

Fundamentum v1.1 — revocation, recovery, the browser, live sync (design note, proposals)

Written before any v1.1 code, so the open decisions can be made first. (proposal) marks my judgment; each has an alternative and its cost. Nothing here changes v1's formats; every new structure is a new magic with its own signing domain.

The gate (roadmap): lose a phone, revoke it, and recover everything from the 24 words, with no data loss.

v1.1 is too big for one session. Proposed split:

Day Contents
v1.1a revocation (§1), renewal (§2), the root-sealed backup and recovery (§3), Custos UI for all three
v1.1b a sans-IO client and its WASM build (§4), live subscribe on the relay (§5), the JS package for PWAs (§6)

v1.1a alone passes the gate for the desktop apps. v1.1b is what the phone apps need.


1. Revocation

What a lost phone holds

  • One device subkey per Domi app it ran (TSC1 certs for that app) and, in the browser, the device key from day-1 pairing.
  • For each group it was in: an MLS leaf, its signature key, the group state and a mailbox key.

Revoking it has to do three separate things:

  1. Readers stop trusting its signatures. Nothing it signs from now on is accepted.
  2. It stops reading. It leaves every MLS group, so it cannot decrypt future epochs.
  3. The relay stops serving it. Its mailbox keys are deregistered.

The revocation statement (TRV1)

"TRV1"        4
root         32   the root that certified the subkey
subkey       32   the revoked subkey
revoked_at    8   u64 Unix seconds, when the person revoked it
accepted    u32 count ‖ count × 32   SHA-256 of every event by this subkey that stays valid, sorted
sig          64   Ed25519(root, "tessera revoke v1\0" ‖ every byte above)
  • Custos signs it. Its vault refuses a tbs that does not start with TRV1 and name its own root, exactly as it does for TSC1, so the root still signs only things that parse as one of its two statements.
  • It travels as an ordinary event (kind = "tessera.revoke") in each group the subkey was in. Any device of the same person sends it.

Why a list of accepted events, not a time (proposal)

v1 checks a cert at the event's own time, so a thief who has the subkey can backdate an event to before revoked_at, and a time cutoff would accept it. Instead, the revocation names exactly which of that subkey's events stay valid: those already in the revoking device's log. Every other event by that subkey, whenever it claims to be from, is rejected.

  • This is deterministic: every device applies the same list once the logs converge.
  • The cost: events the lost phone wrote but never synced are lost too. They exist only on the phone.
  • Size: 32 bytes per kept event (1,000 events from one phone in one group = 32 KB, once).
  • Alternative: a time cutoff (revoked_at only). Simpler and smaller, but it leaves the backdating hole open.

Applying it (tessera::merge)

The verifier gets the group's revocations as a second input. Merging becomes two passes:

  1. Collect every valid TRV1 in the log: root-signed, by a root of the group, for a subkey that root certified.
  2. Drop each event whose author is revoked and whose hash is not in that revocation's list. It goes to rejected with the reason "revoked".

Revoking twice is idempotent: the lists are intersected, never widened.

MLS and the relay

  • The revoking device:
    • commits a Remove of every leaf whose credential names a revoked subkey;
    • deregisters the mailbox key in that credential (v0.2.0's remove does both);
    • then sends the TRV1 event.
  • A member device that sees a valid TRV1 before the Remove lands may commit the Remove itself, so a revocation finishes even if the revoking device goes offline.
  • Shared groups: another person's device in the group accepts a Remove of your leaf only with your TRV1 beside it (a member removing someone else needs a reason the others can verify). (proposal)

In Custos

  • Domi identity → Devices → Revoke. Custos groups certs by the label it recorded when it issued them ("Phone browser", "Fiscus on Mark's PC"), so one revoke covers every key of that device.
  • The accepted list comes from the app's own log: Custos asks each app on this PC (pipe op revoke) for that subkey's event hashes. An app that is not running cannot answer.
  • (Decision) Revoke then: (a) waits until each app has answered, or (b) lets the person revoke with an empty list for apps that did not answer. That throws away everything that phone wrote in those apps. I propose (a), with (b) behind a second, explicit click.

2. Renewal

  • Certs live 365 days. An app asks Custos for a fresh cert for the same subkey when 30 days are left (same subkey op, one click, the same match code).
  • An expired cert keeps its old events valid (they are checked at their own time); the subkey just signs nothing new until renewed.
  • No new format.

3. Recovery from the 24 words

RootKey::from_mnemonic already gives back the same root, so every group still trusts it. What is lost with every device is the data and the MLS state.

  • Shared groups: the other members still hold the group. They re-invite your new device; the credential check passes because the root matches. Their copy of the log comes with the history (v0.2.0 §6).
  • Your self group (your own devices only): if every device is gone, nobody holds it. Hence:

The root-sealed backup (proposal)

  • Custos derives, per app, a backup key and a backup mailbox from the root secret, never stored:
    • backup_key = HKDF(root secret, "tessera backup v1", app_id)
    • mailbox access key = HKDF(root secret, "tessera backup mailbox v1", app_id)
    • The mailbox id is the hash of that key's public half.
    • Both come back from the 24 words alone. Custos hands an app its own pair only (pipe op backup_key).
  • Each desktop app, after a sync, uploads its self group's verified log: TBK1 ‖ XChaCha20-Poly1305(backup_key, envelopes). The relay keeps the latest few; they are ciphertext like everything else.
  • Recovery:
    1. Custos: "Restore from 24 words".
    2. Each app asks for its backup pair, downloads the latest blob, verifies every envelope, opens a new self group and sends the history into it.
    3. Your other people re-invite you into shared groups.
  • Cost: the relay can tell that one backup mailbox gets written now and then. It cannot tell whose it is or what is in it, and it cannot link it to any group mailbox.
  • Alternative: no backup. Recovery then works only if one device survives (an always-on node such as fiscus-node counts). Simpler, but it fails the gate for anyone with one PC and one phone who loses both.

4. The client in the browser (WASM)

The probe (2026-11-04) answers the open point from the plan ("whether OpenMLS runs well in WASM"): it builds. tessera, envelope, tabellarius-proto and OpenMLS 0.9 all compile for wasm32-unknown-unknown once the browser's clock and randomness are switched on. The client itself stops only at its HTTP transport. Details under "Probe" at the end. The client needs two changes:

  • Transport: the client is blocking (ureq). Proposal: split it into a sans-IO core (a state machine that says which request to make and consumes the answer) and two thin drivers: ureq (native, unchanged API) and fetch (browser, async). The tests drive the core directly.
  • Signing: in the browser the device subkey is a non-extractable WebCrypto key. Tessera gets a Signer trait (public, sign_event_tbs, sign_credential_tbs), async in the browser. Subkey implements it on native.
  • MLS keys: OpenMLS makes its own signature key per group; in the browser it lives in the client state. That state is encrypted with a non-extractable WebCrypto AES-GCM key and kept in IndexedDB (the same rule as the desktop's Custos-held state key).

5. Live subscribe

  • GET /v1/live, a WebSocket.
    • The first message is a list of (mailbox, after), each signed as a v0.2.0 request: a browser cannot set headers on a WebSocket.
    • The relay then sends {"mailbox", "seq"} whenever a message arrives, never the message. The client fetches as today.
  • Limits: 32 mailboxes per connection, 4 connections per mailbox key, idle timeout 10 minutes.
  • Privacy: no worse than polling. One connection for several mailboxes links them by connection, as fetching them from one IP already does. Apps that care open one connection per group.
  • Caddy proxies it; the access log stays off.

6. The JS package (@domi/fundamentum)

  • wasm-bindgen over the sans-IO core and the fetch driver, in the Fundamentum repo, served by each PWA itself (Domi: nothing fetched from a CDN).
  • The API mirrors the Rust one (open, selfGroup, openGroup, invite, join, send, sync, log, remove, revoke) plus subscribe(onChange).

Decisions wanted before v1.1a starts

# Question Proposal
1 Revocation keeps a list of accepted events (closes backdating) or uses a time cutoff the list
2 Revoke while an app did not answer wait; an explicit second click to drop its events
3 Another person's device may Remove your leaf only with your TRV1 yes, refined in v1.1a (below)
4 Root-sealed backup on the relay, so recovery works with every device lost yes
5 Split v1.1 into v1.1a (revocation, renewal, recovery) and v1.1b (WASM, live, JS) yes
6 The v1 gate (live relay, two real devices) before v1.1 starts, or in parallel in parallel: v1.1a needs no server

Status

v1.1a in the crates (Fundamentum v0.3.0): TRV1 and RevocationSet, RevokeSigner, BackupSecret (tessera); revoke, announce_revocation, events_by, renew, backup, restore, import and the removal rule (client). The gate's scenario passes against the in-process relay: a phone is revoked, its later and backdated events are dropped on every device, and with every device lost the self group comes back from the backup.

Decision 3, refined while building it. As written, it would also have stopped anyone removing a person from a shared group, which v0.2 deliberately allows. The intent was to stop one person cutting off another's device while that person stays. So:

  • removing some of another person's devices needs their revocation for each one;
  • removing all of them removes the person, as before.

Custos' half (Fundamentum v0.3.1, CustosPublic v0.10.0, Custos 0.5.0): the pipe ops revocations, revoke and backup_key (docs/TESSERA.md §12); Domi identity → a key → Revoke, Revoke without waiting (decision 2's second click) and Restore from 24 words. The vault signs TRV1 only for a key the person revoked, at the time they did. CustosPublic and Custos check the backup secret against the test vector of §12.

One change to §1 "In Custos": Custos cannot call an app over the pipe, so the person starts the revocation in Custos and each app asks on its next sync (revocations), then sends its list (revoke). Device keys are signed at once with an empty list: no app log holds their events in v1.1a.

Still to do for v1.1a: each app, on every sync, calls revocations_to_apply → apply_revocation, then backup; and offers restore on a new device. Then the gate by hand on two real devices.

Probe

cargo build --target wasm32-unknown-unknown, rustc 1.94.1 from the server's nixpkgs-unstable pin (0726a0ec), in WSL, on Fundamentum 95b7579 (v0.2.1). Not run in a browser yet: this shows the code compiles, not that it works there.

Crate Result Needs
tessera builds nothing
envelope builds nothing
tabellarius-proto builds the browser random source (getrandom 0.2 js, 0.3 and 0.4 wasm_js + --cfg getrandom_backend="wasm_js")
OpenMLS 0.9 + openmls_rust_crypto, _basic_credential, _memory_storage builds the same, plus OpenMLS's own js feature (time and randomness from JavaScript)
tabellarius-client fails at ring (C code, via ureq → rustls) the sans-IO split (§4): the browser build has no ureq, it talks through fetch

The browser build therefore needs no change to the crypto, the formats or OpenMLS: only the transport and a Signer for the WebCrypto device key.