pub struct Poly64 {
pub data: Vec<u64>,
pub is_ntt: bool,
}Expand description
Polynomial in R_q = Z_q[X]/(X^N + 1) with 64-bit coefficients.
Tracks whether the data is in coefficient domain or NTT (evaluation) domain. In NTT domain, multiplication is pointwise (O(N) instead of O(N²)).
Fields§
§data: Vec<u64>Coefficients (coefficient domain) or evaluations (NTT domain).
is_ntt: booltrue if the polynomial is in NTT (evaluation) domain.
Implementations§
Source§impl Poly64
impl Poly64
Sourcepub fn forward_ntt(&mut self, ntt_ctx: &Ntt64Context)
pub fn forward_ntt(&mut self, ntt_ctx: &Ntt64Context)
Converts from coefficient domain to NTT domain (in-place).
§Panics
Panics if the polynomial is already in NTT domain.
Sourcepub fn inverse_ntt(&mut self, ntt_ctx: &Ntt64Context)
pub fn inverse_ntt(&mut self, ntt_ctx: &Ntt64Context)
Converts from NTT domain to coefficient domain (in-place).
§Panics
Panics if the polynomial is not in NTT domain.
Sourcepub fn add_assign(&mut self, other: &Poly64, arith: &Ntt64Arith)
pub fn add_assign(&mut self, other: &Poly64, arith: &Ntt64Arith)
Pointwise addition: self += other (mod q).
Both polynomials must be in the same domain (NTT or coefficient).
§Panics
Panics if domains or sizes don’t match.
Sourcepub fn sub_assign(&mut self, other: &Poly64, arith: &Ntt64Arith)
pub fn sub_assign(&mut self, other: &Poly64, arith: &Ntt64Arith)
Pointwise subtraction: self -= other (mod q).
Both polynomials must be in the same domain.
§Panics
Panics if domains or sizes don’t match.
Sourcepub fn mul_assign(&mut self, other: &Poly64, arith: &Ntt64Arith)
pub fn mul_assign(&mut self, other: &Poly64, arith: &Ntt64Arith)
Pointwise multiplication: self *= other (mod q).
Both polynomials must be in NTT domain so that pointwise multiplication corresponds to negacyclic convolution in coefficient domain.
§Panics
Panics if polynomials are not in NTT domain or have different sizes.
Sourcepub fn scalar_mul(&mut self, scalar: u64, arith: &Ntt64Arith)
pub fn scalar_mul(&mut self, scalar: u64, arith: &Ntt64Arith)
Scalar multiplication: self *= scalar (mod q).
Sourcepub fn negate(&mut self, arith: &Ntt64Arith)
pub fn negate(&mut self, arith: &Ntt64Arith)
Negation: self = −self (mod q), i.e. self[i] = q − self[i].