Files
Amicitia-Tabellarius/docs/PROTOCOL.md
T

64 lines
3.9 KiB
Markdown

# Tabellarius protocol v0 — what crosses the wire, and what the relay learns
**Approved 2026-11-08 (Mark)** as v0, before any relay code. Every claim below must have a test. A change
is a protocol version bump: documented, reviewed, approved (`CLAUDE.md` §2.2).
## 1. Threat model
| Adversary | Protected | Not protected |
|:--|:--|:--|
| **Relay operator** (honest but curious, including us) | message content, names, contact lists, which mailboxes belong to the same person *by content* | IP addresses at connection time and timing — an operator who logs at the network layer can correlate. Reduced by not logging (§5), not prevented. |
| **Network observer** | content (TLS + MLS) | that a device talks to a relay, and when |
| **Stranger** | cannot post: no capability token | — |
| **Contact who turns hostile** | block = rotate the token; their posts are refused | what they already received |
| **Stolen phone** | database encrypted; key in the OS keystore | an unlocked phone |
| **Compromised device** | — | everything on it. Out of scope, stated plainly. |
## 2. Building blocks
- **MLS** via OpenMLS *(licence and Tauri mobile build to verify)*. One MLS group per pair of people.
The Orator fans out into these private groups, so replies stay private.
- **Credentials:** an Ed25519 key made on the device. The display name travels **inside** MLS
messages only.
## 3. Mailboxes and tokens
- A client creates **one mailbox per contact** (random 128-bit id), so the relay cannot tell by
addressing that two conversations involve the same person.
- Each mailbox has a **post token** (random 256-bit) given only to that contact, and a **fetch token**
kept by the owner. The relay stores **hashes** of both.
- **Block** = the owner rotates the post token; the old one is refused. The blocked person is not told.
## 4. Invitations
A QR code (in person) or a link carries: relay URL, an invite id, and a one-time fetch secret. The
invitee fetches the inviter's MLS KeyPackage from the relay with it, replies with their own, and
both sides exchange mailbox ids and post tokens **inside** MLS. Unclaimed invites expire after
**7 days** *(decided 2026-11-08)*.
## 5. What the relay stores — the complete list
| Table | Columns |
|:--|:--|
| `mailboxes` | id, hash(post token), hash(fetch token), created day |
| `blobs` | mailbox id, ciphertext, size, received hour (rounded) |
| `invites` | invite id, hash(fetch secret), KeyPackage, expiry |
| `push` *(only if the user opts in, G03)* | mailbox id, push endpoint |
Nothing else. No IP, no user agent, no request log beyond counts. A blob is deleted on acknowledged
delivery and after **30 days** at the latest *(decided 2026-11-08)*. The reverse proxy in front must also not
log; the NixOS module ships configured that way.
## 6. Waking a closed app
A notification for a closed app needs a push service. The wake-up carries **no content and no sender**
— only "something arrived".
- **Android:** UnifiedPush lets the user choose their own distributor; FCM as a fallback.
- **iOS:** only the app's publisher can send through Apple's push service, so a self-hosted relay
cannot wake an iOS app directly. It would go through a small push gateway run by the publisher,
which learns a device token and timing.
**Decided:** iOS uses a small push gateway run by the publisher, carrying no content and no sender.
It learns a device token and timing, and **users are told so plainly** in *How your messages travel*.
The platform facts above are Claude's understanding, to be verified in `.agents/features/wake-up.md`.
## 7. Tests that prove this document
- A canary string sent in a message never appears anywhere in the relay's database or logs.
- A post without a valid token is refused; after rotation the old token is refused.
- A delivered blob is gone; an undelivered blob is gone after the TTL (clock injected).
- Parsers are fuzzed (`cargo fuzz`) for every message type.
- Every check in `VERIFY.md` §1 has a CI job or a documented manual procedure.