Applied PQC GitHub Home Playground Blog @AppliedPQC

Module-LWE (MLWE)

Every code listing from this chapter of Applied Post-Quantum Cryptography — 5 in total, 5 runnable here. Edit any cell and press Run.

The book's snippets build on each other down the chapter, but a Sage Cell kernel runs one cell and keeps no state afterwards, so each cell replays the earlier listings with apqc_book. That call is the only thing added to the book's own code.

← the playground

Listing 1 — Sage construction of a toy module

We can create a very small toy example in Sage. First define the ring.

Listing 2 — Sage construction of a toy module

Now define a secret as a vector of two polynomials.

Listing 3 — Sage construction of a toy module

Create a small polynomial matrix.

Listing 4 — Sage construction of a toy module

Create a noise vector.

Listing 5 — Sage construction of a toy module

Then compute the public-like value.