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.
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 makeThen, add you can add this crate to your project by executing the following command.
cargo add qfall-tools- Find further information on our website. Also check out
qfall-mathandqfall-schemes. - Read the documentation of this crate.
- We recommend our tutorial to start working with qFALL.
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.
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);Please report bugs through the GitHub issue tracker.
Contributors are:
- Marvin Beckmann
- Jan Niklas Siemer
See Contributing for details on how to contribute.
Please use the following bibtex entry to cite qFALL.
TODO: Update to eprint
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.
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.