beacon

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const BoltFileName = "drand.db"

BoltFileName is the name of the file boltdb writes to

Variables

View Source
var ErrNoBeaconSaved = errors.New("no beacon saved in db")

ErrNoBeaconSaved is the error returned when no beacon have been saved in the database yet.

Functions

func Message

func Message(prevSig []byte, round uint64) []byte

Message returns a slice of bytes as the message to sign or to verify alongside a beacon signature.

Types

type Beacon

type Beacon struct {
	// PreviousSig is the previous signature generated
	PreviousSig []byte
	// Round is the round number this beacon is tied to
	Round uint64
	// Signature is the BLS deterministic signature over Round || PreviousRand
	Signature []byte

	// aliases field required for retro-compatibility
	// TODO remove those when transition complete to new Beacon struct
	// PreviousRand is the "old" PreviousSig
	PreviousRand []byte
	// Randomness is the "old" Signature
	Randomness []byte
}

Beacon holds the randomness as well as the info to verify it.

func (*Beacon) GetPreviousSig added in v0.5.1

func (b *Beacon) GetPreviousSig() []byte

GetPreviousSig returns the signature of the previous beacon. Needed for retro-compatibility.

func (*Beacon) GetSignature added in v0.5.1

func (b *Beacon) GetSignature() []byte

GetSignature returns the signature of this beacon. Needed for retro-compatibility

type Config added in v0.5.0

type Config struct {
	Private *key.Pair
	Share   *key.Share
	Group   *key.Group
	Scheme  sign.ThresholdScheme
	Seed    []byte
}

Config holds the different cryptographc informations necessary to run the randomness beacon.

type Handler

type Handler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Handler holds the logic to initiate, and react to the TBLS protocol. Each time a full signature can be recosntructed, it saves it to the given Store.

func NewHandler

func NewHandler(c net.ProtocolClient, s Store, conf *Config, l log.Logger) (*Handler, error)

NewHandler returns a fresh handler ready to serve and create randomness beacon

func (*Handler) ProcessBeacon

func (h *Handler) ProcessBeacon(c context.Context, p *proto.BeaconRequest) (*proto.BeaconResponse, error)

ProcessBeacon receives a request for a beacon partial signature. It replies successfully with a valid partial signature over the given beacon packet information if the following is true: 1- the round for the request is not different than the current round by a certain threshold 2- the partial signature in the embedded response is valid. This proves that the requests comes from a qualified node from the DKG phase.

func (*Handler) Run added in v0.5.0

func (h *Handler) Run(period time.Duration, catchup bool)

Run starts periodically the TBLS protocol. The seed is the first message signed alongside with the current round number. All subsequent signatures are chained: s_i+1 = SIG(s_i || round) The catchup parameter, if true, forces the beacon generator to wait until it receives a RPC call from another node. At that point, the beacon generator knows the current round it must execute. WARNING: It is not a bullet proof solution, as a remote node could trick this beacon generator to start for an outdated or far-in-the-future round. This is a starting point. func (h *Handler) Loop(seed []byte, period time.Duration, catchup bool) {

func (*Handler) Stop

func (h *Handler) Stop()

Stop the beacon loop from aggregating further randomness, but it finishes the one it is aggregating currently.

type PartialSig added in v0.5.1

type PartialSig struct {
	PartialSig []byte
	// contains filtered or unexported fields
}

PartialSig holds partial signature

type Store

type Store interface {
	Len() int
	Put(*Beacon) error
	Last() (*Beacon, error)
	Get(round uint64) (*Beacon, error)
	// XXX Misses a delete function
	Close()
}

Store is an interface to store Beacons packets where they can also be retrieved to be delivered to end clients.

func NewBoltStore

func NewBoltStore(folder string, opts *bolt.Options) (Store, error)

NewBoltStore returns a Store implementation using the boltdb storage engine.

func NewCallbackStore

func NewCallbackStore(s Store, cb func(*Beacon)) Store

NewCallbackStore returns a Store that calls the given callback in a goroutine each time a new Beacon is saved into the given store. It does not call the callback if there has been any errors while saving the beacon.

Jump to

Keyboard shortcuts

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