Documentation ¶
Overview ¶
Package utils contains helper structures and function
Index ¶
- func AllDistinct(s []uint64) bool
- func BitReverse64(index, bitLen uint64) uint64
- func EqualSliceInt64(a, b []int64) (v bool)
- func EqualSliceUint64(a, b []uint64) (v bool)
- func EqualSliceUint8(a, b []uint8) (v bool)
- func HammingWeight64(x uint64) uint64
- func IsInSliceInt(x int, slice []int) (v bool)
- func IsInSliceUint64(x uint64, slice []uint64) (v bool)
- func MaxFloat64(a, b float64) (r float64)
- func MaxInt(a, b int) (r int)
- func MaxSliceUint64(slice []uint64) (max uint64)
- func MaxUint64(a, b uint64) (r uint64)
- func MinInt(a, b int) (r int)
- func MinUint64(a, b uint64) (r uint64)
- func RandComplex128(min, max float64) complex128
- func RandFloat64(min, max float64) float64
- func RandUint64() uint64
- func RotateComplex128Slice(s []complex128, k int) []complex128
- func RotateFloat64Slice(s []float64, k int) []float64
- func RotateInt64Slice(s []int64, k int) []int64
- func RotateSlice(s interface{}, k int) interface{}
- func RotateUint64Slice(s []uint64, k int) []uint64
- func RotateUint64Slots(s []uint64, k int) []uint64
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) ReadUint64() uint64
- func (b *Buffer) ReadUint64Slice(rec []uint64)
- func (b *Buffer) ReadUint8() byte
- func (b *Buffer) ReadUint8Slice(rec []uint8)
- func (b *Buffer) WriteUint64(v uint64)
- func (b *Buffer) WriteUint64Slice(s []uint64)
- func (b *Buffer) WriteUint8(c byte)
- func (b *Buffer) WriteUint8Slice(s []uint8)
- type KeyedPRNG
- type PRNG
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllDistinct ¶
AllDistinct returns true if all elements in s are distinct, and false otherwise.
func BitReverse64 ¶
BitReverse64 returns the bit-reverse value of the input value, within a context of 2^bitLen.
func EqualSliceInt64 ¶
EqualSliceInt64 checks the equality between two int64 slices.
func EqualSliceUint64 ¶
EqualSliceUint64 checks the equality between two uint64 slices.
func EqualSliceUint8 ¶
EqualSliceUint8 checks the equality between two uint8 slices.
func HammingWeight64 ¶
HammingWeight64 returns the hammingweight if the input value.
func IsInSliceInt ¶
IsInSliceInt checks if x is in slice.
func IsInSliceUint64 ¶
IsInSliceUint64 checks if x is in slice.
func MaxFloat64 ¶
MaxFloat64 returns the maximum value of the input slice of float64 values.
func MaxSliceUint64 ¶
MaxSliceUint64 returns the maximum value of the input slice of uint64 values.
func RandComplex128 ¶
func RandComplex128(min, max float64) complex128
RandComplex128 returns a random complex with the real and imaginary part between min and max
func RandFloat64 ¶
RandFloat64 returns a random float between min and max
func RandUint64 ¶
func RandUint64() uint64
RandUint64 return a random value between 0 and 0xFFFFFFFFFFFFFFFF
func RotateComplex128Slice ¶
func RotateComplex128Slice(s []complex128, k int) []complex128
RotateComplex128Slice returns a new slice corresponding to s rotated by k positions to the left.
func RotateFloat64Slice ¶
RotateFloat64Slice returns a new slice corresponding to s rotated by k positions to the left.
func RotateInt64Slice ¶
RotateInt64Slice returns a new slice corresponding to s rotated by k positions to the left.
func RotateSlice ¶
func RotateSlice(s interface{}, k int) interface{}
RotateSlice takes as input an interface slice and returns a new interface slice corresponding to s rotated by k positions to the left. s.(type) can be either []complex128, []float64, []uint64 or []int64.
func RotateUint64Slice ¶
RotateUint64Slice returns a new slice corresponding to s rotated by k positions to the left.
func RotateUint64Slots ¶
RotateUint64Slots returns a new slice corresponding to s where each half of the slice have been rotated by k positions to the left.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a simple wrapper around a []byte to facilitate efficient marshaling of lattigo's objects
func (*Buffer) ReadUint64 ¶
ReadUint64 reads an uint64 from the target byte buffer.
func (*Buffer) ReadUint64Slice ¶
ReadUint64Slice reads an uint64 slice from the target byte buffer.
func (*Buffer) ReadUint8Slice ¶
ReadUint8Slice reads an uint8 slice from the target byte buffer.
func (*Buffer) WriteUint64 ¶
WriteUint64 writes an uint64 on the target byte buffer.
func (*Buffer) WriteUint64Slice ¶
WriteUint64Slice writes an uint64 slice on the target byte buffer.
func (*Buffer) WriteUint8 ¶
WriteUint8 writes an uint8 on the target byte buffer.
func (*Buffer) WriteUint8Slice ¶
WriteUint8Slice writes an uint8 slice on the target byte buffer.
type KeyedPRNG ¶
type KeyedPRNG struct {
// contains filtered or unexported fields
}
KeyedPRNG is a structure storing the parameters used to securely and deterministically generate shared sequences of random bytes among different parties using the hash function blake2b. Backward sequence security (given the digest i, compute the digest i-1) is ensured by default, however forward sequence security (given the digest i, compute the digest i+1) is only ensured if the KeyedPRNG is keyed.
func NewKeyedPRNG ¶
NewKeyedPRNG creates a new instance of KeyedPRNG. Accepts an optional key, else set key=nil which is treated as key=[]byte{} WARNING: A PRNG INITIALISED WITH key=nil IS INSECURE!
func NewPRNG ¶
NewPRNG creates KeyedPRNG keyed from rand.Read for instances were no key should be provided by the user