qfall_math/
lib.rs

1// Copyright © 2023 Marcel Luca Schmidt, Niklas Siemer
2//
3// This file is part of qFALL-math.
4//
5// qFALL-math is free software: you can redistribute it and/or modify it under
6// the terms of the Mozilla Public License Version 2.0 as published by the
7// Mozilla Foundation. See <https://mozilla.org/en-US/MPL/2.0/>.
8
9//! `qFALL` is a prototyping library for lattice-based cryptography.
10//! `qFALL-math` yields the mathematical foundation by providing an easy to use, high-level API based on [FLINT](https://flintlib.org/)
11//! as well as several additional features often used in lattice-based cryptography.
12//! At a high level, it provides the following classes of datatypes:
13//! - Integer-based types such as [`Z`](integer::Z), [`MatZ`](integer::MatZ), [`PolyOverZ`](integer::PolyOverZ), [`MatPolyOverZ`](integer::MatPolyOverZ),
14//! - Residue Classes over Integers such as [`Zq`](integer_mod_q::Zq), [`MatZq`](integer_mod_q::MatZq), [`PolyOverZq`](integer_mod_q::PolyOverZq), [`PolynomialRingZq`](integer_mod_q::PolynomialRingZq), [`MatPolynomialRingZq`](integer_mod_q::MatPolynomialRingZq), [`NTTPolynomialRingZq`](integer_mod_q::NTTPolynomialRingZq), [`MatNTTPolynomialRingZq`](integer_mod_q::MatNTTPolynomialRingZq),
15//! - Rationals such as [Q](rational::Q), [`MatQ`](rational::MatQ), [`PolyOverQ`](rational::PolyOverQ).
16//!
17//! The `qFALL` project contains two more crates called [`qFALL-tools`](https://crates.io/crates/qfall-tools)
18//! and [`qFALL-schemes`](https://crates.io/crates/qfall-schemes) to support prototyping.
19//! - Find further information on [our website](https://qfall.github.io/).
20//! - We recommend [our tutorial](https://qfall.github.io/book) to start working with qFALL.
21//!
22//! ## Quick Example
23//! ```
24//! use qfall_math::{integer_mod_q::MatZq, integer::MatZ};
25//!
26//! let (n, m, q) = (256, 1024, 3329);
27//! let (center, sigma) = (0.0, 8.0);
28//!
29//! let mat_a = MatZq::sample_uniform(n, m, q);
30//! let vec_s = MatZ::sample_uniform(n, 1, 0, 2).unwrap();
31//! let vec_e = MatZ::sample_discrete_gauss(m, 1, center, sigma).unwrap();
32//!
33//! // SIS-Instance: t = A * e mod q
34//! let vec_t = &mat_a * &vec_e;
35//!
36//! // LWE-Instance: b^T = s^T * A + e^T mod q
37//! let vec_b = vec_s.transpose() * mat_a + vec_e.transpose();
38//! ```
39
40pub mod error;
41pub mod integer;
42pub mod integer_mod_q;
43pub mod rational;
44pub mod traits;
45pub mod utils;
46
47mod macros;