5 releases
0.1.4 | Jun 25, 2024 |
---|---|
0.1.3 | Jun 19, 2024 |
0.1.2 | Jun 19, 2024 |
0.1.1 | Jun 19, 2024 |
0.1.0 | Jun 19, 2024 |
#958 in Cryptography
195KB
3K
SLoC
enc_rust
About
A pure rust implementation of the Module-Lattice-based standards ML-KEM and (soon) ML-DSA, also known as the PQC scheme Crystals Kyber and Dilithium.
This package consists of a library (enc_rust
), and (soon :TM:) a binary wrapper. The library currently contains implementations for ML-KEM (Kyber), and will in the future also support ML-DSA (Dilithium).
Why enc_rust?
enc_rust aims to provide a secure, efficient, and ergonomic solution to any problem that requires quantum secure cryptography.
- No unsafe code
no_std
compatible- ergonomic
enc_rust currently supports ML-KEM as a sole mechanism, but will provide:
- ML-KEM in hybrid with x25519
- ML-DSA
- ML-DSA in hybrid with Ed25519
How to use
Install
cargo add enc_rust
or
cargo add --git https://github.com/supinie/enc_rust
.
Example
use enc_rust::kem::*;
fn alice(pk: PublicKey) -> (Ciphertext, [u8; 32]) {
let (ciphertext, shared_secret) = pk.encapsulate(None, None).unwrap();
(ciphertext, shared_secret)
}
fn bob(sk: PrivateKey, ciphertext: &[u8]) -> [u8; 32] {
let shared_secret = sk.decapsulate(ciphertext).unwrap();
shared_secret
}
fn main() {
let (pk, sk) = generate_keypair_768(None).unwrap();
let (ciphertext, alice_secret) = alice(pk);
let bob_secret = bob(sk, ciphertext.as_bytes());
assert_eq!(alice_secret, bob_secret);
}
Disclaimer
This library and binary wrapper is offered as-is, and without a guarantee. Please exercise caution when using this library in a production application, and we accept no liability for any security issues related to the use of this code.
Kyber Algorithm Authors:
- Roberto Avanzi, ARM Limited (DE)
- Joppe Bos, NXP Semiconductors (BE)
- Léo Ducas, CWI Amsterdam (NL)
- Eike Kiltz, Ruhr University Bochum (DE)
- Tancrède Lepoint, SRI International (US)
- Vadim Lyubashevsky, IBM Research Zurich (CH)
- John M. Schanck, University of Waterloo (CA)
- Peter Schwabe, MPI-SP (DE) & Radboud University (NL)
- Gregor Seiler, IBM Research Zurich (CH)
- Damien Stehle, ENS Lyon (FR)
Dependencies
~2.4–3.5MB
~54K SLoC