Chapter 4Ring-LWE, Module-LWE, and the Number Theoretic Transform

Evaluation and Interpolation

August 25, 20265 min readbeginner

The entire transform rests on one observation, and the observation involves no roots of unity, no modular arithmetic, and nothing more advanced than plotting points.

The entire transform rests on one observation, and the observation involves no roots of unity, no modular arithmetic, and nothing more advanced than plotting points. It is worth meeting it in that plain form first.

01.A polynomial is determined by its values

Take a polynomial of degree at most 11, that is, a straight line a(X)=a0+a1Xa(X) = a_0 + a_1 X. Two numbers describe it: a0a_0 and a1a_1.

Two other numbers also describe it. Pick any two distinct inputs, say X=0X = 0 and X=1X = 1, and record the outputs a(0)a(0) and a(1)a(1). Those two values pin the line down completely, because two points determine a line.

The same holds at every degree. A polynomial of degree at most n−1n - 1 has nn coefficients, and it is equally determined by its values at any nn distinct points. Going one way is evaluation. Going back is interpolation.

So there are two equally valid ways to store a polynomial.

Coefficient form. The list (a0,a1,…,an−1)(a_0, a_1, \ldots, a_{n-1}).

Point-value form. The list (a(x0),a(x1),…,a(xn−1))\bigl(a(x_0), a(x_1), \ldots, a(x_{n-1})\bigr), for some agreed set of nn distinct points.

Neither loses information. They are two encodings of the same object.

02.Multiplication is cheap in the second form

Here is why anybody cares.

Suppose aa and bb are both stored in point-value form, at the same points. What is the point-value form of their product c=abc = ab?

At each point xix_i,

c(xi)  =  a(xi)⋅b(xi).c(x_i) \;=\; a(x_i) \cdot b(x_i) .

That is it. One multiplication per point. The value of a product at a point is the product of the values, which is true because that is what multiplying functions means.

So in point-value form, multiplying two polynomials of any degree costs nn multiplications rather than n2n^2. Linear, not quadratic.

Work it concretely with two lines. Let a(X)=1+2Xa(X) = 1 + 2X and b(X)=3+Xb(X) = 3 + X, and evaluate at X=0,1,2,3X = 0, 1, 2, 3.

xxa(x)a(x)b(x)b(x)a(x)⋅b(x)a(x) \cdot b(x)
0133
13412
25525
37642

Check the last column against the true product, which is ab=3+7X+2X2ab = 3 + 7X + 2X^2. At x=2x = 2 that gives 3+14+8=253 + 14 + 8 = 25. Correct. At x=3x = 3, 3+21+18=423 + 21 + 18 = 42. Correct.

Four points were used rather than three because the product has degree 22 and so needs three values to determine it, and taking one extra costs nothing.

03.The round trip

That suggests an algorithm immediately.

  1. Evaluate aa at nn points.
  2. Evaluate bb at the same nn points.
  3. Multiply the values pointwise. Cost: nn multiplications.
  4. Interpolate back to coefficient form.

Step 3 is wonderfully cheap. Steps 1, 2 and 4 are the problem.

Evaluating a polynomial with nn coefficients at one point costs about nn multiplications by Horner's method. Doing that at nn separate points costs n2n^2, which is exactly what we were trying to avoid. Interpolation by the standard method is no better.

So the round trip as described saves nothing. The expensive part simply moved.

04.Where the saving comes from

The way out is to stop treating the evaluation points as arbitrary.

Nothing so far constrained them. Any nn distinct points work. That freedom is the opening: if the points are chosen with a particular relationship to one another, evaluating at all of them at once can share work, and the shared work collapses the cost from n2n^2 to nlog⁡nn \log n.

The relationship that does it is this. Choose the points so that they are the powers of a single element ω\omega, that is

x0=ω0,x1=ω1,x2=ω2,  …,  xn−1=ωn−1,x_0 = \omega^0, \quad x_1 = \omega^1, \quad x_2 = \omega^2, \; \ldots, \; x_{n-1} = \omega^{n-1},

where ω\omega has the property that ωn=1\omega^n = 1 and no smaller positive power of ω\omega equals 11. Such an ω\omega is called a primitive nnth root of unity.

Why that helps is worth seeing rather than taking on trust. Split aa into its even-indexed and odd-indexed coefficients, writing

a(X)  =  aeven(X2)  +  X⋅aodd(X2),a(X) \;=\; a_{\text{even}}(X^2) \;+\; X \cdot a_{\text{odd}}(X^2),

where each half has n/2n/2 coefficients. To evaluate aa at all nn points, you need aevena_{\text{even}} and aodda_{\text{odd}} at the squares of those points.

Now the special property does its work. Squaring the nn powers of ω\omega does not give nn different values. It gives only n/2n/2, because ωk+n/2\omega^{k + n/2} squares to the same thing as ωk\omega^k. So the two half-sized problems are evaluated at half as many points, and the recursion halves the work at every level rather than merely splitting it.

That gives the recurrence

T(n)  =  2 T(n/2)  +  O(n),T(n) \;=\; 2\,T(n/2) \;+\; O(n),

whose solution is O(nlog⁡n)O(n \log n). Two subproblems of half the size, plus linear work to recombine. This is the Cooley-Tukey structure, and The Butterfly and Bit Reversal writes out every step of it for n=4n = 4.

05.One complication to flag now

There is a mismatch that has to be dealt with, and it is easier to name here than to discover later.

The construction above computes the product modulo Xn−1X^n - 1, not modulo Xn+1X^n + 1. The reason is direct: the evaluation points satisfy ωn=1\omega^n = 1, so any multiple of Xn−1X^n - 1 evaluates to zero at every one of them and is invisible to the transform.

That is the cyclic convolution, where the coefficient that overflows past degree nn wraps around and is added back at the bottom.

RqR_q needs the negacyclic version, where the overflow wraps around and is subtracted, because Xn=−1X^n = -1.

Fixing the mismatch requires evaluation points satisfying xn=−1x^n = -1 rather than xn=+1x^n = +1. Those exist, and finding them is the subject of the next note.

FeedbackBook mode
post-quantum-cryptographycryptographymathematics