|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cryptix.util.math.Prime
A utility class to handle different algorithms for large prime number generation, factorisation and tests.
References:
Copyright © 1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.4 $
Field Summary | |
static int |
GERMAIN
|
static int |
PLAIN
|
static int |
STRONG
|
Method Summary | |
(package private) static void |
|
static java.lang.Object[] |
getElGamal(int bitlength,
int certainty,
java.util.Random random,
int prime_type)
Generates a random probable-prime, p, of the given length, such that all the factors of p - 1 are known. |
static java.math.BigInteger |
getGermain(int bitlength,
int certainty,
java.util.Random random)
Returns a Germain (Sophie) probable-prime with an approximate specified bitlength, that is prime with a probability exceeding 1 - (1/2)certainty. |
static java.math.BigInteger[] |
getGordon(int bitlength,
int certainty,
java.util.Random random)
Returns a Gordon strong probable-prime with an approximate specified bitlength, that is prime with a probability exceeding 1 - (1/2)certainty. |
static java.math.BigInteger[] |
getSmallFactors(java.math.BigInteger r,
int certainty)
Returns a BigInteger array whose elements are the prime factors of a designated BigInteger value, or null if the value could not easily be factorised. |
static java.math.BigInteger[] |
getSmallFactors(java.math.BigInteger r,
int certainty,
java.math.BigInteger q)
Return a BigInteger array whose elements are the prime factors of a designated BigInteger value, for which we already have one large prime factor. |
static boolean |
isGeneratorModP(java.math.BigInteger g,
java.math.BigInteger p,
java.math.BigInteger[] z)
|
static boolean |
isGermain(java.math.BigInteger p,
int certainty)
|
static boolean |
isProbablePrimeFast(java.math.BigInteger r,
int certainty)
Implements a faster (on average) primality check than BigInteger.isProbablePrime(r, certainty) . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int PLAIN
public static final int STRONG
public static final int GERMAIN
Method Detail |
public static java.math.BigInteger[] getGordon(int bitlength, int certainty, java.util.Random random)
A prime is said to be strong iff integers r, s, and t exist such that the following three conditions are satisfied:
GORDON's algorithm is described in [HAC] p.150 as follows:
bitlength
- An approximate number of bits that the returned
prime integer must have.certainty
- A measure of the probability that the returned
integer is a prime. The Miller-Rabin test used
ensures that the returned value is a prime with a
probability that exceeds 1 - (1/2)certainty.random
- A source of randomness for the bits to use in
building the prime.public static java.math.BigInteger getGermain(int bitlength, int certainty, java.util.Random random)
An integer p is a GERMAIN prime iff it is a prime, and p = 2q + 1 where q is also a prime.
bitlength
- An approximate number of bits that the returned
prime integer must have.certainty
- A measure of the probability that the returned
integer is a prime. The Miller-Rabin test used
ensures that the returned value is a prime with a
probability that exceeds 1 - (1/2)certainty.random
- A source of randomness for the bits to use in
building the prime.public static java.lang.Object[] getElGamal(int bitlength, int certainty, java.util.Random random, int prime_type)
bitlength
- An approximate number of bits that the returned
prime integer must have.certainty
- A measure of the probability that the returned
integer p, and the largest factor of p - 1
are primes. The Miller-Rabin test used ensures that
these values are prime with a probability that exceeds
1 - (1/2)certainty.random
- A source of randomness for the bits to use in
building the prime.prime_type
- what type of prime to build: PLAIN, STRONG or GERMAIN.public static java.math.BigInteger[] getSmallFactors(java.math.BigInteger r, int certainty)
r
- A BigInteger to factor.certainty
- A measure of the probability that the largest returned
factor is a prime. The Miller-Rabin test used ensures
that this factor is a prime with a probability that
exceeds 1 - (1/2)certainty.S_1 * S_2 * ... * S_n * LWhere S_i are small prime factors found in SMALL_PRIMES and L is a large prime factor. Return null otherwise.
public static java.math.BigInteger[] getSmallFactors(java.math.BigInteger r, int certainty, java.math.BigInteger q)
The returned array conatins all the distinct factors including the one we gave on input. The returned array is not guaranteed to be in any specific order.
r
- A BigInteger to factor.certainty
- A measure of the probability that the returned integers
are primes. The Miller-Rabin test used ensures that
each array element is a prime with a probability that
exceeds 1 - (1/2)certainty.q
- A known prime factor of r.public static boolean isGermain(java.math.BigInteger p, int certainty)
public static boolean isGeneratorModP(java.math.BigInteger g, java.math.BigInteger p, java.math.BigInteger[] z)
public static boolean isProbablePrimeFast(java.math.BigInteger r, int certainty)
BigInteger.isProbablePrime(r, certainty)
.static void()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |