Documentation ¶
Index ¶
- Constants
- func CurrentRound(now int64, period time.Duration, genesis int64) uint64
- func Message(currRound uint64, prevSig []byte, message []byte) []byte
- func NextRound(now int64, period time.Duration, genesis int64) (nextRound uint64, nextTime int64)
- func RandomnessFromSignature(sig []byte) []byte
- func RoundToBytes(r uint64) []byte
- func TimeOfRound(period time.Duration, genesis int64, round uint64) int64
- func Verify(pubkey kyber.Point, prevSig, signature []byte, round uint64) error
- func VerifyBeacon(pubkey kyber.Point, b *Beacon) error
- type Beacon
- type Cursor
- type Info
- type Store
Constants ¶
const TimeOfRoundErrorValue = math.MaxInt64 - maxTimeBuffer
TimeOfRoundErrorValue is the value returned by `TimeOfRound` when an invalid round is specified.
Variables ¶
This section is empty.
Functions ¶
func CurrentRound ¶
CurrentRound calculates the active round at `now`
func Message ¶
Message returns a slice of bytes as the message to sign or to verify alongside a beacon signature. H ( prevSig || currRound)
func NextRound ¶
NextRound returns the next upcoming round and its UNIX time given the genesis time and the period. round at time genesis = round 1. Round 0 is fixed.
func RandomnessFromSignature ¶
RandomnessFromSignature derives the round randomness from its signature
func RoundToBytes ¶
RoundToBytes provides a byte serialized form of a round number
func TimeOfRound ¶
TimeOfRound is returning the time the current round should happen
func Verify ¶
Verify is similar to verify beacon but doesn't require to get the full beacon structure.
func VerifyBeacon ¶
VerifyBeacon returns an error if the given beacon does not verify given the public key. The public key "point" can be obtained from the `key.DistPublic.Key()` method. The distributed public is the one written in the configuration file of the network.
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 // Message is the message to be signed Message []byte }
Beacon holds the randomness as well as the info to verify it.
func GenesisBeacon ¶
GenesisBeacon returns the first beacon inserted in the chain
func (*Beacon) GetMessage ¶ added in v1.1.3
GetMessage provides the message of the beacon
func (*Beacon) Randomness ¶
Randomness returns the hashed signature. It is an example that uses sha256, but it could use blake2b for example.
type Cursor ¶
Cursor iterates over items in sorted key order. This starts from the first key/value pair and updates the k/v variables to the next key/value on each iteration.
The loop finishes at the end of the cursor when a nil key is returned.
for k, v := c.First(); k != nil; k, v = c.Next() { fmt.Printf("A %s is %s.\n", k, v) }
type Info ¶
type Info struct { PublicKey kyber.Point `json:"public_key"` Period time.Duration `json:"period"` GenesisTime int64 `json:"genesis_time"` GroupHash []byte `json:"group_hash"` }
Info represents the public information that is necessary for a client to very any beacon present in a randomness chain.
func InfoFromJSON ¶
InfoFromJSON returns a Info from JSON description in the given reader
func InfoFromProto ¶
func InfoFromProto(p *drand.ChainInfoPacket) (*Info, error)
InfoFromProto returns a Info from the protocol description
func NewChainInfo ¶
NewChainInfo makes a chain Info from a group
func (*Info) Hash ¶
Hash returns the canonical hash representing the chain information. A hash is consistent throughout the entirety of a chain, regardless of the network composition, the actual nodes, generating the randomness.
func (*Info) ToProto ¶
func (c *Info) ToProto() *drand.ChainInfoPacket
ToProto returns the protobuf description of the chain info