|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Math
An implementation for operations on large integers.
Constructor Summary | |
Math()
|
Method Summary | |
static java.math.BigInteger |
gcd(java.math.BigInteger a,
java.math.BigInteger b)
Compute the greatest common divisor (gcd) of two integers. |
static boolean |
isProbablePrime(java.math.BigInteger n,
int certainty)
Check if an integer is prime. |
static java.math.BigInteger |
makePrime(int bitLength,
int certainty)
Create a large prime integer. |
static java.math.BigInteger |
mod4Pow(java.math.BigInteger a,
java.math.BigInteger e,
java.math.BigInteger n)
Same as modPow . |
static java.math.BigInteger |
modInverse(java.math.BigInteger a,
java.math.BigInteger n)
Compute the inverse of an integer a modulo n .
|
static java.math.BigInteger |
modPow(java.math.BigInteger a,
java.math.BigInteger e,
java.math.BigInteger n)
Compute a power e modulo n .
|
static java.math.BigInteger |
polFactors(java.math.BigInteger n)
Factorises a large integer. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public Math()
Method Detail |
public static java.math.BigInteger gcd(java.math.BigInteger a, java.math.BigInteger b)
a
- large integer.b
- large integer.public static java.math.BigInteger modInverse(java.math.BigInteger a, java.math.BigInteger n) throws java.lang.ArithmeticException
a
modulo n
.
It is assumed that a
and n
are relative primes,
ie gcd(a,n)=1
, otherwise an ArithmeticExpression
is thrown. Uses the extended Euclidean algorithm.
a
- integer to inverse.n
- modulo.public static java.math.BigInteger modPow(java.math.BigInteger a, java.math.BigInteger e, java.math.BigInteger n)
a
power e
modulo n
.
a
- integer to exponentiate.e
- exponent.n
- modulo.public static java.math.BigInteger mod4Pow(java.math.BigInteger a, java.math.BigInteger e, java.math.BigInteger n)
modPow
. In theory, it should be faster than modPow
for large numbers, but somehow, java makes it slower...
a
- integer to exponentiate.e
- exponent.n
- modulo.public static java.math.BigInteger polFactors(java.math.BigInteger n)
n
- an integer to factorise.public static java.math.BigInteger makePrime(int bitLength, int certainty)
bitLength
bits, and its first and last bits are set
to 1. isProbablePrime
is used to check whether the generated
integer is prime. The generated integer has a probability
of being prime equal to: 1-1/2^certainty
.
bitLength
- the number of bits in the integer.certainty
- degree of probability of the integer of being prime.public static boolean isProbablePrime(java.math.BigInteger n, int certainty)
certainty
.
n
- the integer to check.certainty
- degree of probability of the integer of being prime.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |