Skip to content

qfall/tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qFALL-tools

github crates.io docs.rs tutorial build license

qFALL is a prototyping library for lattice-based cryptography. This tools-crate collects common sub-modules and features used by lattice-based constructions to simplify and accelerate the development of such.

Quick-Start

First, ensure that you use a Unix-like distribution (Linux or MacOS). Setup WSL if you're using Windows. This is required due to this crate's dependency on FLINT. Then, make sure your rustc --version is 1.85 or newer.

Furthermore, it's required that m4, a C-compiler such as gcc, and make are installed.

sudo apt-get install m4 gcc make

Then, add you can add this crate to your project by executing the following command.

cargo add qfall-tools

What does qFALL-tools offer?

qFALL-tools offers several commonly used sub-modules specific to lattice-based cryptography.

Furthermore, this crate simplifies the implementation of your prototype by supporting a range of utility functions to quickly instantiate commonly used moduli, rotation matrices, and encodings.

Quick Examples

From String to Encoding for Encryption

use qfall_tools::utils::{common_moduli::new_anticyclic, common_encodings::encode_value_in_polynomialringzq};
use qfall_math::integer::Z;

// Create X^256 + 1 mod 3329
let poly_mod = new_anticyclic(256, 3329).unwrap();
// Generate integer from string
let message = Z::from_utf8("Hello!");
// Turn string into encoding q/2 and 0 for each 1 and 0 bit respectively
let mu_q_half = encode_value_in_polynomialringzq(message, 2, &poly_mod).unwrap();

Preimage Sampling using a PSF

use qfall_tools::primitive::psf::{PSF, PSFPerturbation};
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParameters;
use qfall_math::rational::Q;

let psf = PSFPerturbation {
    gp: GadgetParameters::init_default(8, 64),
    r: Q::from(3),
    s: Q::from(25),
};

// Generate matrix A with a trapdoor
let (a, td) = psf.trap_gen();
// Choose a random target
let domain_sample = psf.samp_d();
let target = psf.f_a(&a, &domain_sample);
// Sample a preimage for the given target
let preimage = psf.samp_p(&a, &td, &target);

assert!(psf.check_domain(&preimage));
assert_eq!(a * preimage, target);

Bugs

Please report bugs through the GitHub issue tracker.

Contributions

Contributors are:

  • Marvin Beckmann
  • Jan Niklas Siemer

See Contributing for details on how to contribute.

Citing

Please use the following bibtex entry to cite qFALL.

TODO: Update to eprint

Dependencies

This project is based on qfall-math, which builds on top of the C-based, optimised math-library FLINT. We utilise serde and serde_json to (de-)serialize objects to and from JSON. This crate relies on criterion for benchmarking purposes. An extensive list can be found in our Cargo.toml file.

License

This library is distributed under the Mozilla Public License Version 2.0. Permissions of this weak copyleft license are conditioned on making the source code of licensed files and modifications of those files available under the same license (or in certain cases, under one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added to the larger work.

About

Common sub-modules and procedures in lattice-based constructions

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6

Languages