mpz_invert computes the multiplicative inverse of c modulo n when one exists, providing the inverse needed for modular division. section 2.3
Use the inverse inside a modular division routine:
- Initialize temporary storage so the result can safely overlap an input without clobbering it. section 2.3
- Call mpz_invert(rslt, c, n) and test its return value; failure is treated as a division-by-zero error. section 2.3
Modular division
The routine computes a = b/c mod n by obtaining c's inverse, multiplying it by b, reducing the product modulo n, and aborting if inversion fails.
