pub struct ModuleElement<const N: usize> { /* private fields */ }
Expand description
The Module is a matrix over the cyclotomic ring (i.e., the ring of residue classes of polynomials modulo X^64+1). The matrix contains N cyclotomic ring elements in total.
Implementations§
Source§impl<const N: usize> ModuleElement<N>
impl<const N: usize> ModuleElement<N>
pub fn sample_short(randomness: &[u8]) -> Self
pub fn sample_uniform(randomness: &[u8]) -> Self
pub fn ntt(&self) -> Self
pub fn intt(&self) -> Self
Sourcepub fn multiply_hadamard<const LHS_H: usize, const LHS_N: usize, const RHS_W: usize, const RHS_N: usize, const INNER: usize, const OUT_N: usize>(
lhs: ModuleElement<LHS_N>,
rhs: ModuleElement<RHS_N>,
) -> ModuleElement<OUT_N>
pub fn multiply_hadamard<const LHS_H: usize, const LHS_N: usize, const RHS_W: usize, const RHS_N: usize, const INNER: usize, const OUT_N: usize>( lhs: ModuleElement<LHS_N>, rhs: ModuleElement<RHS_N>, ) -> ModuleElement<OUT_N>
Multiply two module elements from a pair of matrix- multiplication-compatible modules. This method uses hadamard multiplication for cyclotomic ring elements, which is useful for avoiding the repeated conversion to and from NTT domain.
N
counts the total number of elements in the matrix;H
counts the number of rows of the left hand side (and of the output) matrix;W
counts the number of columns of the right hand side (and of the output) matrix;INNER
counts the number of columns of the left hand side, as well as the number of rows of the right hand side.
Sourcepub fn multiply<const LHS_H: usize, const LHS_N: usize, const RHS_W: usize, const RHS_N: usize, const INNER: usize, const OUT_N: usize>(
lhs: ModuleElement<LHS_N>,
rhs: ModuleElement<RHS_N>,
) -> ModuleElement<OUT_N>
pub fn multiply<const LHS_H: usize, const LHS_N: usize, const RHS_W: usize, const RHS_N: usize, const INNER: usize, const OUT_N: usize>( lhs: ModuleElement<LHS_N>, rhs: ModuleElement<RHS_N>, ) -> ModuleElement<OUT_N>
Multiply two module elements from a pair of matrix-
multiplication-compatible modules. This method uses the
multiplication defined for cyclotomic ring elements
abstractly. For a faster method that computes the entire
matrix multiplication in the NTT domain, use fast_multiply
.
N
counts the total number of elements in the matrix;H
counts the number of rows of the left hand side (and of the output) matrix;W
counts the number of columns of the right hand side (and of the output) matrix;INNER
counts the number of columns of the left hand side, as well as the number of rows of the right hand side.
Sourcepub fn fast_multiply<const LHS_H: usize, const LHS_N: usize, const RHS_W: usize, const RHS_N: usize, const INNER: usize, const OUT_N: usize>(
lhs: ModuleElement<LHS_N>,
rhs: ModuleElement<RHS_N>,
) -> ModuleElement<OUT_N>
pub fn fast_multiply<const LHS_H: usize, const LHS_N: usize, const RHS_W: usize, const RHS_N: usize, const INNER: usize, const OUT_N: usize>( lhs: ModuleElement<LHS_N>, rhs: ModuleElement<RHS_N>, ) -> ModuleElement<OUT_N>
Multiply two module elements from a pair of matrix- multiplication-compatible modules, by converting everything into the NTT domain, performing the matrix multiplication, and converting back.
N
counts the total number of elements in the matrix;H
counts the number of rows of the left hand side (and of the output) matrix;W
counts the number of columns of the right hand side (and of the output) matrix;INNER
counts the number of columns of the left hand side, as well as the number of rows of the right hand side.
Trait Implementations§
Source§impl<const N: usize> Add for ModuleElement<N>
impl<const N: usize> Add for ModuleElement<N>
Source§impl<const N: usize> Clone for ModuleElement<N>
impl<const N: usize> Clone for ModuleElement<N>
Source§fn clone(&self) -> ModuleElement<N>
fn clone(&self) -> ModuleElement<N>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<const N: usize> Debug for ModuleElement<N>
impl<const N: usize> Debug for ModuleElement<N>
Source§impl<'de, const N: usize> Deserialize<'de> for ModuleElement<N>
impl<'de, const N: usize> Deserialize<'de> for ModuleElement<N>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<const N: usize> PartialEq for ModuleElement<N>
impl<const N: usize> PartialEq for ModuleElement<N>
Source§impl<const N: usize> Serialize for ModuleElement<N>
impl<const N: usize> Serialize for ModuleElement<N>
Source§impl<const N: usize> Sub for ModuleElement<N>
impl<const N: usize> Sub for ModuleElement<N>
Source§impl<const N: usize> Zero for ModuleElement<N>
impl<const N: usize> Zero for ModuleElement<N>
impl<const N: usize> Copy for ModuleElement<N>
impl<const N: usize> Eq for ModuleElement<N>
impl<const N: usize> StructuralPartialEq for ModuleElement<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for ModuleElement<N>
impl<const N: usize> RefUnwindSafe for ModuleElement<N>
impl<const N: usize> Send for ModuleElement<N>
impl<const N: usize> Sync for ModuleElement<N>
impl<const N: usize> Unpin for ModuleElement<N>
impl<const N: usize> UnwindSafe for ModuleElement<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more