Skip to main content

qfall_math/integer_mod_q/
modulus_polynomial_ring_zq.rs

1// Copyright 2023 Marvin Beckmann
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//! [`ModulusPolynomialRingZq`] is the context object for
10//! [`PolynomialRingZq`](super::PolynomialRingZq).
11//! This implementation uses the [FLINT](https://flintlib.org/) library.
12
13use super::ntt_basis_polynomial_ring_zq::NTTBasisPolynomialRingZq;
14use crate::integer_mod_q::PolyOverZq;
15use std::rc::Rc;
16
17mod cmp;
18mod coefficient_embedding;
19mod from;
20mod get;
21mod norm;
22mod ntt_basis;
23mod ownership;
24mod serialize;
25mod set;
26mod to_string;
27
28/// [`ModulusPolynomialRingZq`] represents the modulus object for
29/// [`PolynomialRingZq`](crate::integer_mod_q::PolynomialRingZq).
30/// The underlying polynomials need to be monic, i.e. the leading coefficient needs to be `1`.
31///
32/// Attributes
33/// - `modulus`: holds the specific content, i.e. the modulus `q` and f(X)
34///
35/// # Examples
36/// ```
37/// use qfall_math::integer_mod_q::ModulusPolynomialRingZq;
38/// use qfall_math::integer_mod_q::PolyOverZq;
39/// use std::str::FromStr;
40///
41/// // initialize X^2 + 1 mod 17, i.e. a polynomial with modulus
42/// let poly_mod = PolyOverZq::from_str("3  1 0 1 mod 17").unwrap();
43/// let modulus = ModulusPolynomialRingZq::from(poly_mod);
44/// ```
45#[derive(Debug)]
46pub struct ModulusPolynomialRingZq {
47    pub(crate) modulus: Rc<PolyOverZq>,
48    pub(crate) ntt_basis: Rc<Option<NTTBasisPolynomialRingZq>>,
49    pub(crate) non_zero: Vec<usize>,
50}