poly
library
Functions
cbd (Poly r , Uint8List buf )
→ void
Samples a polynomial from a uniform distribution using the
Centered Binomial Distribution (CBD) as described in the
Kyber specification.
polyadd (Poly a , Poly b )
→ Poly
Returns a new polynomial r
which is the component-wise sum of polynomials a
and b
.
polybasemul (Poly a , Poly b )
→ Poly
Returns a new polynomial r
which is the component-wise multiplication of polynomials a
and b
in the Montgomery domain.
polycompress (Poly a )
→ Uint8List
Compresses a polynomial into a byte array representation.
polydecompress (Uint8List r )
→ Poly
Decompresses a polynomial from a compressed byte representation.
polyfrombytes (Uint8List r )
→ Poly
Deserializes a polynomial from a byte array representation.
polyfrommsg (Poly p , Uint8List msg )
→ void
Converts a message byte array msg
into a polynomial p
.
polygetnoise (Poly r , Uint8List seed , int nonce )
→ void
Generates a pseudorandom polynomial from a seed and nonce using SHAKE128
and CBD (Centered Binomial Distribution). The output is a polynomial with
coefficients in the range -(q-1)/2, (q-1)/2
.
polyinvntttomont (Poly a )
→ void
Inverse NTT transform of a polynomial, in the Montgomery domain, with the result reduced modulo q.
polyntt (Poly a )
→ void
Applies the Number Theoretic Transform (NTT) to a polynomial a
in-place.
polyreduce (Poly a )
→ Poly
Reduces all coefficients of a polynomial mod q.
polysub (Poly a , Poly b )
→ Poly
Returns a new polynomial r = a - b, i.e. for each coefficient, ri
= ai
- bi
mod q.
polytobytes (Poly a )
→ Uint8List
Serializes a polynomial into a byte array representation.
polytomsg (Uint8List msg , Poly p )
→ void
Converts a polynomial p
into a message byte array msg
.
polyuniform (Poly a , Uint8List seed , int nonce )
→ void
Generates a pseudorandom polynomial a
from a given seed
and nonce
.