public final class BigIntegers
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
BigIntegers.Cache |
Modifier and Type | Field and Description |
---|---|
static java.math.BigInteger |
ONE |
static java.math.BigInteger |
TWO |
static java.math.BigInteger |
ZERO |
Constructor and Description |
---|
BigIntegers() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
asUnsignedByteArray(java.math.BigInteger value)
Return the passed in value as an unsigned byte array.
|
static void |
asUnsignedByteArray(java.math.BigInteger value,
byte[] buf,
int off,
int len)
Write the passed in value as unsigned bytes to the specified buffer range, padded with
leading zeros as necessary.
|
static byte[] |
asUnsignedByteArray(int length,
java.math.BigInteger value)
Return the passed in value as an unsigned byte array of the specified length, padded with
leading zeros as necessary..
|
static byte |
byteValueExact(java.math.BigInteger x) |
static java.math.BigInteger |
createRandomBigInteger(int bitLength,
java.security.SecureRandom random)
Return a positive BigInteger in the range of 0 to 2**bitLength - 1.
|
static java.math.BigInteger |
createRandomInRange(java.math.BigInteger min,
java.math.BigInteger max,
java.security.SecureRandom random)
Return a random BigInteger not less than 'min' and not greater than 'max'
|
static java.math.BigInteger |
createRandomPrime(int bitLength,
int certainty,
java.security.SecureRandom random)
Return a prime number candidate of the specified bit length.
|
static java.math.BigInteger |
fromUnsignedByteArray(byte[] buf) |
static java.math.BigInteger |
fromUnsignedByteArray(byte[] buf,
int off,
int length) |
static int |
getUnsignedByteLength(java.math.BigInteger n) |
static int |
intValueExact(java.math.BigInteger x) |
static long |
longValueExact(java.math.BigInteger x) |
static java.math.BigInteger |
modOddInverse(java.math.BigInteger M,
java.math.BigInteger X) |
static java.math.BigInteger |
modOddInverseVar(java.math.BigInteger M,
java.math.BigInteger X) |
static boolean |
modOddIsCoprime(java.math.BigInteger M,
java.math.BigInteger X) |
static boolean |
modOddIsCoprimeVar(java.math.BigInteger M,
java.math.BigInteger X) |
static short |
shortValueExact(java.math.BigInteger x) |
public static final java.math.BigInteger ZERO
public static final java.math.BigInteger ONE
public static final java.math.BigInteger TWO
public static byte[] asUnsignedByteArray(java.math.BigInteger value)
value
- the value to be converted.public static byte[] asUnsignedByteArray(int length, java.math.BigInteger value)
length
- the fixed length of the resultvalue
- the value to be converted.public static void asUnsignedByteArray(java.math.BigInteger value, byte[] buf, int off, int len)
value
- the value to be converted.buf
- the buffer to which the value is written.off
- the start offset in array buf
at which the data is written.len
- the fixed length of data written (possibly padded with leading zeros).public static java.math.BigInteger createRandomInRange(java.math.BigInteger min, java.math.BigInteger max, java.security.SecureRandom random)
min
- the least value that may be generatedmax
- the greatest value that may be generatedrandom
- the source of randomnesspublic static java.math.BigInteger fromUnsignedByteArray(byte[] buf)
public static java.math.BigInteger fromUnsignedByteArray(byte[] buf, int off, int length)
public static byte byteValueExact(java.math.BigInteger x)
public static short shortValueExact(java.math.BigInteger x)
public static int intValueExact(java.math.BigInteger x)
public static long longValueExact(java.math.BigInteger x)
public static java.math.BigInteger modOddInverse(java.math.BigInteger M, java.math.BigInteger X)
public static java.math.BigInteger modOddInverseVar(java.math.BigInteger M, java.math.BigInteger X)
public static boolean modOddIsCoprime(java.math.BigInteger M, java.math.BigInteger X)
public static boolean modOddIsCoprimeVar(java.math.BigInteger M, java.math.BigInteger X)
public static int getUnsignedByteLength(java.math.BigInteger n)
public static java.math.BigInteger createRandomBigInteger(int bitLength, java.security.SecureRandom random)
bitLength
- maximum bit length for the generated BigInteger.random
- a source of randomness.public static java.math.BigInteger createRandomPrime(int bitLength, int certainty, java.security.SecureRandom random)
bitLength
- bit length for the generated BigInteger.random
- a source of randomness.