9 Computing powers of polynomials
This chapter explains how to compute powers of polynomials modulo an irreducible polynomial, building directly on the multiplication routines developed earlier. That capability matters because many elliptic curve pairing operations depend on efficiently raising polynomials to large exponents, including powers tied to the field prime. Rather than advancing one exponent at a time, the chapter uses the binary expansion of the exponent so that exponentiation can be done through repeated squaring with occasional multiplies.
The core method is square-and-multiply, adapted from the familiar double-and-add idea used for elliptic curves. The chapter shows how to decompose an exponent into bits, begin with the leading bit already handled, and then repeatedly square the current result while multiplying by the base only when the next bit is set. This yields a much faster algorithm than naive repeated multiplication, and the same approach works whether the input is an arbitrary polynomial or a variable reduced modulo a prime polynomial. The code is organized into a small inner routine for one squaring-and-optional-multiply step and a wrapper that iterates through all bits of the exponent.
To make the process concrete, the chapter works through small examples over the field modulo 43 with the irreducible polynomial x^2 + x + 3. These examples show how reductions happen after each square and multiply, and how the final result is obtained in the quotient field. The chapter then specializes the method to compute powers of the field prime itself, which is useful for later construction tasks, and also gives a helper for exponentiation by (p-1)/2. Together, these routines provide the practical polynomial exponentiation tools needed for later work on irreducible polynomials and pairing-friendly elliptic curves.
Polynomial square and multiply algorithm, which will be used in chapter 12 to compute square roots
Summary
- The square and multiply algorithm computes powers of \(x\) modulo a prime polynomial. The variable \(x\) can also be a polynomial, and the same algorithm applies. The square and multiply algorithm is exponentially faster than a straightforward multiplication algorithm.
- Exponentiation uses the square and multiply routine for every bit in a power. Every bit forces a squaring operation; only set bits force a multiply operation.
- Fermat’s Little Theorem applies to field extensions. For prime polynomial \(f\) of degree \(k\) \[x^{p^k-1}\cong 1\text{ mod }f\]This is used to find square roots and irreducible polynomials.
- Computing \(x^{p^i}\) is an important subroutine for finding irreducible polynomials.
FAQ
What is the main goal of Chapter 9, “Computing powers of polynomials”?
It explains how to compute polynomial exponentials modulo an irreducible polynomial, which is needed for tasks like finding irreducible polynomials and supporting pairing-based elliptic curve routines.Why is square-and-multiply used for polynomial exponentiation?
Square-and-multiply is much faster than multiplying one power at a time. It uses the binary expansion of the exponent so each bit determines whether to square only or square and then multiply.How does the binary representation of an exponent help compute powers of a polynomial?
The exponent is expanded in base 2, and each bit corresponds to either a squaring step or a squaring plus multiplication step. This reduces the work needed compared with repeated multiplication.What role does the most significant bit play in the square-and-multiply algorithm?
The most significant bit is always 1, so the algorithm starts from the base polynomial itself and then processes the remaining bits from left to right.What does the function poly_sqm() do?
poly_sqm() performs one square-and-multiply step: it squares the input polynomial, and if the current exponent bit is set, it multiplies the squared result by the base polynomial.Why does poly_pow() call poly_sqm() repeatedly?
poly_pow() uses poly_sqm() to process each bit of the exponent in sequence, building the final result efficiently while always working modulo the irreducible polynomial.What is the result of computing x^5 modulo x^2 + x + 3 over mod 43?
The result is x + 28 modulo 43.Why is computing x^p modulo an irreducible polynomial important?
Computing x^p is a key step toward working with field extensions, and it helps connect polynomial exponentiation to later constructions such as x^{p^j}.What does poly_xp() compute?
poly_xp() computes a polynomial raised to the power of the field prime p, using the same square-and-multiply approach but with the prime as the exponent.Why is gpow_p2() useful?
gpow_p2() computes a polynomial raised to (p-1)/2, which is useful in later pairing and elliptic curve searches. Since the field prime is odd, dividing p-1 by 2 is always exact.
Elliptic Curve Cryptography for Developers ebook for free