utils

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package utils contains helper structures and function

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitReverse64

func BitReverse64(index, bitLen uint64) uint64

BitReverse64 returns the bit-reverse value of the input value, within a context of 2^bitLen.

func EqualSliceUint64

func EqualSliceUint64(a, b []uint64) (v bool)

EqualSliceUint64 checks the equality between two uint64 slices.

func EqualSliceUint8

func EqualSliceUint8(a, b []uint8) (v bool)

EqualSliceUint8 checks the equality between two uint8 slices.

func HammingWeight64

func HammingWeight64(x uint64) uint64

HammingWeight64 returns the hammingweight if the input value.

func IsInSliceUint64

func IsInSliceUint64(x uint64, slice []uint64) (v bool)

IsInSliceUint64 checks if x is in slice.

func MaxFloat64

func MaxFloat64(a, b float64) (r float64)

MaxFloat64 returns the maximum value of the input slice of uint64 values.

func MaxUint64

func MaxUint64(a, b uint64) (r uint64)

MaxUint64 returns the maximum value of the input slice of uint64 values.

func MinUint64

func MinUint64(a, b uint64) (r uint64)

MinUint64 returns the minimum value of the input slice of uint64 values.

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 NewBuffer

func NewBuffer(s []byte) *Buffer

NewBuffer creates a new buffer from the provided backing slice

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes creates a new byte buffer

func (*Buffer) ReadUint64

func (b *Buffer) ReadUint64() uint64

ReadUint64 reads an uint64 from the target byte buffer.

func (*Buffer) ReadUint64Slice

func (b *Buffer) ReadUint64Slice(rec []uint64)

ReadUint64Slice reads an uint64 slice from the target byte buffer.

func (*Buffer) ReadUint8

func (b *Buffer) ReadUint8() byte

ReadUint8 reads an uint8 from the target byte buffer.

func (*Buffer) ReadUint8Slice

func (b *Buffer) ReadUint8Slice(rec []uint8)

ReadUint8Slice reads an uint8 slice from the target byte buffer.

func (*Buffer) WriteUint64

func (b *Buffer) WriteUint64(v uint64)

WriteUint64 writes an uint64 on the target byte buffer.

func (*Buffer) WriteUint64Slice

func (b *Buffer) WriteUint64Slice(s []uint64)

WriteUint64Slice writes an uint64 slice on the target byte buffer.

func (*Buffer) WriteUint8

func (b *Buffer) WriteUint8(c byte)

WriteUint8 writes an uint8 on the target byte buffer.

func (*Buffer) WriteUint8Slice

func (b *Buffer) WriteUint8Slice(s []uint8)

WriteUint8Slice writes an uint8 slice on the target byte buffer.

type PRNG

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

PRNG 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 PRNG is given a key.

func NewPRNG

func NewPRNG(key []byte) (*PRNG, error)

NewPRNG creates a new instance of PRNG. Accepts an optional key, else set key=nil.

func (*PRNG) Clock

func (prng *PRNG) Clock() []byte

Clock returns the right 64 bytes digest value of the current PRNG state and reseeds the PRNG with those same 64 bytes. Also increases the clock cycle by 1.

func (*PRNG) GetClock

func (prng *PRNG) GetClock() uint64

GetClock returns the value of the clock cycle of the PRNG.

func (*PRNG) GetSeed

func (prng *PRNG) GetSeed() []byte

GetSeed returns the current seed of the PRNG.

func (*PRNG) Seed

func (prng *PRNG) Seed(seed []byte)

Seed resets the current state of the PRNG (without changing the optional key) and seeds it with the given bytes. Seed will also reset the clock cycle to 0.

func (*PRNG) SetClock

func (prng *PRNG) SetClock(n uint64) error

SetClock sets the clock cycle of the PRNG to a given number by calling Clock until the clock cycle reaches the desired number. Returns an error if the target clock cycle is smaller than the current clock cycle.

Jump to

Keyboard shortcuts

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