Struct miden_core::crypto::dsa::rpo_falcon512::Polynomial
source · pub struct Polynomial(/* private fields */);
Expand description
A polynomial over Z_p[x]/(phi) where phi := x^512 + 1
Implementations§
source§impl Polynomial
impl Polynomial
sourcepub unsafe fn new(data: [u16; 512]) -> Polynomial
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.
sourcepub fn from_pub_key(input: &[u8]) -> Result<Polynomial, FalconError>
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.
sourcepub fn from_signature(input: &[u8]) -> Result<Polynomial, FalconError>
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.
sourcepub fn to_elements(&self) -> Vec<BaseElement>
pub fn to_elements(&self) -> Vec<BaseElement>
Returns the coefficients of this polynomial as field elements.
sourcepub fn mul_modulo_p(a: &Polynomial, b: &Polynomial) -> [u64; 1024]
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).
sourcepub fn reduce_negacyclic(a: &[u64; 1024]) -> Polynomial
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).
Trait Implementations§
source§impl Add for Polynomial
impl Add for Polynomial
Addition over Z_p[x]/(phi)
§type Output = Polynomial
type Output = Polynomial
+
operator.source§fn add(self, other: Polynomial) -> <Polynomial as Add>::Output
fn add(self, other: Polynomial) -> <Polynomial as Add>::Output
+
operation. Read moresource§impl Clone for Polynomial
impl Clone for Polynomial
source§fn clone(&self) -> Polynomial
fn clone(&self) -> Polynomial
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Polynomial
impl Debug for Polynomial
source§impl Default for Polynomial
impl Default for Polynomial
source§fn default() -> Polynomial
fn default() -> Polynomial
source§impl Mul for Polynomial
impl Mul for Polynomial
Multiplication over Z_p[x]/(phi)
§type Output = Polynomial
type Output = Polynomial
*
operator.source§fn mul(self, other: Polynomial) -> <Polynomial as Mul>::Output
fn mul(self, other: Polynomial) -> <Polynomial as Mul>::Output
*
operation. Read moresource§impl PartialEq for Polynomial
impl PartialEq for Polynomial
source§fn eq(&self, other: &Polynomial) -> bool
fn eq(&self, other: &Polynomial) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Sub for Polynomial
impl Sub for Polynomial
Subtraction over Z_p[x]/(phi)
§type Output = Polynomial
type Output = Polynomial
-
operator.source§fn sub(self, other: Polynomial) -> <Polynomial as Add>::Output
fn sub(self, other: Polynomial) -> <Polynomial as Add>::Output
-
operation. Read more