state

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0, BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Committee

type Committee struct {
	// InstanceID holds the identifier of the dRAND instance.
	InstanceID uint32
	// Threshold holds the threshold of the secret sharing protocol.
	Threshold uint8
	// Identities holds the nodes' identities of the committee members.
	Identities []ed25519.PublicKey
	// DistributedPK holds the drand distributed public key.
	DistributedPK []byte
}

Committee defines the current committee state of a DRNG instance.

type Option

type Option func(*Options)

Option is a function which sets the given option.

func SetCommittee

func SetCommittee(c *Committee) Option

SetCommittee sets the initial committee

func SetRandomness

func SetRandomness(r *Randomness) Option

SetRandomness sets the initial randomness

type Options

type Options struct {
	// The initial committee of the DRNG.
	Committee *Committee
	// The initial randomness of the DRNG.
	Randomness *Randomness
}

Options define state options of a DRNG.

type Randomness

type Randomness struct {
	// Round holds the current DRNG round.
	Round uint64
	// Randomness holds the current randomness as a slice of bytes.
	Randomness []byte
	// Timestamp holds the timestamp when the current randomness was received.
	Timestamp time.Time
}

Randomness defines the current randomness state of a DRNG instance.

func (Randomness) Float64

func (r Randomness) Float64() float64

Float64 returns a float64 [0.0,1.0) representation of the randomness byte slice.

type State

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

The state of the DRNG.

func New

func New(setters ...Option) *State

New creates a new State with the given optional options

func (*State) Committee

func (s *State) Committee() Committee

Committee returns the committee of the DRNG state

func (*State) Randomness

func (s *State) Randomness() Randomness

Randomness returns the randomness of the DRNG state

func (*State) UpdateCommittee

func (s *State) UpdateCommittee(c *Committee)

Update committee updates the committee of the DRNG state

func (*State) UpdateRandomness

func (s *State) UpdateRandomness(r *Randomness)

UpdateRandomness updates the randomness of the DRNG state

Jump to

Keyboard shortcuts

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