tui: F8 rotate prekey + Node::rotate_prekey (hard cut, drops ratchet state)
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.
This commit is contained in:
parent
ad1b994c08
commit
6827b87a29
7 changed files with 177 additions and 2 deletions
63
src/tui.rs
63
src/tui.rs
|
|
@ -463,6 +463,17 @@ Offline friends CANNOT find you until they F3-paste your new invite.\n\
|
|||
Type ROTATE to confirm Esc to cancel"
|
||||
}
|
||||
|
||||
/// F8. Hard cut like the locator rotate: the prekey is our Noise static and the
|
||||
/// ratchet bootstrap is derived from the prekey DH, so nothing short of a fresh
|
||||
/// invite re-syncs a friend.
|
||||
pub fn prekey_screen_text() -> &'static str {
|
||||
"Rotate prekey?\n\
|
||||
Your identity and onion stay the same.\n\
|
||||
Every friend must F3-paste your new invite to pick up the new prekey,\n\
|
||||
or you cannot reach them and they cannot reach you.\n\
|
||||
Type ROTATE to confirm Esc to cancel"
|
||||
}
|
||||
|
||||
pub fn quit_screen_text() -> &'static str {
|
||||
"Quit OnionWire?\n\
|
||||
Message history can be cleared; identity and friends stay.\n\
|
||||
|
|
@ -507,6 +518,7 @@ OnionWire keys\n\
|
|||
F4 rotate onion locator\n\
|
||||
F5 selected friend's profile (/who)\n\
|
||||
F6 wallet (receive QR, create/import)\n\
|
||||
F8 rotate prekey\n\
|
||||
/profile edit name, bio, Monero address\n\
|
||||
/pay <xmr> [memo] invoice to receive\n\
|
||||
/tip <xmr> [memo] pay selected friend\n\
|
||||
|
|
@ -1157,6 +1169,9 @@ enum Screen {
|
|||
Rotate {
|
||||
prompt: RotatePrompt,
|
||||
},
|
||||
RotatePrekey {
|
||||
prompt: RotatePrompt,
|
||||
},
|
||||
Wipe {
|
||||
kind: WipeKind,
|
||||
prompt: WipePrompt,
|
||||
|
|
@ -1296,6 +1311,11 @@ impl App {
|
|||
}
|
||||
KeyCode::F(5) => self.who_open = true,
|
||||
KeyCode::F(6) => self.open_wallet()?,
|
||||
KeyCode::F(8) => {
|
||||
self.screen = Screen::RotatePrekey {
|
||||
prompt: RotatePrompt::new(),
|
||||
};
|
||||
}
|
||||
KeyCode::Esc => self.composer.clear(),
|
||||
KeyCode::Backspace => {
|
||||
if self.focus == Pane::Composer {
|
||||
|
|
@ -1415,6 +1435,18 @@ impl App {
|
|||
}
|
||||
_ => {}
|
||||
},
|
||||
Screen::RotatePrekey { prompt } => match key.code {
|
||||
KeyCode::Esc => self.screen = Screen::Main,
|
||||
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
if prompt.on_char(c) == RotateDecision::Confirm {
|
||||
self.confirm_rotate_prekey()?;
|
||||
}
|
||||
}
|
||||
KeyCode::Backspace => {
|
||||
prompt.on_char('\u{8}');
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Screen::Wipe { kind, prompt } => {
|
||||
let kind = *kind;
|
||||
match key.code {
|
||||
|
|
@ -1687,6 +1719,24 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
/// F8. Local and synchronous: nothing is pushed to peers — the new prekey
|
||||
/// only travels inside a fresh signed invite — so the screen goes straight
|
||||
/// to that invite (the F2 share path) for the user to hand out.
|
||||
fn confirm_rotate_prekey(&mut self) -> Result<(), String> {
|
||||
match self.node.rotate_prekey() {
|
||||
Ok(_) => {
|
||||
self.status_note =
|
||||
Some("prekey rotated · friends must F3-paste your new invite".into());
|
||||
self.open_share()
|
||||
}
|
||||
Err(e) => {
|
||||
self.alert = Some(e);
|
||||
self.screen = Screen::Main;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn open_share(&mut self) -> Result<(), String> {
|
||||
let payload = self.node.qr_payload()?;
|
||||
self.screen = Screen::Share { payload };
|
||||
|
|
@ -2064,6 +2114,7 @@ impl App {
|
|||
Screen::Paste { buf, err } => draw_paste(f, buf, err.as_deref()),
|
||||
Screen::Approve { payload } => draw_approve(f, payload),
|
||||
Screen::Rotate { prompt } => draw_rotate(f, prompt.typed()),
|
||||
Screen::RotatePrekey { prompt } => draw_rotate_prekey(f, prompt.typed()),
|
||||
Screen::Wipe { kind, prompt } => draw_wipe(f, *kind, prompt.typed()),
|
||||
Screen::Profile { editor } => draw_profile(f, editor),
|
||||
Screen::ConfirmKeys { kind, prompt, .. } => draw_confirm_keys(f, *kind, prompt.typed()),
|
||||
|
|
@ -2382,6 +2433,7 @@ match screen {
|
|||
Screen::Paste { .. } => "Enter submit Esc back ? help",
|
||||
Screen::Approve { .. } => "y accept n reject ? help",
|
||||
Screen::Rotate { .. } => "type ROTATE Esc cancel ? help",
|
||||
Screen::RotatePrekey { .. } => "type ROTATE Esc cancel ? help",
|
||||
Screen::Wipe { kind, .. } => match kind {
|
||||
WipeKind::Messages => "type WIPE Esc cancel ? help",
|
||||
WipeKind::All => "type WIPEALL Esc cancel ? help",
|
||||
|
|
@ -2482,6 +2534,17 @@ fn draw_rotate(f: &mut Frame, typed: &str) {
|
|||
);
|
||||
}
|
||||
|
||||
fn draw_rotate_prekey(f: &mut Frame, typed: &str) {
|
||||
let body = format!("{}\n\n{typed}", prekey_screen_text());
|
||||
f.render_widget(
|
||||
Paragraph::new(body)
|
||||
.style(style_text())
|
||||
.wrap(Wrap { trim: false })
|
||||
.block(themed_block("(o) rotate prekey")),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_wipe(f: &mut Frame, kind: WipeKind, typed: &str) {
|
||||
let title = match kind {
|
||||
WipeKind::Messages => "(o) wipe",
|
||||
|
|
|
|||
Loading…
Reference in a new issue