Skip to main content

bit_pack

Function bit_pack 

Source
pub fn bit_pack(w: &[i32; 256], a: u32, b: u32, out: &mut [u8])
Expand description

Pack a polynomial whose coefficients lie in [-a, b].

Implements Algorithm 17 of FIPS 204 (BitPack). Stores each coefficient as (b - coeff), mapping the range [-a, b] to [0, a+b], then packs using bitlen(a+b) bits per coefficient.

  • w: input polynomial with coefficients in [-a, b].
  • a: magnitude of the negative bound.
  • b: positive bound.
  • out: output buffer (must have length >= N * bitlen(a+b) / 8).