Skip to main content

MlDsa44PublicKey

Struct MlDsa44PublicKey 

Source
pub struct MlDsa44PublicKey { /* private fields */ }
Expand description

An ML-DSA-44 public key.

Verification is stateless. Use MlDsa44PublicKey::verify for a message and optional context, or MlDsa44PublicKey::verify_external_mu for a precomputed 64-byte message representative.

let key = MlDsa44SecretKey::new(&seed);
let signature = key.sign_derand(b"message", b"", &[0u8; 32]).unwrap();
assert!(key.public_key().verify(b"message", &signature, b"").is_ok());

Implementations§

Source§

impl MlDsa44PublicKey

Source

pub fn from_bytes(bytes: &[u8; 1312]) -> Self

Creates a public key from its 1312-byte encoded form.

Source

pub fn to_bytes(&self) -> [u8; 1312]

Returns the 1312-byte encoded form of this key.

Source

pub fn verify( &self, message: &[u8], signature: &[u8; 2420], ctx: &[u8], ) -> Result<(), MlDsaError>

Verifies an ML-DSA-44 signature over message with the optional context ctx.

Returns MlDsaError::InvalidSignature if the signature is invalid and MlDsaError::ContextTooLong if ctx exceeds 255 bytes.

Source

pub fn verify_external_mu( &self, mu: &[u8; 64], signature: &[u8; 2420], ) -> Result<(), MlDsaError>

Verifies an ML-DSA-44 signature over a precomputed 64-byte message representative mu (FIPS 204 “external mu” verification).

mu must be the output of the FIPS 204 message-representative computation; this function performs no domain separation or hashing.

Returns MlDsaError::InvalidSignature if the signature is invalid.

Trait Implementations§

Source§

impl Clone for MlDsa44PublicKey

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MlDsa44PublicKey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for MlDsa44PublicKey

Source§

impl From<&[u8; 1312]> for MlDsa44PublicKey

Source§

fn from(bytes: &[u8; 1312]) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for MlDsa44PublicKey

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MlDsa44PublicKey

Source§

impl TryFrom<&[u8]> for MlDsa44PublicKey

Source§

type Error = MlDsaError

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.