Toom-Cook Multiplication
1. Generalizing Karatsuba: Toom-
The Toom–Cook algorithm generalizes Karatsuba (which is Toom-2, where ). For an input polynomial of degree , Toom- splits it into sub-polynomials and reduces the number of necessary recursive multiplications from to .
Complexity Comparison
For multiplying two polynomials of size (degree ), the time complexity is determined by the split count :
Karatsuba (Toom-2)
3
Toom-3
5
Toom-4
7
2. Toom–Cook Process in (Toom-3 Example)
Let and be elements in , represented as polynomials of degree approximately . We aim to compute the polynomial product efficiently.
Step 1: Splitting (Divide)
Divide and into sub-polynomials ( and ) of degree less than :
Step 2: Evaluation
The resulting product has a maximum degree of , meaning it has unknown coefficients(from to )that must be solved for. Therefore, we need to evaluate and at 5 distinct, carefully chosen evaluation points (or a small extension of ).
Commonly chosen evaluation points are for (Similarly, for , we'll evaluate on ).
Compute and :
Evaluation at infinity:
Step 3: Pointwise Multiplication
Perform the recursive multiplications () on the evaluated results. This is where the bulk of the computational cost lies:
Each is a product of polynomials (or numbers) of size , and these recursive calls continue until the polynomials are small enough to be handled by a classical or base-case multiplication algorithm.
Step 4: Interpolation (Solve)
Use the calculated products to find the coefficient blocks () of the unreduced result .
The relationship between the evaluated values and the unknown coefficients is a Vandermonde system of linear equations:
By pre-calculating the inverse of the Vandermonde matrix, the interpolation is performed quickly using only linear combinations (additions and scalar multiplications) of the values over .
This above explains well why Karatuba is a specialized version of Toom-2.
Step 5: Recomposition and Final Reduction
Recomposition: Combine the resulting coefficient blocks using shifts:
Reduction: Apply the final modulo reduction to get the element in :
3. Practical Considerations for
In specialized hardware and software for finite field cryptography (like pairing-based cryptography which uses very large ), Toom–Cook is highly favored over Karatsuba because of its lower exponent.
Choice of : The optimal choice for the splitting factor depends on the size of the extension degree and the hardware architecture. Higher reduces the asymptotic complexity but increases the overhead of the Evaluation and Interpolation steps. Typically, or provides the best real-world performance gain before the overhead becomes prohibitive.
Base Field Operations: All additions, subtractions, and scalar multiplications are performed within the base field , which must itself be computed efficiently (often using Karatsuba or classical methods for the underlying integer arithmetic).
Written by Ryan Kim of Fractalyze
Last updated