transport: ML-KEM-768 hybrid prelude and onionwire:v2 invites
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:
parent
00bb95675f
commit
c741b660e4
26 changed files with 1637 additions and 177 deletions
|
|
@ -103,6 +103,10 @@ pub struct FriendInfo {
|
|||
/// Current locator. May be stale if the peer rotated while you were down.
|
||||
pub onion: String,
|
||||
pub last_connect_ok: bool,
|
||||
/// True when the friend was added from `onionwire:v2` (has an ML-KEM key),
|
||||
/// so sessions are hybrid. False is a legacy v1 friend: classical
|
||||
/// transport, and the UI must say so.
|
||||
pub pq: bool,
|
||||
}
|
||||
|
||||
/// What `send()` did with the message.
|
||||
|
|
@ -190,6 +194,8 @@ pub struct RotateOutcome {
|
|||
pub struct InviteInfo {
|
||||
pub pubkey_hex: String,
|
||||
pub onion: String,
|
||||
/// `onionwire:v2` (ML-KEM key present) vs a legacy v1 invite.
|
||||
pub pq: bool,
|
||||
}
|
||||
|
||||
/// Observable lifecycle state of the node's onion service.
|
||||
|
|
@ -300,6 +306,7 @@ pub fn decode_invite(invite: String) -> WResult<InviteInfo> {
|
|||
Ok(InviteInfo {
|
||||
pubkey_hex: hex(&p.pubkey),
|
||||
onion: p.onion,
|
||||
pq: p.kem_pk.is_some(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -388,6 +395,7 @@ impl Wire {
|
|||
petname: f.petname,
|
||||
onion: f.onion,
|
||||
last_connect_ok: f.last_connect_ok,
|
||||
pq: f.kem_pk.is_some(),
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
|
@ -405,6 +413,7 @@ impl Wire {
|
|||
petname: f.petname,
|
||||
onion: f.onion,
|
||||
last_connect_ok: f.last_connect_ok,
|
||||
pq: f.kem_pk.is_some(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -1656,6 +1665,17 @@ mod tests {
|
|||
.block_on(f)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_v2_invite_round_trips_through_decode_invite() {
|
||||
let onion = "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion";
|
||||
let invite = onionwire::qr::encode(&[7u8; 32], onion, &[1u8; 32], &[9u8; 1184])
|
||||
.expect("encode v2");
|
||||
let info = decode_invite(invite).expect("decode v2");
|
||||
assert_eq!(info.onion, onion);
|
||||
assert_eq!(info.pubkey_hex.len(), 64);
|
||||
assert!(info.pq, "a v2 invite carries the ML-KEM key");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tor_state_of_a_stopped_handle_is_stopped() {
|
||||
assert_eq!(stopped_wire().tor_state(), TorState::Stopped);
|
||||
|
|
|
|||
Loading…
Reference in a new issue