Itoh–Tsujii inversion algorithm

The Itoh–Tsujii inversion algorithm is used to invert elements in a finite field. It was introduced in 1988, first over GF(2m) using the normal basis representation of elements, however, the algorithm is generic and can be used for other bases, such as the polynomial basis. It can also be used in any finite field GF(pm).

The algorithm is as follows:
 * Input: A ∈ GF(pm)
 * Output: A&minus;1
 * r ← (pm &minus; 1)/(p &minus; 1)
 * compute Ar&minus;1 in GF(pm)
 * compute Ar = Ar&minus;1 · A
 * compute (Ar)&minus;1 in GF(p)
 * compute A&minus;1 = (Ar)&minus;1 · Ar&minus;1
 * return A&minus;1

This algorithm is fast because steps 3 and 5 both involve operations in the subfield GF(p). Similarly, if a small value of p is used, a lookup table can be used for inversion in step 4. The majority of time spent in this algorithm is in step 2, the first exponentiation. This is one reason why this algorithm is well suited for the normal basis, since squaring and exponentiation are relatively easy in that basis.