pub struct Plan { /* private fields */ }Expand description
Negacyclic NTT plan for 32bit primes.
Implementations§
Source§impl Plan
impl Plan
Sourcepub fn try_new(polynomial_size: usize, modulus: u32) -> Option<Self>
pub fn try_new(polynomial_size: usize, modulus: u32) -> Option<Self>
Returns a negacyclic NTT plan for the given polynomial size and modulus, or None if no
suitable roots of unity can be found for the wanted parameters.
Sourcepub fn can_use_fast_reduction_code(&self) -> bool
pub fn can_use_fast_reduction_code(&self) -> bool
Returns whether the negacyclic NTT plan can use fast reduction code.
To avoid correctness issues linked to overflows the code has to make performance sacrifices for certain primes and will not yield the best performance possible for them.
Sourcepub fn fwd(&self, buf: &mut [u32])
pub fn fwd(&self, buf: &mut [u32])
Applies a forward negacyclic NTT transform in place to the given buffer.
§Note
On entry, the buffer holds the polynomial coefficients in standard order. On exit, the buffer holds the negacyclic NTT transform coefficients in bit reversed order.
Sourcepub fn inv(&self, buf: &mut [u32])
pub fn inv(&self, buf: &mut [u32])
Applies an inverse negacyclic NTT transform in place to the given buffer.
§Note
On entry, the buffer holds the negacyclic NTT transform coefficients in bit reversed order. On exit, the buffer holds the polynomial coefficients in standard order.
Sourcepub fn mul_assign_normalize(&self, lhs: &mut [u32], rhs: &[u32])
pub fn mul_assign_normalize(&self, lhs: &mut [u32], rhs: &[u32])
Computes the elementwise product of lhs and rhs, multiplied by the inverse of the
polynomial modulo the NTT modulus, and stores the result in lhs.
Sourcepub fn normalize(&self, values: &mut [u32])
pub fn normalize(&self, values: &mut [u32])
Multiplies the values by the inverse of the polynomial modulo the NTT modulus, and stores
the result in values.
Sourcepub fn mul_accumulate(&self, acc: &mut [u32], lhs: &[u32], rhs: &[u32])
pub fn mul_accumulate(&self, acc: &mut [u32], lhs: &[u32], rhs: &[u32])
Computes the elementwise product of lhs and rhs and accumulates the result to acc.