poly
library
Functions
cbd (Poly r , Uint8List buf )
→ void
Implements the Centered Binomial Distribution for η=2.
polyadd (Poly a , Poly b )
→ Poly
Component-wise addition of two polynomials.
polybasemul (Poly a , Poly b )
→ Poly
Component-wise multiplication of two polynomials in Montgomery domain.
polycompress (Poly a )
→ Uint8List
Compresses a polynomial into a compact byte array using 3 bits per coefficient.
polydecompress (Uint8List r )
→ Poly
Decompresses a polynomial from its compressed byte array representation.
polyfrombytes (Uint8List r )
→ Poly
Deserializes a polynomial from a byte array using 12-bit encoding.
polyfrommsg (Poly p , Uint8List msg )
→ void
Converts a message (byte array) into a polynomial.
Each bit of the message is mapped to a coefficient in the polynomial.
If the bit is 1, the corresponding coefficient is set to KYBER_Q/2; otherwise, 0.
polygetnoise (Poly r , Uint8List seed , int nonce )
→ void
Generates a pseudorandom polynomial from a seed and nonce using SHAKE128 and CBD.
polyinvntttomont (Poly a )
→ void
Applies the inverse NTT transform (returning the polynomial in standard representation).
polyntt (Poly a )
→ void
Applies the NTT transform to a polynomial.
polyreduce (Poly a )
→ Poly
Reduces all coefficients of a polynomial modulo KYBER_Q.
polysub (Poly a , Poly b )
→ Poly
Component-wise subtraction of two polynomials.
polytobytes (Poly a )
→ Uint8List
Serializes a polynomial into a byte array using 12-bit encoding per coefficient.
polytomsg (Uint8List msg , Poly p )
→ void
Converts a polynomial into a message (byte array).
Groups of 8 coefficients are converted back into a single byte.
polyuniform (Poly a , Uint8List seed , int nonce )
→ void
Generates a uniform polynomial from a seed and nonce using SHAKE128.