diff --git a/HANDOVER.md b/HANDOVER.md index 0416cdc..6840f37 100644 --- a/HANDOVER.md +++ b/HANDOVER.md @@ -2,6 +2,69 @@ Newest entry first. Where this file and the code disagree, the code wins and the next entry says so. +## 2026-11-25 — v0.2.0 built (builder), on `feature/signatures` (PR #2), not merged, not tagged + +**What it adds:** `arcanum::sign`, hybrid signatures ML-DSA-65 + Ed25519, exactly RFC 10073 +`id-MLDSA65-Ed25519-SHA512` (design: `docs/02_signatures.md`, which now has an "As built" section). +Public key 1984 B, signature 3373 B, private key 64 B (ML-DSA seed || Ed25519 seed). The ML-DSA half is +`ExpandedSigningKey::sign_randomized(M', ctx = Label, rng)`, hedged; the Ed25519 half is pure Ed25519 over +M', checked with `verify_strict`; one `InvalidSignature` whichever half fails. `AppContext` (only +`domi/arcanum/v2/sig/app/` + a 1–231-byte label), `bind_kem_key` / `verify_binding` for X-Wing keys under +`domi/arcanum/v2/sig/kem-key`. The bare RFC interface (`sign_composite_raw`, `verify_composite_raw`, any +ctx) is `hazmat` only and still hedged. Stricter than the RFC: a non-canonical or small-order Ed25519 key +is refused at parse. `ml-dsa =0.1.2` (alloc, rand_core, zeroize) and `ed25519-dalek =3.0.0` (zeroize), +default features off. v0.1.0's bytes are unchanged (`tests/golden_v1.rs` untouched, passing). + +**Vectors** (`tests/vectors/SOURCES.md`, sha256 of every original and subset): ACVP ML-DSA keyGen (whole) +and sigGen at `2972def2`, sigVer at `a7f283cd`; Wycheproof `ed25519_test` and `mldsa_65_sign_seed` (whole) +and `mldsa_65_verify` (subset) at `20b25694`; the composite-sigs `testvectors.json` at `f0627ab` (the +`id-MLDSA65-Ed25519-SHA512` entry); RFC 8032 §7.1. Subsets made by `tests/vectors/make_subsets.py`. + +**Counts, run by the builder** on `feature/signatures`, Windows 10, `cargo 1.99.0` stable MSVC, +`--target-dir D:/cargo-target/arcanum-v2` (intermediates in `D:/cargo-build/`, the machine's `build-dir`): + +| Run | Result | +|:--|:--| +| `cargo test` (debug) | **121 passed, 0 failed, 0 ignored** (82 from v0.1.0 + 39 new) | +| `cargo test --release` | **121 passed, 0 failed, 0 ignored** | +| `cargo clippy --all-targets --all-features -- -D warnings` | clean | +| `cargo fmt --check` | clean | +| `zeroize-probe` (`--test-threads=1`) | 1 passed (now also covers the signing key, `to_bytes`, signing and binding) | +| `cargo deny check` | advisories ok, bans ok, licenses ok, sources ok | +| `cargo audit` | 64 crates, 0 vulnerabilities, 0 warnings (advisory db of 2026-11-25, 1,568 advisories) | +| fuzz `signatures` (new) | **605 s, 38,609 executions, 0 crashes, 0 artifacts** (libFuzzer + ASan, nightly `1.102.0` 2026-11-24, MSVC 14.44 asan runtime; coverage 3,549; 63 exec/s; corpus and artifacts on D:), on `5a52854` + the target | + +New tests: `kat_mldsa65` 6, `kat_ed25519` 3, `sig_composite` 6, `sig_halves` 5, `sig_every_byte` 7, +`sig_malformed` 5, `sig_hygiene` 6, `feature_hygiene` +1. + +**Answers to the doc's open gap:** `verify_strict` accepts both RFC 10073 vectors (`s`, `sWithContext`), +and agrees with all 151 Wycheproof Ed25519 verdicts. + +**Mutation checks by the builder** (each reintroduced with `src/sign.rs` edited, seen to fail, reverted; +`git diff` clean after): +- M1, test 4: verify checks only the ML-DSA half (`if ml_ok`): fails `a_zeroed_or_missing_half_is_refused` + and `a_half_from_another_signature_is_refused`. +- M2, test 3/4: the ML-DSA half signs and verifies with an empty ctx instead of Label: fails + `rfc_signatures_verify`, `own_signatures_verify_under_an_independent_rebuild_of_m_prime`, + `ml_dsa_half_uses_the_label_as_its_context` (cargo stopped there; `sig_halves` not reached). +- M3, test 5: ctx left out of M' (its length kept): fails `flipping_any_byte_of_the_context_fails`. +- M4, test 5: `not_after` left out of the binding hash: fails `every_field_of_a_key_binding_matters` and + `a_key_binding_never_verifies_as_an_app_message_and_back` (the documented encoding no longer matches). +- M5, hygiene: `verify_composite_raw` ungated: fails `the_raw_interface_is_not_reachable_without_hazmat`. +- M6, hygiene: `#[derive(Clone)]` on `SigningKey`: fails `ml_dsa_internals_are_not_reachable`. +- M7, test 6: `is_weak()` dropped from the key check: fails `weak_and_non_canonical_ed25519_keys_are_refused`. + +**Not verified:** constant time (dudect, Day 7); anything on Linux; interop with a non-Rust RFC 10073 +implementation beyond the RFC's own vector (one key, two signatures); a byte-exact composite signing KAT +(the RFC's vectors are hedged; byte-exact checks exist per half); the ACVP and Wycheproof cases dropped by +the subsets; HashML-DSA (not used). The fuzz run is one 10-minute run at 63 exec/s (ASan and ML-DSA are +slow), far fewer executions than v0.1.0's target. The first test commit (`2a432f5`) failed by not compiling +(the module did not exist); it also had one test bug, fixed in `5a52854`. Not audited. + +**For consumers:** as for v0.1.0, and also ban a direct `ml-dsa` dependency in `deny.toml` (its +`sign_internal`, `sign_mu_deterministic` and empty-ctx `Signer` are public) and `ed25519-dalek/hazmat`; +never use a composite signature as an identifier (not SUF-CMA, RFC 10073 §9.2, pinned by `sig_halves`). + ## 2026-11-25 — v0.1.0 (owner session) **Who owns this:** the Via owner session. Mark's decisions go through the orchestrator session. diff --git a/README.md b/README.md index 4b7a936..5cb30d7 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,15 @@ Arcanum is the shared post-quantum crypto core of the Domi ecosystem. It is one crate that gives every Domi product a hybrid key exchange: ML-KEM-768 (FIPS 203) combined with X25519, so a shared secret stays safe as long as either of the two holds. +Since v0.2.0 it also signs: a hybrid ML-DSA-65 + Ed25519 signature, exactly RFC 10073 +`id-MLDSA65-Ed25519-SHA512`, which stays unforgeable while either half holds, and a helper that +binds an X-Wing public key to its owner. + Via Domi uses it first, to derive and rotate the WireGuard pre-shared key. Canalis, Custos sealing and Tabellarius are expected to adopt it later. -- No primitive is written here. ML-KEM, X25519, SHA-3, HKDF and ChaCha20-Poly1305 come from - vetted RustCrypto and dalek crates. +- No primitive is written here. ML-KEM, X25519, ML-DSA, Ed25519, SHA-2, SHA-3, HKDF and + ChaCha20-Poly1305 come from vetted RustCrypto and dalek crates. - No I/O, no network, no clock. Randomness is passed in by the caller. - No `unsafe` code. @@ -21,6 +25,13 @@ let session = init.finish(&ct_ri)?; let psk = session.wireguard_psk(arcanum::epoch_at(unix_seconds)); // one exchange per 120 s epoch ``` +```rust +let ctx = arcanum::sign::AppContext::new(b"plans")?; +let sig = signing_key.sign(plan_bytes, &ctx, &mut rng)?; // 3373 bytes +signing_key.verifying_key().verify(plan_bytes, &ctx, &sig)?; // 1984-byte public key +let binding = arcanum::sign::bind_kem_key(&signing_key, device_id, xwing_sk.public_key(), (from, until), &mut rng)?; +``` + ## Checks ``` @@ -28,6 +39,7 @@ cargo test # KATs, binding, epochs, malformed input, golden vect cargo deny check cargo audit cargo +nightly fuzz run --release untrusted_input -- -max_total_time=600 +cargo +nightly fuzz run --release signatures -- -max_total_time=600 ``` **Not audited.** Nothing here is called secure before an external audit. diff --git a/docs/02_signatures.md b/docs/02_signatures.md index 74f015a..b0dce21 100644 --- a/docs/02_signatures.md +++ b/docs/02_signatures.md @@ -101,7 +101,7 @@ pub mod sign { } ``` -`AppContext` is a newtype that can only be built with the `domi/arcanum/v2/sig/` prefix, so a caller can +`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, and checks both halves before answering, so timing does not @@ -134,6 +134,27 @@ RustCrypto's own ACVP copies predate the sigVer correction, so Arcanum runs the | 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)` and + `verify_composite_raw(vk, msg, ctx, sig)` take any `ctx` of 0 to 255 bytes but still sign through + `sign_randomized` with 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 are `hazmat` only. +- **A stricter Ed25519 key check.** `ed25519-dalek`'s `VerifyingKey::from_bytes` accepts 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 is `TooShort`, a longer one `TooLong`. +- **Key bindings** are hashed field by field (no allocation); the window is inclusive at both ends; + `verify_binding` checks, in this order, the window's shape and the id length + (`InvalidValidity`, `TooLong`), the signature (`InvalidSignature`), then `now` + (`OutsideValidity`), so `OutsideValidity` always means an authentic but expired binding. +- `ml-dsa` gets `alloc` (its large vectors are boxed), `rand_core` and `zeroize`, default features + off; `ed25519-dalek` gets only `zeroize` (not `fast`: no precomputed tables). + ## Gaps - **Not audited**, like v0.1.0; the Day 7 audit pack covers both versions. @@ -141,8 +162,15 @@ RustCrypto's own ACVP copies predate the sigVer correction, so Arcanum runs the - 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 `verify_strict` refuses any RFC 10073 vector is not known yet; test 3 will say. If it does, the - vector, the decision and the reason go here. +- ~~Whether `verify_strict` refuses any RFC 10073 vector~~: **it does not.** Test 3 (2026-11-25) verifies + both the RFC's `s` (empty ctx) and `sWithContext` with `verify_strict`, through Arcanum and through the + independent rebuild of M'. `verify_strict` also agrees with all 151 Wycheproof `ed25519_test.json` verdicts + (test 2: no disagreement to list). +- ACVP sigGen, sigVer and Wycheproof `mldsa_65_verify` run 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 rerunning `make_subsets.py`. +- Stack copies: building a `SigningKey` moves 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)