Skip to content
forked from qfall/math

Library providing mathematical basics in Rust. The library is based on FLINT.

License

Notifications You must be signed in to change notification settings

MoogSven/math-test

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 be published in the second half of 2023.

Installation

In order to use this project one needs to have an installation of Rust. Since we are using flint-sys which itself uses gmp, we are currently restricted to usage on Mac, Linux and Linux subsystems under Windows. For a subsystem under Windows, one additionally is required to have installed m4 and a C-compiler.

Since our project isn't yet published there is no option to find it on Rust's library collection on crates.io. If you want to include this project in your own Rust project, you can include a link to our version on the dev branch in your Cargo.toml.

qfall-math = { git = "https://github.com/qfall/math", branch="dev" }

Be aware that the external libraries in our project have to be compiled at the first installation, which may take about 30 minutes. After the first installation it should be working fine.

What does qFALL-math offer?

An extensive documentation can be generated using

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

once the project is cloned. Following, find 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

  • Z: Represents $\mathbb Z$
  • MatZ: Represents matrices of $\mathbb Z$
  • PolyOverZ: Represents polynomials with coefficients over $\mathbb Z$
  • MatPolyOverZ: Represents matrices of polynomials with coefficients over $\mathbb Z$
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 - b;
let res_mul: Z = a * b;

Integers mod q

  • Zq: Represents $\mathbb Z_q$
  • MatZq: Represents matrices of $\mathbb Z_q$
  • PolyOverZq: Represents polynomials with coefficients over $\mathbb Z_q$
  • PolynomialRingZq: Represents quotient rings of $\mathbb Z_q[X]/f(X)$ where $q$ is prime and $f(X)$ is a PolyOverZq.
use qfall_math::integer_mod_q::Zq;
use qfall_math::integer_mod_q::Modulus;

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

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

Rationals

  • Q: Represents $\mathbb Q$
  • MatQ: Represents matrices of $\mathbb Q$
  • PolyOverQ: Represents polynomials with coefficients over $\mathbb Q$
use qfall_math::rational::Q;

let a = Q::try_from((17, 19)).unwrap();
let b = Q::try_from((42, 24)).unwrap();

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

External Libraries

This project uses the C-based, optimized math library FLINT. In order 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. Last, but not least, we utilized serde and serde_json to (de-)serialize objects to and from JSON. 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 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 in the larger work.

Citing

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

@misc{qFALL-math,
    author = {Porzenheim, Laurens and Beckmann, Marvin and Kramer, Paul and Milewski, Phil and Moog, Sven and Schmidt, Marcel and Siemer, Niklas}
    title = {qFALL-math v0.0},
    howpublished = {Online: \url{https://github.com/qfall/math}},
    month = Mar,
    year = 2023,
    note = {University Paderborn,  Codes and Cryptography}
}

Get in Touch

One can contact the members of the project group with our mailing list pg-qfall(at)lists.upb.de.

About

Library providing mathematical basics in Rust. The library is based on FLINT.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%