# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
EnsureFieldOrder ensures the field order should be more than 2.
EnsureRank ensures the rank+1 should be smaller than threshold.
EnsureThreshold ensures the threshold should be smaller than or equal to n.
EulerFunction :(Special case) Assume that N is square-free and primeFactor consists of prime integers.
The hash result is Hash(salt + "," + message +"," + "0") | Hash(salt + "," + message + "," + "1") | ...
This is a algorithm to get number % 3.
Gcd calculates greatest common divisor (GCD) via Euclidean algorithm.
The algorithm appears in the paper Safe Prime Generation with a Combined Sieve https://eprint.iacr.org/2003/186.pdf safe prime: p = 2q+1, where p and q are both primes.
GenRandomBytes generates a random byte array with indicating the legnth.
No description provided by the author
No description provided by the author
HashProtos hashes a slice of message.
No description provided by the author
Waring: The follwing function only work in S256 and P256, because the output of blake2b is 32 byte.
InRange checks if the checkValue is in [floor, ceil).
IsRelativePrime returns if a and b are relative primes.
Lcm calculates find Least Common Multiple https://rosettacode.org/wiki/Least_common_multiple#Go.
No description provided by the author
RandomInt generates a random number in [-n, n].
RandomAbsoluteRangeIntBySeed generates a random number in (-2^q.bit, 2^q.bit) with seed.
RandomCoprimeInt generates a random relative prime number in [2, n).
RandomInt generates a random number in [0, n).
RandomPositiveInt generates a random number in [1, n).
RandomPrime generates a random prime number with bits size.
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
SaltSize is based on blake2b256.
# Variables
ErrEmptySlice is returned if the length of slice is zero.
ErrExceedMaxRetry is returned if we retried over times.
ErrInvalidInput is returned if the input is invalid.
ErrLargeRank is returned if the rank is too large.
ErrLargerFloor is returned if the floor is larger than ceil.
ErrLargeThreshold is returned if the threshold is too large.
ErrLessOrEqualBig2 is returned if the field order is less than or equal to 2.
ErrNotInRange is returned if the value is not in the given range.
ErrSmallSafePrime is returned if the safePrime < 2^10.
ErrSmallThreshold is returned if the threshold < 2.
No description provided by the author