t_2fb507c6: F8 rotate prekey (Node::rotate_prekey + invite re-encode) #101

Merged
sirius merged 1 commit from wt/t_2fb507c6 into main 2026-09-18 01:21:45 +00:00
Owner

Card

Prekey rotation path — add rotate_prekey() + F8 QR re-encode (t_2fb507c6).

What this does

The signed prekey was generated at invite creation and never rotated: a long-lived static is a long-lived forward-secrecy window. F8 now rotates it.

  • Node::rotate_prekey() (src/node.rs) generates a new X25519 keypair, writes it to the self row, updates the live Keys, drops every stored ratchet session, and returns the new pubkey so the caller can re-encode the invite. The identity key (and the fingerprint) does not move.
  • F8 (Main) opens a confirm screen — the same "type ROTATE" prompt as F4, reusing RotatePrompt — and on confirm re-opens the F2 share path with the new invite.
  • Help overlay and the screen footer list the new key.

Why every friend must re-paste

The prekey is our Noise IK static and the seed of the bootstrap ratchet epoch (bootstrap_ratchet, src/node.rs). After a rotation a friend's dial uses the prekey they pinned from your invite, and their stored epoch is derived from the old one, so nothing decrypts in either direction until they F3-paste the new one. There is no in-band prekey update, so F8 hard-cuts locally: clear_ratchet for every friend, exactly like add_friend_payload does on a peer prekey change.

The card's suggested copy said "Offline friends must F3-paste your new invite"; that implies online friends pick it up on their own, and they do not — no loc frame carries a prekey. The screen text says every friend must re-paste, and docs/THREAT_MODEL.md spells the mechanics out.

Implementation notes

  • No store change was needed: Store::replace_identity_keys already rewrites the prekey_sk / prekey_pk columns, so the identity values passed back are the ones already stored. Card scope was node.rs / tui.rs / THREAT_MODEL.md and this keeps it that way.
  • rotate_prekey is synchronous and does not touch Tor (nothing is pushed to peers), unlike rotate, which has to publish a new onion service.
  • Legacy v1 signature acceptance is untouched.

Scope deviations (disclosed)

  • README.md's key table and docs/PROTOCOL.md's "Roles and keys" gained one line each: the new binding, and the sentence that said the prekey is long-lived and only F4 exists was now stale. docs/TUI.md's help-overlay dump was already stale before this PR (it never listed F6) and was left alone.
  • Test files touched: tests/rotate.rs (screen text + prompt reuse), tests/tui_chrome.rs (the help overlay must list F8), and a node-level test inside src/node.rs's mod tests — tests/*.rs cannot build a Node because both public constructors bootstrap Tor and publish an onion service.

Evidence

  • cargo test --locked — exit 0, 32 suites, 294 passed / 0 failed.
  • cargo clippy --locked --all-targets -- -D warnings — clean.
  • New test rotating_the_prekey_keeps_identity_and_drops_stale_ratchet_state asserts the prekey changes, the live and stored keys follow, the identity is unchanged, the friend's stored ratchet state is gone, and the re-encoded invite decodes back to the same identity with the new spk.
  • rustfmt: the --check hunk count on src/node.rs is 7 both before and after, so no new formatting churn in an already-dirty file.
## Card Prekey rotation path — add `rotate_prekey()` + F8 QR re-encode (t_2fb507c6). ## What this does The signed prekey was generated at invite creation and never rotated: a long-lived static is a long-lived forward-secrecy window. `F8` now rotates it. - `Node::rotate_prekey()` (`src/node.rs`) generates a new X25519 keypair, writes it to the `self` row, updates the live `Keys`, drops every stored ratchet session, and returns the new pubkey so the caller can re-encode the invite. The identity key (and the fingerprint) does not move. - `F8` (Main) opens a confirm screen — the same "type ROTATE" prompt as F4, reusing `RotatePrompt` — and on confirm re-opens the F2 share path with the new invite. - Help overlay and the screen footer list the new key. ## Why every friend must re-paste The prekey is our Noise IK static *and* the seed of the bootstrap ratchet epoch (`bootstrap_ratchet`, `src/node.rs`). After a rotation a friend's dial uses the prekey they pinned from your invite, and their stored epoch is derived from the old one, so nothing decrypts in either direction until they F3-paste the new one. There is no in-band prekey update, so F8 hard-cuts locally: `clear_ratchet` for every friend, exactly like `add_friend_payload` does on a *peer* prekey change. The card's suggested copy said "Offline friends must F3-paste your new invite"; that implies online friends pick it up on their own, and they do not — no `loc` frame carries a prekey. The screen text says every friend must re-paste, and `docs/THREAT_MODEL.md` spells the mechanics out. ## Implementation notes - No store change was needed: `Store::replace_identity_keys` already rewrites the `prekey_sk` / `prekey_pk` columns, so the identity values passed back are the ones already stored. Card scope was node.rs / tui.rs / THREAT_MODEL.md and this keeps it that way. - `rotate_prekey` is synchronous and does not touch Tor (nothing is pushed to peers), unlike `rotate`, which has to publish a new onion service. - Legacy v1 signature acceptance is untouched. ## Scope deviations (disclosed) - `README.md`'s key table and `docs/PROTOCOL.md`'s "Roles and keys" gained one line each: the new binding, and the sentence that said the prekey is long-lived and only F4 exists was now stale. `docs/TUI.md`'s help-overlay dump was already stale before this PR (it never listed F6) and was left alone. - Test files touched: `tests/rotate.rs` (screen text + prompt reuse), `tests/tui_chrome.rs` (the help overlay must list F8), and a node-level test inside `src/node.rs`'s `mod tests` — `tests/*.rs` cannot build a `Node` because both public constructors bootstrap Tor and publish an onion service. ## Evidence - `cargo test --locked` — exit 0, 32 suites, 294 passed / 0 failed. - `cargo clippy --locked --all-targets -- -D warnings` — clean. - New test `rotating_the_prekey_keeps_identity_and_drops_stale_ratchet_state` asserts the prekey changes, the live and stored keys follow, the identity is unchanged, the friend's stored ratchet state is gone, and the re-encoded invite decodes back to the same identity with the new `spk`. - rustfmt: the `--check` hunk count on `src/node.rs` is 7 both before and after, so no new formatting churn in an already-dirty file.
tui: F8 rotate prekey + Node::rotate_prekey (hard cut, drops ratchet state)
All checks were successful
ci / test (pull_request) Successful in 5m0s
ci / sdk (pull_request) Successful in 1m11s
android-ci / android (pull_request) Successful in 8m36s
6827b87a29
The signed prekey was set at invite creation and never rotated: a long-lived
static is a long-lived forward-secrecy window. F8 now rotates it.

- Node::rotate_prekey(): new X25519 keypair, written through the existing
  replace_identity_keys prekey columns (no store change needed), live Keys
  updated, new pubkey returned for the invite re-encode. Identity untouched.
- It drops every stored ratchet session: the bootstrap epoch is derived from
  the prekey DH, so each friend has to F3-paste the new invite. Nothing is
  pushed to peers \u2014 there is no in-band prekey update.
- TUI: F8 on Main opens the confirm screen (type ROTATE, same prompt as F4),
  then re-opens the F2 share path with the new invite; help overlay + footer
  hint list it.
- Docs: THREAT_MODEL gains a section on the F8 hard cut and the prekey-bound
  epoch bullet; README key table and PROTOCOL 'Roles and keys' follow.

Tests: node-level rotation test (identity/pk/stored row/ratchet drop/invite),
tests/rotate.rs screen text + prompt, tui_chrome help needs F8.
sirius merged commit 24b5c93c43 into main 2026-09-18 01:21:45 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!101
No description provided.