- Rust 100%
| examples | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
| rustfmt.toml | ||
gwrizienn
Modular arithmetic, polynomial quotient rings in Rust.
Goals:
- Easy to use, obvious when you look at the documentation and type system
- Fast, most possible work is done at compile time
- All the math you need for implementing cryptographic schemes such as Dilithium
Non-goals:
- Generic (it's generic but only for primitive types)
- Complete (it's simple because it's not a complete implementation of modern algebra)
- Dynamic (vector dimensions and moduli are strongly typed)
- Footgun-free (if you give incoherent arguments to the macros, it may produce unsafe code)
Supported:
- ring Zq
- ring Zq/(x^N+1) with additive operations
- ring Zq/(x^N+1) with multiplicative operations if q=p or q=2p with p prime and 2N divides p-1
- vectors and matrices of the above rings
- lift between different rings (see example ntwe) (lifting may lack some features or be unsafe)
Warning: There are some TODOs in the code. The code has not been audited nor proven. Please don't use it in production yet.
Why
When implementing Dilithium and other similar lattice-based schemes, I found no crate that was both easy and fast, so I made one with the exact set of features I needed.
Name
Pronounce grizienn. It's Breton for "root", because we use roots of unity to compute the NTT for faster O(N log N) polynomial multiplication.
License
GNU AGPL v3, CopyLeft 2025-2026 Pascal Engélibert (why copyleft?)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.