Skip to main content

Module fast_inverse

Module fast_inverse 

Source
Expand description

Fast inversion for GF(2^128) using Itoh-Tsujii with nibble tables

This implements efficient field inversion using precomputed tables of frobenius powers. The algorithm reduces from ~127 multiplications to ~9 multiplications + table lookups.

§Algorithm

Uses the identity: x^(-1) = x^(2^128 - 2)

The exponent 2^128 - 2 is computed using addition chains:

  • 2^128 - 2 = 2 * (2^127 - 1)
  • 2^127 - 1 has binary representation of 127 ones

By using the linearity of frobenius in characteristic 2, we can decompose computations by nibbles and use table lookups.

§References

Functions§

batch_invert_gf128
Batch invert multiple field elements using Montgomery’s trick
batch_invert_gf128_in_place
Batch invert in-place (more memory efficient)
invert_gf128
Invert a field element in GF(2^128)