kyber_kem/lib.rs
1/* This file is part of Kyber-KEM (https://github.com/parazyd/kyber-kem)
2 *
3 * Copyright (C) 2023-2024 Dyne.org foundation
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19//! Implementation of the [Kyber](https://pq-crystals.org/kyber) IND-CCA2
20//! secure key encapsulation mechanism (KEM)
21//!
22//! **Example usage:**
23//~
24//! ```rust
25//! use rand::rngs::OsRng;
26//! use kyber_kem::{kem_keypair_1024, kem_encrypt_1024, kem_decrypt_1024};
27//!
28//! let (secret_key, public_key) = kem_keypair_1024(&mut OsRng);
29//! let (ciphertext, shared_secret) = kem_encrypt_1024(public_key, &mut OsRng);
30//! let dec_shared_secret = kem_decrypt_1024(ciphertext, secret_key);
31//! assert_eq!(shared_secret, dec_shared_secret);
32//! ```
33
34/// Library constants
35pub mod params;
36
37/// Byte operations
38mod byteops;
39
40/// IND-CPA operations
41mod indcpa;
42
43/// Number-theoretic transforms
44mod ntt;
45
46/// Polynomial operations
47mod poly;
48
49/// Kyber IND-CCA2-secure key encapsulation mechanism (KEM)
50mod kem;
51pub use kem::{kem_decrypt_1024, kem_decrypt_512, kem_decrypt_768};
52pub use kem::{kem_encrypt_1024, kem_encrypt_512, kem_encrypt_768};
53pub use kem::{kem_keypair_1024, kem_keypair_512, kem_keypair_768};
54
55#[cfg(test)]
56mod tests;