Crate ntru [−] [src]
This crate implements the NTRUEncrypt 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 NTRUEncrypt implementation. In any case, it is much faster than usual encryption / decryption mecanisms, and quantum-proof. More on NTRUEncrypt here.
To use it you only need to include the following in your crate:
extern crate ntru;
NTRUEncrypt uses its own keys, that must be generated with the included random key generator, and must not be used for other applications such as NTRUSign 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 |
NTRUEncrypt Encryption parameters |
rand |
Rand module |
types |
NTRUEncrypt type definitions |
Macros
if_ntru_sse3! |
Execute if SSE support |
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 |