5a52854ccc
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.
50 lines
2.0 KiB
Rust
50 lines
2.0 KiB
Rust
//! # Arcanum
|
|
//!
|
|
//! The post-quantum crypto core of the Domi ecosystem. **Not audited.**
|
|
//!
|
|
//! - [`xwing`]: the hybrid KEM ML-KEM-768 + X25519 (X-Wing, draft-connolly-cfrg-xwing-kem-11).
|
|
//! - [`exchange`]: a mutual exchange between two peers (each encapsulates to the other), bound to
|
|
//! the full transcript and a context, and the WireGuard pre-shared key it yields per epoch.
|
|
//! - [`seal`]: a one-shot sealed box to a recipient's hybrid public key.
|
|
//! - [`sign`] (v0.2.0): hybrid signatures ML-DSA-65 + Ed25519, exactly RFC 10073
|
|
//! `id-MLDSA65-Ed25519-SHA512`, and a helper that binds an X-Wing public key to its owner.
|
|
//!
|
|
//! No primitive is implemented here; they come from `ml-kem`, `x25519-dalek`, `ml-dsa`,
|
|
//! `ed25519-dalek`, `sha3`, `shake`, `sha2`, `hkdf` and `chacha20poly1305`. No I/O, no clock: randomness and time are parameters.
|
|
//! Design, sources and risks: `docs/01_arcanum.md`, `docs/02_signatures.md` and `docs/THREAT_MODEL.md`.
|
|
//!
|
|
//! The `hazmat` feature exposes the deterministic (`_derand`, `from_seed`) entry points and the
|
|
//! bare RFC 10073 signature interface (`sign_composite_raw`, `verify_composite_raw`) used by the
|
|
//! known-answer tests. It is off by default and must never be enabled in a release build.
|
|
#![no_std]
|
|
#![forbid(unsafe_code)]
|
|
#![deny(missing_docs)]
|
|
|
|
extern crate alloc;
|
|
|
|
mod error;
|
|
pub mod exchange;
|
|
mod schedule;
|
|
pub mod seal;
|
|
pub mod sign;
|
|
pub mod xwing;
|
|
|
|
#[cfg(test)]
|
|
mod binding_tests;
|
|
#[cfg(test)]
|
|
mod qa_review_tests;
|
|
|
|
pub use error::{Error, Input};
|
|
pub use exchange::{Session, WIREGUARD_PSK_LEN, WireGuardPsk};
|
|
|
|
/// The recommended rotation interval in seconds. Rosenpass's responder rekeys every 120 s
|
|
/// (`REKEY_AFTER_TIME_RESPONDER`), following WireGuard's own two-minute rekey.
|
|
pub const RECOMMENDED_EPOCH_SECONDS: u64 = 120;
|
|
|
|
/// The epoch number at `unix_seconds`, for [`Session::wireguard_psk`]. Arcanum has no clock; the
|
|
/// caller passes the time.
|
|
#[must_use]
|
|
pub const fn epoch_at(unix_seconds: u64) -> u64 {
|
|
unix_seconds / RECOMMENDED_EPOCH_SECONDS
|
|
}
|