Skip to main content

PrivateKey1024

Struct PrivateKey1024 

Source
pub struct PrivateKey1024(/* private fields */);
Expand description

An ML-KEM-1024 private key.

Use ML-KEM-768 unless you have a good reason to need this larger size.

Implementations§

Source§

impl PrivateKey1024

Source

pub fn generate() -> (Vec<u8>, PrivateKey1024, [u8; 64])

Generates a random public/private key pair returning a serialized public key, a private key, and a private seed value that can be used to regenerate the same private key in the future.

Source

pub fn from_seed(seed: &[u8; 64]) -> Self

Regenerate a private key from a seed value.

Source

pub fn to_public_key(&self) -> PublicKey1024

Derives the public key corresponding to this private key.

Source

pub fn decapsulate(&self, ciphertext: &[u8]) -> Option<[u8; 32]>

Decapsulates a shared secret from a ciphertext. This function only returns None if ciphertext is the wrong length. For invalid ciphertexts it returns a key that will always be the same for the same ciphertext and private key, but which appears to be random unless one has access to the private key. These alternatives occur in constant time. Any subsequent symmetric encryption using the result must use an authenticated encryption scheme in order to discover the decapsulation failure.

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> 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, 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.