common

package
v0.0.0-...-5bb28f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2018 License: Apache-2.0 Imports: 6 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConcatenateNumbers

func ConcatenateNumbers(numbers ...*big.Int) []byte

It takes big.Int numbers, transform them to bytes, and concatenate the bytes.

func Contains

func Contains(arr []int, el int) bool

Contains returns true if array contains a given element, otherwise false.

func Exponentiate

func Exponentiate(x, y, m *big.Int) *big.Int

It computes x^y mod m. Negative y are supported.

func GetGermainPrime

func GetGermainPrime(bits int) (p *big.Int)

GetGermainPrime returns a prime number p for which 2*p + 1 is also prime. Note that conversely p is called safe prime.

func GetRandomInt

func GetRandomInt(max *big.Int) *big.Int

GetRandomInt returns random integer from [0, max).

func GetRandomIntAlsoNeg

func GetRandomIntAlsoNeg(max *big.Int) *big.Int

GetRandomIntAlsoNeg returns random integer from (-max, max).

func GetRandomIntFromRange

func GetRandomIntFromRange(min, max *big.Int) (*big.Int, error)

Returns random integer from [min, max).

func GetRandomIntOfLength

func GetRandomIntOfLength(bitLength int) *big.Int

GetRandomIntOfLength returns random *big.Int exactly of length bitLengh.

func GetRandomZnInvertibleElement

func GetRandomZnInvertibleElement(n *big.Int) *big.Int

GetZnInvertibleElement returns random element from Z_n*.

func GetSafePrime

func GetSafePrime(bits int) (p *big.Int, err error)

GetSafePrime returns a safe prime p (p = 2*p1 + 2 where p1 is prime too).

func Hash

func Hash(numbers ...*big.Int) *big.Int

It concatenates numbers (their bytes), computes a hash and outputs a hash as *big.Int.

func HashIntoBytes

func HashIntoBytes(numbers ...*big.Int) []byte

It concatenates numbers (their bytes), computes a hash and outputs a hash as []byte.

func LCM

func LCM(x, y *big.Int) *big.Int

Computes least common multiple.

func LagrangeInterpolation

func LagrangeInterpolation(a *big.Int, points map[*big.Int]*big.Int, prime *big.Int) *big.Int

Given degree+1 points which are on the polynomial, LagrangeInterpolation computes p(a).

Types

type Pair

type Pair struct {
	A *big.Int
	B *big.Int
}

Pair is the same as ECGroupElement, but to be used in non EC schemes when a pair of *big.Int is needed.

func NewPair

func NewPair(a, b *big.Int) *Pair

type Polynomial

type Polynomial struct {
	// contains filtered or unexported fields
}

Polynomial with coefficients in Z_prime. Coefficients are given as [a_0, a_1, ..., a_degree] where polynomial is p(x) = a_0 + a_1 * x + ... + a_degree * x^degree

func NewRandomPolynomial

func NewRandomPolynomial(degree int, prime *big.Int) (*Polynomial, error)

func (*Polynomial) GetValue

func (polynomial *Polynomial) GetValue(point *big.Int) *big.Int

Computes polynomial values at given point.

func (*Polynomial) GetValues

func (polynomial *Polynomial) GetValues(points []*big.Int) map[*big.Int]*big.Int

Computes polynomial values at given points.

func (*Polynomial) SetCoefficient

func (polynomial *Polynomial) SetCoefficient(coeff_ind int, coefficient *big.Int)

type Triple

type Triple struct {
	A *big.Int
	B *big.Int
	C *big.Int
}

func NewTriple

func NewTriple(a, b, c *big.Int) *Triple

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL