This repository presents an implementation of high-security prime-degree large-Galois-group inert-modulus ideal-lattice-based cryptography on rust programing langudge. “Prime degree” etc. are defenses against potential attacks; see official website.
This implementation uses: Fields of the form (Z/q)[x]/(xp −x−1), where p is prime, are used in “NTRU Prime”, introduced in this paper, and have all of our recommended defenses.
bash
cargo add ntrulp
bash
cargo test
bash
cargo bench
```rust const P: usize = 761; const W: usize = 286; const Q: usize = 4591; const Q12: usize = (Q - 1) / 2; const PPLUSONE: usize = P + 1; const RQBYTES: usize = 1158; const PTWICEMINUSONE: usize = P + P - 1; const ROUNDED_BYTES: usize = 1007;
let mut rng = rand::threadrng(); let randlen = rng.genrange(5..10000); let mut ntrup = NTRUPrime::
::new()
.unwrap();
let bytes: Vec
ntrup.keypairgen().unwrap();
let (pk, ) = ntrup.keypair.export_pair().unwrap();
let encrypted = ntrup.encrypt(&bytes, &pk).unwrap(); let decrypted = ntrup.decrypt(encrypted).unwrap();
assert_eq!(decrypted, bytes); ```
This implementation has not undergone any security auditing and while care has been taken no guarantees can be made for either correctness or the constant time running of the underlying functions. Please use at your own risk.