docs: ratchet wire spec + forward-secrecy/PCS threat-model claims

PROTOCOL.md gains a 'Ratchet (v1 chat layer)' section written so a second
implementation can interoperate from the text alone: byte-exact frame layout
(rat , 0x01, dh_pub||N||PN as header and AAD, 12-byte nonce,
ChaCha20-Poly1305), the KDF_RK/KDF_CK constructions and the role-separated
epoch rule, the derived bootstrap epoch, the receive and DH-step rules, the
MAX_SKIP/MAX_SKIPPED_KEYS bounds with the replay rule, the SQLCipher
ratchet_sessions row, and what stays unratcheted.

THREAT_MODEL.md gains the corresponding gains (per-chain forward secrecy, PCS
after a DH step, header not on the wire) and honest limits (skipped-key
window, the prekey-bound bootstrap epoch, no deniability, no one-time
prekeys, compromised endpoint out of scope, no metadata gain, the no-server-
outbox lock untouched) plus the amended transport wording.

README.md documents the operator-visible consequence: no reset command yet,
prekey change / invite re-paste is the only recovery, /wipe keeps the state,
and a desync is currently stderr-only.
This commit is contained in:
agent 2026-09-16 19:40:40 -04:00
commit 7f3ef8c3fc
No known key found for this signature in database
3 changed files with 335 additions and 4 deletions

View file

@ -3,7 +3,7 @@
Lean Tor messenger: one Rust process (ratatui + Noise IK + sqlite + in-process Arti).
No hosted server. Identity is a public key; the onion is only a locator.
**v0.2.1** — Linux TUI + Android SDK/APK. Two people add each other with an `onionwire:v1:…` invite string (`F2` share / `F3` paste). There is no QR graphic. Chat is Noise IK over your own v3 onion. Unreachable chat peers go to a **local outbox** (device-only retry queue — no relay); file transfer and payment frames still fail closed. Optional Monero payments: `/pay` invoices (receive), `/tip` payments (send), and a full in-app wallet create/import (`F6` wallet screen, `/wallet create`, `/wallet import`). Arti onion services are still experimental. The whole store is encrypted at rest with SQLCipher; message bodies add a row-bound AEAD layer on top.
**v0.2.1** — Linux TUI + Android SDK/APK. Two people add each other with an `onionwire:v1:…` invite string (`F2` share / `F3` paste). There is no QR graphic. Chat is Noise IK over your own v3 onion, and every chat message is ratcheted inside that session. Unreachable chat peers go to a **local outbox** (device-only retry queue — no relay); file transfer and payment frames still fail closed. Optional Monero payments: `/pay` invoices (receive), `/tip` payments (send), and a full in-app wallet create/import (`F6` wallet screen, `/wallet create`, `/wallet import`). Arti onion services are still experimental. The whole store is encrypted at rest with SQLCipher; message bodies add a row-bound AEAD layer on top.
You do **not** install a `tor` daemon, `torrc`, Prosody, or XMPP. OnionWire embeds Arti and publishes its own v3 onion.
@ -185,6 +185,40 @@ Still **fail closed** (no queue, no retry):
- Arti cannot publish the onion (no C-tor fallback)
- no DHT, no name server, no hosted chat server
## Chat ratchet (per friend, on device)
Chat is ratcheted on top of the Noise session: each chat send is
Double-Ratchet encrypted first, and the resulting `rat ` frame is what the
one-shot Noise session carries. Forward secrecy is per chain, and a snapshot of
one side's state stops reading the conversation at the next DH ratchet step.
The wire format and the honest limits are in
[docs/PROTOCOL.md](docs/PROTOCOL.md) and
[docs/THREAT_MODEL.md](docs/THREAT_MODEL.md).
- Per-friend state lives in the encrypted store (`ratchet_sessions`, one row per
friend). Nothing about it is transmitted, so the "no relay, no server queue"
rule is unchanged.
- Message numbers, ratchet keys and chain state ride *inside* the Noise
ciphertext; there is nothing new to observe on the wire.
- **Only chat is ratcheted.** `loc`, `prf`, `inv`, `rcp`, `tip` and file chunks
keep the one-shot Noise shape.
- Out-of-order delivery works (bounded skipped keys: 2000 per chain jump, 2000
stored, oldest-first eviction; a used key is deleted, so a replay fails
closed). A queued chat message re-sends the *same* `rat ` frame, so an outbox
retry never burns a second chain key.
- `/wipe` clears chat, payments and outbox rows but **keeps** the ratchet state
(roster and identity stay), so chat continues on the same epoch. `/wipe-all`
removes the data dir and the state with it.
- **Session reset.** There is no `/reset` command and no in-band reset in
v0.2.1. The state is dropped automatically when the friend's prekey changes —
i.e. when you `F3`-paste a refreshed invite — and the next chat frame
bootstraps a fresh epoch. That re-paste is the only recovery path today.
- **Desync today is quiet.** An inbound `rat ` frame that does not authenticate
is logged as `rat dropped (<reason>)` on stderr and dropped: no chat row, no
TUI marker, nothing stored. A send-side failure surfaces as the usual
`send failed: …` status note. There is no in-app "ratchet desynced" banner
yet, so a desync is diagnosed from the terminal the app was started in.
## File transfer
`/file /path` sends a local file to the selected friend. Both must be online.