Skip to main content

Crate sntrup761

Crate sntrup761 

Source
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 sntrup761 parameter 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 (serde feature)

§Algorithm and References

§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 (DecapsulationKey or CompressedDecapsulationKey) 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.
CompressedDecapsulationKey
Compressed form of the decapsulation key (32-byte seed).
DecapsulationKey
Decapsulation (secret) key. Zeroized on drop.
EncapsulationKey
Encapsulation (public) key.
SharedSecret
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.