github.com/koko1123/flow-go-1@v0.29.6/storage/dkg.go (about)

     1  package storage
     2  
     3  import (
     4  	"github.com/koko1123/flow-go-1/model/flow"
     5  	"github.com/onflow/flow-go/crypto"
     6  )
     7  
     8  // DKGState is the storage interface for storing all artifacts and state
     9  // related to the DKG process, including the latest state of a running or
    10  // completed DKG, and computed beacon keys.
    11  type DKGState interface {
    12  
    13  	// SetDKGStarted sets the flag indicating the DKG has started for the given epoch.
    14  	SetDKGStarted(epochCounter uint64) error
    15  
    16  	// GetDKGStarted checks whether the DKG has been started for the given epoch.
    17  	GetDKGStarted(epochCounter uint64) (bool, error)
    18  
    19  	// SetDKGEndState stores that the DKG has ended, and its end state.
    20  	SetDKGEndState(epochCounter uint64, endState flow.DKGEndState) error
    21  
    22  	// GetDKGEndState retrieves the end state for the given DKG.
    23  	GetDKGEndState(epochCounter uint64) (flow.DKGEndState, error)
    24  
    25  	// InsertMyBeaconPrivateKey stores the random beacon private key for an epoch.
    26  	//
    27  	// CAUTION: these keys are stored before they are validated against the
    28  	// canonical key vector and may not be valid for use in signing. Use SafeBeaconKeys
    29  	// to guarantee only keys safe for signing are returned
    30  	InsertMyBeaconPrivateKey(epochCounter uint64, key crypto.PrivateKey) error
    31  
    32  	// RetrieveMyBeaconPrivateKey retrieves the random beacon private key for an epoch.
    33  	//
    34  	// CAUTION: these keys are stored before they are validated against the
    35  	// canonical key vector and may not be valid for use in signing. Use SafeBeaconKeys
    36  	// to guarantee only keys safe for signing are returned
    37  	RetrieveMyBeaconPrivateKey(epochCounter uint64) (crypto.PrivateKey, error)
    38  }
    39  
    40  // SafeBeaconKeys is a safe way to access beacon keys.
    41  type SafeBeaconKeys interface {
    42  
    43  	// RetrieveMyBeaconPrivateKey retrieves my beacon private key for the given
    44  	// epoch, only if my key has been confirmed valid and safe for use.
    45  	//
    46  	// Returns:
    47  	// * (key, true, nil) if the key is present and confirmed valid
    48  	// * (nil, false, nil) if no key was generated or the key has been marked invalid (by SetDKGEnded)
    49  	// * (nil, false, error) for any other condition, or exception
    50  	RetrieveMyBeaconPrivateKey(epochCounter uint64) (key crypto.PrivateKey, safe bool, err error)
    51  }