Skip to main content

FrodoKem

Struct FrodoKem 

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

FrodoKEM-1344-AES (security level 5).

FrodoKEM is a lattice-based KEM whose security relies on the plain Learning With Errors (LWE) problem — a far more conservative variant than the structured (module/ring) lattice assumptions used by ML-KEM. The 1344 variant targets NIST security level 5; the AES flavour uses AES in counter mode as its pseudo-random generator, which benefits from hardware AES-NI acceleration on most modern CPUs.

§Sizes

ObjectBytes
Public key21,520
Secret key43,088
Ciphertext21,632
Shared secret32

§Pros

  • Based on plain (unstructured) LWE rather than module/ring variants — a more conservative assumption with a longer analysis history.
  • No known algebraic attacks that exploit ring structure.
  • AES variant is fast on hardware with AES-NI.
  • Standardized by the French and Germans as their preferred PQC KEM because it is so conservative.

§Cons

  • Large public key and ciphertext (~21 KB each) — significantly larger than ML-KEM; unsuitable for protocols that must transmit both in every handshake without compression or caching.

§Reuse

Construct once with FrodoKem::new and reuse across operations — each instance owns the underlying liboqs algorithm object, so reusing it avoids re-allocating that object on every encapsulation/decapsulation.

Implementations§

Source§

impl FrodoKem

Source

pub const PUBLIC_KEY_LEN: usize = 21_520

Length in bytes of a serialized public key.

Source

pub const SECRET_KEY_LEN: usize = 43_088

Length in bytes of a serialized secret key.

Source

pub const CIPHERTEXT_LEN: usize = 21_632

Length in bytes of a ciphertext.

Source

pub const SHARED_SECRET_LEN: usize = 32

Length in bytes of the encapsulated shared secret.

Source

pub fn new() -> Self

Construct a reusable FrodoKEM-1344-AES instance.

Infallible: FrodoKEM-1344-AES is always compiled in via the crate’s oqs feature set, so the underlying algorithm object can always be created.

Source

pub fn keypair(&self) -> Result<(PublicKey, SecretKey)>

Source

pub fn encapsulate( &self, public_key: &PublicKey, ) -> Result<(Ciphertext, SharedSecret)>

Source

pub fn decapsulate( &self, secret_key: &SecretKey, ciphertext: &Ciphertext, ) -> Result<SharedSecret>

Source

pub fn ciphertext_from_bytes(&self, bytes: &[u8]) -> Result<Ciphertext>

Reconstruct a ciphertext from its serialized bytes.

Returns Error::InvalidLength if bytes is not exactly CIPHERTEXT_LEN bytes long.

Source

pub fn public_key_from_bytes(&self, bytes: &[u8]) -> Result<PublicKey>

Reconstruct a public key from its serialized bytes.

Returns Error::InvalidLength if bytes is not exactly PUBLIC_KEY_LEN bytes long.

Source

pub fn secret_key_from_bytes(&self, bytes: &[u8]) -> Result<SecretKey>

Reconstruct a secret key from its serialized bytes.

Returns Error::InvalidLength if bytes is not exactly SECRET_KEY_LEN bytes long.

Trait Implementations§

Source§

impl Default for FrodoKem

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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.