open-standards/smart-byte/smart-byte-rs/crates/smart-byte-pq/src/lib.rs
Transaction Science 01d4ad9c7b Ingest batch 2: 9 new crates across openpay / smart-byte / eoc
openpay/ (+3 crates, ~8400 LOC, 162 tests)
  op-iso8583/         ISO 8583 messages for direct acquirer / card-network
                      connectivity. MTIs, primary+secondary bitmaps, full
                      DE catalogue, BCD/ASCII/EBCDIC/LLVAR/LLLVAR codecs,
                      five dialects (Visa Base I, Mastercard MDS, Amex GNS,
                      Discover, JCB), network-management messages
                      (sign-on/echo/cutover), DE 55 EMV TLV.
  op-mobile-wallets/  Apple Pay (ECDH-P256 + AES-256-GCM), Google Pay ECv2
                      (ECDH + HKDF + AES-256-CTR + HMAC), Samsung Pay. PAN
                      never leaves the decryption boundary as a String;
                      lands in VaultRef. No-PAN-leakage assertions per
                      wallet.
  op-routing/         Least-cost routing + MCC-aware routing + intelligent
                      retry / soft-decline recovery. 231-MCC catalogue.
                      Real ISO 8583 DE-39 soft/hard decline taxonomies.

smart-byte/smart-byte-rs/ (+3 crates, ~7100 LOC, 96 tests)
  smart-byte-vc/      W3C Verifiable Credentials 2.0: VCDM, presentations,
                      Data Integrity proofs (eddsa-jcs-2022), VC-JWT,
                      SD-JWT (selective disclosure), Bitstring Status
                      List 2021. Cargo-bridge maps VCs to Smart Byte
                      envelopes with SAID stability.
  smart-byte-did/     W3C DID resolution: did:key (Ed25519/P-256/secp256k1),
                      did:web (HTTPS), did:peer (numalgo 2+4), did:jwk,
                      did:ion (feature-gated stub). DID URL dereferencer.
  smart-byte-pq/      Post-quantum signatures: ML-DSA-44/65/87 (FIPS 204),
                      SLH-DSA across 12 parameter sets (FIPS 205), FN-DSA
                      (draft FIPS 206, feature-gated). Hybrid Ed25519 +
                      ML-DSA pattern for the transition. Secret-key
                      zeroize-on-drop.

eoc/eoc-rs/ (+3 crates, ~6450 LOC, 76 tests)
  eoc-vendor-api/     NeuralBackend implementations: Anthropic, OpenAI,
                      Google, Mistral, Cohere, Groq, Together, Fireworks.
                      SSE streaming. Prompt-caching where supported.
                      Joule estimates per published energy coefficient
                      (12-model curated table).
  eoc-embeddings/     21 embedding models behind one Embedder trait:
                      OpenAI v3 (3), Cohere v3 (3), Voyage (5), Mistral,
                      Jina, plus local ONNX (BGE x3, nomic, mxbai, GTE,
                      E5) behind 'local' feature. Matryoshka-style
                      dimension projection. Per-content-hash cache.
  eoc-route-learned/  RouteLLM-style matrix-factorisation router +
                      multinomial-logreg classifier + LinUCB / Thompson
                      bandits for online learning. LearnedCascade wraps
                      the rule-based cascade with a confidence-threshold
                      skip policy. Synthetic-eval accuracy: MF 0.935,
                      LogReg 0.980.

Quality:
- cargo check across all three workspaces: clean
- cargo clippy --all-targets -- -D warnings on every new crate: clean
- 334 new tests total; all passing
- #![forbid(unsafe_code)] across every new crate
- No unwrap/expect outside #[cfg(test)]

Rust 1.95.0 edition 2024 (inherited via root rust-toolchain.toml).
2026-05-23 18:12:24 -04:00

62 lines
2.5 KiB
Rust

//! # smart-byte-pq
//!
//! Post-quantum signature algorithms for the Smart Byte substrate.
//!
//! NIST finalised the first three post-quantum signature standards in
//! August 2024:
//!
//! * **FIPS 204 — ML-DSA** (Module-Lattice-Based Digital Signature
//! Algorithm, formerly CRYSTALS-Dilithium). Three parameter sets:
//! ML-DSA-44, ML-DSA-65, ML-DSA-87.
//! * **FIPS 205 — SLH-DSA** (Stateless Hash-Based Digital Signature
//! Algorithm, formerly SPHINCS+). Twelve parameter sets across two
//! hash families (SHA-2, SHAKE), three security levels (128, 192,
//! 256 bit), and two size/speed trade-offs (small `s`, fast `f`).
//! * **Draft FIPS 206 — FN-DSA** (FFT-over-NTRU Digital Signature
//! Algorithm, formerly Falcon). Two parameter sets: FN-DSA-512 and
//! FN-DSA-1024. The FIPS 206 standard is in late draft as of mid-2025;
//! for that reason the FN-DSA implementation in this crate is gated
//! behind the `falcon` feature. When the feature is off, the public
//! API is preserved (so callers can still match on the enum variants)
//! but the signer functions return [`error::PqError::UnsupportedAlgorithm`].
//!
//! Smart Byte signs *envelope SAIDs* (BLAKE3 commitments to the
//! canonical CBOR encoding of an envelope with `id` zeroed). The choice
//! of signature algorithm is selected per envelope via the one-byte
//! *algorithm identifier* defined in the Smart Byte spec
//! (`§4.1 / §8.3 / §8.4 / §19`). This crate provides the wire-side
//! signer/verifier implementations for every algorithm in the enum.
//!
//! The default for v1 envelopes remains Ed25519; PQ algorithms are
//! opt-in per envelope until the substrate-wide migration cutover
//! described in `§19.5` / `§19.8`.
//!
//! ## Hybrid signatures
//!
//! For the transition period NIST and the IETF
//! (`draft-ietf-pquip-pqt-hybrid-terminology`) recommend hybrid
//! signatures that combine a classical scheme (Ed25519 or ECDSA-P256)
//! with a post-quantum scheme (typically ML-DSA). A hybrid signature
//! is valid only if **both** component signatures verify; an attacker
//! must break both schemes to forge one. See [`hybrid`].
#![forbid(unsafe_code)]
#![deny(missing_docs)]
pub mod algorithm;
pub mod error;
pub mod hybrid;
pub mod mldsa;
pub mod signer_trait;
pub mod slhdsa;
#[cfg(feature = "falcon")]
pub mod fndsa;
#[cfg(not(feature = "falcon"))]
#[path = "fndsa_stub.rs"]
pub mod fndsa;
pub use algorithm::SignatureAlgorithm;
pub use error::PqError;
pub use signer_trait::{Signer, Verifier};