chat: pad plaintext to a normative length ladder
All checks were successful
ci / test (pull_request) Successful in 15m47s
ci / sdk (pull_request) Successful in 1m31s

Chat plaintext is padded inside the ratchet AEAD to one of
256/512/1024/2048/4096/8192/16384/32768 bytes, with an explicit big-endian
uint16 pad_len followed by the body and random fill. An observer sees only
the bucket; the padding is authenticated by ChaCha20-Poly1305 and by the
Noise session. The receiver trusts pad_len only, rejects an overrun before
appending or persisting anything, and never infers a boundary from trailing
bytes. fil chunks are unchanged.

docs/PROTOCOL.md gains a normative Length buckets section, THREAT_MODEL
replaces the no-padding limit, README notes the bucketed chat length.
This commit is contained in:
agent 2026-10-20 12:38:04 -04:00
commit 7fa3edcdb4
No known key found for this signature in database
8 changed files with 517 additions and 11 deletions

View file

@ -177,8 +177,14 @@ device.
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.
- *Length is bucketed; timing is not.* One Noise session per message, and chat
plaintext is padded inside the ratchet ciphertext to a fixed ladder (256 B to
32 KiB — `docs/PROTOCOL.md`, “Length buckets”), so an observer sees only the
bucket and not the body length. That is all it hides: message timing, retry
cadence, the one-shot-per-message circuits, and the timing of the handshake
are unchanged, and no cover traffic or jitter is generated. Non-chat frames
(`loc `, `prf `, `inv `, `rcp `, `tip `, `fil `) are not padded and still
reveal their own sizes.
- *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