feat: X-Wing (draft -11), mutual exchange, WireGuard PSK per epoch, sealed box
X-Wing is composed from ml-kem, x25519-dalek, sha3 and shake and matches the draft's vectors. The PSK comes from a mutual exchange (each peer encapsulates to the other, QA A-15) bound to the full transcript in Arcanum's own HKDF layer (QA D-QA-1). Low-order X25519 values are refused. Deterministic entry points sit behind the off-by-default hazmat feature, enabled only for the tests.
This commit is contained in:
+21
-7
@@ -8,11 +8,16 @@ use std::collections::HashSet;
|
||||
|
||||
const CONTEXT: &[u8] = b"via/test: epochs";
|
||||
|
||||
fn exchange_with(eseed_i: [u8; 64]) -> (exchange::Session, exchange::Session) {
|
||||
let i = SecretKey::from_seed([0x01; 32]);
|
||||
let r = SecretKey::from_seed([0x04; 32]);
|
||||
let init = exchange::initiate_derand(&i, r.public_key(), CONTEXT, &eseed_i).unwrap();
|
||||
let (ct_ri, rs) = exchange::respond_derand(&r, i.public_key(), init.ciphertext(), CONTEXT, &[0x05; 64]).unwrap();
|
||||
(init.finish(&ct_ri).unwrap(), rs)
|
||||
}
|
||||
|
||||
fn sessions() -> (exchange::Session, exchange::Session) {
|
||||
let sk = SecretKey::from_seed([0x01; 32]);
|
||||
let (ct, a) = exchange::initiate_derand(sk.public_key(), CONTEXT, &[0x02; 64]).unwrap();
|
||||
let b = exchange::respond(&sk, &ct, CONTEXT).unwrap();
|
||||
(a, b)
|
||||
exchange_with([0x02; 64])
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -43,9 +48,8 @@ fn the_same_epoch_is_reproducible_from_the_same_inputs() {
|
||||
|
||||
#[test]
|
||||
fn a_different_exchange_gives_different_psks_for_the_same_epoch() {
|
||||
let sk = SecretKey::from_seed([0x01; 32]);
|
||||
let (_, a) = exchange::initiate_derand(sk.public_key(), CONTEXT, &[0x02; 64]).unwrap();
|
||||
let (_, c) = exchange::initiate_derand(sk.public_key(), CONTEXT, &[0x03; 64]).unwrap();
|
||||
let (a, _) = exchange_with([0x02; 64]);
|
||||
let (c, _) = exchange_with([0x03; 64]);
|
||||
for epoch in 0..16 {
|
||||
assert_ne!(a.wireguard_psk(epoch).as_bytes(), c.wireguard_psk(epoch).as_bytes());
|
||||
}
|
||||
@@ -83,3 +87,13 @@ fn epoch_helper_uses_two_minute_epochs() {
|
||||
assert_eq!(epoch_at(1_764_000_000), 1_764_000_000 / 120);
|
||||
assert_eq!(epoch_at(u64::MAX), u64::MAX / 120);
|
||||
}
|
||||
|
||||
/// QA A-11: the epoch is encoded at its full 64-bit width; nothing truncates it.
|
||||
#[test]
|
||||
fn the_epoch_is_not_truncated() {
|
||||
let (a, _) = sessions();
|
||||
let p = |e: u64| *a.wireguard_psk(e).as_bytes();
|
||||
assert_ne!(p(0), p(1 << 32));
|
||||
assert_ne!(p(1), p(1 << 8));
|
||||
assert_ne!(p(u64::MAX), p(u64::MAX >> 1));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user