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.
With legacy_compatibility, ed25519-dalek checks only the top bits of S, so
S + l is accepted: a second encoding of the Ed25519 half, and the
malleability promise of verify_strict is gone. Feature unification lets
any crate in the final binary turn it on. deny.toml now bans it for
ed25519-dalek and curve25519-dalek, and ed25519-dalek/hazmat with it
(cargo-deny 0.20 [[bans.features]]).
Checked: bans ok as committed; enabling legacy_compatibility on
ed25519-dalek in Cargo.toml fails `cargo deny --offline check bans` for
both crates, and enabling hazmat fails it for ed25519-dalek (reverted).
A label is one fixed string per purpose; taking any runtime bytes let a
consumer derive it from a peer name, a file name or a message field, and
two purposes could then collide. AppContext::new now takes
&'static [u8] and is a const fn, so contexts are built as consts and a bad
label fails the consumer's build; there is no runtime constructor (the
simplest API: one constructor, no escape hatch until a need appears).
Tests: a const OK and a const EMPTY context; sig_hygiene refuses a
consumer that passes a runtime Vec (E0597/E0716); the one test that needs
runtime labels (flipping label bytes) leaks them on purpose. The random
labels in sig_malformed and fuzz mode 5's AppContext part are dropped (the
raw-ctx part of mode 5 stays). A doctest shows the const pattern, and
docs/02_signatures.md says so.
With t1 = 0 (Wycheproof's ZeroPublicKey), ML-DSA verification only checks
c~ = H(mu || w1(A·z)), which anyone can satisfy with s1 = s2 = t0 = 0: such
a composite key is silently no stronger than its Ed25519 half.
VerifyingKey::from_bytes now refuses it as InvalidVerifyingKey, like a
small-order Ed25519 half. Invisible to honest keys (t1 = 0 has negligible
probability); rho may be anything.
sig_malformed::an_ml_dsa_key_with_zero_t1_is_refused, from QA's qa_s07
inverted: the key is refused, one non-zero t1 byte anywhere makes it parse,
and with the component crate alone a secret-free expanded key signs for it.
Removing the check makes the test fail.
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.
HANDOVER: the builder's counts (121 tests in debug and release, clippy,
fmt, the zeroize probe, deny, audit, a 605 s fuzz run with no crash), seven
mutation checks, the vector sources, and what is not verified.
docs/02_signatures.md: an "As built" section (the raw interface stays
hedged, the canonical Ed25519 key check, label lengths, the order of the
binding checks, crate features); the gap on verify_strict is answered (it
accepts both RFC 10073 vectors and agrees with all 151 Wycheproof
verdicts), and the subsets and stack copies are listed as gaps. The app
context prefix in the AppContext paragraph is corrected to
domi/arcanum/v2/sig/app/.
README: signatures in the summary, a usage sketch, the new fuzz target.
fuzz/fuzz_targets/signatures.rs: raw bytes into VerifyingKey, Signature,
SigningKey and AppContext; and the input XORed into a valid verifying key,
signature, message, raw ctx, key-binding id/window/time, X-Wing key and
binding signature. Beyond "never panics" it asserts that only the exact
signed bytes verify.
Run on 5a52854 plus this target, Windows 10, nightly 1.102.0
(739adecd4 2026-11-24), libFuzzer + ASan (MSVC 14.44 asan runtime),
corpus and artifacts on D:, 12 seed inputs: 605 s, 38,609 executions,
63 exec/s, 0 crashes, 0 artifacts, coverage 3,549, 122 corpus units.
arcanum::sign, as docs/02_signatures.md sets out. M' = Prefix || Label ||
u8(len ctx) || ctx || SHA-512(M), built on the stack. The ML-DSA-65 half is
ExpandedSigningKey::sign_randomized(M', ctx = Label, rng), hedged; the
Ed25519 half is pure Ed25519 over M' (try_sign), checked with verify_strict.
Verification computes both halves before answering, and returns one
InvalidSignature whichever failed. ml-dsa's Signer/Verifier traits,
sign_deterministic and sign_mu_deterministic are never called.
- SigningKey: two 32-byte seeds (RFC 10073's private key format), the
expanded ML-DSA key boxed; ZeroizeOnDrop, not Clone, Debug redacted.
- VerifyingKey: 1984 bytes; refuses an Ed25519 half that is not a point,
not its canonical encoding, or of small order (InvalidVerifyingKey).
- AppContext: only "domi/arcanum/v2/sig/app/" + a 1..=231-byte label.
- bind_kem_key / verify_binding: an X-Wing public key bound to a key id and
an inclusive validity window under "domi/arcanum/v2/sig/kem-key"; the
message is hashed field by field; window and id are checked first, then
the signature, then now (InvalidValidity, TooLong, InvalidSignature,
OutsideValidity).
- sign_composite_raw / verify_composite_raw: the bare RFC ctx, hazmat only.
They still take an RNG (the ML-DSA half stays hedged), not the
deterministic variant the doc mentions.
- Error gains TooLong, InvalidVerifyingKey, InvalidSignature,
SigningFailed, InvalidValidity, OutsideValidity; Input gains SigningKey,
VerifyingKey, Signature, Context, KeyId.
Also fixes tests/kat_mldsa65.rs, which passed a &[&Vec<u8>] to
sign_internal and did not compile.
cargo test (debug): 121 passed, 0 failed (82 from v0.1.0, golden_v1
unchanged). clippy --all-targets --all-features -D warnings: clean.
The mandatory tests of docs/02_signatures.md, against the API the doc sets
out (arcanum::sign). They do not compile yet: the module does not exist.
1 kat_mldsa65: ACVP keyGen, sigGen (deterministic and hedged groups, byte
for byte, through sign_randomized/sign_mu_randomized fed the vector's
rnd), sigVer on the corrected file; Wycheproof sign_seed and verify.
2 kat_ed25519: RFC 8032 section 7.1 and Wycheproof, with verify_strict.
3 sig_composite: the RFC 10073 vectors s and sWithContext verify, the RFC
key derives the RFC public key, own signatures verify under an
independent rebuild of M', ML-DSA hedged with ctx = Label.
4 sig_halves: either half swapped in from another signature, zeroed or
cut, or the halves swapped, is refused; the ML-DSA half fails an
empty-ctx verifier. Not SUF-CMA (RFC 10073 9.2) is pinned.
5 sig_every_byte: any flipped byte of message, ctx, public key or
signature fails; contexts are prefix-free; key bindings and app
messages never verify as each other; every binding field matters.
6 sig_malformed: wrong lengths, weak and non-canonical Ed25519 keys,
0- and 256-byte contexts, a 65536-byte key id, random bytes.
7 sig_hygiene and feature_hygiene: compile-fail checks against a
default-features consumer (hazmat raw interface, ml-dsa internals,
non-crypto RNG, Clone), ZeroizeOnDrop, Debug; ml-dsa and ed25519-dalek
in the normal graph with zeroize and without hazmat or defaults. The
allocator probe covers the signing keys.
8 golden_v1.rs is untouched.
Adds ml-dsa =0.1.2 (alloc, rand_core, zeroize) and ed25519-dalek =3.0.0
(zeroize) with default features off, base64 for the tests, and bumps the
version to 0.2.0. The fuzz target follows with the code.
Official vectors for the signature tests, fetched 2026-11-25 at the commits
docs/02_signatures.md names: ACVP keyGen and sigGen at 2972def2, sigVer at
a7f283cd (after the ModifyZ correction), Wycheproof at 20b25694, the
composite-sigs repository at f0627ab, and RFC 8032 section 7.1.
Files under about 1 MB are kept whole. The larger ones are reduced to their
ML-DSA-65 groups and a few cases per group by make_subsets.py, which checks
each original's sha256 and drops only whole cases and groups; RFC 8032's
vectors are extracted from the RFC text by extract_rfc8032.py. SOURCES.md
records the URL, commit, git blob, original sha256 and the selection of
every file.
Mark decided on 2026-11-25 to add post-quantum signatures before Day 3, so
exchanged X-Wing keys can be authenticated post-quantum. The construction is
RFC 10073 id-MLDSA65-Ed25519-SHA512, byte for byte, on ml-dsa =0.1.2 and
ed25519-dalek =3.0.0. Covers the crate choices and the API traps (the crate's
Signer/Verifier traits use an empty context and sign deterministically), the
Arcanum contexts, a key-binding helper, the eight mandatory tests with their
vector sources (ACVP after the 2026-07-31 sigVer correction, Wycheproof, the
RFC's Appendix E), risks and gaps. Tests and code follow.
X-Wing draft -11 (ML-KEM-768 + X25519) unmodified, a mutual exchange with the
full transcript bound in Arcanum's HKDF layer, the WireGuard PSK per 120 s
epoch, and a one-shot sealed box. Two QA reviews answered, R2-01 to R2-05
fixed. 82 tests passed in debug and release; fuzzed 631 s on 96086be with no
crash. Not audited.
R2-01: PublicKey::encapsulate, SecretKey::decapsulate and SharedSecret::as_bytes
are hazmat-only; release consumers reach keys only through exchange and seal.
R2-02: PublicKey::from_bytes refuses a non-canonical X25519 half (bit 255 set,
or a value of at least 2^255 - 19). Honest keys and the draft vectors pass.
R2-03: schedule::expand takes one static label and one fixed-width field, so
its info is injective by signature. v1 bytes unchanged (golden vectors pass).
R2-04: generate, initiate, respond and seal say the RNG must be the OS RNG.
R2-05: Initiation is ZeroizeOnDrop; seal's buffer stays Zeroizing until the
plaintext in it is encrypted, so the MessageTooLong path wipes it.
QA's A-33 case for PublicKey::encapsulate moves to exchange::respond, and its
A-08 test pins the new expand signature to the v1 encoding.
A separate, unpublished crate with its own workspace (like fuzz/), because a
GlobalAlloc needs unsafe and arcanum keeps forbid(unsafe_code). dealloc scans
each freed block for a 32-byte canary. Controls prove it sees an unwiped Vec
and the reallocation case; checked by adding a reserve(1) after decryption in
open(), which it catches. Heap only: stack copies are out of its reach.
Builds a throwaway crate that depends on arcanum without features and runs
cargo check --offline on small programs: the safe API compiles (control), a
non-CryptoRng RNG is refused (A-33), and no _derand/from_seed entry point is
reachable (A-34). Each was checked by reintroducing the bug.
qa_r2_01_raw_shared_secret_is_not_reachable_without_hazmat FAILS on purpose:
PublicKey::encapsulate(..).1.as_bytes() hands a release consumer the raw
one-way X-Wing secret, the single-direction PSK that A-15 rules out.
Completes the partial QA cases and adds the not-done ones that need no new
dependency: compile-time checks that no secret type is Copy, Clone, PartialEq
or Display (A-28, A-31, hand-rolled assert_not_impl), ZeroizeOnDrop markers,
redacted Debug, no input bytes in errors (A-30), distinct secrets for all 1120
ciphertext flips (A-03), a spliced key (A-06), deterministic implicit rejection
(A-18), and the KDF-encoding and purpose-separation unit tests (A-08, A-09).
qa_r2_02_non_canonical_x25519_public_key_is_refused FAILS on purpose: a pk_X
with bit 255 set parses, and the exchange then silently derives mismatched PSKs.
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.