Crate libcrux_kem

Crate libcrux_kem 

Source
Expand description

§Key Encapsulation Mechanism

A KEM interface.

For ECDH structs, check the libcrux_ecdh crate.

Available algorithms:

use libcrux_kem::*;
use rand::TryRngCore;
use rand::rngs::OsRng;

let mut os_rng = OsRng;
let mut rng = os_rng.unwrap_mut();

let (sk_a, pk_a) = key_gen(Algorithm::MlKem768, &mut rng).unwrap();
let received_pk = pk_a.encode();

let pk = PublicKey::decode(Algorithm::MlKem768, &received_pk).unwrap();
let (ss_b, ct_b) = pk.encapsulate(&mut rng).unwrap();
let received_ct = ct_b.encode();

let ct_a = Ct::decode(Algorithm::MlKem768, &received_ct).unwrap();
let ss_a = ct_a.decapsulate(&sk_a).unwrap();
assert_eq!(ss_b.encode(), ss_a.encode());

Structs§

MlKem512
The ML-KEM 512 algorithms
MlKem768
The ML-KEM 768 algorithms
MlKem1024
The ML-KEM 1024 algorithms
MlKemCiphertext
An ML-KEM Ciphertext
MlKemKeyPair
An ML-KEM key pair
P256
X25519
X25519MlKem768Draft00PrivateKey
An ML-KEM768-x25519 private key.
X25519MlKem768Draft00PublicKey
An ML-KEM768-x25519 public key.
XWing
XWingKemDraft06PrivateKey
An X-Wing private key.
XWingKemDraft06PublicKey
An X-Wing public key.

Enums§

Algorithm
KEM Algorithms
Ct
A KEM ciphertext
Error
PrivateKey
A KEM private key.
PublicKey
A KEM public key.
Ss
A KEM shared secret

Functions§

key_gen
Generate a key pair for the Algorithm using the provided rng.
key_gen_derand
Generate a key pair for the Algorithm using the provided rng.
secret_to_public
Compute the public key for a private key of the given Algorithm. Applicable only to X25519 and secp256r1.

Type Aliases§

MlKem512Ciphertext
An ML-KEM 512 Ciphertext
MlKem512PrivateKey
An ML-KEM 512 Private key
MlKem512PublicKey
An ML-KEM 512 Public key
MlKem768Ciphertext
An ML-KEM 768 Ciphertext
MlKem768PrivateKey
An ML-KEM 768 Private key
MlKem768PublicKey
An ML-KEM 768 Public key
MlKem1024Ciphertext
An ML-KEM 1024 Ciphertext
MlKem1024PrivateKey
An ML-KEM 1024 Private key
MlKem1024PublicKey
An ML-KEM 1024 Public key