pub struct MlDsaPublicKey { /* private fields */ }Expand description
ML-DSA public key
Contains the public verification key for ML-DSA signatures. This key can be freely shared and is used to verify signatures.
§Examples
use saorsa_pqc::api::sig::{ml_dsa_65, MlDsaPublicKey, MlDsaVariant};
let dsa = ml_dsa_65();
let (public_key, _) = dsa.generate_keypair()?;
// Export for distribution
let key_bytes = public_key.to_bytes();
println!("Public key size: {} bytes", key_bytes.len());
// Import from bytes
let imported = MlDsaPublicKey::from_bytes(MlDsaVariant::MlDsa65, &key_bytes)?;
assert_eq!(public_key.variant(), imported.variant());Implementations§
Source§impl MlDsaPublicKey
impl MlDsaPublicKey
Sourcepub const fn variant(&self) -> MlDsaVariant
pub const fn variant(&self) -> MlDsaVariant
Get the variant of this key
Sourcepub fn from_bytes(
variant: MlDsaVariant,
bytes: &[u8],
) -> Result<MlDsaPublicKey, PqcError>
pub fn from_bytes( variant: MlDsaVariant, bytes: &[u8], ) -> Result<MlDsaPublicKey, PqcError>
Import a public key from bytes
§Errors
Returns an error if the byte slice has an incorrect length for the specified variant.
Trait Implementations§
Source§impl Clone for MlDsaPublicKey
impl Clone for MlDsaPublicKey
Source§fn clone(&self) -> MlDsaPublicKey
fn clone(&self) -> MlDsaPublicKey
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 MlDsaPublicKey
impl Drop for MlDsaPublicKey
Auto Trait Implementations§
impl Freeze for MlDsaPublicKey
impl RefUnwindSafe for MlDsaPublicKey
impl Send for MlDsaPublicKey
impl Sync for MlDsaPublicKey
impl Unpin for MlDsaPublicKey
impl UnsafeUnpin for MlDsaPublicKey
impl UnwindSafe for MlDsaPublicKey
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