Expand description
§sntrup761
This crate provides a pure-Rust implementation of the Streamlined NTRU Prime 761 post-quantum key encapsulation mechanism (KEM). Streamlined NTRU Prime is a lattice-based, quantum-resistant cryptographic algorithm designed for secure key exchange and public-key encryption.
§Features
- Pure Rust,
no_std-compatible, and dependency-minimal - Implements the NTRU Prime
sntrup761parameter set (as submitted for standardization to NIST) - Simple API for key generation, encapsulation, and decapsulation
- Zeroizes secret key material on drop
- Optional Serde support for key and ciphertext serialization (
serdefeature)
§Algorithm and References
- NTRU Prime: Stronger and Simpler Public Key Cryptography, by D.J. Bernstein, Ch. Chuengsatiansup, T. Lange, and C. van Vredendaal
- NTRUEncrypt Algorithm Description
- sntrup761 official specification
- PQClean reference implementation (C)
§Example Usage
use sntrup761::*;
// Key generation
let (pk, sk) = generate_key(rand::rng());
// Key encapsulation
let (ct, ss_sender) = pk.encapsulate(rand::rng());
// Key decapsulation
let ss_receiver = sk.decapsulate(&ct);
assert!(ss_sender == ss_receiver);§Use Cases
- Post-quantum TLS key exchange (e.g., hybrid modes)
- Encrypted messaging systems requiring quantum resistance
- Secure session key establishment
§Security Notes
- Always keep your secret keys (
DecapsulationKeyorCompressedDecapsulationKey) confidential! - This implementation aims to be constant-time, but always use the latest version and audit for updates.
- For more details, see the NTRU Prime design page.
Re-exports§
pub use rand;pub use rand_chacha;pub use sha2;pub use subtle;
Structs§
- Ciphertext
- Ciphertext produced by encapsulation.
- Compressed
Decapsulation Key - Compressed form of the decapsulation key (32-byte seed).
- Decapsulation
Key - Decapsulation (secret) key. Zeroized on drop.
- Encapsulation
Key - Encapsulation (public) key.
- Shared
Secret - Shared secret established by encapsulation/decapsulation. Zeroized on drop.
Enums§
- Error
- Errors returned by sntrup761 operations.
Constants§
- CIPHERTEXT_
SIZE - Size in bytes of a serialized ciphertext.
- PUBLIC_
KEY_ SIZE - Size in bytes of a serialized public key.
- SECRET_
KEY_ SIZE - Size in bytes of a serialized secret (decapsulation) key.
- SHARED_
SECRET_ SIZE - Size in bytes of a shared secret.
Functions§
- generate_
key - Generates a public and private keypair.
- generate_
key_ from_ seed - Generates a deterministic keypair from a 32-byte seed.