pub struct MatNTTPolynomialRingZq {
pub matrix: Vec<Z>,
pub nr_rows: usize,
pub nr_columns: usize,
pub modulus: ModulusPolynomialRingZq,
}Expand description
MatNTTPolynomialRingZq contains the NTT representation of a matrix over polynomials with respect to
a NTTBasisPolynomialRingZq that itself isn’t aware of.
Any polynomial in NTT representation in row i and column j can be accessed via matrix[j * nr_columns + i].
Attributes
matrix: holds the matrix entries with its coefficientsnr_rows: the number of rows of the matrixnr_columns: the number of columns of the matrixmodulus: theModulusPolynomialRingZqdefining the modulusq, the ringZ_q[X]/f(X), and the NTT transformNTTBasisPolynomialRingZq
§Examples
use qfall_math::integer_mod_q::{Modulus, MatPolynomialRingZq, MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use std::str::FromStr;
// setup modulus with ability to transform to NTT
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
// sample random matrix
let mat_rnd = MatNTTPolynomialRingZq::sample_uniform(2, 2, &modulus);
// or instantiate matrix from MatPolynomialRingZq
let mat_poly_ring = MatPolynomialRingZq::identity(2, 2, &modulus);
let mat_ntt_poly_ring = MatNTTPolynomialRingZq::from(&mat_poly_ring);
// multiply, add and subtract objects
let mut tmp_mat_ntt = mat_ntt_poly_ring * &mat_rnd;
tmp_mat_ntt += &mat_rnd;
tmp_mat_ntt -= &mat_rnd;
// Return to MatPolynomialRingZq
let res = tmp_mat_ntt.inv_ntt();Fields§
§matrix: Vec<Z>§nr_rows: usize§nr_columns: usize§modulus: ModulusPolynomialRingZqImplementations§
Source§impl MatNTTPolynomialRingZq
impl MatNTTPolynomialRingZq
Sourcepub fn inv_ntt(self) -> MatPolynomialRingZq
pub fn inv_ntt(self) -> MatPolynomialRingZq
Computes the inverse NTT of self with respect to the given modulus.
Returns a new MatPolynomialRingZq with the entries from self.
§Examples
use qfall_math::integer_mod_q::{MatPolynomialRingZq, MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let ntt_mat = MatNTTPolynomialRingZq::sample_uniform(1, 1, &modulus);
let poly_ring_mat = ntt_mat.inv_ntt();§Panics …
- if the
NTTBasisPolynomialRingZqinmodulusis not set.
Source§impl MatNTTPolynomialRingZq
impl MatNTTPolynomialRingZq
Sourcepub fn get_mod(&self) -> ModulusPolynomialRingZq
pub fn get_mod(&self) -> ModulusPolynomialRingZq
Returns the modulus of the matrix in NTT representation as a ModulusPolynomialRingZq.
§Examples
use qfall_math::integer_mod_q::{MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use std::str::FromStr;
let modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 17").unwrap();
let matrix = MatNTTPolynomialRingZq::sample_uniform(2, 2, &modulus);
let modulus = matrix.get_mod();Sourcepub fn get_entry(&self, row: usize, column: usize) -> &[Z]
pub fn get_entry(&self, row: usize, column: usize) -> &[Z]
Returns the slice of matrix corresponding to the entry in row row and column column.
Parameters:
row: defines the row where the entry to fetch is locatedcolumn: defines the column where the entry to fetch is located
Returns a slice &[Z] containing the requested entry.
§Examples
use qfall_math::integer_mod_q::{MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let matrix = MatNTTPolynomialRingZq::sample_uniform(2, 2, &modulus);
let entry = matrix.get_entry(0, 0);
assert_eq!(4, entry.len());§Panics …
- if
row >= self.get_num_rows()orcolumn >= self.get_num_columns().
Source§impl MatNTTPolynomialRingZq
impl MatNTTPolynomialRingZq
Sourcepub fn sample_uniform(
nr_rows: usize,
nr_columns: usize,
modulus: &ModulusPolynomialRingZq,
) -> Self
pub fn sample_uniform( nr_rows: usize, nr_columns: usize, modulus: &ModulusPolynomialRingZq, ) -> Self
Generates a MatNTTPolynomialRingZq instance with maximum degree modulus_degree
and entries chosen uniform at random in [0, modulus).
The internally used uniform at random chosen bytes are generated
by ThreadRng, which uses ChaCha12 and
is considered cryptographically secure.
Parameters:
num_rows: defines the number of rows of the matrixnum_columns: defines the number of columns of the matrixmodulus_degree: specifies the degree of the modulus polynomial, i.e. the maximum number of sampled coefficients ismodulus_degree - 1modulus: specifies the modulus of the values and thus, the interval size over which is sampled
Returns a fresh MatNTTPolynomialRingZq instance of length modulus_degree with entries
chosen uniform at random in [0, modulus).
§Examples
use qfall_math::integer_mod_q::{MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let sample = MatNTTPolynomialRingZq::sample_uniform(3, 2, &modulus);§Panics …
- if
nr_rowsornr_columnsis0.
Trait Implementations§
Source§impl Add for &MatNTTPolynomialRingZq
impl Add for &MatNTTPolynomialRingZq
Source§fn add(self, other: Self) -> Self::Output
fn add(self, other: Self) -> Self::Output
Adds self with other.
Paramters:
other: specifies the NTT-representation of the polynomial to add toself
Returns the NTT-representation of the sum of self and other.
§Example
use qfall_math::integer_mod_q::{MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use crate::qfall_math::traits::SetCoefficient;
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let a = MatNTTPolynomialRingZq::sample_uniform(2, 3, &modulus);
let b = MatNTTPolynomialRingZq::sample_uniform(2, 3, &modulus);
let c = a + b;§Panics …
- if the number of rows of
selfandotheror their number of columns is not equal. - if their moduli do not match.
Source§type Output = MatNTTPolynomialRingZq
type Output = MatNTTPolynomialRingZq
+ operator.Source§impl AddAssign<&MatNTTPolynomialRingZq> for MatNTTPolynomialRingZq
impl AddAssign<&MatNTTPolynomialRingZq> for MatNTTPolynomialRingZq
Source§fn add_assign(&mut self, other: &Self)
fn add_assign(&mut self, other: &Self)
Adds self with other reusing the memory of self.
Paramters:
other: specifies the NTT-representation of the polynomial to add toself
Computes the NTT-representation of the sum of self and other.
§Example
use qfall_math::integer_mod_q::{MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use crate::qfall_math::traits::SetCoefficient;
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let mut a = MatNTTPolynomialRingZq::sample_uniform(2, 3, &modulus);
let b = MatNTTPolynomialRingZq::sample_uniform(2, 3, &modulus);
a += b;§Panics …
- if the number of rows of
selfandotheror their number of columns is not equal. - if their moduli do not match.
Source§impl AddAssign for MatNTTPolynomialRingZq
impl AddAssign for MatNTTPolynomialRingZq
Source§fn add_assign(&mut self, other: MatNTTPolynomialRingZq)
fn add_assign(&mut self, other: MatNTTPolynomialRingZq)
Documentation at MatNTTPolynomialRingZq::add_assign.
Source§impl Clone for MatNTTPolynomialRingZq
impl Clone for MatNTTPolynomialRingZq
Source§fn clone(&self) -> MatNTTPolynomialRingZq
fn clone(&self) -> MatNTTPolynomialRingZq
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl CompareBase<&MatNTTPolynomialRingZq> for MatNTTPolynomialRingZq
impl CompareBase<&MatNTTPolynomialRingZq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &&MatNTTPolynomialRingZq) -> bool
fn compare_base(&self, other: &&MatNTTPolynomialRingZq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(
&self,
other: &&MatNTTPolynomialRingZq,
) -> Option<MathError>
fn call_compare_base_error( &self, other: &&MatNTTPolynomialRingZq, ) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl CompareBase<&MatPolyOverZ> for MatNTTPolynomialRingZq
impl CompareBase<&MatPolyOverZ> for MatNTTPolynomialRingZq
Source§impl CompareBase<&MatPolynomialRingZq> for MatNTTPolynomialRingZq
impl CompareBase<&MatPolynomialRingZq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &&MatPolynomialRingZq) -> bool
fn compare_base(&self, other: &&MatPolynomialRingZq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(
&self,
other: &&MatPolynomialRingZq,
) -> Option<MathError>
fn call_compare_base_error( &self, other: &&MatPolynomialRingZq, ) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl CompareBase<&MatZ> for MatNTTPolynomialRingZq
impl CompareBase<&MatZ> for MatNTTPolynomialRingZq
Source§impl CompareBase<&MatZq> for MatNTTPolynomialRingZq
impl CompareBase<&MatZq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &&MatZq) -> bool
fn compare_base(&self, other: &&MatZq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(&self, other: &&MatZq) -> Option<MathError>
fn call_compare_base_error(&self, other: &&MatZq) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl CompareBase<&PolyOverZ> for MatNTTPolynomialRingZq
impl CompareBase<&PolyOverZ> for MatNTTPolynomialRingZq
Source§impl CompareBase<&PolyOverZq> for MatNTTPolynomialRingZq
impl CompareBase<&PolyOverZq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &&PolyOverZq) -> bool
fn compare_base(&self, other: &&PolyOverZq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(&self, other: &&PolyOverZq) -> Option<MathError>
fn call_compare_base_error(&self, other: &&PolyOverZq) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl CompareBase<&PolynomialRingZq> for MatNTTPolynomialRingZq
impl CompareBase<&PolynomialRingZq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &&PolynomialRingZq) -> bool
fn compare_base(&self, other: &&PolynomialRingZq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(
&self,
other: &&PolynomialRingZq,
) -> Option<MathError>
fn call_compare_base_error( &self, other: &&PolynomialRingZq, ) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl CompareBase<&Zq> for MatNTTPolynomialRingZq
impl CompareBase<&Zq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &&Zq) -> bool
fn compare_base(&self, other: &&Zq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(&self, other: &&Zq) -> Option<MathError>
fn call_compare_base_error(&self, other: &&Zq) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl<Integer: Into<Z>> CompareBase<Integer> for MatNTTPolynomialRingZq
impl<Integer: Into<Z>> CompareBase<Integer> for MatNTTPolynomialRingZq
Source§impl CompareBase<MatPolyOverZ> for MatNTTPolynomialRingZq
impl CompareBase<MatPolyOverZ> for MatNTTPolynomialRingZq
Source§impl CompareBase<MatPolynomialRingZq> for MatNTTPolynomialRingZq
impl CompareBase<MatPolynomialRingZq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &MatPolynomialRingZq) -> bool
fn compare_base(&self, other: &MatPolynomialRingZq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(
&self,
other: &MatPolynomialRingZq,
) -> Option<MathError>
fn call_compare_base_error( &self, other: &MatPolynomialRingZq, ) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl CompareBase<MatZ> for MatNTTPolynomialRingZq
impl CompareBase<MatZ> for MatNTTPolynomialRingZq
Source§impl CompareBase<MatZq> for MatNTTPolynomialRingZq
impl CompareBase<MatZq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &MatZq) -> bool
fn compare_base(&self, other: &MatZq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(&self, other: &MatZq) -> Option<MathError>
fn call_compare_base_error(&self, other: &MatZq) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl CompareBase<PolyOverZ> for MatNTTPolynomialRingZq
impl CompareBase<PolyOverZ> for MatNTTPolynomialRingZq
Source§impl CompareBase<PolyOverZq> for MatNTTPolynomialRingZq
impl CompareBase<PolyOverZq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &PolyOverZq) -> bool
fn compare_base(&self, other: &PolyOverZq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(&self, other: &PolyOverZq) -> Option<MathError>
fn call_compare_base_error(&self, other: &PolyOverZq) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl CompareBase<PolynomialRingZq> for MatNTTPolynomialRingZq
impl CompareBase<PolynomialRingZq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &PolynomialRingZq) -> bool
fn compare_base(&self, other: &PolynomialRingZq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(&self, other: &PolynomialRingZq) -> Option<MathError>
fn call_compare_base_error(&self, other: &PolynomialRingZq) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl CompareBase<Zq> for MatNTTPolynomialRingZq
impl CompareBase<Zq> for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &Zq) -> bool
fn compare_base(&self, other: &Zq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(&self, other: &Zq) -> Option<MathError>
fn call_compare_base_error(&self, other: &Zq) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl CompareBase for MatNTTPolynomialRingZq
impl CompareBase for MatNTTPolynomialRingZq
Source§fn compare_base(&self, other: &MatNTTPolynomialRingZq) -> bool
fn compare_base(&self, other: &MatNTTPolynomialRingZq) -> bool
Compares the moduli of the two elements.
Parameters:
other: The other object whose base is compared toself
Returns true if the moduli match and false otherwise.
Source§fn call_compare_base_error(
&self,
other: &MatNTTPolynomialRingZq,
) -> Option<MathError>
fn call_compare_base_error( &self, other: &MatNTTPolynomialRingZq, ) -> Option<MathError>
Returns an error that gives a small explanation of how the moduli are incomparable.
Parameters:
other: The other object whose base is compared toself
Returns a MathError of type MismatchingModulus.
Source§impl Debug for MatNTTPolynomialRingZq
impl Debug for MatNTTPolynomialRingZq
Source§impl<'de> Deserialize<'de> for MatNTTPolynomialRingZq
impl<'de> Deserialize<'de> for MatNTTPolynomialRingZq
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 Display for MatNTTPolynomialRingZq
impl Display for MatNTTPolynomialRingZq
Source§impl From<&MatPolynomialRingZq> for MatNTTPolynomialRingZq
impl From<&MatPolynomialRingZq> for MatNTTPolynomialRingZq
Source§fn from(matrix: &MatPolynomialRingZq) -> Self
fn from(matrix: &MatPolynomialRingZq) -> Self
Computes the NTT representation of matrix.
Parameters:
matrix: the matrix that’s going to be represented in NTT format.
Returns the NTT representation as a MatNTTPolynomialRingZq of matrix.
§Examples
use qfall_math::integer_mod_q::{MatNTTPolynomialRingZq, MatPolynomialRingZq, ModulusPolynomialRingZq};
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let mat_poly_ring = MatPolynomialRingZq::sample_uniform(2, 3, &modulus);
let mat_ntt_poly_ring = MatNTTPolynomialRingZq::from(&mat_poly_ring);§Panics …
- if the
NTTBasisPolynomialRingZq, which is part of theModulusPolynomialRingZqinmatrixis not set.
Source§impl From<MatNTTPolynomialRingZq> for MatPolynomialRingZq
impl From<MatNTTPolynomialRingZq> for MatPolynomialRingZq
Source§fn from(matrix: MatNTTPolynomialRingZq) -> Self
fn from(matrix: MatNTTPolynomialRingZq) -> Self
Creates a polynomial ring matrix of type MatPolynomialRingZq from
the corresponding MatNTTPolynomialRingZq.
Parameters:
matrix: the polynomial matrix defining each entry.
Returns a new MatPolynomialRingZq with the entries from matrix.
§Examples
use qfall_math::integer_mod_q::{MatPolynomialRingZq, MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let ntt_mat = MatNTTPolynomialRingZq::sample_uniform(1, 1, &modulus);
let poly_ring_mat = MatPolynomialRingZq::from(ntt_mat);§Panics …
- if the
NTTBasisPolynomialRingZqinmodulusis not set.
Source§impl MatrixDimensions for MatNTTPolynomialRingZq
impl MatrixDimensions for MatNTTPolynomialRingZq
Source§fn get_num_rows(&self) -> i64
fn get_num_rows(&self) -> i64
Returns the number of rows of the matrix as an i64.
§Examples
use qfall_math::{integer_mod_q::{MatNTTPolynomialRingZq, ModulusPolynomialRingZq}, traits::MatrixDimensions};
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let matrix = MatNTTPolynomialRingZq::sample_uniform(3, 2, &modulus);
let nr_rows = matrix.get_num_rows();Source§fn get_num_columns(&self) -> i64
fn get_num_columns(&self) -> i64
Returns the number of columns of the matrix as an i64.
§Examples
use qfall_math::{integer_mod_q::{MatNTTPolynomialRingZq, ModulusPolynomialRingZq}, traits::MatrixDimensions};
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let matrix = MatNTTPolynomialRingZq::sample_uniform(3, 2, &modulus);
let nr_columns = matrix.get_num_columns();Source§impl Mul for &MatNTTPolynomialRingZq
impl Mul for &MatNTTPolynomialRingZq
Source§fn mul(self, other: Self) -> Self::Output
fn mul(self, other: Self) -> Self::Output
Multiplies self with other.
Paramters:
other: specifies the NTT-representation of the polynomial to multiply toself
Returns the NTT-representation of the multiplication of self and other.
§Example
use qfall_math::integer_mod_q::{MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use crate::qfall_math::traits::SetCoefficient;
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let a = MatNTTPolynomialRingZq::sample_uniform(2, 3, &modulus);
let b = MatNTTPolynomialRingZq::sample_uniform(3, 4, &modulus);
let c = a * b;§Panics …
- if the number of rows of
selfand the number of columns ofotherdoes not match up. - if their moduli do not match.
Source§type Output = MatNTTPolynomialRingZq
type Output = MatNTTPolynomialRingZq
* operator.Source§impl PartialEq for MatNTTPolynomialRingZq
impl PartialEq for MatNTTPolynomialRingZq
Source§impl Serialize for MatNTTPolynomialRingZq
impl Serialize for MatNTTPolynomialRingZq
Source§impl Sub for &MatNTTPolynomialRingZq
impl Sub for &MatNTTPolynomialRingZq
Source§fn sub(self, other: Self) -> Self::Output
fn sub(self, other: Self) -> Self::Output
Subtracts other from self.
Paramters:
other: specifies the NTT-representation of the polynomial to subtract fromself
Returns the NTT-representation of the subtraction of other from self.
§Example
use qfall_math::integer_mod_q::{MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let a = MatNTTPolynomialRingZq::sample_uniform(2, 3, &modulus);
let b = MatNTTPolynomialRingZq::sample_uniform(2, 3, &modulus);
let c = a - b;§Panics …
- if the number of rows of
selfandotheror their number of columns is not equal. - if their moduli do not match.
Source§type Output = MatNTTPolynomialRingZq
type Output = MatNTTPolynomialRingZq
- operator.Source§impl SubAssign<&MatNTTPolynomialRingZq> for MatNTTPolynomialRingZq
impl SubAssign<&MatNTTPolynomialRingZq> for MatNTTPolynomialRingZq
Source§fn sub_assign(&mut self, other: &Self)
fn sub_assign(&mut self, other: &Self)
Subtracts other from self reusing the memory of self.
Paramters:
other: specifies the NTT-representation of the polynomial to subtract fromself
Computes the NTT-representation of the subtraction of other from self.
§Example
use qfall_math::integer_mod_q::{MatNTTPolynomialRingZq, ModulusPolynomialRingZq};
use std::str::FromStr;
let mut modulus = ModulusPolynomialRingZq::from_str("5 1 0 0 0 1 mod 257").unwrap();
modulus.set_ntt_unchecked(64);
let mut a = MatNTTPolynomialRingZq::sample_uniform(2, 3, &modulus);
let b = MatNTTPolynomialRingZq::sample_uniform(2, 3, &modulus);
a -= b;§Panics …
- if the number of rows of
selfandotheror their number of columns is not equal. - if their moduli do not match.
Source§impl SubAssign for MatNTTPolynomialRingZq
impl SubAssign for MatNTTPolynomialRingZq
Source§fn sub_assign(&mut self, other: MatNTTPolynomialRingZq)
fn sub_assign(&mut self, other: MatNTTPolynomialRingZq)
Documentation at MatNTTPolynomialRingZq::sub_assign.