Commit Graph

21 Commits

Author SHA1 Message Date
mnovak b245e1054c docs: the expanded ML-DSA-65 key is about 64 kB, not 60 2026-11-25 13:33:53 +01:00
mnovak ddda8415eb test: fuzz target for the signature API (mandatory test 6)
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.
2026-11-25 13:33:53 +01:00
mnovak 5a52854ccc feat: hybrid signatures ML-DSA-65 + Ed25519, RFC 10073 id-MLDSA65-Ed25519-SHA512
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.
2026-11-25 13:12:22 +01:00
mnovak 2a432f5d86 test: the v0.2.0 signature tests, written before the code
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.
2026-11-25 12:48:39 +01:00
mnovak 5b9e3ee8fb test: v0.2.0 signature vectors (ACVP ML-DSA, Wycheproof, RFC 8032, RFC 10073)
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.
2026-11-25 12:40:04 +01:00
mnovak c7294612ae docs: v0.2.0 design, hybrid signatures ML-DSA-65 + Ed25519 per RFC 10073
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.
2026-11-25 11:10:31 +01:00
mnovak 2fae9ad3eb Merge feature/arcanum: Day 1, Arcanum (PR #1)
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.
v0.1.0
2026-11-25 09:37:59 +01:00
mnovak 9f8d1161ad docs: HANDOVER for v0.1.0, with the owner session's counts, mutation checks and fuzz run 2026-11-25 09:37:57 +01:00
mnovak 96086be4b3 docs: R2-01 to R2-05 decisions, canonical pk_X, and rules for Arcanum's consumers 2026-11-25 08:37:11 +01:00
mnovak 6780abc0c2 fix: QA second review R2-01 to R2-05
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.
2026-11-25 08:37:11 +01:00
mnovak f3e17f3d5c test(qa): A-29 allocator probe, secrets wiped before their heap memory is freed
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.
2026-11-25 08:16:44 +01:00
mnovak f31872d0d5 test(qa): compile-fail checks against a default-features consumer (A-33, A-34, R2-01)
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.
2026-11-25 08:16:44 +01:00
mnovak 3dfc75075f test(qa): second review, A-03/A-06/A-08/A-09/A-18/A-28/A-30/A-31 and R2-02 (non-canonical pk_X)
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.
2026-11-25 08:16:44 +01:00
mnovak 853f59ca60 fix: report an over-long plaintext as MessageTooLong, not DecryptionFailed 2026-11-25 07:48:55 +01:00
mnovak e0c6d53a99 docs: record D-QA-1, the mutual exchange (A-15), the hazmat gate (A-35) and the corrected ml-kem fact 2026-11-25 07:47:46 +01:00
mnovak 91b84459b0 test: frozen v1 golden vectors for PSKs and the sealed format (QA A-10, A-38) 2026-11-25 07:42:27 +01:00
mnovak 6233c8244e test: hygiene check sees arcanum's own features; A-15 binding goes through session_prk 2026-11-25 07:40:57 +01:00
mnovak 89b5329f06 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.
2026-11-25 07:38:55 +01:00
mnovak c7d050ed65 test: the six mandatory tests, pinned KAT vectors, fuzz target and cargo-deny config (written before the code) 2026-11-25 07:28:48 +01:00
mnovak ed9b8a3b17 docs: Day 1 analysis (X-Wing draft -11, key schedule, PSK rotation) and threat model 2026-11-25 07:23:10 +01:00
mnovak 9b4d2c40d3 chore: licence (CPAL-1.0), gitignore, CLAUDE.md and README 2026-11-25 07:15:55 +01:00