|
Bouncy Castle Cryptography Library 1.81 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.bouncycastle.pqc.legacy.math.linearalgebra.IntegerFunctions
Class of number-theory related functions for use with integers represented as int's or BigInteger objects.
Method Summary | |
static java.math.BigInteger |
binomial(int n,
int t)
Computes the binomial coefficient (n|t) ("n over t"). |
static int |
bitCount(int a)
|
static int |
ceilLog(java.math.BigInteger a)
Compute the smallest integer that is greater than or equal to the logarithm to the base 2 of the given BigInteger. |
static int |
ceilLog(int a)
Compute the smallest integer that is greater than or equal to the logarithm to the base 2 of the given integer. |
static int |
ceilLog256(int n)
Compute ceil(log_256 n), the number of bytes needed to encode the integer n. |
static int |
ceilLog256(long n)
Compute ceil(log_256 n), the number of bytes needed to encode the long integer n. |
static java.math.BigInteger[] |
divideAndRound(java.math.BigInteger[] a,
java.math.BigInteger b)
|
static java.math.BigInteger |
divideAndRound(java.math.BigInteger a,
java.math.BigInteger b)
|
static java.math.BigInteger[] |
extgcd(java.math.BigInteger a,
java.math.BigInteger b)
Extended euclidian algorithm (computes gcd and representation). |
static int[] |
extGCD(int a,
int b)
Extended euclidian algorithm (computes gcd and representation). |
static float |
floatPow(float f,
int i)
int power of a base float, only use for small ints |
static int |
floorLog(java.math.BigInteger a)
Compute the integer part of the logarithm to the base 2 of the given integer. |
static int |
floorLog(int a)
Compute the integer part of the logarithm to the base 2 of the given integer. |
static int |
gcd(int u,
int v)
Computes the greatest common divisor of the two specified integers |
static byte[] |
integerToOctets(java.math.BigInteger val)
|
static float |
intRoot(int base,
int root)
Takes an approximation of the root from an integer base, using newton's algorithm |
static boolean |
isIncreasing(int[] a)
|
static int |
isPower(int a,
int p)
Tests whether an integer a is power of another integer p. |
static boolean |
isPrime(int n)
Miller-Rabin-Test, determines wether the given integer is probably prime or composite. |
static int |
jacobi(java.math.BigInteger A,
java.math.BigInteger B)
Computes the value of the Jacobi symbol (A|B). |
static java.math.BigInteger |
leastCommonMultiple(java.math.BigInteger[] numbers)
Computation of the least common multiple of a set of BigIntegers. |
static int |
leastDiv(int a)
Find and return the least non-trivial divisor of an integer a. |
static double |
log(double x)
Deprecated. use MathFunctions.log(double) instead |
static double |
log(long x)
Deprecated. use MathFunctions.log(long) instead |
static int |
maxPower(int a)
Compute the largest h with 2^h | a if a! |
static long |
mod(long a,
long m)
Returns a long integer whose value is (a mod m). |
static int |
modInverse(int a,
int mod)
Computes the modular inverse of an integer a |
static long |
modInverse(long a,
long mod)
Computes the modular inverse of an integer a |
static int |
modPow(int a,
int e,
int n)
Compute a e mod n. |
static java.math.BigInteger |
nextPrime(long n)
Computes the next prime greater than n. |
static java.math.BigInteger |
nextProbablePrime(java.math.BigInteger n)
Compute the next probable prime greater than n with the default certainty (20). |
static java.math.BigInteger |
nextProbablePrime(java.math.BigInteger n,
int certainty)
Compute the next probable prime greater than n with the specified certainty. |
static int |
nextSmallerPrime(int n)
Returns the largest prime smaller than the given integer |
static java.math.BigInteger |
octetsToInteger(byte[] data)
|
static java.math.BigInteger |
octetsToInteger(byte[] data,
int offset,
int length)
|
static int |
order(int g,
int p)
determines the order of g modulo p, p prime and 1 < g < p. |
static boolean |
passesSmallPrimeTest(java.math.BigInteger candidate)
Short trial-division test to find out whether a number is not prime. |
static int |
pow(int a,
int e)
Compute a e. |
static long |
pow(long a,
int e)
Compute a e. |
static java.math.BigInteger |
randomize(java.math.BigInteger upperBound)
|
static java.math.BigInteger |
randomize(java.math.BigInteger upperBound,
java.security.SecureRandom prng)
|
static java.math.BigInteger |
reduceInto(java.math.BigInteger n,
java.math.BigInteger begin,
java.math.BigInteger end)
Reduces an integer into a given interval |
static java.math.BigInteger |
squareRoot(java.math.BigInteger a)
Extract the truncated square root of a BigInteger. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static int jacobi(java.math.BigInteger A, java.math.BigInteger B)
(A|B) = 0 IF gcd(A,B) > 1 (-1|B) = 1 IF n = 1 (mod 1) (-1|B) = -1 IF n = 3 (mod 4) (A|B) (C|B) = (AC|B) (A|B) (A|C) = (A|CB) (A|B) = (C|B) IF A = C (mod B) (2|B) = 1 IF N = 1 OR 7 (mod 8) (2|B) = 1 IF N = 3 OR 5 (mod 8)
A
- integer valueB
- integer value
public static int gcd(int u, int v)
u
- - first integerv
- - second integer
public static int[] extGCD(int a, int b)
a
- the first integerb
- the second integer
public static java.math.BigInteger divideAndRound(java.math.BigInteger a, java.math.BigInteger b)
public static java.math.BigInteger[] divideAndRound(java.math.BigInteger[] a, java.math.BigInteger b)
public static int ceilLog(java.math.BigInteger a)
a
- the integer
public static int ceilLog(int a)
a
- the integer
public static int ceilLog256(int n)
n
- the integer
public static int ceilLog256(long n)
n
- the long integer
public static int floorLog(java.math.BigInteger a)
a
- the integer
public static int floorLog(int a)
a
- the integer
public static int maxPower(int a)
a
- an integer
public static int bitCount(int a)
a
- an integer
public static int order(int g, int p)
g
- an integer with 1 < g < pp
- a prime
public static java.math.BigInteger reduceInto(java.math.BigInteger n, java.math.BigInteger begin, java.math.BigInteger end)
n
- - the integerbegin
- - left bound of the intervalend
- - right bound of the interval
public static int pow(int a, int e)
a
- the basee
- the exponent
public static long pow(long a, int e)
a
- the basee
- the exponent
public static int modPow(int a, int e, int n)
a
- the basee
- the exponentn
- the modulus
public static java.math.BigInteger[] extgcd(java.math.BigInteger a, java.math.BigInteger b)
a
- - the first integerb
- - the second integer
public static java.math.BigInteger leastCommonMultiple(java.math.BigInteger[] numbers)
numbers
- - the set of numbers
public static long mod(long a, long m)
a
- value on which the modulo operation has to be performed.m
- the modulus.
public static int modInverse(int a, int mod)
a
- - the integer to invertmod
- - the modulus
public static long modInverse(long a, long mod)
a
- - the integer to invertmod
- - the modulus
public static int isPower(int a, int p)
a
- - the first integerp
- - the second integer
public static int leastDiv(int a)
a
- - the integer
public static boolean isPrime(int n)
n
- the integer to test for primality
public static boolean passesSmallPrimeTest(java.math.BigInteger candidate)
candidate
- the number to test
public static int nextSmallerPrime(int n)
n
- - upper bound
public static java.math.BigInteger nextProbablePrime(java.math.BigInteger n, int certainty)
n
- a integer numbercertainty
- the certainty that the generated number is prime
public static java.math.BigInteger nextProbablePrime(java.math.BigInteger n)
n
- a integer number
public static java.math.BigInteger nextPrime(long n)
n
- a integer number
public static java.math.BigInteger binomial(int n, int t)
n
- - the "upper" integert
- - the "lower" integer
public static java.math.BigInteger randomize(java.math.BigInteger upperBound)
public static java.math.BigInteger randomize(java.math.BigInteger upperBound, java.security.SecureRandom prng)
public static java.math.BigInteger squareRoot(java.math.BigInteger a)
a
- - value out of which we extract the square root
public static float intRoot(int base, int root)
base
- the base to take the root fromroot
- the root, for example 2 for a square rootpublic static float floatPow(float f, int i)
f
- base floati
- power to be raised to.
public static double log(double x)
x
- any double value
public static double log(long x)
x
- any long value >=1
public static boolean isIncreasing(int[] a)
public static byte[] integerToOctets(java.math.BigInteger val)
public static java.math.BigInteger octetsToInteger(byte[] data, int offset, int length)
public static java.math.BigInteger octetsToInteger(byte[] data)
|
Bouncy Castle Cryptography Library 1.81 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |