1

What is the algorithm used by GMP to invert a element in a finite field?

Régis B.
  • 10,092
  • 6
  • 54
  • 90
Rick
  • 361
  • 5
  • 17

1 Answers1

4

It uses extended GCD as implemented in mpz_gcdext: https://fossies.org/dox/gmp-6.1.0/mpz_2invert_8c_source.html .

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120
  • See section 15.3.4 of the GMP manual: [https://gmplib.org/manual/Extended-GCD.html#Extended-GCD](https://gmplib.org/manual/Extended-GCD.html#Extended-GCD) – user448810 Apr 05 '16 at 21:19
  • Specifically, it calls `mpz_gcdext` with a NULL argument for one of the Bézout coefficients - since it's not required. `(g, z, NULL, x, modulus)`. The least non-negative residue (the inverse) will be within: `+/- modulus` if `(z < 0)`. This is due to gcdext returning one of two possible 'minimal' coefficient pairs. – Brett Hale Apr 11 '16 at 14:38