test: pin verify_strict, the verify_binding order and independent seeds (QA S-01 to S-03)

Ported from QA's proof tests for PR #2 (qa_s03 to qa_s05):

- S-01, sig_halves: an Ed25519 half with a small-order R (the identity,
  s = H(R || A || M')·a from a throwaway key's own scalar) is accepted by
  plain verify and refused by verify_strict; Arcanum must refuse it.
- S-02, sig_every_byte: a forged window that also excludes now gives
  InvalidSignature, never OutsideValidity.
- S-03, sig_composite: generate draws exactly 64 bytes, and the two seeds
  are those bytes in order (RFC 10073 3.1, independent component keys).

Each mutation QA describes now fails (applied to src/sign.rs, reverted):
Q1 verify_strict -> verify fails the S-01 test; Q3 now checked before the
signature fails the S-02 test; Q4 the Ed25519 seed copied from the ML-DSA
seed fails the S-03 test. Adds curve25519-dalek =5.0.0 as a dev-dependency
(already in the lock) for the scalar arithmetic.
This commit is contained in:
2026-11-26 03:42:56 +01:00
parent d56ee10f0d
commit 99db18af16
5 changed files with 107 additions and 0 deletions
+16
View File
@@ -194,3 +194,19 @@ fn every_field_of_a_key_binding_matters() {
flipped[i] ^= 0x01;
}
}
/// QA S-02 (their `qa_s04`): `OutsideValidity` only ever means "authentic, but not now". A forged
/// window that also excludes `now` is `InvalidSignature`. Kills checking `now` before the signature.
#[test]
fn a_forged_window_that_excludes_now_is_invalid_signature_not_outside_validity() {
let mut r = rng(57);
let sk = SigningKey::generate(&mut r);
let kem = xwing::SecretKey::generate(&mut r);
let sig = sign::bind_kem_key(&sk, b"dev", kem.public_key(), (1_000, 2_000), &mut r).unwrap();
let check =
|v: (u64, u64), now: u64| sign::verify_binding(sk.verifying_key(), b"dev", kem.public_key(), v, now, &sig);
assert_eq!(check((1_000, 2_000), 1_500), Ok(()), "control");
assert_eq!(check((1_000, 2_000), 2_500), Err(Error::OutsideValidity), "control: authentic, expired");
assert_eq!(check((1_000, 2_001), 2_500), Err(Error::InvalidSignature), "forged window, now after it");
assert_eq!(check((3_000, 4_000), 2_500), Err(Error::InvalidSignature), "forged window, now before it");
}