Crate ntru [] [src]

This crate implements the NTRU encryption library in Rust. It is an interface to libntru, even though many of the methods are being implemented in pure Rust. The plan is to gradually implement the library natively. It uses this library since it has proven to be faster than the original NTRU encryption implementation. In any case, it is much faster than usual encryption / decryption mecanisms, and quantum-proof. More on NTRU encryption here.

To use it you only need to include the following in your crate:

extern crate ntru;

NTRU encryption uses its own keys, that must be generated with the included random key generator, and must not be used for other applications such as NTRU signing or NTRUNMLS.

Examples

use ntru::rand::RNG_DEFAULT;
use ntru::encparams::DEFAULT_PARAMS_256_BITS;

let rand_ctx = ntru::rand::init(&RNG_DEFAULT).unwrap();
let kp = ntru::generate_key_pair(&DEFAULT_PARAMS_256_BITS, &rand_ctx).unwrap();

This creates a key pair that can be uses to encrypt and decrypt messages:

use ntru::encparams::DEFAULT_PARAMS_256_BITS;

let msg = b"Hello from Rust!";
let encrypted = ntru::encrypt(msg, kp.get_public(), &DEFAULT_PARAMS_256_BITS,
                              &rand_ctx).unwrap();
let decrypted = ntru::decrypt(&encrypted, &kp, &DEFAULT_PARAMS_256_BITS).unwrap();

assert_eq!(&msg[..], &decrypted[..]);

Modules

encparams

NTRU encryption parameters

rand

Rand module

types

NTRU type definitions

Functions

decrypt

Decrypts a message.

encrypt

Encrypts a message

generate_key_pair

Key generation

generate_multiple_key_pairs

Key generation with multiple public keys

generate_public

New public key