pub struct Polynomial(/* private fields */);
Expand description

A polynomial over Z_p[x]/(phi) where phi := x^512 + 1

Implementations§

source§

impl Polynomial

source

pub unsafe fn new(data: [u16; 512]) -> Polynomial

Constructs a new polynomial from a list of coefficients.

Safety

This constructor validates that the coefficients are in the valid range only in debug mode.

source

pub fn from_pub_key(input: &[u8]) -> Result<Polynomial, FalconError>

Decodes raw bytes representing a public key into a polynomial in Z_p[x]/(phi).

Errors

Returns an error if:

  • The provided input is not exactly 897 bytes long.
  • The first byte of the input is not equal to log2(512) i.e., 9.
  • Any of the coefficients encoded in the provided input is greater than or equal to the Falcon field modulus.
source

pub fn from_signature(input: &[u8]) -> Result<Polynomial, FalconError>

Decodes the signature into the coefficients of a polynomial in Z_p[x]/(phi). It assumes that the signature has been encoded using the uncompressed format.

Errors

Returns an error if:

  • The signature has been encoded using a different algorithm than the reference compressed encoding algorithm.
  • The encoded signature polynomial is in Z_p[x]/(phi’) where phi’ = x^N’ + 1 and N’ != 512.
  • While decoding the high bits of a coefficient, the current accumulated value of its high bits is larger than 2048.
  • The decoded coefficient is -0.
  • The remaining unused bits in the last byte of input are non-zero.
source

pub fn inner(&self) -> [u16; 512]

Returns the coefficients of this polynomial as integers.

source

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

Returns the coefficients of this polynomial as field elements.

source

pub fn mul_modulo_p(a: &Polynomial, b: &Polynomial) -> [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]) -> Polynomial

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

source

pub fn sq_norm(&self) -> u64

Computes the norm squared of a polynomial in Z_p[x]/(phi) after normalizing its coefficients to be in the interval (-p/2, p/2].

Trait Implementations§

source§

impl Add for Polynomial

Addition over Z_p[x]/(phi)

§

type Output = Polynomial

The resulting type after applying the + operator.
source§

fn add(self, other: Polynomial) -> <Polynomial as Add>::Output

Performs the + operation. Read more
source§

impl Clone for Polynomial

source§

fn clone(&self) -> Polynomial

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

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

Performs copy-assignment from source. Read more
source§

impl Debug for Polynomial

source§

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

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

impl Default for Polynomial

source§

fn default() -> Polynomial

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

impl Mul for Polynomial

Multiplication over Z_p[x]/(phi)

§

type Output = Polynomial

The resulting type after applying the * operator.
source§

fn mul(self, other: Polynomial) -> <Polynomial as Mul>::Output

Performs the * operation. Read more
source§

impl PartialEq for Polynomial

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sub for Polynomial

Subtraction over Z_p[x]/(phi)

§

type Output = Polynomial

The resulting type after applying the - operator.
source§

fn sub(self, other: Polynomial) -> <Polynomial as Add>::Output

Performs the - operation. Read more
source§

impl Copy for Polynomial

source§

impl StructuralPartialEq for Polynomial

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.