From 43f6f9b70c95544b22e1b14d6558afd25622ca9e Mon Sep 17 00:00:00 2001 From: mnovak Date: Mon, 2 Nov 2026 00:25:59 +0100 Subject: [PATCH] [docs] F03: protocol v0, verification plan and operating manual README, CLAUDE.md, docs/PROTOCOL.md (threat model, relay storage list) and docs/VERIFY.md. Phase 0: under review, no code yet. --- .agents/features/.gitkeep | 0 .gitignore | 7 +++++ CLAUDE.md | 40 +++++++++++++++++++++++++ README.md | 21 +++++++++++++ docs/PROTOCOL.md | 62 +++++++++++++++++++++++++++++++++++++++ docs/VERIFY.md | 26 ++++++++++++++++ 6 files changed, 156 insertions(+) create mode 100644 .agents/features/.gitkeep create mode 100644 .gitignore create mode 100644 CLAUDE.md create mode 100644 README.md create mode 100644 docs/PROTOCOL.md create mode 100644 docs/VERIFY.md diff --git a/.agents/features/.gitkeep b/.agents/features/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef41a7b --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +target/ +node_modules/ +dist/ +gen/ +*.db +*.sqlite +.env diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..29d881f --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,40 @@ +# CLAUDE.md — Tabellarius + +Operating manual for AI agents. This repository is **public**. Write every file, commit and review as +if a stranger auditing your privacy claims will read it — because one will. + +## 1. Layout (proposed) +``` +crates/protocol/ # wire types, versioned; no I/O +crates/client/ # OpenMLS wrapper + mailbox client; embedded by Amicitia Domi +crates/relay/ # axum + SQLite; stores exactly docs/PROTOCOL.md §5 +deploy/nixos/ # NixOS module (non-logging reverse proxy included) +deploy/container/ # container image +``` +`relay` never depends on `client`. `protocol` depends on nothing in this repository. + +## 2. Absolute rules +1. **No hand-written cryptography.** MLS via OpenMLS; hashes and randomness from vetted crates. +2. **The relay stores only `docs/PROTOCOL.md` §5.** A new column is a protocol change: document, + review, version bump — never a migration slipped into a feature. +3. **No logging of IP addresses, user agents or request bodies**, in code or in the shipped deploy + configuration. Counts only. +4. **Every privacy claim in the docs has a test** (§7 of the protocol). A claim without a test is + removed from the docs until it has one. +5. Secrets (tokens, keys) never in the repository, test fixtures included — fixtures generate them. +6. **Builds are reproducible** (Nix flake) and every release publishes a signed `SHA256SUMS`. A + change that breaks reproducibility is a review **blocker** (`docs/VERIFY.md`). +7. The name *Tabellarius* is for developers and auditors. User-facing copy says *your message relay*. + +## 3. Workflow +Same as Amicitia: analysis document in `.agents/features/` before code ((D)TDD), branch per feature, +adversarial self-review in `.agents/reviews/`, merge `--no-ff`, push and verify the remote hash. +**No AI attribution in commits, ever.** Quote test counts per crate; an exit code is not a count. + +## 4. Known traps +| Trap | Why it bites | +|:--|:--| +| **The helpful debug log** | One `tracing::info!(?request)` logs an IP or a token. Logging goes through a filter that knows which fields are allowed. | +| **The reverse proxy logs** | The relay can be clean while nginx/caddy logs every IP. The deploy module disables access logs; the review checks it. | +| **Metadata by timing** | Fetching all mailboxes in one connection links them. Document it honestly; do not claim otherwise. | +| **iOS wake-ups** | See protocol §6 — the publisher's push gateway is a privacy cost, stated, not hidden. | diff --git a/README.md b/README.md new file mode 100644 index 0000000..68a80bc --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Tabellarius + +*Tabellarius* — the Roman letter carrier. He carried sealed tablets and could not read them. + +An open-source, self-hostable relay and client library for **end-to-end encrypted messages between +devices that are rarely online at the same time**. Built for Amicitia Domi; usable by anyone. + +- **The relay stores only ciphertext addressed to a random mailbox id**, deletes it once delivered, + and forgets it after a fixed time either way. No accounts, no phone numbers, no contact lists, no + IP logs. +- **Encryption is MLS** (RFC 9420) via OpenMLS. Nothing cryptographic is written here by hand. +- **Only people you invited can post to your mailbox** — invitations carry a capability token. +- Runs on a home server: a NixOS module and a container image. + +Read `docs/PROTOCOL.md` for exactly what the relay sees and what it does not protect against, and +`docs/VERIFY.md` for how to check every claim yourself — reproducible builds, signed SHA-256 +footprints, key fingerprints and a wire inspector. + +**Status:** Phase 0 — protocol and threat model under review; no code yet. +**Licence:** relay under AGPL-3.0, so a modified public relay stays open; client and protocol crates +under Apache-2.0 OR MIT, so any app can embed them. diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md new file mode 100644 index 0000000..883207f --- /dev/null +++ b/docs/PROTOCOL.md @@ -0,0 +1,62 @@ +# Tabellarius protocol v0 — what crosses the wire, and what the relay learns + +Reviewed and approved **before** any relay code is written. Every claim below must have a test. + +## 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 *(proposal)*. + +## 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 *(proposal)*. The reverse proxy in front must also not +log; the NixOS module ships configured that way. + +## 6. Waking a closed app (open — decide before Phase 2) +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. diff --git a/docs/VERIFY.md b/docs/VERIFY.md new file mode 100644 index 0000000..bfdc331 --- /dev/null +++ b/docs/VERIFY.md @@ -0,0 +1,26 @@ +# Verifying it yourself — SHA-256 footprints and audits + +The promise is that messages are end-to-end encrypted and the relay learns nothing readable. A promise +nobody can check is not a promise, so every part of it has a way for a user — or anyone they trust — +to check it. Legend: **[decided]** · **[proposed]** · **[judgment]**. + +## 1. What can be verified, and how +| Claim | How a user checks it | Status | +|:--|:--|:--| +| The messaging code is what is published | **Reproducible builds** (Nix flake): anyone builds the client library and the relay and gets the **same SHA-256**. Releases carry a signed `SHA256SUMS` (Ed25519, minisign) on GitHub and Gitea. | [proposed] | +| Amicitia runs that exact code | Desktop: the messaging library ships as a **separate file**; *Settings → Privacy → Check messaging code* computes its SHA-256 and compares it with the signed manifest (fetched, or pasted by hand to stay offline). | [proposed] | +| …on a phone | The library is linked into the app; the app shows the commit and crate checksum it was built from. A full binary proof is not possible here — said plainly. | [proposed] | +| I am talking to the right person | **Safety footprint**: a SHA-256 fingerprint of both people's keys, shown as digits and a QR. Compare in person once; a change is announced. | [proposed] | +| Nothing readable crosses the wire | `tabellarius-inspect`, an open CLI: feed it the app's raw envelope export or a network capture; it confirms every payload is MLS ciphertext and finds no plaintext canary. | [proposed] | +| The relay stores only `PROTOCOL.md` §5 | The relay's schema and the non-logging deploy config are in this repository; a self-hosted relay is built from source; `/version` returns its build hash. | [proposed] | +| The encryption is real MLS | Published MLS test vectors run in CI; anyone can run them. | [proposed] | + +## 2. Honest limit [judgment] +Amicitia itself is a **private** repository. A user can verify the messaging library, the wire and the +relay, but cannot prove from the outside that the closed app never copies plaintext before handing it +to the library. Ways to narrow this later: an independent audit with a published report, or opening the +app's message path. Stated in the app's *About messages* page, not hidden. + +## 3. Where the user sees this +Not on the main screens. One place: **Settings → Privacy → How your messages travel** — the relay is +called *your message relay*; the name *Tabellarius* appears only there, with a link to this repository.