simple-ring 0.1.0

Educational implementation of polynomial rings, NTT, and coefficient sampling for lattice-based cryptography
Documentation
  • Coverage
  • 0%
    0 out of 38 items documented0 out of 26 items with examples
  • Size
  • Source code size: 29.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.08 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • VRAM-RAM

simple-ring : Simple implementation of mathematical primitives for LWE-based crypto in Rust

simple-ring provides mathematical primitives, such as NTT or Polynomials, but also coefficient sampling for LWE-based schemes. For more informations and explanations, please see /docs/simple-ring.pdf.

Warning

This code isn’t audited, isn’t intended for production use, and is vulnerable to timing-based attacks.

Quick start

To use it, simply do :

cargo add simple-ring

Then, in your code, you can use it as you want :

use simple_ring::*;

fn main() {
    let parameters = RingParams::new(4, 17, find_valid_omega(4, 17));
    let ntt_tables = &precalculate(&parameters);
    let first_polynomial = Polynomial::new(vec![8u64; 4]);
    let mut second_coeffs = vec![9u64; 4];
    second_coeffs[3] = 1;
    let second_polynomial = Polynomial::new(second_coeffs);
    let mul = first_polynomial.mul_ntt(&parameters, ntt_tables, &second_polynomial);
    let mul2 = first_polynomial.mul(&parameters, &second_polynomial);
    println!("The result of the mul is : {:?}", mul2);
    println!("The result of the mul ntt is : {:?}", mul);
    let ntt_first = forward_ntt(&parameters, &first_polynomial, ntt_tables);
    println!("First polynomial in NTT domain is {:?}", ntt_first);
    let sample = generate_small_sample(&parameters);
    println!("Sample is {:?}", sample);
}

Tests & modifications

To run the tests, or modify the code, you can git clone the repo, and then run the tests or do any modification you want :

cargo test --release -- --nocapture

License

This code is licensed under the same license as simple-crypto-lab, so under MIT or APACHE 2.0 License, your choice.