pub enum MLDSASignature {
MLDSA44(Box<DetachedSignature>),
MLDSA65(Box<DetachedSignature>),
MLDSA87(Box<DetachedSignature>),
}Expand description
A digital signature created with the ML-DSA post-quantum signature algorithm.
MLDSASignature represents a digital signature created using the ML-DSA
(Module Lattice-based Digital Signature Algorithm) post-quantum algorithm.
It supports multiple security levels through the variants:
MLDSA44: NIST security level 2 (roughly equivalent to AES-128)MLDSA65: NIST security level 3 (roughly equivalent to AES-192)MLDSA87: NIST security level 5 (roughly equivalent to AES-256)
ML-DSA signatures can be verified using the corresponding public key.
§Examples
use bc_components::MLDSA;
// Generate a keypair
let (private_key, public_key) = MLDSA::MLDSA44.keypair();
// Sign a message
let message = b"Hello, post-quantum world!";
let signature = private_key.sign(message);
// Verify the signature
assert!(public_key.verify(&signature, message).unwrap());Variants§
MLDSA44(Box<DetachedSignature>)
An ML-DSA44 signature (NIST security level 2)
MLDSA65(Box<DetachedSignature>)
An ML-DSA65 signature (NIST security level 3)
MLDSA87(Box<DetachedSignature>)
An ML-DSA87 signature (NIST security level 5)
Implementations§
Source§impl MLDSASignature
impl MLDSASignature
Sourcepub fn from_bytes(level: MLDSA, bytes: &[u8]) -> Result<Self>
pub fn from_bytes(level: MLDSA, bytes: &[u8]) -> Result<Self>
Creates an ML-DSA signature from raw bytes and a security level.
§Parameters
level- The security level of the signature.bytes- The raw bytes of the signature.
§Returns
An MLDSASignature if the bytes represent a valid signature for the given level,
or an error otherwise.
§Errors
Returns an error if the bytes do not represent a valid ML-DSA signature for the specified security level.
Trait Implementations§
Source§impl CBORTagged for MLDSASignature
Defines CBOR tags for ML-DSA signatures.
impl CBORTagged for MLDSASignature
Defines CBOR tags for ML-DSA signatures.
Returns the CBOR tag for ML-DSA signatures.
Source§impl CBORTaggedDecodable for MLDSASignature
Implements CBOR decoding for ML-DSA signatures.
impl CBORTaggedDecodable for MLDSASignature
Implements CBOR decoding for ML-DSA signatures.
Source§fn from_untagged_cbor(untagged_cbor: CBOR) -> Result<Self>
fn from_untagged_cbor(untagged_cbor: CBOR) -> Result<Self>
Creates an MLDSASignature from untagged CBOR.
§Errors
Returns an error if the CBOR value doesn’t represent a valid ML-DSA signature.
Source§fn from_tagged_cbor(cbor: CBOR) -> Result<Self, Error>where
Self: Sized,
fn from_tagged_cbor(cbor: CBOR) -> Result<Self, Error>where
Self: Sized,
Source§impl CBORTaggedEncodable for MLDSASignature
Implements CBOR encoding for ML-DSA signatures.
impl CBORTaggedEncodable for MLDSASignature
Implements CBOR encoding for ML-DSA signatures.
Source§fn untagged_cbor(&self) -> CBOR
fn untagged_cbor(&self) -> CBOR
Creates the untagged CBOR representation as an array with level and signature bytes.
Source§fn tagged_cbor(&self) -> CBOR
fn tagged_cbor(&self) -> CBOR
Source§impl Clone for MLDSASignature
impl Clone for MLDSASignature
Source§fn clone(&self) -> MLDSASignature
fn clone(&self) -> MLDSASignature
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MLDSASignature
Provides debug formatting for ML-DSA signatures.
impl Debug for MLDSASignature
Provides debug formatting for ML-DSA signatures.
Source§impl From<MLDSASignature> for CBOR
Converts an MLDSASignature to CBOR.
impl From<MLDSASignature> for CBOR
Converts an MLDSASignature to CBOR.
Source§fn from(value: MLDSASignature) -> Self
fn from(value: MLDSASignature) -> Self
Converts to tagged CBOR.