From Convolution to Negacyclic Ring Arithmetic
Every code listing from this chapter of Applied Post-Quantum Cryptography — 2 in total, 2 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.
Listing 1 — A reproducible Sage experiment
The following experiment uses one field, one input vector, and the negacyclic matrix on both sides of the comparison.
Listing 2 — A cyclic comparison
It is useful to see the conventional circulant case too, provided it is labelled correctly. This version changes both the matrix and the quotient modulus to x⁴-1: