miden_crypto::dsa::rpo_falcon512

Struct Polynomial

source
pub struct Polynomial<F> {
    pub coefficients: Vec<F>,
}

Fields§

§coefficients: Vec<F>

Implementations§

source§

impl<F> Polynomial<F>
where F: Clone,

source

pub fn new(coefficients: Vec<F>) -> Self

source§

impl<F: Mul<Output = F> + Sub<Output = F> + AddAssign + Zero + Div<Output = F> + Clone + Inverse> Polynomial<F>

source

pub fn hadamard_mul(&self, other: &Self) -> Self

source

pub fn hadamard_div(&self, other: &Self) -> Self

source

pub fn hadamard_inv(&self) -> Self

source§

impl<F: Zero + PartialEq + Clone> Polynomial<F>

source

pub fn degree(&self) -> Option<usize>

source

pub fn lc(&self) -> F

source§

impl<F: One + Zero + Clone + Neg<Output = F> + MulAssign + AddAssign + Div<Output = F> + Sub<Output = F> + PartialEq> Polynomial<F>

The following implementations are specific to cyclotomic polynomial rings, i.e., F[ X ] / <X^n + 1>, and are used extensively in Falcon.

source

pub fn reduce_by_cyclotomic(&self, n: usize) -> Self

Reduce the polynomial by X^n + 1.

source

pub fn field_norm(&self) -> Self

Computes the field norm of the polynomial as an element of the cyclotomic ring F[ X ] / <X^n + 1 > relative to one of half the size, i.e., F[ X ] / <X^(n/2) + 1> .

Corresponds to formula 3.25 in the spec [1, p.30].

source

pub fn lift_next_cyclotomic(&self) -> Self

Lifts an element from a cyclotomic polynomial ring to one of double the size.

source

pub fn galois_adjoint(&self) -> Self

Computes the galois adjoint of the polynomial in the cyclotomic ring F[ X ] / < X^n + 1 > , which corresponds to f(x^2).

source§

impl<F: Mul<Output = F> + Sub<Output = F> + AddAssign + Zero + Div<Output = F> + Clone> Polynomial<F>

source

pub fn karatsuba(&self, other: &Self) -> Self

Multiply two polynomials using Karatsuba’s divide-and-conquer algorithm.

source§

impl<F: Zero + Clone> Polynomial<F>

source

pub fn shift(&self, shamt: usize) -> Self

source

pub fn constant(f: F) -> Self

source

pub fn map<G: Clone, C: FnMut(&F) -> G>(&self, closure: C) -> Polynomial<G>

source

pub fn fold<G, C: FnMut(G, &F) -> G + Clone>( &self, initial_value: G, closure: C, ) -> G

source§

impl Polynomial<FalconFelt>

source

pub fn norm_squared(&self) -> u64

source

pub fn to_elements(&self) -> Vec<Felt>

Returns the coefficients of this polynomial as field elements.

source

pub fn mul_modulo_p(a: &Self, b: &Self) -> [u64; 1024]

Multiplies two polynomials over Z_p[x] without reducing modulo p. Given that the degrees of the input polynomials are less than 512 and their coefficients are less than the modulus q equal to 12289, the resulting product polynomial is guaranteed to have coefficients less than the Miden prime.

Note that this multiplication is not over Z_p[x]/(phi).

source

pub fn reduce_negacyclic(a: &[u64; 1024]) -> Self

Reduces a polynomial, that is the product of two polynomials over Z_p[x], modulo the irreducible polynomial phi. This results in an element in Z_p[x]/(phi).

Trait Implementations§

source§

impl<F> Add for &Polynomial<F>
where F: Add<Output = F> + AddAssign + Clone,

source§

type Output = Polynomial<F>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<F> Add for Polynomial<F>
where F: Add<Output = F> + AddAssign + Clone,

source§

type Output = Polynomial<F>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<F> AddAssign for Polynomial<F>
where F: Add<Output = F> + AddAssign + Clone,

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl<F: Clone> Clone for Polynomial<F>

source§

fn clone(&self) -> Polynomial<F>

Returns a copy of the value. Read more
1.6.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<F: Debug> Debug for Polynomial<F>

source§

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

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

impl<F: Default> Default for Polynomial<F>

source§

fn default() -> Polynomial<F>

Returns the “default value” for a type. Read more
source§

impl<F> Div for Polynomial<F>
where F: Zero + One + PartialEq + AddAssign + Clone + Mul<Output = F> + MulAssign + Div<Output = F> + Neg<Output = F> + Sub<Output = F>,

source§

type Output = Polynomial<F>

The resulting type after applying the / operator.
source§

fn div(self, denominator: Self) -> Self::Output

Performs the / operation. Read more
source§

impl From<&Polynomial<FalconFelt>> for Polynomial<Felt>

source§

fn from(item: &Polynomial<FalconFelt>) -> Self

Converts to this type from the input type.
source§

impl From<&Polynomial<i16>> for Polynomial<FalconFelt>

source§

fn from(item: &Polynomial<i16>) -> Self

Converts to this type from the input type.
source§

impl From<&Vec<i16>> for Polynomial<FalconFelt>

source§

fn from(item: &Vec<i16>) -> Self

Converts to this type from the input type.
source§

impl From<Polynomial<FalconFelt>> for Polynomial<Felt>

source§

fn from(item: Polynomial<FalconFelt>) -> Self

Converts to this type from the input type.
source§

impl From<Polynomial<FalconFelt>> for PubKeyPoly

source§

fn from(pk_poly: Polynomial<FalconFelt>) -> Self

Converts to this type from the input type.
source§

impl From<Polynomial<FalconFelt>> for SignaturePoly

source§

fn from(pk_poly: Polynomial<FalconFelt>) -> Self

Converts to this type from the input type.
source§

impl From<Polynomial<i16>> for Polynomial<FalconFelt>

source§

fn from(item: Polynomial<i16>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<i16>> for Polynomial<FalconFelt>

source§

fn from(item: Vec<i16>) -> Self

Converts to this type from the input type.
source§

impl<F: Add + Mul<Output = F> + Zero + Clone> Mul<F> for &Polynomial<F>

source§

type Output = Polynomial<F>

The resulting type after applying the * operator.
source§

fn mul(self, other: F) -> Self::Output

Performs the * operation. Read more
source§

impl<F: Add + Mul<Output = F> + Zero + Clone> Mul<F> for Polynomial<F>

source§

type Output = Polynomial<F>

The resulting type after applying the * operator.
source§

fn mul(self, other: F) -> Self::Output

Performs the * operation. Read more
source§

impl<F> Mul for &Polynomial<F>
where F: Add + AddAssign + Mul<Output = F> + Sub<Output = F> + Zero + PartialEq + Clone,

source§

type Output = Polynomial<F>

The resulting type after applying the * operator.
source§

fn mul(self, other: Self) -> Self::Output

Performs the * operation. Read more
source§

impl<F> Mul for Polynomial<F>
where F: Add + AddAssign + Mul<Output = F> + Zero + PartialEq + Clone,

source§

type Output = Polynomial<F>

The resulting type after applying the * operator.
source§

fn mul(self, other: Self) -> Self::Output

Performs the * operation. Read more
source§

impl<F: Neg<Output = F> + Clone> Neg for &Polynomial<F>

source§

type Output = Polynomial<F>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<F: Neg<Output = F> + Clone> Neg for Polynomial<F>

source§

type Output = Polynomial<F>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<F> One for Polynomial<F>
where F: Clone + One + PartialEq + Zero + AddAssign,

source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
source§

impl<F> PartialEq for Polynomial<F>
where F: Zero + PartialEq + Clone + AddAssign,

source§

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

Tests for self and other values to be equal, and is used by ==.
1.6.0 · 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<F> Sub for &Polynomial<F>
where F: Sub<Output = F> + Clone + Neg<Output = F> + Add<Output = F> + AddAssign,

source§

type Output = Polynomial<F>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<F> Sub for Polynomial<F>
where F: Sub<Output = F> + Clone + Neg<Output = F> + Add<Output = F> + AddAssign,

source§

type Output = Polynomial<F>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<F> SubAssign for Polynomial<F>
where F: Add<Output = F> + Neg<Output = F> + AddAssign + Clone + Sub<Output = F>,

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl<F> Zero for Polynomial<F>
where F: Zero + PartialEq + Clone + AddAssign,

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<F> Eq for Polynomial<F>
where F: Zero + PartialEq + Clone + AddAssign,

Auto Trait Implementations§

§

impl<F> Freeze for Polynomial<F>

§

impl<F> RefUnwindSafe for Polynomial<F>
where F: RefUnwindSafe,

§

impl<F> Send for Polynomial<F>
where F: Send,

§

impl<F> Sync for Polynomial<F>
where F: Sync,

§

impl<F> Unpin for Polynomial<F>
where F: Unpin,

§

impl<F> UnwindSafe for Polynomial<F>
where F: UnwindSafe,

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V