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:
parent
1c998e9472
commit
7f3ef8c3fc
3 changed files with 335 additions and 4 deletions
|
|
@ -23,8 +23,9 @@ A 32-byte key is derived from the store passphrase with Argon2id (same params as
|
|||
identity backup) over a per-install 16-byte salt in `store_salt`, and handed to
|
||||
SQLCipher as a **raw** key (`PRAGMA key = "x'…'"`) — no second KDF pass over it.
|
||||
The key is the first statement after open, so the file header, schema, identity
|
||||
secret key, friend public keys, locators, profiles and payment rows are all
|
||||
ciphertext on disk. There is no `identity_sk`-on-disk problem to work around
|
||||
secret key, friend public keys, locators, profiles, payment rows and the
|
||||
per-friend ratchet session blobs (`ratchet_sessions`) are all ciphertext on
|
||||
disk. There is no `identity_sk`-on-disk problem to work around
|
||||
because `identity_sk` is inside the encrypted file. A wrong or empty passphrase
|
||||
fails closed before any write; an encrypted store whose `store_salt` is missing
|
||||
refuses to open instead of guessing.
|
||||
|
|
@ -65,6 +66,72 @@ A chat send to an unreachable onion is written to an `outbox` row next to its `m
|
|||
|
||||
The queue is bounded in scope: chat only. File transfer and `rcp` frames are one-shot, so a failed payment claim does not sit in the store being retried forever.
|
||||
|
||||
## Chat is ratcheted on top of the one-shot Noise session
|
||||
|
||||
The Noise IK session is still the transport: handshake, **one** application
|
||||
frame, close, one circuit per message. Chat stacks a Double Ratchet *inside*
|
||||
that frame (`rat `, [PROTOCOL.md](PROTOCOL.md)), with per-friend state persisted
|
||||
in the encrypted store (`ratchet_sessions`). The ratchet changes what a stolen
|
||||
chat line is worth; it does not re-open any lock: no relay, no server-side
|
||||
queue, one frame per Noise session, and the ratchet state never leaves the
|
||||
device.
|
||||
|
||||
**Gains.**
|
||||
|
||||
- *Per-chain forward secrecy.* Every message key is `HMAC-SHA256(chain_key,
|
||||
0x01)` over a chain key that is replaced by `HMAC-SHA256(chain_key, 0x02)`
|
||||
after each message, so state recovered after a chain has moved on does not
|
||||
decrypt the messages already sent on it — outside the skipped-key window
|
||||
below.
|
||||
- *Post-compromise security after a DH ratchet step.* An attacker holding a
|
||||
snapshot of one side's state cannot read the conversation past the next DH
|
||||
ratchet step: that step feeds a fresh X25519 output into the root, and the
|
||||
snapshot stops producing chain keys. The window is not zero — it lasts until
|
||||
the next step — but no attacker can prevent it closing.
|
||||
- *The ratchet header is not on the wire.* `dh_pub`, `N` and `PN` ride inside
|
||||
the Noise ciphertext (authenticated as AEAD associated data), so message
|
||||
counts and ratchet-key changes are not observable, and a tampered header fails
|
||||
closed.
|
||||
|
||||
**Honest limits.**
|
||||
|
||||
- *Skipped-key window.* Up to `MAX_SKIP` (2000) message keys of one chain, or up
|
||||
to `MAX_SKIPPED_KEYS` (2000) entries across a friend, stay decryptable to
|
||||
whoever holds the state until they are used (deleted on use) or evicted
|
||||
oldest-first. A snapshot also carries the current sending and receiving chain
|
||||
keys, which read the current chain until it advances. This is the price of
|
||||
out-of-order delivery, and it is per friend.
|
||||
- *The bootstrap epoch is prekey-bound.* The initial root and both initial
|
||||
ratchet secrets are HKDF outputs of the X25519 DH between the two long-lived
|
||||
signed prekeys, and the identity pubkeys that separate them are public. An
|
||||
attacker who has both peers' prekey statics can therefore reconstruct the
|
||||
**first** epoch. What that does not buy is a recorded message: every `rat `
|
||||
frame travels inside a one-shot Noise session whose ephemerals are not derived
|
||||
from the prekeys, so the prekeys alone do not open stored traffic. From the
|
||||
first DH ratchet step on, fresh X25519 secrets enter and the prekeys derive
|
||||
nothing — the bootstrap epoch is the exception, not the rule, and it is the
|
||||
reason the state is dropped when a peer's prekey changes.
|
||||
- *No deniability and no non-repudiation claim.* Chat frames are not signed and
|
||||
both parties derive the same chain keys, so nothing here would let a third
|
||||
party decide which of the two authored a chat line. Identity is proven per
|
||||
Noise session (the 96-byte proof), not per message.
|
||||
- *No one-time prekeys.* The bootstrap epoch uses the long-lived signed prekey
|
||||
only, so there is no per-session prekey consumption. A peer prekey change
|
||||
drops the state locally and the next chat frame re-bootstraps; there is no
|
||||
in-band reset and no key confirmation.
|
||||
- *A compromised endpoint is out of scope.* The ratchet state lives in the same
|
||||
SQLCipher file as the chat log, under the same passphrase. Anyone who opens
|
||||
the store holds the roots, both chain keys, the skipped keys and the plaintext
|
||||
history. `/wipe` clears chat, payments and outbox rows but **keeps** the
|
||||
ratchet state (roster and identity stay), so chat resumes on the same epoch;
|
||||
`/wipe-all` removes the data dir with it.
|
||||
- *No metadata protection beyond Noise.* One Noise session per message, no
|
||||
padding: sizes and timing are what they were before the ratchet.
|
||||
- *The ratchet does not re-open the "no server-side outbox" lock.* The state is
|
||||
device-local, one row per friend in the encrypted store, and nothing about it
|
||||
is transmitted. The local retry queue's two accepted consequences (device
|
||||
seizure, retry cadence) are unchanged.
|
||||
|
||||
## Profile is friend-visible, not a directory
|
||||
|
||||
A signed `prf` frame is shown to people who already have a session with you. Apply only for existing friends. There is still no name lookup, DHT, or public profile server. Anyone who already has a Noise session can see the profile you send them; that is not confidentiality against that friend.
|
||||
|
|
|
|||
Loading…
Reference in a new issue