|
size(N)
size(N:long) : int
Returns the size of the number N in bits. |
|
|
|
getRandomNumber(N,
randfunc=None)
Deprecated. Use getRandomInteger or getRandomNBitInteger instead. |
|
|
|
getRandomInteger(N,
randfunc=None)
getRandomInteger(N:int, randfunc:callable):long
Return a random number with at most N bits. |
|
|
|
getRandomRange(a,
b,
randfunc=None)
getRandomRange(a:int, b:int, randfunc:callable):long
Return a random number n so that a <= n < b. |
|
|
|
getRandomNBitInteger(N,
randfunc=None)
getRandomInteger(N:int, randfunc:callable):long
Return a random number with exactly N-bits, i.e. a random number
between 2**(N-1) and (2**N)-1. |
|
|
|
GCD(x,
y)
GCD(x:long, y:long): long
Return the GCD of x and y. |
|
|
|
inverse(u,
v)
inverse(u:long, v:long):long
Return the inverse of u mod v. |
|
|
|
getPrime(N,
randfunc=None)
getPrime(N:int, randfunc:callable):long
Return a random N-bit prime number. |
|
|
|
_rabinMillerTest(n,
rounds,
randfunc=None)
_rabinMillerTest(n:long, rounds:int, randfunc:callable):int
Tests if n is prime.
Returns 0 when n is definitly composite.
Returns 1 when n is probably prime.
Returns 2 when n is definitly prime. |
|
|
|
getStrongPrime(N,
e=0,
false_positive_prob=1e-06,
randfunc=None)
getStrongPrime(N:int, e:int, false_positive_prob:float, randfunc:callable):long
Return a random strong N-bit prime number.
In this context p is a strong prime if p-1 and p+1 have at
least one large prime factor.
N should be a multiple of 128 and > 512. |
|
|
|
isPrime(N,
false_positive_prob=1e-06,
randfunc=None)
isPrime(N:long, false_positive_prob:float, randfunc:callable):bool
Return true if N is prime. |
|
|
|
long_to_bytes(n,
blocksize=0)
long_to_bytes(n:long, blocksize:int) : string
Convert a long integer to a byte string. |
|
|
|
bytes_to_long(s)
bytes_to_long(string) : long
Convert a byte string to a long integer. |
|
|
|
|
|
|
|
|