Expand description
§RustCrypto: ML-DSA
Pure Rust implementation of the Module-Lattice-Based Digital Signature Standard (ML-DSA) as described in the FIPS 204 (final).
§About
ML-DSA was formerly known as CRYSTALS-Dilithium.
§⚠️ Security Warning
The implementation contained in this crate has never been independently audited!
USE AT YOUR OWN RISK!
§License
All crates licensed under either of
at your option.
§Contribution
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.
§Usage
The following types provide the core functionality of this crate, and are all generic around the
MlDsaParams trait which defines the security level and is one of MlDsa44, MlDsa65,
or MlDsa87 (with MlDsa65 recommended as providing the best balance of security and
performance):
SigningKey: secret key capable of generating signatures. Implements theKeyInit,KeyExport,Keypair, andSignertraits, as well asGeneratewhen therand_corefeature of this crate is enabled.VerifyingKey: public key associated with a givenSigningKey. Implements theKeyInit,KeyExport, andVerifiertraits.Signature: ML-DSA signature generated by aSigningKey, and verifiable by aVerifyingKey. Implements theSignatureEncodingtrait.
// NOTE: requires the `getrandom` feature is enabled
use ml_dsa::{MlDsa65, Generate, Keypair, SigningKey, Signer, Verifier};
let sk = SigningKey::<MlDsa65>::generate();
let msg = b"Hello world";
let sig = sk.sign(msg);
sk.verifying_key().verify(msg, &sig)?;Re-exports§
Modules§
- pkcs8
pkcs8 - PKCS#8 private key encoding support.
Structs§
- Error
- Signature errors.
- Expanded
Signing Key - An ML-DSA signing key
- MlDsa44
MlDsa44is the parameter set for security category 2, providing the equivalent of 128-bit symmetric security.- MlDsa65
MlDsa65is the parameter set for security category 3, providing the equivalent of 192-bit symmetric security, and is the recommended parameter set.- MlDsa87
MlDsa87is the parameter set for security category 5, providing the equivalent of 256-bit symmetric security.- Signature
- An ML-DSA signature
- Signing
Key - ML-DSA signing key (i.e. private/secret key).
- Verifying
Key - An ML-DSA verification key.
Traits§
- Generate
rand_core - Secure random generation.
- KeyExport
- Serialize a key to a byte array.
- KeyInit
- Types which can be initialized from a key.
- KeySize
User - Types which use key for initialization.
- Keypair
- Signing keypair with an associated verifying key.
- MlDsa
Params - An instance of
MlDsaParamsdefines all of the parameters necessary for ML-DSA operations. Typically this is done by implementingParameterSetwith values that will fit into the blanket implementations ofSigningKeyParams,VerifyingKeyParams, andSignatureParams. - Signature
Encoding - Support for decoding/encoding signatures as bytes.
- Signer
- Sign the provided message bytestring using
Self(e.g. a cryptographic key or connection to an HSM), returning a digital signature. - Verifier
- Verify the provided message bytestring using
Self(e.g. a public key).
Type Aliases§
- B32
- A 32-byte array, defined here for brevity because it is used several times
- Encoded
Signature - A signature encoded as a byte array
- Encoded
Verifying Key - A verifying key encoded as a byte array
- Expanded
Signing KeyBytes - A signing key encoded as a byte array
- Seed
- ML-DSA seeds are signing (private) keys, which are consistently 32-bytes across all security levels, and are the preferred serialization for representing such keys.