Crates.io | enc_rust |
lib.rs | enc_rust |
version | 0.1.4 |
source | src |
created_at | 2024-06-19 15:17:01.923722 |
updated_at | 2024-06-25 19:05:01.92732 |
description | 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. |
homepage | |
repository | https://github.com/supinie/enc_rust |
max_upload_size | |
id | 1276989 |
size | 290,294 |
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).
enc_rust aims to provide a secure, efficient, and ergonomic solution to any problem that requires quantum secure cryptography.
no_std
compatibleenc_rust currently supports ML-KEM as a sole mechanism, but will provide:
cargo add enc_rust
or
cargo add --git https://github.com/supinie/enc_rust
.
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);
}
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.