How to "undo" mpz_invert()
James Buchanan
james at jamesbuchanan.net
Thu Dec 2 23:51:34 CET 2004
Sisyphus wrote:
> 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 ?
I have tried it with:
x = 12682271391376756984
n = 3527
Calculating the inverse modulo of x and n is:
p = 2288
Now I try to get x back by calculating the inverse modulo of n and p and
get:
x = 2209
So what happened to the original big x? Or is there some constant
multiplier now that I must find so that 2209*k = the original x?
Cheers,
James
More information about the gmp-discuss
mailing list