github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/signer.go (about) 1 package module 2 3 import ( 4 "errors" 5 6 "github.com/onflow/crypto" 7 ) 8 9 var ( 10 // ErrNoBeaconKeyForEpoch indicates that no beacon key is available for the given epoch. 11 // This can happen for several reasons: 12 // 1. The DKG for the epoch has not completed yet, and the beacon key may be available later. 13 // 2. The DKG succeeded globally, but this node failed to generate a local beacon key. 14 // This can happen if the node is unavailable or behind during the DKG. 15 // In this case, no beacon key will ever be available for this epoch. 16 // 3. The DKG failed globally, so no nodes generated a local beacon key. 17 // 18 // Regardless of the reason, beacon key users should fall back to signing with 19 // only their staking key - hence these situations are not differentiated. 20 ErrNoBeaconKeyForEpoch = errors.New("no beacon key available for epoch") 21 ) 22 23 // RandomBeaconKeyStore provides access to the node's locally computed random beacon for a given epoch. 24 // We determine which epoch to use based on the view, each view belongs to exactly one epoch. 25 // Beacon keys are only returned once: 26 // - the DKG has completed successfully locally AND 27 // - the DKG has completed successfully globally (EpochCommit event sealed) with a consistent result 28 // 29 // Therefore keys returned by this module are guaranteed to be safe for use. 30 type RandomBeaconKeyStore interface { 31 // ByView returns the node's locally computed beacon private key for the epoch containing the given view. 32 // It returns: 33 // - (key, nil) if the node has beacon keys in the epoch of the view 34 // - (nil, model.ErrViewForUnknownEpoch) if no epoch found for given view 35 // - (nil, module.ErrNoBeaconKeyForEpoch) if beacon key for epoch is unavailable 36 // - (nil, error) if there is any exception 37 ByView(view uint64) (crypto.PrivateKey, error) 38 }