Skip to main content

MLKEMSeedPrivateKey

Struct MLKEMSeedPrivateKey 

Source
pub struct MLKEMSeedPrivateKey<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> { /* private fields */ }
Expand description

An ML-KEM private key.

Implementations§

Source§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

Source

pub fn new(seed: &KeyMaterial<64>) -> Result<Self, KEMError>

Create a new MLKEMSeedPrivateKey from a 64-byte KeyMaterial. Seed SecurityStrength must match algorithm security strength: 128-bit (ML-KEM-512), 192-bit (ML-KEM-768), or 256-bit (ML-KEM-1024).

Trait Implementations§

Source§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> Clone for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

Source§

fn clone( &self, ) -> MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

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<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> Debug for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

Debug impl mainly to prevent the secret key from being printed in logs.

Source§

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

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

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> Display for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

Display impl mainly to prevent the secret key from being printed in logs.

Source§

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

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

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> Drop for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

Zeroizing drop

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> Eq for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

Source§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> KEMPrivateKey<SK_LEN> for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

Source§

fn encode(&self) -> [u8; SK_LEN]

Encode the private key as a 64-byte seed (d || z)

Source§

fn encode_out(&self, out: &mut [u8; SK_LEN]) -> usize

Write it out to bytes in its standard encoding.
Source§

fn from_bytes(bytes: &[u8]) -> Result<Self, KEMError>

Read it in from bytes in its standard encoding.
Source§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> MLKEMPrivateKeyTrait<k, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN> for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

Source§

fn encode_full_sk(&self) -> [u8; FULL_SK_LEN]

This produces the full private key in the encoding specified in FIPS 203 so that it is compatible with other implementations.

Note that since this encoding does not include the seed, this is a one-way operation; after exporting in this encoding, it will be impossible to re-import it into a MLKEMSeedPrivateKey.

As described on Algorithm 16 line 3: dk ← (dkPKE ‖ ek ‖ H(ek) ‖ 𝑧)

Source§

fn full_sk_encode_out(&self, out: &mut [u8; FULL_SK_LEN]) -> usize

This produces the full private key in the encoding specified in the FIPS so that it is compatible with other implementations. Note that this encoding does not include the seed, so if exporting in this encoding, it will be impossible to re-import it into this implementation.

As described on Algorithm 16 line 3: dk ← (dkPKE ‖ ek ‖ H(ek) ‖ 𝑧)

Source§

fn from_keymaterial(seed: &KeyMaterial<64>) -> Result<Self, KEMError>

New from KeyMaterial. Can throw a KEMError if the KeyMaterial does not contain sufficient entropy.
Source§

fn seed(&self) -> Option<KeyMaterial<64>>

Get a ref to the seed, which there always will be for a MLKEMSeedPrivateKey In this implementation, we always have a seed, so will always return Some.
Source§

fn pk(&self) -> MLKEMPublicKey<k, PK_LEN, T_PACKED_LEN>

Runs essentially a full keygen according to Algorithm 13.
Source§

fn pk_hash(&mut self) -> &[u8; 32]

Get a ref to the stored public key hash. Since in this implementation, this requires running the full keygen, this is a lazy evaluation and will only be computationally heavy the first time it is called for a given key. This requires a mutable copy. If you don’t have then, then you can compute the full public key via MLKEMPrivateKeyTrait::pk and then get the hash of that.
Source§

fn sk_decode(sk: &[u8; SK_LEN]) -> Self

Decode the private key.
Source§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> PartialEq for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> Secret for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

Auto Trait Implementations§

§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> Freeze for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> RefUnwindSafe for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> Send for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> Sync for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> Unpin for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> UnsafeUnpin for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

§

impl<const k: usize, const eta1: i16, const LAMBDA: i16, const SK_LEN: usize, const FULL_SK_LEN: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> UnwindSafe for MLKEMSeedPrivateKey<k, eta1, LAMBDA, SK_LEN, FULL_SK_LEN, PK_LEN, T_PACKED_LEN>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.