Introduction
qFALL-math provides the fundamental arithmetic backend for the entire qFALL suite. It is a dedicated Rust crate engineered for fast, arbitrarily-precise number theory, specifically designed to meet the mathematical requirements of lattice-based cryptography.
Abstraction Layer
The primary purpose of qFALL-math is to function as a safe and idiomatic abstraction layer over the highly-optimized C library, FLINT (Fast Library for Number Theory).
By utilizing the FFI crate flint-sys, qFALL-math achieves two critical goals simultaneously:
- Performance: Leveraging FLINT’s battle-tested and highly-efficient algorithms for large number arithmetic.
- Safety & Usability: Taking over all responsibilities regarding manual memory management and unsafe C calls, wrapping them in idiomatic Rust interfaces. (See Safety Guarantees for more details.)
The core premise of this library is to provide a user-friendly interface that aligns closely with research notation, allowing for direct translation of cryptographic schemes while ensuring maximum efficiency and reliability. The underlying FFI can be updated or exchanged, if more up-to-date versions are desired.
Mathematical Scope
qFALL-math provides the required foundation for all subsequent cryptographic components in qFALL-tools and qFALL-schemes.
Its fundamentals include:
- Arbitrarily-Precise Integers: \(\mathbb{Z}\)
- Integers in the Quotient Ring: \(\mathbb{Z}_q\)
- Rationals: \(\mathbb{Q}\)
- Polynomial Rings over Quotients: \(\mathbb{Z}_q[X]/f(X)\)
These basic types are then extended to support more complex structures essential for lattice cryptography, such as polynomials, matrices, and matrices of polynomials.
In essence, qFALL-math black-boxes the complex, low-level behavior of FLINT and transforms it into a robust, memory-safe, and highly usable mathematical toolkit for the Rust ecosystem.
Safety Guarantees
In Rust, the memory management prevents memory leaks. The memory management of the underlying FLINT objects is abstracted away from the user and handled in a memory safe way. We have additional dedicated error handling that provides developers with more information when errors occur. These errors also differentiate different types of errors which should help while debugging.