|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--de.bb.minissl.BigInteger
A small and fast implementation for BigInteger. Like the String class, all public functions do not modify an existing BigInteger, but return a new created BigInteger with the result.
| Field Summary | |
static BigInteger |
ONE
|
static BigInteger |
TEN
|
static BigInteger |
THREE
|
static BigInteger |
TWO
|
static BigInteger |
ZERO
|
| Constructor Summary | |
BigInteger()
default ct, constructs a BigInteger with value 0. |
|
BigInteger(byte[] d)
Create a BigInteger from a byte array, which is interpreted as a big endian number. |
|
BigInteger(int bitLength,
int certainty,
java.util.Random rand)
Create a prime number for given bit length. |
|
BigInteger(int bitLength,
java.util.Random rand)
Create a random number for given bit length. |
|
BigInteger(long l)
Create a BigInteger from a long value. |
|
BigInteger(java.lang.String s)
Create a BigInteger from a String, the String is expected to contain some number with radix 10. |
|
BigInteger(java.lang.String s,
int radix)
Create a BigInteger from a String, the String is expected to contain some number with the given radix. |
|
| Method Summary | |
BigInteger |
add(BigInteger o)
Add to this number the value o, and return a new BigInteger containing the result. pseudo: return this + o |
int |
bitLength()
Return the count of used bits. |
java.lang.Object |
clone()
Clone this BigInteger. |
int |
compareTo(BigInteger o)
Compare this BigInteger to another BigInteger. |
BigInteger |
divide(BigInteger div)
Divide this number by the value o, and return a new BigInteger containing the result. pseudo: return this / o |
BigInteger[] |
divideAndRemainder(BigInteger div)
Calculate the division and modulo for this number by the value o, and return a new BigInteger array containing the results. pseudo: return {this / o, this mod o } |
BigInteger |
gcd(BigInteger b)
Calculate the greatest common divisor. |
int |
getLowestSetBit()
Get the index of the lowest set bit. |
boolean |
isProbablePrime(java.util.Random rand,
int numChecks)
Performs a check whether this number is probably prime. |
BigInteger |
mod(BigInteger div)
Calculate the modulo for this number by the value o, and return a new BigInteger containing the result. pseudo: return this mod o |
BigInteger |
modInverse(BigInteger n)
Calculate the modulo inverse for this number by the value n, and return a new BigInteger containing the result. pseudo: solves a * result == 1 (mod n) |
BigInteger |
modPow(BigInteger exp,
BigInteger mod)
Calculate this^exp % mod. |
BigInteger |
multiply(BigInteger o)
Multiply this number by the value o, and return a new BigInteger containing the result. pseudo: return this * o |
BigInteger |
negate()
Create a BigInteger with - this value. x.negate() + x = 0 |
BigInteger |
shiftLeft(int n)
Calculate the left shift for this number by the value n, and return a new BigInteger containing the result. pseudo: return this << n |
BigInteger |
shiftRight(int n)
Calculate the rights shift for this number by the value n, and return a new BigInteger containing the result. pseudo: return this >> n |
BigInteger |
subtract(BigInteger o)
Subtract from this number the value o, and return a new BigInteger containing the result. pseudo: return this - o |
byte[] |
toByteArray()
Convert this BigInteger into a byte array. |
java.lang.String |
toHexString()
Convert this BigInteger into an hex string. |
java.lang.String |
toString()
Convert this BigInteger into a decimal string. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final BigInteger ZERO
public static final BigInteger ONE
public static final BigInteger TWO
public static final BigInteger THREE
public static final BigInteger TEN
| Constructor Detail |
public BigInteger()
public BigInteger(int bitLength,
int certainty,
java.util.Random rand)
bitLength - the desired bit length of the prime.certainty - how sure is it a prim P = 1 - (1/2)^certainty.rand - the random generator for random numbers.
public BigInteger(int bitLength,
java.util.Random rand)
bitLength - the desired bit length of the number.rand - the random generator for random numbers.public BigInteger(long l)
l - the long value which is assigned to this BigInteger.public BigInteger(java.lang.String s)
s - input string, containing a number with radix 10.
public BigInteger(java.lang.String s,
int radix)
s - input string, containing a number with the given radix.radix - the radix to use, right now 10 and 16 are supported.public BigInteger(byte[] d)
d - input byte array.| Method Detail |
public java.lang.String toHexString()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.Object clone()
clone in class java.lang.Objectpublic byte[] toByteArray()
public BigInteger subtract(BigInteger o)
o - the subtracted valuepublic BigInteger add(BigInteger o)
o - the added valuepublic BigInteger multiply(BigInteger o)
o - the multiplicator.public BigInteger divide(BigInteger div)
div - the divisor.public BigInteger mod(BigInteger div)
div - the modulo.public BigInteger[] divideAndRemainder(BigInteger div)
div - the divisor/modulo.public BigInteger modInverse(BigInteger n)
n - the modulo.public int compareTo(BigInteger o)
o - the other BigInteger.public int getLowestSetBit()
public BigInteger shiftLeft(int n)
n - Count of left shifts.public BigInteger shiftRight(int n)
n - Count of right shifts.public int bitLength()
public boolean isProbablePrime(java.util.Random rand,
int numChecks)
rand - the used randomgenerator to perform the checks.numChecks - count of performed checkspublic BigInteger gcd(BigInteger b)
b - the 2nd BigInteger.
public BigInteger modPow(BigInteger exp,
BigInteger mod)
exp - the exponent.mod - the modulus.public BigInteger negate()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||