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

@ -3750,6 +3750,10 @@ pub struct FriendRow {
pub fingerprint: String,
/// Last dial to this peer's onion did not answer.
pub stale: bool,
/// Friend row has an ML-KEM key (v2 invite). `false` means sessions to
/// this friend are the classical `onionwire-v1` transport, and the roster
/// says so in words — no pretending it is hybrid.
pub pq: bool,
}
/// The roster row for one friend, fitted to the pane's inner width in cells.
@ -3759,6 +3763,7 @@ pub fn friend_row(friend: &Friend) -> FriendRow {
label: sanitize::display_text(raw.as_bytes()).to_string(),
fingerprint: friend.fingerprint.clone(),
stale: !friend.last_connect_ok,
pq: friend.kem_pk.is_some(),
}
}
@ -5552,7 +5557,10 @@ fn truncate_fp(fp: &str) -> String {
fn roster_row_text(row: &FriendRow, inner_width: u16) -> String {
let budget = (inner_width as usize).saturating_sub(2);
let stale_s = if row.stale { " stale" } else { "" };
let avail = budget.saturating_sub(cell_width(stale_s));
// A legacy v1 friend has no PQ transport; say the word rather than let the
// roster imply protection it does not have.
let pq_s = if row.pq { "" } else { " classical" };
let avail = budget.saturating_sub(cell_width(stale_s) + cell_width(pq_s));
// The name is what the reader is looking for. The fingerprint only
// disambiguates two friends with the same petname, so it gets what is left
// and is dropped entirely when the pane is too narrow to show a usable
@ -5568,7 +5576,7 @@ fn roster_row_text(row: &FriendRow, inner_width: u16) -> String {
} else {
(fit_cells(&row.label, avail), String::new())
};
fit_cells(&format!("{shown}{fp_part}{stale_s}"), budget)
fit_cells(&format!("{shown}{fp_part}{pq_s}{stale_s}"), budget)
}
fn to_hex(bytes: &[u8]) -> String {