fast modular inverse
843811Dec 5 2005 — edited Dec 8 2005For 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?