Skip to content
cryptidtechPublic

About

Pluggable, auditable cryptography trait surface (KEM, DSA, NIKE) with PQ and classical schemes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Meliora

Meliora (Latin: "better things") is a self-contained, pluggable cryptography abstraction: unified KEM and DSA traits that span classical and post-quantum schemes, with runtime algorithm selection through a Provider registry.

The crate is deliberately independent of everything else in this repository — it has its own workspace, lockfile, and dependency tree — so it can be audited in isolation (FIPS or otherwise) and replaced wholesale by any implementation of its traits (a FIPS-validated build, an HSM bridge, a plugin process).

Design

  • KEM is the common shape for key establishment. Post-quantum KEMs implement it natively; classical Diffie-Hellman is lifted via DHKEM (RFC 9180 §4.1); RSA via key transport. There is no post-quantum Diffie-Hellman, so a KEX-shaped abstraction cannot be universal — a KEM-shaped one can.
  • One signature shape. Dsa::sign(key, msg, rng) covers deterministic (Ed25519) and randomized (RSA-PSS, hedged ML-DSA) schemes. Context strings live on ContextDsa: Dsa (ML-DSA, SLH-DSA, Ed448 only): the context is bound at construction — MlDsa65Scheme::new(b"my-domain")? — and the inherited Dsa API signs with it; a Default instance uses the empty context. Passing a context to a scheme that doesn't define one is a type error, not a runtime rejection; domain separation is never emulated.
  • Security claims are data. KemInfo/DsaInfo carry claimed NIST level, IND-CCA / EUF-CMA / SUF-CMA, and context support so callers can enforce policy at runtime (the liboqs model).
  • Secrets are guarded. SharedSecret zeroizes on drop and is not Clone; secret keys may be raw (zeroized) bytes or opaque provider handles (HSM slot, plugin key id) that never enter this process.

Feature matrix

Every scheme is an adapter behind its own cargo feature; the core crate has no scheme dependencies.

Feature Schemes Backend
ed25519 Ed25519 (RFC 8032) ed25519-dalek
x25519 DHKEM(X25519, HKDF-SHA256) (RFC 9180) x25519-dalek + hkdf
frodo-kem FrodoKEM-640/976/1344, AES + SHAKE (salted spec) frodo-kem-rs
mayo MAYO-1/2/3/5 (NIST PQC signature on-ramp) pq-mayo
ml-kem ML-KEM-512/768/1024 (FIPS 203, seed-stored keys) ml-kem
ml-dsa ML-DSA-44/65/87 (FIPS 204, native context strings) ml-dsa
p256 / p384 / k256 ECDSA (RFC 6979 deterministic, SEC1 compressed) curve crates
ecdsa all three ECDSA curves
sntrup-kem sntrup653/761/857/953/1013/1277 (Streamlined NTRU Prime) sntrup
slh-dsa all 12 SLH-DSA sets (FIPS 205, native context strings) slh-dsa
hqc-kem HQC-128/192/256 hqc-kem
fn-dsa FN-DSA-512/1024 (Falcon, FIPS 206 draft) fn-dsa
ed448 Ed448 (RFC 8032, native context strings) ed448-goldilocks-plus
rsa RSA-2048/3072/4096 OAEP key-transport KEM + PSS signatures rsa
p256 (also) DHKEM(P-256, HKDF-SHA256) — RFC 9180 p256
p384 (also) DHKEM(P-384, HKDF-SHA384) — RFC 9180 p384
hybrid X25519+ML-KEM-768; with p256/p384: P-256+ML-KEM-768, P-384+ML-KEM-1024. With hqc-kem: X25519+HQC-128/192, P-256+HQC-128/192, P-384+HQC-256. With frodo-kem: X25519+FrodoKEM-640/976 (AES and SHAKE), P-256+FrodoKEM-640-AES and 976-SHAKE, P-384+FrodoKEM-1344 (AES and SHAKE). With sntrup-kem: X25519+sntrup761/857, P-256+sntrup761/857, P-384+sntrup1277. 21 in all, DHKEM first; labeled SHA3-256 combiner over both secrets, ciphertexts and public keys sha3
bls BLS12-381 G1/G2 (message augmentation, deterministic) blsful (pure Rust)
lamport Lamport one-time signatures + threshold Lamport (StatefulDsa, OneShotThresholdDsa) lamport_signature_plus
xmss XMSS-SHA2 10/16/20_256 (RFC 8391, StatefulDsa) xmss
frost FROST DKG (P-256/P-384/secp256k1) + FROST signing (RFC 9591, P-256/secp256k1) frost-dkg, ZF frost-*
full all of the above
serde Serialize/Deserialize for PublicKey, KemInfo, DsaInfo (not in full; secret material never derives serde) serde

StatefulDsa (signing consumes key state, returns the successor — persist it before releasing the signature) is implemented by Lamport and XMSS. The dealerless-DKG abstraction (threshold::Dkg/DkgParticipant) is a round-agnostic advance/receive loop - frost-dkg implements it today, and a Gennaro-style engine fits the same shape. threshold::ThresholdDsa (deal/commit/partial-sign/combine/verify) is implemented by the FROST signing engine, consuming the same raw-scalar shares the DKG emits. Planned: gennaro-dkg engine, FROST P-384 signing (needs a published ciphersuite), vector-verified X-Wing.

Usage

use meliora::{Provider, SoftwareProvider};

let provider = SoftwareProvider::new();
let kem = provider
    .kem(meliora::schemes::x25519::DHKEM_X25519_HKDF_SHA256)
    .expect("x25519 feature enabled");

let mut rng = /* any rand_core 0.10 CryptoRng */
# unimplemented!();
let keypair = kem.generate(&mut rng)?;
let (ciphertext, shared_secret) = kem.encapsulate(&keypair.public, &mut rng)?;
let recovered = kem.decapsulate(&keypair.secret, &ciphertext)?;
assert_eq!(shared_secret.as_bytes(), recovered.as_bytes());

Verification

cargo test --features full
cargo clippy --all-targets --features full -- -D warnings

Tests include per-scheme roundtrips, negative cases (tampered signatures, wrong-length ciphertexts, cross-algorithm keys, non-empty contexts), and the RFC 9180 A.1 known-answer vector for DHKEM(X25519, HKDF-SHA256).

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Pluggable, auditable cryptography trait surface (KEM, DSA, NIKE) with PQ and classical schemes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages