qfall / math

Library providing mathematical basics in Rust. The library is based on FLINT.
Mozilla Public License 2.0
20 stars 2 forks source link
cryptography math rust

qFALL-math

made-with-rust CI License: MPL 2.0

This repository is currently being developed by the project group qFALL - quantum resistant fast lattice library in the winter term 2022 and summer term 2023 by the Codes and Cryptography research group in Paderborn.

The main objective of this project is to develop a memory-safe and efficient usage of FLINT in Rust. Its main purpose is to use this library as a building block to build other projects on top of it.

Disclaimer

Currently, we are in the development phase and interfaces might change. Feel free to check out the current progress, but be aware, that the content will change in the upcoming weeks and months. An official release will most likely be published in the second half of 2024.

Quick-Start

Please refer to our website as a central information point.

To install and add our library to your project, please refer to our tutorial. It provides a step-by-step guide to install the required libraries and gives further insights into the usage of our crates.

What does qFALL-math offer?

Extensive documentation can be generated using

cargo doc               # suffix with --open to directly open the documentation

once the project is cloned. Following, there is a small overview containing the general types of our library qFALL-math.

math
├── ...
├── src
│   ├── integer         # src folder containing implementations of integers
│   ├── integer_mod_q   # src folder containing implementations of integers
│   │                   # for which a certain modulus is applied
│   └── rational        # src folder containing implementations of rationals
└── ...

Integers

use qfall_math::integer::Z;

let a = Z::from(24);
let b = Z::from(42);

let res_add: Z = &a + &b;
let res_sub: Z = a - 10;
let res_mul: Z = 3 * b;

Integers mod q

use qfall_math::integer_mod_q::Zq;
use qfall_math::integer_mod_q::Modulus;

let modulus = Modulus::from(24);
let a = Zq::from((42, &modulus));
let b = Zq::from((17, &modulus));

let res_add: Zq = &a + &b;
let res_sub: Zq = a - 10;
let res_mul: Zq = 3 * b;

Rationals

use qfall_math::rational::Q;

let a = Q::from((17, 19));
let b = Q::from(0.5);

let res_add: Q = &a + &b;
let res_sub: Q = a - 10.5;
let res_mul: Q = 3 * b;

External Libraries

This project uses the C-based, optimized math library FLINT. To use a C-library in Rust, there has to be an FFI (Foreign Function Interface) which allows to call the methods from FLINT in Rust. This project uses the crate flint-sys as a binding for FLINT. Furthermore, we utilized serde and serde_json to (de-)serialize objects to and from JSON. Last, but not least, our sampling algorithms heavily rely on the rand-crate. An extensive list can be found in our Cargo.toml file.

License

This library is distributed under the Mozilla Public License Version 2.0 which can be found here License. Permissions of this weak copyleft license are conditioned on making available the source code of licensed files and modifications of those files under the same license (or in certain cases, 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.

Citing

Please use the following bibtex entry to cite qFALL-math:

@software{Porzenheim_qFALL-math,
    author = {Porzenheim, Laurens and Beckmann, Marvin and Kramer, Paul and Milewski, Phil and Moog, Sven and Schmidt, Marcel and Siemer, Niklas},
    license = {MPL-2.0},
    title = {{qFALL-math}},
    url = {https://github.com/qfall/math}
}

Get in Touch

To contact us, please refer to our mailing list pg-qfall(at)lists.upb.de.