How to "undo" mpz_invert()

Sisyphus kalinabears at iinet.net.au
Thu Dec 2 23:31:49 CET 2004



James Buchanan wrote:
> Once mpz_invert has been applied to find an inverse modulo, is there 
> some way to "undo" it?
> 

Not sure that I follow.

mpz_invert(p, x, n) will set p to the inverse of x, modulo n. The 
relationship can now be written:
px = sn + 1
and we're usually not interested in the value of s.
Alternatively we say that px = 1 mod n.

If you already have 'p' and you want to know what it's the inverse of, 
then you simply:
mpz_invert(p, p, n);
and p will now be set to the value of x.

Does that help ?

Cheers,
Rob



More information about the gmp-discuss mailing list