Powers modulo X^r - 1 and n on the word RAM #
Raising a polynomial modulo X^r - 1 and n to the power e by repeated squaring: with a result
block R, a base block B and a scratch block T, each round multiplies R by B into T and
copies it back when e is odd, squares B into T and copies it back, and halves e. The class
of R · B^e is invariant, so when e reaches 0 the result block holds the class of
R · B^e for the original R, B and e. The loop makes Nat.size e rounds, each of O(r²)
instructions (Cslib.Algorithms.WordRAM.AKS.PolyMul.program and
Cslib.WordRAM.ArrayCopy.program). This is the polynomial arithmetic of step 5 of the AKS
algorithm Agrawal, Kayal, Saxena, Section 4.
Main definitions #
Cslib.Algorithms.WordRAM.AKS.PolyPow.program: the repeated-squaring loop.Cslib.Algorithms.WordRAM.AKS.PolyPow.time: its instruction bound.
Main results #
Cslib.Algorithms.WordRAM.AKS.PolyPow.exec: the result block receives the coefficients ofR · B^ewithintime r einstructions.
References #
Base address of the result block.
Base address of the base block.
Base address of the scratch block.
The number r of coefficients.
The modulus n of the coefficients.
The exponent, halved every round.
The parity of the exponent.
Constant zero, for the loop test.
First argument of the multiplication, and source of the copy.
Second argument of the multiplication, and destination of the copy.
Product block of the multiplication.
Multiply the blocks at x and y into T, then copy T into the block at d.
Repeated squaring while the exponent is positive.
The instruction bound of one multiplication followed by a copy.
Powers modulo X^r - 1 and n. If the result, base and scratch blocks [a, a + r),
[b, b + r) and [t, t + r) are pairwise disjoint, the result and base coefficients are below
n ≥ 1, and the word size holds the block ends, 2 r, n² + n and the exponent e, then within
time r e instructions the result block receives reduced coefficients whose class is that of
R · B^e.