Skip to main content

KemAlgorithm

Enum KemAlgorithm 

Source
pub enum KemAlgorithm {
    MlKem512,
    MlKem768,
    MlKem1024,
    HybridX25519MlKem768,
    XWing,
    Hqc128,
    Hqc192,
    Hqc256,
    Bike,
    ClassicMceliece,
}
Expand description

Identifies the KEM algorithm used.

Variants§

§

MlKem512

ML-KEM-512 (NIST FIPS 203, Security Level 1)

§

MlKem768

ML-KEM-768 (NIST FIPS 203, Security Level 3) — recommended default

§

MlKem1024

ML-KEM-1024 (NIST FIPS 203, Security Level 5)

§

HybridX25519MlKem768

Hybrid: X25519 + ML-KEM-768 — primary construction (profile v1, HYBRID_PROFILE_V1; see docs/hybrid-profiles.md)

§

XWing

X-Wing: X25519 + ML-KEM-768, per draft-connolly-cfrg-xwing-kem (profile v2, HYBRID_PROFILE_V2) — same component KEMs as KemAlgorithm::HybridX25519MlKem768, different combiner and byte layout (ML-KEM first). Recommended for new deployments; see docs/hybrid-profiles.md. Added 0.3.0.

§

Hqc128

HQC-128 (NIST 2025, Security Level 1) — requires hqc feature

§

Hqc192

HQC-192 (NIST 2025, Security Level 3) — requires hqc feature

§

Hqc256

HQC-256 (NIST 2025, Security Level 5) — requires hqc feature

§

Bike

👎Deprecated since 0.3.0:

BIKE was never implemented; the bike feature/module were removed in 0.3.0. This variant is kept only for wire compatibility and will be removed in 0.4.0.

BIKE (NIST Round 4 alternate) — never implemented in this crate.

The bike feature and src/bike module (a permanent compile_error! stub) were removed entirely in 0.3.0. This variant is retained only so previously-serialized values (e.g. "bike" in JSON) continue to deserialize without error; it carries no working implementation in any release and never did. Scheduled for removal in 0.4.0 per STABILITY.md §3’s one-minor-version deprecation floor.

§

ClassicMceliece

👎Deprecated since 0.3.0:

Classic McEliece was never implemented; the mceliece feature/module were removed in 0.3.0. This variant is kept only for wire compatibility and will be removed in 0.4.0.

Classic McEliece (NIST Round 4 alternate) — never implemented in this crate.

The mceliece feature and src/mceliece module (a permanent compile_error! stub) were removed entirely in 0.3.0. This variant is retained only so previously-serialized values (e.g. "classic_mceliece" in JSON) continue to deserialize without error; it carries no working implementation in any release and never did. Scheduled for removal in 0.4.0 per STABILITY.md §3’s one-minor-version deprecation floor.

Implementations§

Source§

impl KemAlgorithm

Source

pub fn as_str(&self) -> &'static str

Returns the algorithm identifier string (for DID Documents, JWK, etc.)

Source

pub fn public_key_size(&self) -> usize

Returns the expected public key size in bytes (0 = variable).

Source

pub fn ciphertext_size(&self) -> usize

Returns the expected ciphertext size in bytes (0 = variable).

HQC-128/256 sizes were corrected from 4481/14469 to 4433/14421 bytes during the P2/alpha-001 HQC implementation pass — verified live against both pqcrypto-hqc 0.2.2 and liboqs 0.13.0 (two independent implementations of the same NIST submission, which agree). HQC-192’s 8978-byte ciphertext was already correct. This reflects the HQC round-4/2023 parameter revision to the error-correcting code, which changed ciphertext size at the 128- and 256-bit levels but not the 192-bit level.

Source

pub fn shared_secret_size(&self) -> usize

Returns the shared secret size in bytes (always 32 for all supported algorithms).

Trait Implementations§

Source§

impl Clone for KemAlgorithm

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 Copy for KemAlgorithm

Source§

impl Debug for KemAlgorithm

Source§

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

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

impl<'de> Deserialize<'de> for KemAlgorithm

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for KemAlgorithm

Source§

impl PartialEq for KemAlgorithm

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 Serialize for KemAlgorithm

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for KemAlgorithm

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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