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 { // 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
GetPreviousSig returns the signature of the previous beacon. Needed for retro-compatibility.
func (*Beacon) GetSignature ¶ added in v0.5.1
GetSignature returns the signature of this beacon. Needed for retro-compatibility
type Config ¶ added in v0.5.0
Config holds the different cryptographc informations necessary to run the randomness beacon.
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) 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
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) {
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 ¶
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.