Skip to main content

compress

Function compress 

Source
pub fn compress(d: u32, x: u16) -> u16
Expand description

Lossy compression from Z_q to Z_{2^d} (FIPS 203 eq. 4.7).

Computes x -> round(2^d / q * x) mod 2^d using integer-only arithmetic: floor((2^d * x + q/2) / q) mod 2^d.

§Arguments

  • d - Target bit-width (1..=12).
  • x - A coefficient in [0, q-1].

§Returns

The compressed value in [0, 2^d - 1].