Background reading Kyber / ML-KEM

Compress the coefficient

ML-KEM uses q = 3329. The ciphertext has a polynomial vector u and a polynomial v. For ML-KEM-768, u coefficients use 10 bits each and v coefficients use 4. Take a coefficient 1650 of v just before compression. Multiply it by 16/3329, round to the nearest integer, and reduce modulo 16. The result is 8.

Pack and recover the integer

FIPS 203 packs coefficient bits from least to most significant. If the adjacent compressed coefficient is 3, the two 4-bit values occupy one byte 0x38. The low nibble recovers 8. Decompression computes round(3329·8/16) = 1665, shifting the example coefficient by +15.

v coefficient: 1650 → 8 → low nibble of 0x38 → 8 → 1665

Round the residual to a message bit

The PKE decryption inside ML-KEM decompresses both u and v and subtracts the secret-dependent product from v. Suppose the corresponding coefficient of that product is 10. The residual is 1655, and rounding 2·1655/3329 yields bit 1. This example follows one coordinate of the subtraction. Computing the product requires whole polynomials.

Check a wraparound case. A v coefficient of 3300 compresses to 0 after reduction modulo 16, so it decompresses to 0. The circular error is +29. The KEM then uses the recovered message in its decapsulation checks and returns a shared secret. FIPS 203, Sections 4.2.1 and 5.