Skip to main content

Poly

Struct Poly 

Source
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

Source

pub const fn zero() -> Self

Zero polynomial.

Source

pub const fn from_coeffs(coeffs: [FieldElement; 256]) -> Self

Construct from canonical coefficients (already reduced mod q is recommended).

Source

pub fn add_assign(&mut self, rhs: &Self)

Coefficient-wise addition mod q (Barrett reduction).

Source

pub fn sub_assign(&mut self, rhs: &Self)

Coefficient-wise subtraction mod q.

Source

pub fn scalar_mul_assign(&mut self, k: i32)

Multiply every coefficient by a small integer, then reduce mod q.

Source

pub fn mul_negacyclic(&self, rhs: &Self) -> Self

Negacyclic convolution mod (X^256 + 1) via schoolbook (O(n^2)) (test / reference).

Source

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.

Source

pub fn norm_within_bound(&self, bound: i32) -> Choice

Returns 1 iff Self::infinity_norm is at most bound (inclusive).

Source

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).

Source

pub fn scalar_mul_by_u32_mod_q(&self, scalar: u32) -> Poly

Multiply every coefficient by scalar (mod q) using wide multiply + Barrett reduction.

Source

pub fn to_simd(&self) -> [Coefficients; 32]

SIMD lane layout (ML-DSA coefficient order).

Source

pub fn to_ntt(&self) -> NttPoly

Map to the NTT/Montgomery SIMD representation used by ML-DSA.

Trait Implementations§

Source§

impl Clone for Poly

Source§

fn clone(&self) -> Poly

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Poly

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Poly

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for Poly

Source§

impl Hash for Poly

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Poly

Source§

fn eq(&self, other: &Poly) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Poly

Source§

impl Zeroize for Poly

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

§

impl Freeze for Poly

§

impl RefUnwindSafe for Poly

§

impl Send for Poly

§

impl Sync for Poly

§

impl Unpin for Poly

§

impl UnsafeUnpin for Poly

§

impl UnwindSafe for Poly

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.