pub struct MLKEM768X25519;Expand description
MLKEM768-X25519 hybrid post-quantum KEM (ML-KEM-768 with X25519), as
specified in draft-ietf-hpke-pq-05.
This is the same construction as X-Wing (draft-connolly-cfrg-xwing-kem),
as noted in draft-irtf-cfrg-concrete-hybrid-kems-03 Section 4.2.
MLKEM768-X25519 is usable with the Base and pre-shared key modes of HPKE.
draft-ietf-hpke-hpke-05 removed the authenticated modes, so no KEM is
required to provide AuthEncap/AuthDecap; for sender authentication, sign
the (encapped_key, ciphertext) tuple instead.
The KEM identifier is 0x647a, as registered by the draft in the IANA
“HPKE KEM Identifiers” registry.
§Key encoding
A secret key is the 32-byte X-Wing seed: Kem::secret_key_to_bytes
returns that seed, and Kem::secret_key_from_bytes takes it and
re-derives the full key pair (recomputing the public key). The seed is
therefore the entire secret; treat it as such.
§Example
use hpke::kem::{Kem, MLKEM768X25519};
let (secret_key, public_key) = MLKEM768X25519::generate_keypair().unwrap();
let (shared_secret, encapped_key) = MLKEM768X25519::encap(&public_key).unwrap();
let decapsulated = MLKEM768X25519::decap(&encapped_key, &secret_key).unwrap();
assert_eq!(shared_secret.as_ref(), decapsulated.as_ref());Trait Implementations§
Source§impl Clone for MLKEM768X25519
impl Clone for MLKEM768X25519
impl Copy for MLKEM768X25519
Source§impl Debug for MLKEM768X25519
impl Debug for MLKEM768X25519
impl Eq for MLKEM768X25519
Source§impl Kem for MLKEM768X25519
impl Kem for MLKEM768X25519
Source§const HPKE_KEM_ID: u16 = 0x647a
const HPKE_KEM_ID: u16 = 0x647a
draft-ietf-hpke-hpke-05 Section 7.1, IANA “HPKE KEM
Identifiers”), used to build the ciphersuite suite_id.Source§const SHARED_SECRET_SIZE: usize = crypto::xwing::SHARED_SECRET_SIZE
const SHARED_SECRET_SIZE: usize = crypto::xwing::SHARED_SECRET_SIZE
Source§const ENCAPPED_KEY_SIZE: usize = crypto::xwing::CIPHERTEXT_SIZE
const ENCAPPED_KEY_SIZE: usize = crypto::xwing::CIPHERTEXT_SIZE
Source§const PUBLIC_KEY_SIZE: usize = crypto::xwing::PUBLIC_KEY_SIZE
const PUBLIC_KEY_SIZE: usize = crypto::xwing::PUBLIC_KEY_SIZE
Source§const SECRET_KEY_SIZE: usize = crypto::xwing::SECRET_KEY_SIZE
const SECRET_KEY_SIZE: usize = crypto::xwing::SECRET_KEY_SIZE
Source§const RANDOMNESS_SIZE: usize = 64
const RANDOMNESS_SIZE: usize = 64
Kem::encap_deterministic. Read moreSource§type EncappedKey = [u8; 1120]
type EncappedKey = [u8; 1120]
Source§fn derive_keypair(
input_keying_material: &[u8],
) -> Result<(Self::SecretKey, Self::PublicKey), HpkeError>
fn derive_keypair( input_keying_material: &[u8], ) -> Result<(Self::SecretKey, Self::PublicKey), HpkeError>
Source§fn generate_keypair() -> Result<(Self::SecretKey, Self::PublicKey), HpkeError>
fn generate_keypair() -> Result<(Self::SecretKey, Self::PublicKey), HpkeError>
Source§fn derive_public_key(secret_key: &Self::SecretKey) -> Self::PublicKey
fn derive_public_key(secret_key: &Self::SecretKey) -> Self::PublicKey
Source§fn public_key_to_bytes(
out: &mut [u8],
public_key: &Self::PublicKey,
) -> Result<(), HpkeError>
fn public_key_to_bytes( out: &mut [u8], public_key: &Self::PublicKey, ) -> Result<(), HpkeError>
Source§fn public_key_from_bytes(bytes: &[u8]) -> Result<Self::PublicKey, HpkeError>
fn public_key_from_bytes(bytes: &[u8]) -> Result<Self::PublicKey, HpkeError>
bytes, which must be exactly
Kem::PUBLIC_KEY_SIZE bytes long and a valid, fully validated public key. Read moreSource§fn secret_key_to_bytes(
out: &mut [u8],
secret_key: &Self::SecretKey,
) -> Result<(), HpkeError>
fn secret_key_to_bytes( out: &mut [u8], secret_key: &Self::SecretKey, ) -> Result<(), HpkeError>
Source§fn secret_key_from_bytes(bytes: &[u8]) -> Result<Self::SecretKey, HpkeError>
fn secret_key_from_bytes(bytes: &[u8]) -> Result<Self::SecretKey, HpkeError>
bytes, which must be exactly
Kem::SECRET_KEY_SIZE bytes long. Read moreSource§fn encapped_key_to_bytes(
out: &mut [u8],
encapped_key: &Self::EncappedKey,
) -> Result<(), HpkeError>
fn encapped_key_to_bytes( out: &mut [u8], encapped_key: &Self::EncappedKey, ) -> Result<(), HpkeError>
out, which must be exactly
Kem::ENCAPPED_KEY_SIZE bytes long. Read moreSource§fn encapped_key_from_bytes(bytes: &[u8]) -> Result<Self::EncappedKey, HpkeError>
fn encapped_key_from_bytes(bytes: &[u8]) -> Result<Self::EncappedKey, HpkeError>
bytes, which must be exactly
Kem::ENCAPPED_KEY_SIZE bytes long. Read moreSource§fn encap(
recipient_public_key: &Self::PublicKey,
) -> Result<(Hash, Self::EncappedKey), HpkeError>
fn encap( recipient_public_key: &Self::PublicKey, ) -> Result<(Hash, Self::EncappedKey), HpkeError>
recipient_public_key using a freshly
generated ephemeral key pair. Read moreSource§fn encap_deterministic(
recipient_public_key: &Self::PublicKey,
randomness: &[u8],
) -> Result<(Hash, Self::EncappedKey), HpkeError>
fn encap_deterministic( recipient_public_key: &Self::PublicKey, randomness: &[u8], ) -> Result<(Hash, Self::EncappedKey), HpkeError>
recipient_public_key from caller-provided
randomness (EncapDerand). Read moreSource§fn encap_with_ephemeral(
ephemeral_secret_key: &Self::SecretKey,
recipient_public_key: &Self::PublicKey,
) -> Result<(Hash, Self::EncappedKey), HpkeError>
fn encap_with_ephemeral( ephemeral_secret_key: &Self::SecretKey, recipient_public_key: &Self::PublicKey, ) -> Result<(Hash, Self::EncappedKey), HpkeError>
recipient_public_key, using the given ephemeral
secret key ephemeral_secret_key. Read more