Documentation ¶
Index ¶
- Variables
- func EnsureFieldOrder(fieldOrder *big.Int) error
- func EnsureRank(rank uint32, threshold uint32) error
- func EnsureThreshold(threshold uint32, n uint32) error
- func EulerFunction(primeFactor []*big.Int) (*big.Int, error)
- func Gcd(a *big.Int, b *big.Int) *big.Int
- func GenRandomBytes(size int) ([]byte, error)
- func HashProtos(blake2bKey []byte, fieldOrder *big.Int, msgs ...proto.Message) (*big.Int, error)
- func InRange(checkValue *big.Int, floor *big.Int, ceil *big.Int) error
- func IsRelativePrime(a *big.Int, b *big.Int) bool
- func Lcm(a, b *big.Int) (*big.Int, error)
- func RandomCoprimeInt(n *big.Int) (*big.Int, error)
- func RandomInt(n *big.Int) (*big.Int, error)
- func RandomPositiveInt(n *big.Int) (*big.Int, error)
- func RandomPrime(bits int) (*big.Int, error)
- type Hash
- func (*Hash) Descriptor() ([]byte, []int)
- func (m *Hash) GetMsgs() []*any.Any
- func (*Hash) ProtoMessage()
- func (m *Hash) Reset()
- func (m *Hash) String() string
- func (m *Hash) XXX_DiscardUnknown()
- func (m *Hash) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Hash) XXX_Merge(src proto.Message)
- func (m *Hash) XXX_Size() int
- func (m *Hash) XXX_Unmarshal(b []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrLessOrEqualBig2 is returned if the field order is less than or equal to 2 ErrLessOrEqualBig2 = errors.New("less 2") //ErrExceedMaxRetry is returned if we retried over times ErrExceedMaxRetry = errors.New("exceed max retries") //ErrInvalidInput is returned if the input is invalid ErrInvalidInput = errors.New("invalid input") //ErrLargeRank is returned if the rank is too large ErrLargeRank = errors.New("large rank") //ErrLargeThreshold is returned if the threshold is too large ErrLargeThreshold = errors.New("large threshold") // ErrNotInRange is returned if the value is not in the given range. ErrNotInRange = errors.New("not in range") // ErrLargerFloor is returned if the floor is larger than ceil. ErrLargerFloor = errors.New("larger floor") // ErrEmptySlice is returned if the length of slice is zero. ErrEmptySlice = errors.New("empty slice") )
Functions ¶
func EnsureFieldOrder ¶
EnsureFieldOrder ensures the field order should be more than 2.
func EnsureRank ¶
EnsureRank ensures the rank should be smaller than threshold.
func EnsureThreshold ¶
EnsureThreshold ensures the threshold should be smaller than or equal to n.
func EulerFunction ¶
EulerFunction :(Special case) Assume that N is square-free and primeFactor consists of prime integers. Formula: N = prod_i P_i, the output is prod_i (P_i -1). TODO: general case.
func GenRandomBytes ¶
GenRandomBytes generates a random byte array with indicating the legnth.
func HashProtos ¶
HashProtos hashes a slice of message to a field.
func IsRelativePrime ¶
IsRelativePrime returns if a and b are relative primes
func Lcm ¶
Lcm calculates find Least Common Multiple https://rosettacode.org/wiki/Least_common_multiple#Go
func RandomCoprimeInt ¶
RandomCoprimeInt generates a random relative prime number in [2, n)
func RandomPositiveInt ¶
RandomPositiveInt generates a random number in [1, n).
Types ¶
type Hash ¶
type Hash struct { Msgs []*any.Any `protobuf:"bytes,1,rep,name=msgs,proto3" json:"msgs,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Hash) Descriptor ¶
func (*Hash) ProtoMessage ¶
func (*Hash) ProtoMessage()
func (*Hash) XXX_DiscardUnknown ¶
func (m *Hash) XXX_DiscardUnknown()