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
113
crates/onionwire-sdk/Cargo.lock
generated
113
crates/onionwire-sdk/Cargo.lock
generated
|
|
@ -1181,7 +1181,9 @@ version = "0.2.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
|
||||
dependencies = [
|
||||
"getrandom 0.4.3",
|
||||
"hybrid-array",
|
||||
"rand_core 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1888,6 +1890,16 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "der"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a"
|
||||
dependencies = [
|
||||
"const-oid 0.10.2",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "der-parser"
|
||||
version = "10.0.0"
|
||||
|
|
@ -2084,12 +2096,12 @@ version = "0.16.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca"
|
||||
dependencies = [
|
||||
"der",
|
||||
"der 0.7.10",
|
||||
"digest 0.10.7",
|
||||
"elliptic-curve",
|
||||
"rfc6979",
|
||||
"signature",
|
||||
"spki",
|
||||
"spki 0.7.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2098,7 +2110,7 @@ version = "2.2.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53"
|
||||
dependencies = [
|
||||
"pkcs8",
|
||||
"pkcs8 0.10.2",
|
||||
"signature",
|
||||
]
|
||||
|
||||
|
|
@ -2148,7 +2160,7 @@ dependencies = [
|
|||
"ff",
|
||||
"generic-array",
|
||||
"group",
|
||||
"pkcs8",
|
||||
"pkcs8 0.10.2",
|
||||
"rand_core 0.6.4",
|
||||
"sec1",
|
||||
"subtle",
|
||||
|
|
@ -2811,6 +2823,7 @@ version = "0.4.15"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
|
||||
dependencies = [
|
||||
"ctutils",
|
||||
"typenum",
|
||||
"zeroize",
|
||||
]
|
||||
|
|
@ -3260,6 +3273,16 @@ dependencies = [
|
|||
"cpufeatures 0.3.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kem"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01737161ba802849cfd486b5bd209d38ba4943494c249a8126005170c7621edd"
|
||||
dependencies = [
|
||||
"crypto-common 0.2.2",
|
||||
"rand_core 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "konst"
|
||||
version = "0.2.20"
|
||||
|
|
@ -3525,6 +3548,34 @@ dependencies = [
|
|||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ml-kem"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9ba01ebcf90f6aff8e9b9f55bb69b19e6250e4ade5787d0040eaa27dd226238"
|
||||
dependencies = [
|
||||
"hybrid-array",
|
||||
"kem",
|
||||
"module-lattice",
|
||||
"pkcs8 0.11.0",
|
||||
"rand_core 0.10.1",
|
||||
"sha3 0.12.0",
|
||||
"shake",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "module-lattice"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c61b87c9683ab7cb1c6871d261ad5479b6b10ceb52c4352aaca3b5d35a8febe"
|
||||
dependencies = [
|
||||
"ctutils",
|
||||
"hybrid-array",
|
||||
"num-traits",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "monero-address"
|
||||
version = "0.1.0"
|
||||
|
|
@ -3865,6 +3916,7 @@ dependencies = [
|
|||
"hkdf",
|
||||
"hmac",
|
||||
"md-5",
|
||||
"ml-kem",
|
||||
"qrcode",
|
||||
"rand 0.8.8",
|
||||
"ratatui",
|
||||
|
|
@ -4156,9 +4208,9 @@ version = "0.7.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f"
|
||||
dependencies = [
|
||||
"der",
|
||||
"pkcs8",
|
||||
"spki",
|
||||
"der 0.7.10",
|
||||
"pkcs8 0.10.2",
|
||||
"spki 0.7.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4167,8 +4219,18 @@ version = "0.10.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
|
||||
dependencies = [
|
||||
"der",
|
||||
"spki",
|
||||
"der 0.7.10",
|
||||
"spki 0.7.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkcs8"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7"
|
||||
dependencies = [
|
||||
"der 0.8.2",
|
||||
"spki 0.8.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4765,11 +4827,11 @@ dependencies = [
|
|||
"num-integer",
|
||||
"num-traits",
|
||||
"pkcs1",
|
||||
"pkcs8",
|
||||
"pkcs8 0.10.2",
|
||||
"rand_core 0.6.4",
|
||||
"sha2",
|
||||
"signature",
|
||||
"spki",
|
||||
"spki 0.7.3",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
|
@ -4989,9 +5051,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc"
|
||||
dependencies = [
|
||||
"base16ct",
|
||||
"der",
|
||||
"der 0.7.10",
|
||||
"generic-array",
|
||||
"pkcs8",
|
||||
"pkcs8 0.10.2",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
|
@ -5207,6 +5269,17 @@ dependencies = [
|
|||
"sponge-cursor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shake"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09057cb2149ad4cbd2da1e26b351f9a4c354219421229c69c3063e6f61947c4a"
|
||||
dependencies = [
|
||||
"digest 0.11.3",
|
||||
"keccak 0.2.2",
|
||||
"sponge-cursor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.7"
|
||||
|
|
@ -5386,7 +5459,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"der",
|
||||
"der 0.7.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spki"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ef958a98b9d5da290cfc78946e9f3e61e1e62a18db0d92cac0b83cc161491a9"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"der 0.8.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -5607,7 +5690,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874"
|
||||
dependencies = [
|
||||
"rustix",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -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