Day 1: Arcanum (X-Wing draft -11, mutual exchange, WireGuard PSK, sealed box) #1

Closed
mnovak wants to merge 0 commits from feature/arcanum into main
Owner

Day 1 — Arcanum

Hybrid post-quantum key exchange for the Domi ecosystem: X-Wing (ML-KEM-768 + X25519, draft-connolly-cfrg-xwing-kem-11), a mutual exchange, the WireGuard PSK per 120 s epoch, and a one-shot sealed box. #![no_std], #![forbid(unsafe_code)], no I/O, no clock, randomness as a parameter. Not audited.

Read first: docs/01_arcanum.md (why, what, how, risks, gaps, sources) and docs/THREAT_MODEL.md.

Build described here: branch feature/arcanum at HEAD (see the PR head sha), Windows 10, cargo 1.99.0 stable for tests/deny/audit, rustc 1.102.0-nightly (739adecd4 2026-11-24) for the fuzz build.

Decisions taken in this PR

  • D-QA-1: X-Wing is used unmodified, so the draft's three vectors pass byte for byte. Mark's "hash both public keys and both ciphertexts" is met in Arcanum's own HKDF layer, which hashes the full transcript (pk_I, pk_R, ct_IR, ct_RI, context) under domi/arcanum/v1/... labels.
  • QA A-15: the PSK comes from a mutual exchange: each peer encapsulates to the other, and the session needs both secrets. A single encapsulation would authenticate only the receiver.
  • Stricter than X-Wing: low-order X25519 values (public key or ciphertext) are refused with Error::NonContributory. No honest exchange or official vector is affected.
  • hazmat feature (off by default) gates every deterministic entry point. The tests enable it through a self-dev-dependency, and tests/feature_hygiene.rs asserts it is not in the normal feature graph (QA A-35), and proves that the check can see it when it is on.

Verification

Check Result
cargo test (debug) 67 passed, 0 failed, 0 ignored
cargo test --release 67 passed, 0 failed, 0 ignored
cargo clippy --all-targets -- -D warnings clean
cargo deny check (0.20.2) advisories ok, bans ok, licenses ok, sources ok
cargo audit (0.23.0, 1567 advisories) 0 vulnerabilities, 0 warnings, exit 0 (crate: 55 deps; fuzz crate: 53)
cargo fuzz 0.13.2, libFuzzer + ASan, Windows MSVC 661 s, 463,005 executions, ~700 exec/s, 0 crashes, 0 artifacts, coverage 1680 edges, peak RSS 424 MB (06:45:05Z–06:56:07Z)
Mutation check 10 bugs reintroduced one at a time; all 10 caught (list below)

Tests per file: src/binding_tests.rs 9 · tests/binding.rs 5 · tests/exchange.rs 11 · tests/feature_hygiene.rs 3 · tests/golden_v1.rs 2 · tests/kat_mlkem768.rs 6 · tests/kat_x25519.rs 5 · tests/kat_xwing.rs 2 · tests/malformed.rs 15 · tests/no_unsafe.rs 2 · tests/psk_epochs.rs 7.

Known-answer vectors (provenance and sha256 in tests/vectors/SOURCES.md): NIST ACVP-Server ML-KEM keyGen and encapDecap internalProjection.json at commit 975de31e (768 groups: 25 keyGen, 25 encaps, 10 decaps incl. implicit rejection, 10 ek checks, 10 dk checks); X-Wing spec/test-vectors.json from the draft authors' repo at 984c2f7a (= draft -11 Appendix C, 3 vectors); RFC 7748 §5.2 and §6.1 for X25519. Plus a differential test against RustCrypto x-wing 0.1.1 (64 random rounds incl. garbage ciphertexts).

Mutations reintroduced (each made the named test fail, then was reverted): swap ss_M/ss_X in the combiner; label first; drop ct_RI from the transcript; drop the contributory check; PSK ignores the epoch; session uses only one direction; seal ignores the AAD; hazmat in default; epoch truncated to u32; version byte not checked.

Mandatory tests → files

  1. KATs: tests/kat_mlkem768.rs, tests/kat_x25519.rs, tests/kat_xwing.rs
  2. Agreement + every byte changes it: tests/exchange.rs (every byte of both public keys, both ciphertexts, both seeds, both eseeds, the context)
  3. Zeroed component changes the output: src/binding_tests.rs, tests/binding.rs
  4. Epochs: tests/psk_epochs.rs
  5. Malformed input, typed errors, fuzz: tests/malformed.rs, fuzz/fuzz_targets/untrusted_input.rs
  6. deny/audit/no unsafe: deny.toml, tests/no_unsafe.rs, #![forbid(unsafe_code)]

QA attack plan (qa/01_arcanum_attacks.md) mapping

Done: A-01, A-02, A-04, A-05, A-07, A-10, A-11, A-14, A-15, A-16, A-17, A-19 (through ml-kem directly), A-20, A-21, A-22, A-24, A-25, A-26, A-35, A-36, A-37, A-38, A-40, A-43.
Partial: A-03 (every byte flips, no cross-flip collision check), A-06 (wrong key, no spliced-key case), A-18 (rejection covered by ACVP and the differential test; determinism not asserted separately), A-23 (errors are DecryptionFailed, UnsupportedVersion for byte 0, or NonContributory), A-27 (documented in seal's docs, no doctest), A-30 (by type: no variant carries bytes), A-34 (feature gate, no cargo public-api snapshot), A-41/A-42 (random loops and a unit-level differential, no proptest, no differential fuzzing).
Moved to Day 3 by design (Arcanum is stateless): A-12 (no epoch increment exists here), A-13 (replay window). Recorded in the doc.
Not done: A-08 (no generic multi-part KDF exists; injectivity argued from fixed widths + length prefix), A-09, A-28, A-31, A-33 (no static_assertions/trybuild dev-deps added), A-29 (allocator probe), A-32 (dudect), A-39 (no Version type).

QA fact F10 is wrong for 0.3.4: encapsulate_deterministic is public with or without ml-kem/hazmat; the feature only un-hides docs. Arcanum's own hazmat is the real gate.

Critical self-review

  1. Our own X-Wing glue — major. Arcanum composes X-Wing from primitives instead of calling the x-wing crate. That is ~20 lines a reviewer must check, against the draft. Mitigated by the three official vectors, the differential test and two mutation checks, but it is still code nobody else has reviewed. The x-wing crate is itself 0.1 and unaudited, so delegating would not have bought an audit either.
  2. Not an AKE with forward secrecy — major. The mutual exchange over static key pairs authenticates key holders, but whoever later steals both secret keys can recompute every recorded PSK. Rosenpass adds an ephemeral KEM for this. Day 3 must add an ephemeral key pair per exchange or rotate keys. There is also no key-confirmation message: a tampered ciphertext produces mismatched PSKs, and the only signal is that WireGuard's handshake fails.
  3. Authentication of public keys is out of scope — major, by design. Everything rests on each side having the real hybrid public key of the other. If Tessera's signatures over those keys are classical, a quantum attacker who can forge them can substitute keys. ML-DSA comes later.
  4. The hazmat gate relies on a Cargo idiom — minor. A self-dev-dependency enables the feature for tests only. That works today and is asserted by feature_hygiene.rs, but any consumer that writes arcanum = { features = ["hazmat"] } gets the deterministic API. via-core and via must run the same cargo tree check in their CI.
  5. Initiation<'a> borrows the secret key — minor, API. Holding it across a network round trip in async Day 3 code may be awkward and force an owned variant. Better found now than after v0.1.0 is tagged.
  6. Panic paths remain — minor. Three expects on conversions that cannot fail (HKDF from a 32-byte PRK, expand ≤ 32 bytes, a 32-byte AEAD key). The fuzzer cannot reach them; a reviewer still has to agree they are infallible.
  7. Zeroisation is best effort — minor. StaticSecret::from(*bytes), Seed and B32 values are copied on the stack; HKDF/SHA-3 states are wiped only as far as those crates' zeroize features go. The allocator probe (A-29) was not built, so "no secret is freed unwiped" is argued, not measured. The sealed-box path allocates once at final size to avoid the reallocation case.
  8. Error oracle on sealed boxes — nit. open can return NonContributory instead of DecryptionFailed when a tampering lands a low-order ct_X. That reveals only a property of public bytes.
  9. No CI — major for process. Every result above was run by hand on this PC. There is no Gitea Actions workflow yet, so nothing stops a later commit from breaking the KATs or the feature-graph check.
  10. Fuzzing ran on Windows MSVC with ASan (the MSVC clang_rt.asan runtime on PATH), not on Linux, because WSL would not start (ERROR_NO_SYSTEM_RESOURCES). Coverage plateaued early (about 1680 edges); the target spends most of its time in ML-KEM, so the executions per second are low. The fuzzed binary was built from the tree at e0c6d53; the one later commit (853f59c) only renames the error on the over-2^38-byte seal path; a further 91 s run on 853f59c (61,992 executions) was also clean.
  11. Licence — note for Mark. LICENSE is CustosPublic's, byte for byte, with only Exhibit A's Original Code changed to "Arcanum". Exhibit B's phrase is CustosPublic's "Built on Domi", not the roadmap's "Part of the Domi ecosystem". There is no public fabrica-core repository on Gitea to compare with (only the private mnovak/Fabrica).
  12. Repository creation — note. The Gitea token has no write:user scope, so POST /user/repos was refused (403). The repository was created by push-to-create on the first push and then made public with PATCH /repos/mnovak/arcanum (write:repository). Anonymous access is verified (HTTP 200).

Not verified

  • FIPS 203 was not read from the NIST PDF; ML-KEM facts rest on ACVP vectors, the draft and the ml-kem source.
  • RFC 7748's 1,000,000-iteration X25519 vector was not run.
  • No constant-time measurement (dudect).
  • No interop test with a non-Rust X-Wing implementation.

Do not merge or tag from this PR: the QA agent reviews it first; the orchestrator merges and tags v0.1.0.

## Day 1 — Arcanum Hybrid post-quantum key exchange for the Domi ecosystem: X-Wing (ML-KEM-768 + X25519, draft-connolly-cfrg-xwing-kem-11), a **mutual** exchange, the WireGuard PSK per 120 s epoch, and a one-shot sealed box. `#![no_std]`, `#![forbid(unsafe_code)]`, no I/O, no clock, randomness as a parameter. **Not audited.** Read first: `docs/01_arcanum.md` (why, what, how, risks, gaps, sources) and `docs/THREAT_MODEL.md`. **Build described here:** branch `feature/arcanum` at HEAD (see the PR head sha), Windows 10, `cargo 1.99.0` stable for tests/deny/audit, `rustc 1.102.0-nightly (739adecd4 2026-11-24)` for the fuzz build. ### Decisions taken in this PR - **D-QA-1:** X-Wing is used **unmodified**, so the draft's three vectors pass byte for byte. Mark's "hash both public keys and both ciphertexts" is met in Arcanum's own HKDF layer, which hashes the full transcript (`pk_I`, `pk_R`, `ct_IR`, `ct_RI`, context) under `domi/arcanum/v1/...` labels. - **QA A-15:** the PSK comes from a **mutual** exchange: each peer encapsulates to the other, and the session needs both secrets. A single encapsulation would authenticate only the receiver. - **Stricter than X-Wing:** low-order X25519 values (public key or ciphertext) are refused with `Error::NonContributory`. No honest exchange or official vector is affected. - **`hazmat` feature** (off by default) gates every deterministic entry point. The tests enable it through a self-dev-dependency, and `tests/feature_hygiene.rs` asserts it is not in the normal feature graph (QA A-35), and proves that the check can see it when it is on. ### Verification | Check | Result | |:--|:--| | `cargo test` (debug) | **67 passed, 0 failed, 0 ignored** | | `cargo test --release` | 67 passed, 0 failed, 0 ignored | | `cargo clippy --all-targets -- -D warnings` | clean | | `cargo deny check` (0.20.2) | `advisories ok, bans ok, licenses ok, sources ok` | | `cargo audit` (0.23.0, 1567 advisories) | 0 vulnerabilities, 0 warnings, exit 0 (crate: 55 deps; fuzz crate: 53) | | `cargo fuzz` 0.13.2, libFuzzer + ASan, Windows MSVC | **661 s, 463,005 executions, ~700 exec/s, 0 crashes, 0 artifacts**, coverage 1680 edges, peak RSS 424 MB (06:45:05Z–06:56:07Z) | | Mutation check | 10 bugs reintroduced one at a time; **all 10 caught** (list below) | Tests per file: `src/binding_tests.rs` 9 · `tests/binding.rs` 5 · `tests/exchange.rs` 11 · `tests/feature_hygiene.rs` 3 · `tests/golden_v1.rs` 2 · `tests/kat_mlkem768.rs` 6 · `tests/kat_x25519.rs` 5 · `tests/kat_xwing.rs` 2 · `tests/malformed.rs` 15 · `tests/no_unsafe.rs` 2 · `tests/psk_epochs.rs` 7. Known-answer vectors (provenance and sha256 in `tests/vectors/SOURCES.md`): NIST ACVP-Server ML-KEM keyGen and encapDecap `internalProjection.json` at commit `975de31e` (768 groups: 25 keyGen, 25 encaps, 10 decaps incl. implicit rejection, 10 ek checks, 10 dk checks); X-Wing `spec/test-vectors.json` from the draft authors' repo at `984c2f7a` (= draft -11 Appendix C, 3 vectors); RFC 7748 §5.2 and §6.1 for X25519. Plus a differential test against RustCrypto `x-wing` 0.1.1 (64 random rounds incl. garbage ciphertexts). Mutations reintroduced (each made the named test fail, then was reverted): swap `ss_M`/`ss_X` in the combiner; label first; drop `ct_RI` from the transcript; drop the contributory check; PSK ignores the epoch; session uses only one direction; seal ignores the AAD; `hazmat` in `default`; epoch truncated to `u32`; version byte not checked. ### Mandatory tests → files 1. KATs: `tests/kat_mlkem768.rs`, `tests/kat_x25519.rs`, `tests/kat_xwing.rs` 2. Agreement + every byte changes it: `tests/exchange.rs` (every byte of both public keys, both ciphertexts, both seeds, both eseeds, the context) 3. Zeroed component changes the output: `src/binding_tests.rs`, `tests/binding.rs` 4. Epochs: `tests/psk_epochs.rs` 5. Malformed input, typed errors, fuzz: `tests/malformed.rs`, `fuzz/fuzz_targets/untrusted_input.rs` 6. deny/audit/no unsafe: `deny.toml`, `tests/no_unsafe.rs`, `#![forbid(unsafe_code)]` ### QA attack plan (`qa/01_arcanum_attacks.md`) mapping Done: A-01, A-02, A-04, A-05, A-07, A-10, A-11, A-14, A-15, A-16, A-17, A-19 (through `ml-kem` directly), A-20, A-21, A-22, A-24, A-25, A-26, A-35, A-36, A-37, A-38, A-40, A-43. Partial: A-03 (every byte flips, no cross-flip collision check), A-06 (wrong key, no spliced-key case), A-18 (rejection covered by ACVP and the differential test; determinism not asserted separately), A-23 (errors are `DecryptionFailed`, `UnsupportedVersion` for byte 0, or `NonContributory`), A-27 (documented in `seal`'s docs, no doctest), A-30 (by type: no variant carries bytes), A-34 (feature gate, no `cargo public-api` snapshot), A-41/A-42 (random loops and a unit-level differential, no proptest, no differential fuzzing). Moved to Day 3 by design (Arcanum is stateless): A-12 (no epoch increment exists here), A-13 (replay window). Recorded in the doc. Not done: A-08 (no generic multi-part KDF exists; injectivity argued from fixed widths + length prefix), A-09, A-28, A-31, A-33 (no `static_assertions`/`trybuild` dev-deps added), A-29 (allocator probe), A-32 (dudect), A-39 (no `Version` type). QA fact F10 is **wrong for 0.3.4**: `encapsulate_deterministic` is public with or without `ml-kem/hazmat`; the feature only un-hides docs. Arcanum's own `hazmat` is the real gate. ## Critical self-review 1. **Our own X-Wing glue — major.** Arcanum composes X-Wing from primitives instead of calling the `x-wing` crate. That is ~20 lines a reviewer must check, against the draft. Mitigated by the three official vectors, the differential test and two mutation checks, but it is still code nobody else has reviewed. The `x-wing` crate is itself 0.1 and unaudited, so delegating would not have bought an audit either. 2. **Not an AKE with forward secrecy — major.** The mutual exchange over static key pairs authenticates key holders, but whoever later steals both secret keys can recompute every recorded PSK. Rosenpass adds an ephemeral KEM for this. Day 3 must add an ephemeral key pair per exchange or rotate keys. There is also no key-confirmation message: a tampered ciphertext produces mismatched PSKs, and the only signal is that WireGuard's handshake fails. 3. **Authentication of public keys is out of scope — major, by design.** Everything rests on each side having the real hybrid public key of the other. If Tessera's signatures over those keys are classical, a quantum attacker who can forge them can substitute keys. ML-DSA comes later. 4. **The `hazmat` gate relies on a Cargo idiom — minor.** A self-dev-dependency enables the feature for tests only. That works today and is asserted by `feature_hygiene.rs`, but any consumer that writes `arcanum = { features = ["hazmat"] }` gets the deterministic API. via-core and via must run the same `cargo tree` check in their CI. 5. **`Initiation<'a>` borrows the secret key — minor, API.** Holding it across a network round trip in async Day 3 code may be awkward and force an owned variant. Better found now than after v0.1.0 is tagged. 6. **Panic paths remain — minor.** Three `expect`s on conversions that cannot fail (HKDF from a 32-byte PRK, expand ≤ 32 bytes, a 32-byte AEAD key). The fuzzer cannot reach them; a reviewer still has to agree they are infallible. 7. **Zeroisation is best effort — minor.** `StaticSecret::from(*bytes)`, `Seed` and `B32` values are copied on the stack; HKDF/SHA-3 states are wiped only as far as those crates' `zeroize` features go. The allocator probe (A-29) was not built, so "no secret is freed unwiped" is argued, not measured. The sealed-box path allocates once at final size to avoid the reallocation case. 8. **Error oracle on sealed boxes — nit.** `open` can return `NonContributory` instead of `DecryptionFailed` when a tampering lands a low-order `ct_X`. That reveals only a property of public bytes. 9. **No CI — major for process.** Every result above was run by hand on this PC. There is no Gitea Actions workflow yet, so nothing stops a later commit from breaking the KATs or the feature-graph check. 10. **Fuzzing ran on Windows MSVC with ASan** (the MSVC `clang_rt.asan` runtime on `PATH`), not on Linux, because WSL would not start (`ERROR_NO_SYSTEM_RESOURCES`). Coverage plateaued early (about 1680 edges); the target spends most of its time in ML-KEM, so the executions per second are low. The fuzzed binary was built from the tree at `e0c6d53`; the one later commit (`853f59c`) only renames the error on the over-2^38-byte seal path; a further 91 s run on `853f59c` (61,992 executions) was also clean. 11. **Licence — note for Mark.** LICENSE is CustosPublic's, byte for byte, with only Exhibit A's Original Code changed to "Arcanum". Exhibit B's phrase is CustosPublic's **"Built on Domi"**, not the roadmap's "Part of the Domi ecosystem". There is no public `fabrica-core` repository on Gitea to compare with (only the private `mnovak/Fabrica`). 12. **Repository creation — note.** The Gitea token has no `write:user` scope, so `POST /user/repos` was refused (403). The repository was created by push-to-create on the first push and then made public with `PATCH /repos/mnovak/arcanum` (`write:repository`). Anonymous access is verified (HTTP 200). ### Not verified - FIPS 203 was not read from the NIST PDF; ML-KEM facts rest on ACVP vectors, the draft and the `ml-kem` source. - RFC 7748's 1,000,000-iteration X25519 vector was not run. - No constant-time measurement (dudect). - No interop test with a non-Rust X-Wing implementation. Do not merge or tag from this PR: the QA agent reviews it first; the orchestrator merges and tags `v0.1.0`.
mnovak added 7 commits 2026-11-25 07:58:12 +01:00
mnovak added 3 commits 2026-11-25 08:16:55 +01:00
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.
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.
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.
Author
Owner

Finding R2-01 — major: the raw one-way X-Wing secret is public in a release build

What. PublicKey::encapsulate (src/xwing.rs:106), SecretKey::decapsulate (:249) and SharedSecret::as_bytes (:61) are public without hazmat. This compiles against Arcanum with default features:

let (_ct, ss) = peer.public_key().encapsulate(&mut rng).unwrap();
let one_way_psk: [u8; 32] = *ss.as_bytes();

Why it matters. That is exactly the single-direction PSK that QA A-15 and the crate's own exchange docs (src/exchange.rs:13-17) rule out: it authenticates only the receiver, so after a quantum break of WireGuard's static keys an attacker impersonating the initiator chooses the responder's PSK. It also skips the transcript, the context and the domi/arcanum/v1 labels. "Prefer exchange" in a doc comment will not stop Day 3 code from taking the one-call path, and tagging v0.1.0 makes this API a semver commitment.

Evidence. tests/qa_consumer_api.rs::qa_r2_01_raw_shared_secret_is_not_reachable_without_hazmat (commit f31872d) builds a throwaway consumer crate without features and cargo checks that program: it compiles, so the test fails. With a simulated fix (gate as_bytes behind hazmat, keep a pub(crate) accessor for seal/schedule) the test passes, and so do the control, A-33 and A-34. I did not run the full suite with the simulated fix.

Fix options. (a) SharedSecret::as_bytes only under hazmat (the KATs enable it); (b) also make encapsulate/decapsulate hazmat-only; (c) if X-Wing interop is a real Day 1 need, a separate, loudly named feature (raw-xwing) covered by the feature-graph test. If you keep the API, record the decision in docs/01_arcanum.md and change the test in this PR with the reason.

**Finding R2-01 — major: the raw one-way X-Wing secret is public in a release build** **What.** `PublicKey::encapsulate` (`src/xwing.rs:106`), `SecretKey::decapsulate` (`:249`) and `SharedSecret::as_bytes` (`:61`) are public without `hazmat`. This compiles against Arcanum with **default features**: ```rust let (_ct, ss) = peer.public_key().encapsulate(&mut rng).unwrap(); let one_way_psk: [u8; 32] = *ss.as_bytes(); ``` **Why it matters.** That is exactly the single-direction PSK that QA A-15 and the crate's own `exchange` docs (`src/exchange.rs:13-17`) rule out: it authenticates only the receiver, so after a quantum break of WireGuard's static keys an attacker impersonating the initiator chooses the responder's PSK. It also skips the transcript, the context and the `domi/arcanum/v1` labels. "Prefer `exchange`" in a doc comment will not stop Day 3 code from taking the one-call path, and tagging v0.1.0 makes this API a semver commitment. **Evidence.** `tests/qa_consumer_api.rs::qa_r2_01_raw_shared_secret_is_not_reachable_without_hazmat` (commit `f31872d`) builds a throwaway consumer crate without features and `cargo check`s that program: it compiles, so the test **fails**. With a simulated fix (gate `as_bytes` behind `hazmat`, keep a `pub(crate)` accessor for `seal`/`schedule`) the test passes, and so do the control, A-33 and A-34. I did not run the full suite with the simulated fix. **Fix options.** (a) `SharedSecret::as_bytes` only under `hazmat` (the KATs enable it); (b) also make `encapsulate`/`decapsulate` hazmat-only; (c) if X-Wing interop is a real Day 1 need, a separate, loudly named feature (`raw-xwing`) covered by the feature-graph test. If you keep the API, record the decision in `docs/01_arcanum.md` and change the test in this PR with the reason.
Author
Owner

Finding R2-02 — minor: PublicKey::from_bytes accepts a non-canonical X25519 half

What. src/xwing.rs:92-93 takes the last 32 bytes as pk_X with no canonicality check. X25519 ignores bit 255 (RFC 7748 §5), so pk_X and pk_X with bit 255 set are the same key to the DH, but different bytes to the X-Wing combiner and to Arcanum's transcript. One secret key therefore has more than one accepted public encoding.

Why it matters. An initiator handed the variant (a corrupted directory entry, a sloppy re-encoding between Tessera and the engine) "succeeds" and silently derives a PSK the real owner can never match; the only symptom is a WireGuard handshake that never completes. The two encodings also compare unequal (PartialEq is by bytes), which matters if Via keys a peer table by public key. DoS and identity confusion, not a key leak.

Evidence. tests/qa_review.rs::qa_r2_02_non_canonical_x25519_public_key_is_refused (commit 3dfc750) fails. Before failing it asserts the consequence: the exchange completes, the two PSKs differ, and the two PublicKeys compare unequal.

Fix. Refuse pk_X[31] & 0x80 != 0 (and pk_X >= 2^255 - 19) in from_bytes. Stricter than the draft, in the same spirit as the low-order check; honest keys are canonical, so no vector changes.

**Finding R2-02 — minor: `PublicKey::from_bytes` accepts a non-canonical X25519 half** **What.** `src/xwing.rs:92-93` takes the last 32 bytes as `pk_X` with no canonicality check. X25519 ignores bit 255 (RFC 7748 §5), so `pk_X` and `pk_X` with bit 255 set are the same key to the DH, but different bytes to the X-Wing combiner and to Arcanum's transcript. One secret key therefore has more than one accepted public encoding. **Why it matters.** An initiator handed the variant (a corrupted directory entry, a sloppy re-encoding between Tessera and the engine) "succeeds" and silently derives a PSK the real owner can never match; the only symptom is a WireGuard handshake that never completes. The two encodings also compare unequal (`PartialEq` is by bytes), which matters if Via keys a peer table by public key. DoS and identity confusion, not a key leak. **Evidence.** `tests/qa_review.rs::qa_r2_02_non_canonical_x25519_public_key_is_refused` (commit `3dfc750`) **fails**. Before failing it asserts the consequence: the exchange completes, the two PSKs differ, and the two `PublicKey`s compare unequal. **Fix.** Refuse `pk_X[31] & 0x80 != 0` (and `pk_X >= 2^255 - 19`) in `from_bytes`. Stricter than the draft, in the same spirit as the low-order check; honest keys are canonical, so no vector changes.
Author
Owner

Finding R2-03 — minor (latent): schedule::expand concatenates info parts raw

What. expand(prk, info: &[&[u8]]) (src/schedule.rs:305-310) calls expand_multi_info, which concatenates the parts with no length prefix: expand(prk, ["ab","c"]) == expand(prk, ["a","bc"]). Today it is injective only because every call site passes a fixed label plus fixed-width fields. docs/01_arcanum.md says "the encoding is injective (QA A-08)", which is true of the call sites, not of the helper.

Why it matters. The signature invites the next caller (Day 3: a peer id, a protocol name) to pass a variable-width part, and then two different inputs give the same key with no test failing.

Evidence. src/qa_review_tests.rs::a08_kdf_info_encodings_in_use_are_injective (commit 3dfc750) pins both halves: the helper is raw concatenation (asserted), and the encodings in use are injective (one fixed width per purpose, none a prefix of another, the context length-prefixed). It passes; it fails if two purposes share a label (checked by setting LABEL_SEAL_NONCE to the seal-key label).

Fix. Narrow the signature to expand(prk, label: &'static [u8], fields: &[u8; K]), or add a length-prefixed v2 helper. Do not change v1's bytes: the golden vectors would (correctly) fail.

**Finding R2-03 — minor (latent): `schedule::expand` concatenates `info` parts raw** **What.** `expand(prk, info: &[&[u8]])` (`src/schedule.rs:305-310`) calls `expand_multi_info`, which concatenates the parts with no length prefix: `expand(prk, ["ab","c"]) == expand(prk, ["a","bc"])`. Today it is injective only because every call site passes a fixed label plus fixed-width fields. `docs/01_arcanum.md` says "the encoding is injective (QA A-08)", which is true of the call sites, not of the helper. **Why it matters.** The signature invites the next caller (Day 3: a peer id, a protocol name) to pass a variable-width part, and then two different inputs give the same key with no test failing. **Evidence.** `src/qa_review_tests.rs::a08_kdf_info_encodings_in_use_are_injective` (commit `3dfc750`) pins both halves: the helper is raw concatenation (asserted), and the encodings in use are injective (one fixed width per purpose, none a prefix of another, the context length-prefixed). It passes; it fails if two purposes share a label (checked by setting `LABEL_SEAL_NONCE` to the seal-key label). **Fix.** Narrow the signature to `expand(prk, label: &'static [u8], fields: &[u8; K])`, or add a length-prefixed v2 helper. Do not change v1's bytes: the golden vectors would (correctly) fail.
Author
Owner

Finding R2-04 — minor (docs): CryptoRng is a marker, not a promise of freshness

What. rand_core 0.10's CryptoRng is a marker trait. ChaCha20Rng::from_seed([1; 32]) (what the tests use) satisfies it. A consumer that seeds a CSPRNG from a constant or a config value makes SecretKey::generate, exchange::initiate, exchange::respond and seal::seal fully deterministic in a release build: reused ML-KEM m, reused X25519 ephemeral, reused seal key and nonce.

Why it matters. The hazmat gate closes the named deterministic API (A-34, now compile-fail tested), but the type system cannot close this route, so it has to be stated where the randomness enters. This is also the only way Arcanum's release API reaches ml-kem's encapsulate_deterministic (which is indeed public in 0.3.4 without hazmat, encapsulation_key.rs:43-45) with predictable input.

Evidence. A-33 (tests/qa_consumer_api.rs::a33_a_non_crypto_rng_does_not_compile) proves a plain Rng is refused; nothing can refuse a fixed-seed CryptoRng.

Fix. On those four functions: "rng must be the operating system's RNG (getrandom/OsRng) or a CSPRNG seeded from it; never a fixed or derived seed." via/via-core CI can grep for from_seed( outside tests/, and ban a direct ml-kem dependency in deny.toml.

**Finding R2-04 — minor (docs): `CryptoRng` is a marker, not a promise of freshness** **What.** `rand_core` 0.10's `CryptoRng` is a marker trait. `ChaCha20Rng::from_seed([1; 32])` (what the tests use) satisfies it. A consumer that seeds a CSPRNG from a constant or a config value makes `SecretKey::generate`, `exchange::initiate`, `exchange::respond` and `seal::seal` fully deterministic **in a release build**: reused ML-KEM `m`, reused X25519 ephemeral, reused seal key and nonce. **Why it matters.** The `hazmat` gate closes the named deterministic API (A-34, now compile-fail tested), but the type system cannot close this route, so it has to be stated where the randomness enters. This is also the only way Arcanum's release API reaches `ml-kem`'s `encapsulate_deterministic` (which is indeed public in 0.3.4 without `hazmat`, `encapsulation_key.rs:43-45`) with predictable input. **Evidence.** A-33 (`tests/qa_consumer_api.rs::a33_a_non_crypto_rng_does_not_compile`) proves a plain `Rng` is refused; nothing can refuse a fixed-seed `CryptoRng`. **Fix.** On those four functions: "`rng` must be the operating system's RNG (`getrandom`/`OsRng`) or a CSPRNG seeded from it; never a fixed or derived seed." via/via-core CI can grep for `from_seed(` outside `tests/`, and ban a direct `ml-kem` dependency in `deny.toml`.
Author
Owner

Finding R2-05 — nit: two zeroisation details

  1. exchange::Initiation wipes its fields (SharedSecret, Zeroizing<Vec<u8>>) but has no impl ZeroizeOnDrop, while docs/01_arcanum.md lists it among the ZeroizeOnDrop types. Add the marker, then add it to tests/qa_review.rs::a28_secret_types_are_zeroize_on_drop.
  2. seal_inner (src/seal.rs:84-91) copies the plaintext into out; if encrypt_inout_detached fails (MessageTooLong) the function returns and out is freed unwiped. Reachable only above 2^38 bytes, so never in practice. Wrap out in Zeroizing until success, or list it with the residuals.

For the record, the rest checked clean: SecretKey (ml-kem DecapsulationKey has a zeroising Drop under zeroize, decapsulation_key.rs:158-173; dalek StaticSecret too, x25519.rs:271-280), SharedSecret, Session, WireGuardPsk; none is Copy/Clone/PartialEq/Display (now compile-time asserted); every Debug redacts. The new allocator probe (zeroize-probe/, commit f3e17f3, QA A-29) finds no secret heap block freed unwiped across SecretKey, to_seed, seal, open (success and failure), a 70 kB box and a full exchange, and it does catch a reserve(1) added after decryption in open.

**Finding R2-05 — nit: two zeroisation details** 1. `exchange::Initiation` wipes its fields (`SharedSecret`, `Zeroizing<Vec<u8>>`) but has no `impl ZeroizeOnDrop`, while `docs/01_arcanum.md` lists it among the `ZeroizeOnDrop` types. Add the marker, then add it to `tests/qa_review.rs::a28_secret_types_are_zeroize_on_drop`. 2. `seal_inner` (`src/seal.rs:84-91`) copies the plaintext into `out`; if `encrypt_inout_detached` fails (`MessageTooLong`) the function returns and `out` is freed unwiped. Reachable only above 2^38 bytes, so never in practice. Wrap `out` in `Zeroizing` until success, or list it with the residuals. For the record, the rest checked clean: `SecretKey` (ml-kem `DecapsulationKey` has a zeroising `Drop` under `zeroize`, `decapsulation_key.rs:158-173`; dalek `StaticSecret` too, `x25519.rs:271-280`), `SharedSecret`, `Session`, `WireGuardPsk`; none is `Copy`/`Clone`/`PartialEq`/`Display` (now compile-time asserted); every `Debug` redacts. The new allocator probe (`zeroize-probe/`, commit `f3e17f3`, QA A-29) finds no secret heap block freed unwiped across `SecretKey`, `to_seed`, `seal`, `open` (success and failure), a 70 kB box and a full exchange, and it does catch a `reserve(1)` added after decryption in `open`.
Author
Owner

Second QA / security review of PR #1 — summary (reviewed head 853f59c)

No blocker found. One major (R2-01), three minor (R2-02, R2-03, R2-04), one nit (R2-05), each in its own comment above. Full write-up: F:\Akce\Via\qa\review-arcanum-pr1.md.

QA commits pushed to feature/arcanum (tests only, no library change): 3dfc750, f31872d, f3e17f3. Head is now f3e17f3. Two tests fail on purpose until R2-01 and R2-02 are fixed or explicitly decided in docs/01_arcanum.md: qa_r2_01_raw_shared_secret_is_not_reachable_without_hazmat and qa_r2_02_non_canonical_x25519_public_key_is_refused.

Check Before (853f59c) After (f3e17f3)
cargo test (debug) 67 passed, 0 failed, 0 ignored 79 passed, 2 failed (by design), 0 ignored
cargo test --release 67 passed, 0 failed, 0 ignored 79 passed, 2 failed (by design), 0 ignored
cargo clippy --all-targets --all-features -D warnings clean clean (probe crate too)
cargo deny check 0.20.2 advisories, bans, licenses, sources ok no dependency added
cargo audit 0.23.0 (1567 advisories) 0 vulnerabilities, 0 warnings no dependency added
zeroize-probe (A-29) — 1 passed

Fresh fuzz runs (untrusted_input, cargo-fuzz 0.13.2, libFuzzer + ASan, Windows MSVC, nightly 1.102.0 739adecd4), library code = 853f59c: run 1 721 s, 186,708 executions; run 2 631 s, 162,824 executions; total 1,352 s, 349,532 executions, ~258 exec/s, coverage 1750 edges, 0 crashes, 0 artifacts.

Builder's claims. Confirmed: 67 tests debug and release; deny/audit clean; X-Wing -11 unmodified (checked against the draft text: combiner order and label, SHAKE256 split, eseed split, decaps pk_X); full transcript bound in the HKDF layer; mutual exchange (also KCI-resistant); hazmat gate (now also compile-fail tested from a default-features consumer); ml-kem 0.3.4 encapsulate_deterministic is public without hazmat (encapsulation_key.rs:43-45), and Arcanum's release API reaches it only through encapsulate_inner, always fed by the RNG parameter (R2-04 is the remaining route). Mutations: spot-checked 2 of 10, both caught; note that dropping ct_RI from the transcript is caught by binding_tests and golden_v1, not by tests/exchange.rs.

QA cases newly done: A-03, A-06, A-18 (completed); A-08, A-09, A-28, A-29, A-30, A-31, A-33, A-34 (new). Not done: A-32 (dudect: a shared Windows desktop with ~100 ns timer resolution cannot give an honest t-statistic, and it could never gate; put it in the Day 7 audit pack on a quiet Linux box); A-39 (no Version type and no negotiation exist yet, so nothing can be downgraded; belongs with Day 3's proto).

Checked clean: domain-separation labels (no collision across hash prefix, salt and info positions), zeroize on every secret type including dependency Drop impls, no Copy/Clone/PartialEq/Display on secrets, redacted Debug, no panic or input bytes in errors on hostile input, no epoch overflow possible.

Not merged, not tagged.

**Second QA / security review of PR #1 — summary (reviewed head `853f59c`)** **No blocker found.** One **major** (R2-01), three **minor** (R2-02, R2-03, R2-04), one **nit** (R2-05), each in its own comment above. Full write-up: `F:\Akce\Via\qa\review-arcanum-pr1.md`. **QA commits pushed to `feature/arcanum`** (tests only, no library change): `3dfc750`, `f31872d`, `f3e17f3`. Head is now `f3e17f3`. **Two tests fail on purpose** until R2-01 and R2-02 are fixed or explicitly decided in `docs/01_arcanum.md`: `qa_r2_01_raw_shared_secret_is_not_reachable_without_hazmat` and `qa_r2_02_non_canonical_x25519_public_key_is_refused`. | Check | Before (`853f59c`) | After (`f3e17f3`) | |:--|:--|:--| | `cargo test` (debug) | 67 passed, 0 failed, 0 ignored | 79 passed, **2 failed** (by design), 0 ignored | | `cargo test --release` | 67 passed, 0 failed, 0 ignored | 79 passed, **2 failed** (by design), 0 ignored | | `cargo clippy --all-targets --all-features -D warnings` | clean | clean (probe crate too) | | `cargo deny check` 0.20.2 | advisories, bans, licenses, sources ok | no dependency added | | `cargo audit` 0.23.0 (1567 advisories) | 0 vulnerabilities, 0 warnings | no dependency added | | `zeroize-probe` (A-29) | — | 1 passed | **Fresh fuzz runs** (`untrusted_input`, cargo-fuzz 0.13.2, libFuzzer + ASan, Windows MSVC, nightly 1.102.0 739adecd4), library code = `853f59c`: run 1 **721 s, 186,708 executions**; run 2 **631 s, 162,824 executions**; total 1,352 s, 349,532 executions, ~258 exec/s, coverage 1750 edges, **0 crashes, 0 artifacts**. **Builder's claims.** Confirmed: 67 tests debug and release; deny/audit clean; X-Wing -11 unmodified (checked against the draft text: combiner order and label, SHAKE256 split, eseed split, decaps pk_X); full transcript bound in the HKDF layer; mutual exchange (also KCI-resistant); hazmat gate (now also compile-fail tested from a default-features consumer); `ml-kem` 0.3.4 `encapsulate_deterministic` is public without `hazmat` (`encapsulation_key.rs:43-45`), and Arcanum's release API reaches it only through `encapsulate_inner`, always fed by the RNG parameter (R2-04 is the remaining route). Mutations: spot-checked 2 of 10, both caught; note that dropping `ct_RI` from the transcript is caught by `binding_tests` and `golden_v1`, not by `tests/exchange.rs`. **QA cases newly done:** A-03, A-06, A-18 (completed); A-08, A-09, A-28, A-29, A-30, A-31, A-33, A-34 (new). **Not done:** A-32 (dudect: a shared Windows desktop with ~100 ns timer resolution cannot give an honest t-statistic, and it could never gate; put it in the Day 7 audit pack on a quiet Linux box); A-39 (no `Version` type and no negotiation exist yet, so nothing can be downgraded; belongs with Day 3's `proto`). **Checked clean:** domain-separation labels (no collision across hash prefix, salt and info positions), zeroize on every secret type including dependency `Drop` impls, no `Copy`/`Clone`/`PartialEq`/`Display` on secrets, redacted `Debug`, no panic or input bytes in errors on hostile input, no epoch overflow possible. Not merged, not tagged.
mnovak added 2 commits 2026-11-25 08:37:14 +01:00
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.
Author
Owner

Re R2-01 (#49902): fixed in 6780abc, documented in 96086be. I took option (b). PublicKey::encapsulate, SecretKey::decapsulate and SharedSecret::as_bytes are now #[cfg(feature = "hazmat")]. The crate uses the crate-private encapsulate_inner, decapsulate_inner and SharedSecret::bytes instead. A release consumer can parse keys and ciphertexts and generate a key pair, but it can reach a key only through exchange (mutual, transcript-bound) or seal. qa_r2_01_raw_shared_secret_is_not_reachable_without_hazmat now passes. One test change, with the reason: a33_a_non_crypto_rng_does_not_compile had a PublicKey::encapsulate case. That method no longer exists for a consumer, so the case failed for the wrong reason (E0599). I replaced it with exchange::respond, the other release function that takes an RNG. The refusal of encapsulate itself is what qa_r2_01 asserts.

**Re R2-01 (#49902): fixed in 6780abc**, documented in 96086be. I took option (b). `PublicKey::encapsulate`, `SecretKey::decapsulate` and `SharedSecret::as_bytes` are now `#[cfg(feature = "hazmat")]`. The crate uses the crate-private `encapsulate_inner`, `decapsulate_inner` and `SharedSecret::bytes` instead. A release consumer can parse keys and ciphertexts and generate a key pair, but it can reach a key only through `exchange` (mutual, transcript-bound) or `seal`. `qa_r2_01_raw_shared_secret_is_not_reachable_without_hazmat` now passes. One test change, with the reason: `a33_a_non_crypto_rng_does_not_compile` had a `PublicKey::encapsulate` case. That method no longer exists for a consumer, so the case failed for the wrong reason (E0599). I replaced it with `exchange::respond`, the other release function that takes an RNG. The refusal of `encapsulate` itself is what `qa_r2_01` asserts.
Author
Owner

Re R2-02 (#49903): fixed in 6780abc, documented in 96086be. Draft -11 says nothing about pk_X encoding beyond "the 32 byte string representing the u-coordinate" (§4), and its Python reference decodes with % p. So this check is stricter than the draft, like the low-order check. PublicKey::from_bytes now returns Error::InvalidPublicKey when bit 255 is set or the value is at least 2^255 - 19 (is_canonical_x25519). X25519 outputs are always canonical, so kat_xwing::draft_11_vectors and the differential test still pass unchanged. qa_r2_02_non_canonical_x25519_public_key_is_refused passes. Builder tests: binding::low_order_x25519_public_key_is_refused now expects the 9 non-canonical low-order encodings (7 with bit 255 set, plus p and p+1) to be refused at parse and the 5 canonical ones at use. A new binding::the_canonical_boundary_is_exactly_p checks the boundary: p-1 accepted, p refused, and a value below p whose first byte is 0xff accepted. ct_X is deliberately not checked this way: its raw bytes are bound by the combiner (A-04), so an alias only gives a different secret.

**Re R2-02 (#49903): fixed in 6780abc**, documented in 96086be. Draft -11 says nothing about `pk_X` encoding beyond "the 32 byte string representing the u-coordinate" (§4), and its Python reference decodes with `% p`. So this check is stricter than the draft, like the low-order check. `PublicKey::from_bytes` now returns `Error::InvalidPublicKey` when bit 255 is set or the value is at least 2^255 - 19 (`is_canonical_x25519`). X25519 outputs are always canonical, so `kat_xwing::draft_11_vectors` and the differential test still pass unchanged. `qa_r2_02_non_canonical_x25519_public_key_is_refused` passes. Builder tests: `binding::low_order_x25519_public_key_is_refused` now expects the 9 non-canonical low-order encodings (7 with bit 255 set, plus p and p+1) to be refused at parse and the 5 canonical ones at use. A new `binding::the_canonical_boundary_is_exactly_p` checks the boundary: p-1 accepted, p refused, and a value below p whose first byte is 0xff accepted. `ct_X` is deliberately not checked this way: its raw bytes are bound by the combiner (A-04), so an alias only gives a different secret.
Author
Owner

Re R2-03 (#49904): fixed in 6780abc. The signature is now expand<N, K>(prk, label: &'static [u8], field: &[u8; K]), with exactly one label and one fixed-width field. Its info is injective by construction: the labels are prefix-free (A-07), so an equal info implies an equal label and therefore an equal field. The old ["ab","c"] vs ["a","bc"] call can no longer be written. The bytes did not change: it is still label || field, and golden_v1 passes without regenerating anything. Test change, with the reason: your A-08 part (1) asserted the raw-concatenation collision, which the new signature cannot express. It now pins the helper to HKDF-Expand(prk, label || field) computed independently with hkdf, for the PSK and seal-key cases. Parts (2) and A-09 are unchanged apart from the call syntax.

**Re R2-03 (#49904): fixed in 6780abc.** The signature is now `expand<N, K>(prk, label: &'static [u8], field: &[u8; K])`, with exactly one label and one fixed-width field. Its `info` is injective by construction: the labels are prefix-free (A-07), so an equal `info` implies an equal label and therefore an equal field. The old `["ab","c"]` vs `["a","bc"]` call can no longer be written. The bytes did not change: it is still `label || field`, and `golden_v1` passes **without regenerating anything**. Test change, with the reason: your A-08 part (1) asserted the raw-concatenation collision, which the new signature cannot express. It now pins the helper to `HKDF-Expand(prk, label || field)` computed independently with `hkdf`, for the PSK and seal-key cases. Parts (2) and A-09 are unchanged apart from the call syntax.
Author
Owner

Re R2-04 (#49905): fixed in 6780abc, documented in 96086be. SecretKey::generate, exchange::initiate, exchange::respond and seal::seal each say that rng must be the OS RNG (getrandom/OsRng) or a CSPRNG seeded from it once per process, never a fixed, derived or configured seed. They also say that CryptoRng is only a marker. docs/01_arcanum.md now has rules for consumers. via-core and via run the same cargo tree -e features,normal check. They take no direct ml-kem, x25519-dalek or x-wing dependency, banned in deny.toml, because ml-kem 0.3.4's encapsulate_deterministic is public regardless of its feature. They also grep for from_seed( outside tests/.

**Re R2-04 (#49905): fixed in 6780abc**, documented in 96086be. `SecretKey::generate`, `exchange::initiate`, `exchange::respond` and `seal::seal` each say that `rng` must be the OS RNG (`getrandom`/`OsRng`) or a CSPRNG seeded from it once per process, never a fixed, derived or configured seed. They also say that `CryptoRng` is only a marker. `docs/01_arcanum.md` now has rules for consumers. via-core and via run the same `cargo tree -e features,normal` check. They take **no direct `ml-kem`, `x25519-dalek` or `x-wing` dependency**, banned in `deny.toml`, because ml-kem 0.3.4's `encapsulate_deterministic` is public regardless of its feature. They also grep for `from_seed(` outside `tests/`.
Author
Owner

Re R2-05 (#49906): fixed in 6780abc. (1) impl ZeroizeOnDrop for Initiation<'_> is in place, and a28_secret_types_are_zeroize_on_drop now also asserts Initiation. (2) seal_inner keeps its output buffer in Zeroizing until the plaintext in it has been encrypted, and then moves the buffer out with mem::take (no copy). The MessageTooLong early return now wipes the plaintext copy. zeroize-probe still passes (1/1).

**Re R2-05 (#49906): fixed in 6780abc.** (1) `impl ZeroizeOnDrop for Initiation<'_>` is in place, and `a28_secret_types_are_zeroize_on_drop` now also asserts `Initiation`. (2) `seal_inner` keeps its output buffer in `Zeroizing` until the plaintext in it has been encrypted, and then moves the buffer out with `mem::take` (no copy). The `MessageTooLong` early return now wipes the plaintext copy. `zeroize-probe` still passes (1/1).
Author
Owner

Builder: R2-01 to R2-05 addressed. Head 96086be (fixes in 6780abc, docs in 96086be; replies on #49902-#49906).

Check at 96086be Result
cargo test (debug) 82 passed, 0 failed, 0 ignored. Unit 11 · binding 6 · exchange 11 · feature_hygiene 3 · golden_v1 2 · kat_mlkem768 6 · kat_x25519 5 · kat_xwing 2 · malformed 15 · no_unsafe 2 · psk_epochs 7 · qa_consumer_api 4 · qa_review 8. Doc-tests: 0.
cargo test --release 82 passed, 0 failed, 0 ignored
zeroize-probe (--test-threads=1) 1 passed
cargo clippy --all-targets --all-features -D warnings, --no-default-features, probe crate clean
cargo fmt --check clean
cargo deny check (0.20.2) advisories ok, bans ok, licenses ok, sources ok
cargo audit (0.23.0) exit 0, no vulnerabilities (crate: 55 deps; fuzz crate: 53)
cargo fuzz, libFuzzer + ASan, Windows MSVC, built from 96086be 331 s, 218,223 executions, 659 exec/s, 0 crashes, 0 artifacts, cov 1742, peak RSS 371 MB (07:37:25Z-07:42:59Z)

The golden v1 vectors did not change: the narrowed expand keeps the v1 encoding byte for byte.

I changed two of QA's tests, giving the reason in the replies: the A-33 encapsulate case became exchange::respond, and A-08 part (1) now pins the new expand signature to the v1 encoding. I added one builder test, binding::the_canonical_boundary_is_exactly_p, and updated binding::low_order_x25519_public_key_is_refused for R2-02.

Not merged, not tagged.

**Builder: R2-01 to R2-05 addressed. Head `96086be`** (fixes in `6780abc`, docs in `96086be`; replies on #49902-#49906). | Check at `96086be` | Result | |:--|:--| | `cargo test` (debug) | **82 passed, 0 failed, 0 ignored.** Unit 11 · binding 6 · exchange 11 · feature_hygiene 3 · golden_v1 2 · kat_mlkem768 6 · kat_x25519 5 · kat_xwing 2 · malformed 15 · no_unsafe 2 · psk_epochs 7 · qa_consumer_api 4 · qa_review 8. Doc-tests: 0. | | `cargo test --release` | 82 passed, 0 failed, 0 ignored | | `zeroize-probe` (`--test-threads=1`) | 1 passed | | `cargo clippy --all-targets --all-features -D warnings`, `--no-default-features`, probe crate | clean | | `cargo fmt --check` | clean | | `cargo deny check` (0.20.2) | `advisories ok, bans ok, licenses ok, sources ok` | | `cargo audit` (0.23.0) | exit 0, no vulnerabilities (crate: 55 deps; fuzz crate: 53) | | `cargo fuzz`, libFuzzer + ASan, Windows MSVC, built from `96086be` | **331 s, 218,223 executions, 659 exec/s, 0 crashes, 0 artifacts**, cov 1742, peak RSS 371 MB (07:37:25Z-07:42:59Z) | The golden v1 vectors did **not** change: the narrowed `expand` keeps the v1 encoding byte for byte. I changed two of QA's tests, giving the reason in the replies: the A-33 `encapsulate` case became `exchange::respond`, and A-08 part (1) now pins the new `expand` signature to the v1 encoding. I added one builder test, `binding::the_canonical_boundary_is_exactly_p`, and updated `binding::low_order_x25519_public_key_is_refused` for R2-02. Not merged, not tagged.
mnovak added 1 commit 2026-11-25 09:37:59 +01:00
Author
Owner

Merged and released by the owner session. main is now 2fae9ad (merge --no-ff of feature/arcanum at 9f8d116, which is 96086be plus HANDOVER.md), and v0.1.0 is an annotated tag on it. git rev-parse HEAD origin/main printed the same hash.

Re-run on a fresh clone at 96086be: 82 passed, 0 failed, 0 ignored in debug and release; clippy, fmt, deny and audit clean; zeroize probe 1 passed; fuzz untrusted_input 631 s, 172,694 executions, 0 crashes (ASan).

Mutation checks: R2-02 (skip the canonical check) fails its test. R2-01 (encapsulate and as_bytes public again) fails its test. Ungating as_bytes alone does not, correctly, because nothing in the release API produces a SharedSecret. The test only reaches the secret through encapsulate, not decapsulate, which is a minor gap.

Gitea's manual-merge detection is off for this repository, so this PR is closed by hand. The tag is not signed: whether releases go through Artifex is still open with Mark. Not audited.

**Merged and released by the owner session.** `main` is now `2fae9ad` (`merge --no-ff` of `feature/arcanum` at `9f8d116`, which is `96086be` plus `HANDOVER.md`), and `v0.1.0` is an annotated tag on it. `git rev-parse HEAD origin/main` printed the same hash. Re-run on a fresh clone at `96086be`: **82 passed, 0 failed, 0 ignored** in debug and release; clippy, fmt, deny and audit clean; zeroize probe 1 passed; fuzz `untrusted_input` **631 s, 172,694 executions, 0 crashes** (ASan). Mutation checks: R2-02 (skip the canonical check) fails its test. R2-01 (`encapsulate` and `as_bytes` public again) fails its test. Ungating `as_bytes` alone does not, correctly, because nothing in the release API produces a `SharedSecret`. The test only reaches the secret through `encapsulate`, not `decapsulate`, which is a minor gap. Gitea's manual-merge detection is off for this repository, so this PR is closed by hand. The tag is not signed: whether releases go through Artifex is still open with Mark. Not audited.
mnovak closed this pull request 2026-11-25 09:38:33 +01:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/arcanum#1