beacon

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2018 License: MIT Imports: 18 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(prevRand []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 {
	// PreviousRand is the previous randomness generated
	PreviousRand []byte
	// Round is the round number this beacon is tied to
	Round uint64
	// Randomness is the tbls signature of Round || PreviousRand
	Randomness []byte
	// Gid is the group id of the randomness - usually fixed
	Gid int32
}

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

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.InternalClient, priv *key.Pair, sh *key.Share, group *key.Group, s Store) *Handler

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

func (*Handler) Loop

func (h *Handler) Loop(seed []byte, period time.Duration, catchup bool)

Loop 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 (*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) Stop

func (h *Handler) Stop()

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