The design doc, VerifyingKey::verify and Error::InvalidSignature claimed that both halves are always checked so timing does not tell which failed. Not so: a malformed ML-DSA half is refused at decode without verification, and verify_strict returns early on a bad R (QA measured 59/187/217 us against 225 us). The docs now say the error does not name the half, the timing may, and that is fine because verification uses only public data (RFC 10073 3.3 allows failing early). The `&` and its comment, which bought nothing (both booleans were already computed), become a plain `&&`. No behaviour change.
14 KiB
Arcanum v0.2.0: hybrid post-quantum signatures
(D)TDD document, written before the tests and the code. Mark decided on 2026-11-25: "Yes, before Day 3". Research behind every fact here, with URLs and dates:
F:\Akce\Via\research\ml-dsa-2026-11-25.md. The crate facts below were also read from the local cargo registry (ml-dsa-0.1.2,ed25519-dalek-3.0.0).
Why
Arcanum v0.1.0 makes the key exchange post-quantum, but its threat model says that everything rests on each peer holding the real hybrid public key of the other. Today that key would be vouched for by Tessera's Ed25519 signatures, which a quantum attacker can forge, and then substitute keys. v0.2.0 adds a signature that stays secure while either ML-DSA or Ed25519 does, so Day 3 can authenticate exchanged X-Wing public keys, and signed plans, post-quantum.
What
- A composite signature, ML-DSA-65 + Ed25519, exactly RFC 10073 (November 2026)
id-MLDSA65-Ed25519-SHA512(OID1.3.6.1.5.5.7.6.48). No combiner of our own. - Key binding: a helper that signs an X-Wing public key (and a key id and a validity) under a fixed Arcanum context, so Day 3 can check "this X-Wing key belongs to that device" with one call.
- Same rules as v0.1.0:
#![no_std],#![forbid(unsafe_code)], no I/O, no clock, randomness as a parameter, secrets zeroised on drop, typed errors, deterministic entry points only underhazmat.
Out of scope: certificates and X.509 (we use the RFC's construction, not its ASN.1); SLH-DSA; HashML-DSA;
changing v0.1.0's KEM, exchange or seal bytes (they stay frozen by tests/golden_v1.rs).
How
Primitives (vetted crates, none written here)
| Crate | Version | Features | Why |
|---|---|---|---|
ml-dsa (RustCrypto) |
=0.1.2 (2026-10-31) |
default-features = false, rand_core, zeroize, alloc |
FIPS 204; pure Rust, forbid(unsafe_code), no_std; hedged signing with a context; same ecosystem as ml-kem (rand_core 0.10, signature 3, module-lattice 0.2.4, keccak 0.2) |
ed25519-dalek |
=3.0.0 (2026-07-06) |
default-features = false, zeroize |
RFC 8032; shares curve25519-dalek 5.0.0 with x25519-dalek; verify_strict |
sha2 |
0.11 (already a dependency) |
— | PH = SHA-512 |
Alternatives looked at and refused: fips204 (no RustSec history, deterministic signing only behind a test
feature), libcrux-ml-dsa (SIMD unsafe, four advisories in 2026), aws-lc-rs (needs std, empty context
only), pqcrypto-mldsa (archived).
Parameter set: ML-DSA-65, NIST category 3, matching ML-KEM-768 in X-Wing. It is RFC 10073's recommendation for the Ed25519 composite and RustCrypto's default. Cost: public key 1984 B, signature 3373 B, private key 64 B (two seeds). ML-DSA-44 (OpenSSH 10.6's choice, signature 2484 B) is the fallback if size ever matters more than a matched level; it would be a new label, never a silent switch.
The construction (RFC 10073 §2.2, §3.2, §3.3, §4, §6)
Prefix = "CompositeAlgorithmSignatures2025" (32 ASCII bytes)
Label = "COMPSIG-MLDSA65-Ed25519-SHA512" (ASCII, fixed)
M' = Prefix || Label || u8(len(ctx)) || ctx || SHA-512(M) ctx: 0..=255 bytes
Sign: mldsaSig = ML-DSA-65.Sign(mldsaSK, M', ctx = Label) hedged (fresh rnd from the caller's RNG)
edSig = Ed25519.Sign(edSK, M') pure Ed25519, no Ed25519ctx
sig = mldsaSig (3309 B) || edSig (64 B)
Verify: split by fixed lengths (wrong length: invalid); rebuild M';
valid only if ML-DSA-65.Verify(mldsaPK, M', mldsaSig, ctx = Label)
and Ed25519.verify_strict(edPK, M', edSig)
Keys: public = mldsaPK (1952 B) || edPK (32 B)
private = mldsaSeed (32 B) || edSeed (32 B), both generated fresh and never used outside the composite
Crate calls, chosen because the convenient traits are wrong for this: ml-dsa's Signer/Verifier impls
sign deterministically with an empty context, which is not RFC 10073. Arcanum calls the inherent
ExpandedSigningKey::sign_randomized(M', Label, rng) and VerifyingKey::verify_with_context(M', Label, sig),
and builds the expanded key with ExpandedSigningKey::from_seed. SigningKey::sign_internal (public in 0.1.2,
caller-chosen randomness) is never called outside hazmat tests, and via must ban a direct ml-dsa
dependency the way it bans ml-kem.
Arcanum's contexts
The RFC's ctx is the application's domain separator. Arcanum fixes one per purpose, versioned like the KDF
labels, so a signature made for one purpose never verifies for another:
| Purpose | ctx |
|---|---|
| Binding an X-Wing public key to its owner | domi/arcanum/v2/sig/kem-key |
| A caller's own messages (Day 3: plans) | domi/arcanum/v2/sig/app/ + the caller's label (total ≤ 255 B) |
The key-binding message is u8(version=1) || u64be(not_before) || u64be(not_after) || u16be(len(id)) || id || xwing_pk (1216 B): fixed widths and one length prefix, so it is injective. Arcanum has no clock: the caller
passes now to verify_binding.
Shape of the API
pub mod sign {
pub struct SigningKey; // two 32-byte seeds; ZeroizeOnDrop; no Clone/Copy/PartialEq/Display; Debug redacted
pub struct VerifyingKey; // 1984 bytes; from_bytes checks lengths and the Ed25519 point (not weak)
pub struct Signature; // 3373 bytes
impl SigningKey {
pub fn generate<R: CryptoRng + ?Sized>(rng: &mut R) -> Self;
pub fn from_bytes(&[u8]) -> Result<Self, Error>; pub fn to_bytes(&self) -> Zeroizing<[u8; 64]>;
pub fn verifying_key(&self) -> &VerifyingKey;
pub fn sign<R: CryptoRng + ?Sized>(&self, msg: &[u8], ctx: &AppContext, rng: &mut R) -> Result<Signature, Error>;
}
impl VerifyingKey { pub fn verify(&self, msg: &[u8], ctx: &AppContext, sig: &Signature) -> Result<(), Error>; }
pub fn bind_kem_key<R>(sk: &SigningKey, id: &[u8], kem: &xwing::PublicKey, valid: (u64, u64), rng: &mut R) -> Result<Signature, Error>;
pub fn verify_binding(vk: &VerifyingKey, id: &[u8], kem: &xwing::PublicKey, valid: (u64, u64), now: u64, sig: &Signature) -> Result<(), Error>;
#[cfg(feature = "hazmat")] pub fn sign_composite_raw(...); // the bare RFC ctx, for the RFC's own vectors
}
AppContext is a newtype that can only be built with the domi/arcanum/v2/sig/app/ prefix, so a caller can
never pass an empty or foreign context by accident. The bare RFC interface (any ctx, deterministic ML-DSA)
exists only under hazmat, for the known-answer tests. Verification returns one error,
Error::InvalidSignature, whichever half failed. Correction (QA S-06): the timing does tell which half
failed: a malformed ML-DSA half is refused at decode without being verified, and verify_strict returns early
on an undecodable or small-order R (QA measured 59 µs, 187 µs and 217 µs against 225 µs for a valid signature).
That is harmless: verification handles only public data (the message, the public key, the signature), so its
timing leaks nothing secret, and RFC 10073 §3.3 allows failing early. No dummy work is added.
Tests (written first)
| # | Mandatory test | Source of truth |
|---|---|---|
| 1 | ML-DSA-65 KATs: keyGen, sigGen (deterministic groups, byte for byte), sigVer (accept and reject) | NIST ACVP-Server gen-val/json-files/ML-DSA-*-FIPS204/, keyGen/sigGen at 2972def2 (2026-07-20), sigVer at a7f283cd (2026-07-31, the ModifyZ correction); sha256 pinned in tests/vectors/SOURCES.md |
| 2 | Ed25519 KATs and edge cases, with verify_strict |
RFC 8032 §7.1; Wycheproof ed25519_test.json |
| 3 | The composite: verify the RFC's s and sWithContext for id-MLDSA65-Ed25519-SHA512; our own signatures verify under an independent rebuild of M′ in the test |
RFC 10073 Appendix E (lamps-wg/draft-composite-sigs testvectors.json at f0627ab) |
| 4 | Both halves are bound: a signature with either half replaced by a valid half from another signature, a zeroed half, or the halves swapped, is refused; an empty-ctx ML-DSA verifier refuses the ML-DSA half alone | constructed |
| 5 | Every byte matters: flipping any byte of the message, ctx, public key or signature fails verification; contexts are prefix-free and a key-binding signature never verifies as an app message, or the other way round | constructed |
| 6 | Malformed input (wrong lengths, a weak Ed25519 key, a 256-byte ctx) gives typed errors, never a panic; a fuzz target, 10 minutes | cargo fuzz |
| 7 | Hygiene: hazmat and ml-dsa's own randomness-taking internals are not reachable from a default-features consumer (compile-fail, like v0.1.0's A-33/A-34); the feature graph has no hazmat; secret types are ZeroizeOnDrop and freed wiped (the allocator probe) |
v0.1.0's feature_hygiene.rs, qa_consumer_api.rs, zeroize-probe |
| 8 | v0.1.0 is unchanged: tests/golden_v1.rs still passes |
v0.1.0 |
Also Wycheproof mldsa_65_sign_seed_test.json and mldsa_65_verify_test.json (20b25694, 2026-10-12).
RustCrypto's own ACVP copies predate the sigVer correction, so Arcanum runs the current files itself.
Risks
| Risk | Consequence | Mitigation |
|---|---|---|
ml-dsa is unaudited and 0.1.x; three advisories in 2026 (a timing side channel, signature malleability, a use_hint bug), constant-time fixes in 0.1.2 |
a forgery or a key leak in the PQ half | the hybrid: Ed25519 still holds; version pinned; ACVP + Wycheproof + RFC vectors; cargo audit in every run |
Using the crate's Signer/Verifier traits |
signatures that are not RFC 10073 (empty ctx, deterministic) | never called; the RFC vectors fail if they are |
zeroize is opt-in in ml-dsa |
secret keys left in memory | the feature is set, a hygiene test asserts it in the feature graph, the allocator probe covers signing |
| The composite is not SUF-CMA and only weakly non-separable (RFC 10073 §9.2) | two valid signatures for one message; an Ed25519 half could be lifted out | Arcanum never uses a signature as an identifier; component keys never exist outside the composite; the Ed25519 half signs M′, which starts with the RFC Prefix (§9.4) |
| Signing can fail (rejection sampling bound) | a panic in a release build | 0.1.2 returns an error from the hedged path; Arcanum surfaces it as Error::SigningFailed; the deterministic sign_mu_deterministic (documented to panic) is never called |
| A 1984-byte key and a 3373-byte signature | larger control messages | fine over the control channel; noted for Day 5's QR import (classic keys only there) |
As built (v0.2.0, src/sign.rs)
Where the code differs from, or adds to, the design above (the code wins):
- The raw interface stays hedged.
sign_composite_raw(sk, msg, ctx, rng)andverify_composite_raw(vk, msg, ctx, sig)take anyctxof 0 to 255 bytes but still sign throughsign_randomizedwith the caller's RNG; there is no deterministic ML-DSA path in Arcanum at all. A test that needs repeatable bytes passes a seeded RNG. Both arehazmatonly. - A stricter Ed25519 key check.
ed25519-dalek'sVerifyingKey::from_bytesaccepts y >= p and a set sign bit on x = 0. Arcanum re-encodes the point and refuses any encoding that is not the canonical one, as well as small-order points (Error::InvalidVerifyingKey). Invisible to honest keys and to the RFC's vectors. - App labels are 1 to 231 bytes (
MAX_APP_LABEL_LEN= 255 minus the 24-byte prefix); an empty label isTooShort, a longer oneTooLong. And&'static(QA S-09):AppContext::newis aconst fntaking&'static [u8], so a label is written in the source, not derived from a peer name, file name or message field at run time (a consumer would have to leak memory on purpose to get around it). A consumer builds its contexts asconsts, which also moves the length check to its compile time. There is no runtime constructor. - Key bindings are hashed field by field (no allocation); the window is inclusive at both ends;
verify_bindingchecks, in this order, the window's shape and the id length (InvalidValidity,TooLong), the signature (InvalidSignature), thennow(OutsideValidity), soOutsideValidityalways means an authentic but expired binding. ml-dsagetsalloc(its large vectors are boxed),rand_coreandzeroize, default features off;ed25519-dalekgets onlyzeroize(notfast: no precomputed tables).
Gaps
- Not audited, like v0.1.0; the Day 7 audit pack covers both versions.
- No constant-time measurement (dudect) of our own; inherited from the crates.
- No HashML-DSA and no X.509: not needed.
- The RFC's signing vectors are hedged, so the composite has no byte-exact signing KAT; byte-exact checks exist for the ML-DSA half (ACVP deterministic groups) and Ed25519.
Whether: it does not. Test 3 (2026-11-25) verifies both the RFC'sverify_strictrefuses any RFC 10073 vectors(empty ctx) andsWithContextwithverify_strict, through Arcanum and through the independent rebuild of M'.verify_strictalso agrees with all 151 Wycheproofed25519_test.jsonverdicts (test 2: no disagreement to list).- ACVP sigGen, sigVer and Wycheproof
mldsa_65_verifyrun as subsets (tests/vectors/SOURCES.md): 18 of the sigGen cases, 15 sigVer cases, 70 of 210 Wycheproof verify cases. The full files' sha256 are pinned, so the subsets can be rechecked against them by rerunningmake_subsets.py. - Stack copies: building a
SigningKeymoves the expanded ML-DSA key (about 64 kB) through the stack before it is boxed; the allocator probe sees only the heap (as in v0.1.0's threat model).
Questions (none blocks the work)
- Should Tessera's device identity itself move to this composite key, or should Tessera keep Ed25519 and
this key be a separate Via identity signed by it? Day 3's
docs/03_engine.mdmust decide; Arcanum works either way. - Validity windows on key bindings: the default the engine should use (proposal: 30 days, renewed by the control service).