transport: ML-KEM-768 hybrid prelude and onionwire:v2 invites
All checks were successful
ci / test (pull_request) Successful in 18m32s
android-ci / android (pull_request) Successful in 20m14s
ci / sdk (pull_request) Successful in 3m11s

Adds an ML-KEM-768 install key beside the ed25519 identity and x25519
prekey. A friend added from a v2 invite always gets a version-2 PQ
prelude before Noise msg 1, and both sides bind (ct, ss_kem) into the
Noise prologue (onionwire-v2 \0 ct \0 ss_kem). The row decides: a
kem_pk friend without a prelude is rejected with 'prelude required',
a prelude for a classical row with 'unexpected prelude'.

Invites are now onionwire:v2 with kem=<base64url pk>; decode still
accepts v1 (no kem) and yields a classical friend. F8 rotates the
KEM key with the prekey and hard-cuts stored ratchet state. The TUI
labels a legacy friend 'classical'.

Docs: PROTOCOL (keys, framing, prologues, no-downgrade, invite v2),
THREAT_MODEL (what PQ transport does and does not buy; epoch 0 stays
classical), README (invite size, F8, legacy caveat). SDK exposes pq on
InviteInfo/FriendInfo and gains a v2 decode round-trip test.
This commit is contained in:
agent 2026-10-20 11:15:46 -04:00
commit c741b660e4
No known key found for this signature in database
26 changed files with 1637 additions and 177 deletions

View file

@ -19,7 +19,8 @@ use onionwire::tui::{
cell_width, chat_no_friends_lines, chat_with_delivery, compact_banner, draw_main_chrome,
draw_share, draw_text_overlay, fingerprint_mismatch_banner, help_overlay_text,
main_footer_hints, onion_glyph, quit_screen_text, restore_screen_text, rotate_screen_text,
status_footer, who_overlay_text, wipe_screen_text, wordmark_banner, ProfileEditor, WipeKind,
roster_line, status_footer, who_overlay_text, wipe_screen_text, wordmark_banner, ProfileEditor,
WipeKind,
};
use onionwire::{FriendProfile, Message};
use ratatui::Frame;
@ -90,15 +91,46 @@ fn friend_rows() -> Vec<FriendRow> {
label: "alice".into(),
fingerprint: "aaaaaaaaaaaaaaaa".into(),
stale: false,
pq: true,
},
FriendRow {
label: "bob-the-stale-peer".into(),
fingerprint: "bbbbbbbbbbbbbbbb".into(),
stale: true,
pq: true,
},
]
}
#[test]
fn a_legacy_friend_row_says_classical_in_the_roster() {
let pq = FriendRow {
label: "alice".into(),
fingerprint: "aaaaaaaaaaaaaaaa".into(),
stale: false,
pq: true,
};
let legacy = FriendRow {
pq: false,
..pq.clone()
};
let pq_text: String = roster_line(&pq, 40).spans.iter().map(|s| s.content.clone()).collect();
let legacy_text: String = roster_line(&legacy, 40)
.spans
.iter()
.map(|s| s.content.clone())
.collect();
assert!(pq_text.contains("alice"), "{pq_text}");
assert!(
!pq_text.contains("classical"),
"a v2 friend must not be labelled classical: {pq_text}"
);
assert!(
legacy_text.contains("classical"),
"a v1 friend must be visibly labelled as lacking PQ protection: {legacy_text}"
);
}
fn out_msg(id: i64, body: &str) -> Message {
Message {
id,
@ -152,7 +184,7 @@ fn empty_chat(phase: TorPhase) -> Vec<String> {
#[test]
fn dump_audit_frames() {
let invite = qr::encode(&[7u8; 32], ONION, &[1u8; 32]).expect("encode");
let invite = qr::encode(&[7u8; 32], ONION, &[1u8; 32], &[9u8; 1184]).expect("encode");
let friends = friend_rows();
let chat = chat_ok();
let (queued_chat, queued_note) = chat_queued();
@ -744,7 +776,7 @@ fn status_footer_drops_send_failed_when_crowded() {
#[test]
fn share_invite_wraps_at_three_sizes() {
let invite = qr::encode(&[7u8; 32], ONION, &[1u8; 32]).expect("encode");
let invite = qr::encode(&[7u8; 32], ONION, &[1u8; 32], &[9u8; 1184]).expect("encode");
for (w, h) in SIZES {
let backend = TestBackend::new(w, h);
let mut terminal = Terminal::new(backend).expect("terminal");
@ -757,7 +789,7 @@ fn share_invite_wraps_at_three_sizes() {
}
screen.push('\n');
}
assert!(screen.contains("onionwire:v1:"), "{w}x{h}\n{screen}");
assert!(screen.contains("onionwire:v2:"), "{w}x{h}\n{screen}");
assert!(screen.contains("(o) invite"), "{w}x{h}\n{screen}");
}
}