pub struct MlDsaSignature { /* private fields */ }Expand description
ML-DSA signature
A quantum-resistant digital signature produced by ML-DSA. Signatures are non-deterministic (include randomness) for enhanced security.
§Size Requirements
- ML-DSA-44: 2420 bytes
- ML-DSA-65: 3309 bytes
- ML-DSA-87: 4627 bytes
§Examples
use saorsa_pqc::api::sig::{ml_dsa_65, MlDsaSignature, MlDsaVariant};
let dsa = ml_dsa_65();
let (public_key, secret_key) = dsa.generate_keypair()?;
// Create signature
let message = b"Document to sign";
let signature = dsa.sign(&secret_key, message)?;
// Serialize for transmission
let sig_bytes = signature.to_bytes();
assert_eq!(sig_bytes.len(), 3309); // ML-DSA-65 signature size
// Deserialize received signature
let received_sig = MlDsaSignature::from_bytes(MlDsaVariant::MlDsa65, &sig_bytes)?;
// Verify
assert!(dsa.verify(&public_key, message, &received_sig)?);Implementations§
Source§impl MlDsaSignature
impl MlDsaSignature
Sourcepub const fn variant(&self) -> MlDsaVariant
pub const fn variant(&self) -> MlDsaVariant
Get the variant of this signature
Sourcepub fn from_bytes(
variant: MlDsaVariant,
bytes: &[u8],
) -> Result<MlDsaSignature, PqcError>
pub fn from_bytes( variant: MlDsaVariant, bytes: &[u8], ) -> Result<MlDsaSignature, PqcError>
Import a signature from bytes
§Errors
Returns an error if the byte slice has an incorrect length for the specified variant.
Trait Implementations§
Source§impl Clone for MlDsaSignature
impl Clone for MlDsaSignature
Source§fn clone(&self) -> MlDsaSignature
fn clone(&self) -> MlDsaSignature
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Drop for MlDsaSignature
impl Drop for MlDsaSignature
Auto Trait Implementations§
impl Freeze for MlDsaSignature
impl RefUnwindSafe for MlDsaSignature
impl Send for MlDsaSignature
impl Sync for MlDsaSignature
impl Unpin for MlDsaSignature
impl UnsafeUnpin for MlDsaSignature
impl UnwindSafe for MlDsaSignature
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more