Documentation ¶
Index ¶
Constants ¶
const BoltFileName = "drand.db"
BoltFileName is the name of the file boltdb writes to
Variables ¶
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 ¶
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 ¶
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 ¶
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.
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 ¶
NewBoltStore returns a Store implementation using the boltdb storage engine.
func NewCallbackStore ¶
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.