deserializePoly function
Deserialize a bytestring back into a polynomial of length n.
Mirrors deserialize_to_poly: interprets the bytes as one big-endian big
integer, then peels off 14-bit coefficients from the low end, lowest index
first.
Implementation
List<int> deserializePoly(Uint8List bytestring, int n) {
assert(
8 * bytestring.length % n == 0,
'bit length must be a multiple of the coefficient count',
);
final BigInt mask = (BigInt.one << _bitsPerCoef) - BigInt.one;
BigInt buffer = _bytesToBigIntBE(bytestring);
final List<int> poly = List<int>.filled(n, 0);
for (int idx = 0; idx < n; idx++) {
poly[idx] = (buffer & mask).toInt();
buffer >>= _bitsPerCoef;
}
return poly;
}