Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

fast modular inverse

843811Dec 5 2005 — edited Dec 8 2005
For an Implementation of the MP Quadratic Sieve I need to calculate the modular inverse of BigIntger mod a long (or int) modulus.
i.e. the solution y : x * y = 1 mod m. where x is a BigInteger and m is a long value.
A first solution was to calculate y^(m-2) mod m, which works.
Then I programmed the extended euclidean algorithm, which is a little bit faster.

In BigInteger I saw the method modInverse. It is slower the the extended euclidean algorithm. But this migth be due to the BigInteger parameter for the modulus.

Has anybody a fast method for calculating the modular inverse?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 5 2006
Added on Dec 5 2005
5 comments
507 views