[docs] F21: analysis — the client, and the OpenMLS licence and Android check
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
# F21 — The client: MLS 1:1, a mailbox per contact, invites
|
||||
|
||||
Analysis, 2026-11-14. Issues #3 (OpenMLS check) and #6 (client). It builds on F20: the relay and
|
||||
`PROTOCOL.md` §8.
|
||||
|
||||
## 1. Why and what
|
||||
Chat must be end-to-end encrypted with MLS, and the relay must learn nothing readable. The client
|
||||
library is the one place where that happens. Amicitia embeds it in F22, and any other app could too.
|
||||
|
||||
After F21, two clients in one test can:
|
||||
1. pair through an invite;
|
||||
2. learn each other's mailbox and post token *inside* MLS;
|
||||
3. exchange text both ways through a real relay.
|
||||
|
||||
A canary string in a message, and both display names, never appear in the relay's database.
|
||||
|
||||
### The OpenMLS check (#3), measured 2026-11-14
|
||||
| Question | Answer |
|
||||
|:--|:--|
|
||||
| Version | `openmls` 0.9.2, `openmls_rust_crypto` / `_basic_credential` / `_traits` 0.6.0; MSRV 1.91 (we pin 1.99) |
|
||||
| Licence | OpenMLS crates **MIT**. The whole tree is MIT, Apache-2.0 or BSD, except **`hpke-rs` 0.7 (MPL-2.0)**, OpenMLS's HPKE. MPL-2.0 is file-level copyleft: an app that ships it unmodified must say where its source is. That goes into Amicitia's licence notices (F22) |
|
||||
| C code | none: no `cc`, `cmake` or `-sys` crate in the tree. The crypto is RustCrypto (pure Rust) |
|
||||
| Android | `cargo build -p tabellarius-client` passes for `aarch64-linux-android`, `x86_64-linux-android` and `armv7-linux-androideabi`. The client's tests also *run* on the x86_64 emulator (§5) |
|
||||
|
||||
## 2. Architecture
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant A as Inviter A
|
||||
participant R as Relay
|
||||
participant B as Invitee B
|
||||
A->>R: POST /v0/mailboxes Mw (id and post token derived from the secret)
|
||||
A->>R: POST /v0/invites {id, hash(secret), KeyPackage(A)}
|
||||
A-->>B: link: relay, invite id, secret (QR or link, outside the relay)
|
||||
B->>R: GET /v0/invites/{id} (secret) → KeyPackage(A), invite deleted
|
||||
B->>B: create group G, add A → Welcome
|
||||
B->>R: POST Mw: Welcome; then an MLS message {hello: mailbox M_B, post token P_B, name}
|
||||
A->>R: GET Mw → join G, read hello
|
||||
A->>R: POST M_B: MLS {hello: mailbox M_A, post token P_A, name}
|
||||
B->>R: GET M_B → read hello
|
||||
Note over A,B: A posts to M_B, B posts to M_A. One MLS group per pair.
|
||||
```
|
||||
- **Identity:** an Ed25519 key made on the device, behind a `BasicCredential` that carries 16
|
||||
random bytes, not a name. The display name travels only inside MLS (`PROTOCOL.md` §2).
|
||||
- **Ciphersuite:** `MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519`, RFC 9420's mandatory one.
|
||||
- **The welcome mailbox, Mw.** The link carries three things (§4): the relay, the invite id and the
|
||||
secret. The invitee's first reply needs somewhere to go, so its id and post token are **derived
|
||||
from the invite secret** with HKDF-SHA256 (crate `hkdf`, labels `tabellarius v0 welcome mailbox`
|
||||
and `… post`). The inviter creates Mw and keeps a random fetch token for it. To the relay it is an
|
||||
ordinary mailbox, so §5 and §8 are unchanged.
|
||||
- **The invitee creates the group.** It holds the inviter's KeyPackage, so it can add the inviter at
|
||||
once and send the Welcome. §4 says the invitee *replies with their own* KeyPackage. That is not
|
||||
needed when the invitee creates the group, so §4's text changes (§4 below).
|
||||
- **Payloads inside MLS** are JSON: `{"kind":"hello","mailbox","postToken","name"}` and
|
||||
`{"kind":"text","body"}`. The relay sees only MLS ciphertext.
|
||||
- **Blob framing:** each blob is one TLS-serialised `MlsMessageOut` (a Welcome, or a private
|
||||
message).
|
||||
- **Transport is a trait.** `Transport` covers create mailbox, post, fetch, acknowledge, create
|
||||
invite and claim invite. The library makes no network calls itself. F22 gives it an HTTP
|
||||
implementation. The tests use the real relay over loopback, plus an in-memory double for the run
|
||||
on Android.
|
||||
- **Poll:** fetch every own mailbox, process blobs in order, and acknowledge each one processed
|
||||
(or refused as not MLS). Each call returns events: `Joined {contact, name}`,
|
||||
`Message {contact, text}`.
|
||||
|
||||
## 3. Risks
|
||||
- **Privacy:**
|
||||
- The relay sees: mailbox ids, token hashes, ciphertext sizes and hours, and the KeyPackage (A's
|
||||
public key and the random credential id).
|
||||
- It does not see: names, text, or which two mailboxes belong to one pair.
|
||||
- The welcome mailbox's id is derived from the secret. Whoever has the link can post there, which
|
||||
is exactly the invite's capability. Mw is used once, but a mailbox cannot be deleted in v0 (F20
|
||||
§4), so it stays empty.
|
||||
- **Crypto:** none written here. MLS, HKDF and SHA-256 come from OpenMLS, `hkdf` and `sha2`.
|
||||
- **State:** in memory in F21. Keeping MLS state across restarts, in Amicitia's encrypted `mls`
|
||||
table, is F22.
|
||||
- **A stolen link:** whoever opens it first becomes the contact. The inviter sees the joiner's name
|
||||
and can block. Safety footprints (F26) are the real answer, and the link is meant to be shared in
|
||||
person or privately.
|
||||
|
||||
## 4. Gaps and designed solutions
|
||||
| Gap | Solution |
|
||||
|:--|:--|
|
||||
| §4 says the invitee *replies with their own KeyPackage*, and the reply channel (Mw) is not described | Change §4 to this flow: the invitee creates the group; the first reply goes to a mailbox derived from the secret. **Needs Mark's approval** before merging (CLAUDE.md §3) |
|
||||
| RFC 9420 test vectors | OpenMLS runs them in its own CI. Here, interop is tested between two of our clients, plus OpenMLS's validation of every message |
|
||||
| State across restarts | F22 (an `mls` table, an SQLite storage provider) |
|
||||
| Deleting the used welcome mailbox | protocol v1 (F20 §4) |
|
||||
| Block, delivery state | F24 |
|
||||
| Several devices per person | Phase 5 (G04) |
|
||||
|
||||
## 5. Verification matrix
|
||||
| Case | Kind | Test |
|
||||
|:--|:--|:--|
|
||||
| Two clients pair through an invite and exchange text both ways, through the real relay over loopback | integration | `client` `pair_and_talk_through_a_real_relay` |
|
||||
| A canary in a message, and both names, never appear in the relay's database file | integration | `client` `the_relay_never_sees_a_name_or_a_word` |
|
||||
| A link opened twice: the second claim fails, and nobody else joins | integration | `client` |
|
||||
| A blob that is not MLS, or not for this group, is acknowledged and skipped, never shown | integration | `client` |
|
||||
| The welcome mailbox derivation is fixed (a test vector) | unit | `client` |
|
||||
| Pairing and talking run **on the Android emulator** (an in-memory transport) | device | `cargo test --target x86_64-linux-android` binary run with `adb` |
|
||||
| The client does not depend on the relay (except in its tests) | CI | `scripts/check-deps.sh` (normal edges only) |
|
||||
Reference in New Issue
Block a user