sign/encoding/poly_codec library

Serialization of Falcon polynomials whose coefficients live in [0, q).

This is a direct port of serialize_poly / deserialize_to_poly from the Python reference (falcon.py). Each coefficient is packed into exactly 14 bits (because q == 12289 < 2^14), little-endian by coefficient index inside one big integer, then emitted as a big-endian bytestring — matching Python's int.to_bytes(bytelen) (which defaults to big-endian).

Web-safety: a degree-512 polynomial needs 512 * 14 == 7168 bits of buffer, far beyond the 53-bit range of a JS int, so we use BigInt for the packing buffer. The per-coefficient values themselves stay below q, so they remain safe plain ints.

Functions

deserializePoly(Uint8List bytestring, int n) List<int>
Deserialize a bytestring back into a polynomial of length n.
serializePoly(List<int> poly) Uint8List
Serialize a polynomial (a list of integers in [0, q)) into a bytestring.