ML-KEM coefficient compression #
FIPS 203 compresses a coefficient x ∈ ℤ_q to d bits and lifts it back by
Compress_d(x) = ⌈(2^d / q) · x⌋ mod 2^d and Decompress_d(y) = ⌈(q / 2^d) · y⌋
(NIST, Section 4.2.1), where ⌈r⌋ rounds to the nearest
integer with ties rounded up. Natural-number rounded division roundDiv a b = ⌊(2a + b) / (2b)⌋
implements ⌈a / b⌋, so compress and decompress below are these two maps for every modulus
q and width d, written on canonical representatives.
The three facts used by K-PKE are proved for every positive modulus:
compress_decompress: compression inverts decompression when2^d < q.natAbs_valMinAbs_decompress_compress_sub_le: the centered rounding error ofDecompress_d ∘ Compress_dis at most⌈q / 2^(d + 1)⌋.compress_one_decompress_one_add: one-bit decoding tolerates any centered error of magnitude at mostBwhen4 * B + 2 < q; this is the decoding step of K-PKE decryption.
Main definitions #
Cslib.Crypto.MLKEM.roundDiv: rounded natural division⌈a / b⌋, ties up.Cslib.Crypto.MLKEM.compress,Cslib.Crypto.MLKEM.decompress: FIPS 203 coefficient maps.Cslib.Crypto.MLKEM.compressPoly,Cslib.Crypto.MLKEM.decompressPoly: coefficientwise maps on polynomialsFin n → ZMod q.
References #
Rounded natural division ⌈a / b⌋ = ⌊(2a + b) / (2b)⌋, with ties rounded up.
Compression inverts decompression (NIST, Section 4.2.1): whenever
2^d < q, Compress_d(Decompress_d(y)) = y for every d-bit value y.
Rounding error of compression: for every positive modulus q, width d and coefficient
x, the centered representative of Decompress_d(Compress_d(x)) - x has magnitude at most
⌈q / 2^(d + 1)⌋. This is the standard error bound used in the correctness analysis of Kyber;
FIPS 203 itself only remarks that the error is small.
One-bit decoding with bounded error: when 4 * B + 2 < q and the centered representative
of w has magnitude at most B, Compress_1(Decompress_1(y) + w) = y for each bit y.