Computing A^x (mod n)

Philip Lee rocketman768 at
Mon Oct 4 06:41:22 CEST 2004

>PS: it's almost insulting to suggest that the GMP guys would have implemented
>modular exponentiation without reduction after each step. Better put your
>asbestos suit on

Sorry for the insult. The function just seems very simple to me, and
it's not working. I mean, there's not too much I can screw up about
it...all the numbers I give it are what I intended to pass, all valid
mpz_t's of correct values. Just tell me what would be wrong about:

mpz_powm( plaintext, cipher, d, n );

Where ciper, d, and n are all about 576 bits. I mean, surely it
wouldn't overflow if at each step it's doing it modulo n right? Again,
sorry if I made somebody mad; it's just that I'M the mad one right now

More information about the gmp-discuss mailing list