Documentation ¶
Index ¶
- func Crt(a *big.Int, pa *big.Int, b *big.Int, pb *big.Int) *big.Int
- func FastRandomBigInt(limit *big.Int) *big.Int
- func GetHashNumber(a *big.Int, b *big.Int, index int, bitlen uint) *big.Int
- func HashCommit(values []*big.Int, issig bool) *big.Int
- func IntHashSha256(input []byte) *big.Int
- func LegendreSymbol(a, p *big.Int) int
- func ModInverse(a, n *big.Int) (ia *big.Int, ok bool)
- func ModPow(x, y, m *big.Int) *big.Int
- func ModSqrt(a *big.Int, factors []*big.Int) (*big.Int, bool)
- func PrimeSqrt(a *big.Int, pa *big.Int) (*big.Int, bool)
- func RandomBigInt(numBits uint) (*big.Int, error)
- func RandomPrimeInRange(rand io.Reader, start, length uint) (p *big.Int, err error)
- func RandomQR(n *big.Int) *big.Int
- func RepresentToBases(bases, exps []*big.Int, modulus *big.Int, maxMessageLength uint) *big.Int
- type CPRNG
- type FastMod
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FastRandomBigInt ¶
Derives a random number uniformly chosen below the given limit from a random 256 bit seed generated when the application starts.
func GetHashNumber ¶
GetHashNumber uses a hash to generate random numbers of a given bitlength in the fiat-shamir heuristic
func HashCommit ¶
hashCommit computes the sha256 hash over the asn1 representation of a slice of big integers and returns a positive big integer that can be represented with that hash.
func IntHashSha256 ¶
intHashSha256 is a utility function compute the sha256 hash over a byte array and return this hash as a big.Int.
func LegendreSymbol ¶
legendreSymbol calculates the Legendre symbol (a/p).
func ModInverse ¶
modInverse returns ia, the inverse of a in the multiplicative group of prime order n. It requires that a be a member of the group (i.e. less than n). This function was taken from Go's RSA implementation
func ModPow ¶
modPow computes x^y mod m. The exponent (y) can be negative, in which case it uses the modular inverse to compute the result (in contrast to Go's Exp function).
func ModSqrt ¶
Calculate Sqrt modulo a number with given prime factors. Also allows 4 as a factor All factors should be relatively prime to each other!
func RandomBigInt ¶
RandomBigInt returns a random big integer value in the range [0,(2^numBits)-1], inclusive.
func RandomPrimeInRange ¶
RandomPrimeInRange returns a random probable prime in the range [2^start, 2^start + 2^length] This code is an adaption of Go's own Prime function in rand/util.go
func RepresentToBases ¶
RepresentToPublicKey returns a representation of the given exponents in terms of the R bases from the public key. For example given exponents exps[1],...,exps[k] this function returns
R[1]^{exps[1]}*...*R[k]^{exps[k]} (mod N)
with R and N coming from the public key. The exponents are hashed if their length exceeds the maximum message length from the public key.