Appendix D: Solutions for Chapter 10
This page collects solutions and editorial notes for the exercises in Chapter 10: Regev encryption from scratch. Compute and derivation exercises have worked solutions; open-ended exercises have an editorial note describing what a strong answer addresses.
The fuller versions of these routines are in the regev_pke package under solutions/ch10-regev-pke. From a clone of the companion repository, pytest tests/ch10 runs its suite. Appendix C has the setup.
Exercise 1
Section titled “Exercise 1”Take uniform and uniform at . The noise term is then a sum of up to products, each in , so it is supported on .
At the decoder’s two codewords are and , and its regions have different widths. It returns on the seven residues and on the six residues . The bit therefore survives , while the bit survives only . At the decrypted value under the bit is , which the decoder reads as .
Enumerating all pairs gives and . Averaged over the two message bits the exact rate is , which is the figure the chapter quotes as about . Reading the failure condition as the symmetric for both bits gives instead, understating the true rate by a factor of about .
Over 1000 seeds with both bits encrypted the sample is 2000 trials, so the standard error is . An observed rate outside roughly 4 to 6 percent points at a bug rather than at sampling noise.
Exercise 2
Section titled “Exercise 2”Each single-bit ciphertext is , which is entries in . Encrypting bits independently produces ciphertexts of entries each, for a total of entries to deliver bits. The expansion factor is entries in per plaintext bit. At this is 5, and at ML-KEM-style it would be 769 (which is why ML-KEM packs 256 message bits into one Module-LWE ciphertext rather than running 256 independent flat ciphertexts).
Exercise 3: noise budget under signed randomness
Section titled “Exercise 3: noise budget under signed randomness”The single-bit Regev decryption error is
with each and each now in instead of .
Worst-case bound. Each product is in regardless of which sign bag is drawn from, because in both cases. The triangle inequality gives
So the worst-case bound is unchanged at .
Typical magnitude. What changes is the variance of under the random sampling. With uniform, , so and . With uniform, and , so .
Treating as independent zero-mean with variance , the sum has variance
For : , so and the typical magnitude is .
For : , so and the typical magnitude is .
The ratio is , so signed randomness inflates the typical noise magnitude by about 15%. The worst case is unchanged, but the average failure probability rises slightly because the noise distribution is wider.
import mathprint(round(math.sqrt(4 / 3), 3))# ==> 1.155The practical implication: schemes that use signed randomness (like ML-KEM’s centered binomial distribution, which produces signed values) need a slightly wider decoding band or slightly tighter noise bound than schemes using -valued randomness, all else equal.
ML-KEM does not answer that by narrowing the distribution. Its encryption randomness comes from , with at ML-KEM-512 and at the other two parameter sets, and has second moment (National Institute of Standards and Technology, 2024). That is or , above both the -uniform and the ternary . The room comes from the modulus instead. ML-KEM encodes one message bit per coefficient of at , so its decoder has a radius of , against the this chapter’s toy works with.
Exercise 4
Section titled “Exercise 4”The encoding shift places bit 0 near 0 and bit 1 near in , with each band wide on each side, so the decoder must distinguish noise of magnitude up to . Shifting bit 1 to instead puts the two encoding centers at distance apart. The decoder now splits into bit 0 (around 0) and bit 1 (around ), and on the cycle it has two boundaries rather than one. They are the midpoint of the short arc between the codewords, at , and the midpoint of the long arc, at . Each codeword sits from the first boundary and from the second, so the first is the binding one. The noise bound that still decodes correctly drops to , two thirds of the original at the same .