pub struct Poly {
pub coeffs: [FieldElement; 256],
}Expand description
Polynomial in the time (coefficient) domain, canonical representatives mod q.
Fields§
§coeffs: [FieldElement; 256]Coefficients c[0] + c[1] X + … + c[255] X^{255}.
Implementations§
Source§impl Poly
impl Poly
Sourcepub const fn from_coeffs(coeffs: [FieldElement; 256]) -> Self
pub const fn from_coeffs(coeffs: [FieldElement; 256]) -> Self
Construct from canonical coefficients (already reduced mod q is recommended).
Sourcepub fn add_assign(&mut self, rhs: &Self)
pub fn add_assign(&mut self, rhs: &Self)
Coefficient-wise addition mod q (Barrett reduction).
Sourcepub fn sub_assign(&mut self, rhs: &Self)
pub fn sub_assign(&mut self, rhs: &Self)
Coefficient-wise subtraction mod q.
Sourcepub fn scalar_mul_assign(&mut self, k: i32)
pub fn scalar_mul_assign(&mut self, k: i32)
Multiply every coefficient by a small integer, then reduce mod q.
Sourcepub fn mul_negacyclic(&self, rhs: &Self) -> Self
pub fn mul_negacyclic(&self, rhs: &Self) -> Self
Negacyclic convolution mod (X^256 + 1) via schoolbook (O(n^2)) (test / reference).
Sourcepub fn infinity_norm(&self) -> i32
pub fn infinity_norm(&self) -> i32
Infinity norm on absolute representatives in ([-q/2, q/2])-style range.
Branch-free over coefficient values (ML-DSA portable infinity_norm_exceeds model):
leaking which coefficient exceeds a bound is acceptable on verify paths; the sign of the
centered representative must not leak via control flow.
Sourcepub fn norm_within_bound(&self, bound: i32) -> Choice
pub fn norm_within_bound(&self, bound: i32) -> Choice
Returns 1 iff Self::infinity_norm is at most bound (inclusive).
Sourcepub fn normalize_mod_q_assign(&mut self)
pub fn normalize_mod_q_assign(&mut self)
Map every coefficient into canonical [0, q) via Barrett reduction, then branch-free
non-negative fixup: v + ((v >> 31) & q).
Sourcepub fn scalar_mul_by_u32_mod_q(&self, scalar: u32) -> Poly
pub fn scalar_mul_by_u32_mod_q(&self, scalar: u32) -> Poly
Multiply every coefficient by scalar (mod q) using wide multiply + Barrett reduction.
Sourcepub fn to_simd(&self) -> [Coefficients; 32]
pub fn to_simd(&self) -> [Coefficients; 32]
SIMD lane layout (ML-DSA coefficient order).