Documentation ¶
Index ¶
Constants ¶
const BoltFileName = "drand.db"
Variables ¶
This section is empty.
Functions ¶
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 }
Beacon holds the randomness as well as the info to verify it.
type Cursor ¶
type Cursor interface { Next() (*Beacon, error) Prev() (*Beacon, error) First() (*Beacon, error) Last() (*Beacon, error) }
XXX To be implemented
type Handler ¶
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 ¶
NewHandler returns a fresh handler ready to serve and create randomness beacon
func (*Handler) Loop ¶
RandomBeacon starts periodically the TBLS protocol. The seed is the first message signed alongside with the current timestamp. All subsequent signatures are chained: s_i+1 = SIG(s_i || timestamp)
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.
type Store ¶
type Store interface { Len() int Put(*Beacon) error Last() (*Beacon, error) Get(round uint64) (*Beacon, error) }
Store is an interface to store Beacons packets where they can also be retrieved to be delivered to end clients.
func NewBoltStore ¶
NewBoltStore returns a Store implementation using the boltdb storage engine.
func NewCallbackStore ¶
NewCallbackStore returns a Store that calls the given callback 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.