Skip to content

Commit

Permalink
Use ML-KEM 512 in doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneider-bensch committed Oct 21, 2024
1 parent d2ad709 commit c56dd15
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions libcrux-ml-kem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
Functions in this crate use CPU feature detection to pick the most efficient version
on each platform. To use a specific version with your own feature detection
use e.g. one of the following
- `mlkem768::avx2::generate_key_pair`,
- `mlkem768::neon::generate_key_pair`,
- `mlkem768::portable::generate_key_pair`,
- `mlkem512::avx2::generate_key_pair`,
- `mlkem512::neon::generate_key_pair`,
- `mlkem512::portable::generate_key_pair`,
analogously for encapsulation and decapsulation."##
)]
#![cfg_attr(
feature = "mlkem768",
feature = "mlkem512",
doc = r##"
```
use rand::{rngs::OsRng, RngCore};
Expand All @@ -35,22 +35,22 @@ analogously for encapsulation and decapsulation."##
use libcrux_ml_kem::*;
// This example uses ML-KEM 768. The other variants can be used the same way.
// This example uses ML-KEM 512. The other variants can be used the same way.
// Generate a key pair.
let key_pair = {
let randomness = random_array();
mlkem768::generate_key_pair(randomness)
mlkem512::generate_key_pair(randomness)
};
// Encapsulating a shared secret to a public key.
let (ciphertext, shared_secret) = {
let randomness = random_array();
mlkem768::encapsulate(key_pair.public_key(), randomness)
mlkem512::encapsulate(key_pair.public_key(), randomness)
};
// Decapsulating a shared secret with a private key.
let shared_secret_decapsulated = mlkem768::decapsulate(key_pair.private_key(), &ciphertext);
let shared_secret_decapsulated = mlkem512::decapsulate(key_pair.private_key(), &ciphertext);
assert_eq!(shared_secret_decapsulated, shared_secret);
```"##
Expand Down

0 comments on commit c56dd15

Please sign in to comment.