Documentation ¶
Index ¶
- Variables
- func CategorizeGroupSigners(publishedPublicKeys [][4]*big.Int, participants ParticipantList, ...) (ParticipantList, ParticipantList, ParticipantList, error)
- func ComputeDistributedSharesHash(encryptedShares []*big.Int, commitments [][2]*big.Int) ([32]byte, [32]byte, [32]byte, error)
- func GenerateGroupKeys(transportPrivateKey *big.Int, privateCoefficients []*big.Int, ...) (*big.Int, [4]*big.Int, error)
- func GenerateKeyShare(secretValue *big.Int) ([2]*big.Int, [2]*big.Int, [4]*big.Int, error)
- func GenerateKeys() (*big.Int, [2]*big.Int, error)
- func GenerateMasterPublicKey(keyShare1s [][2]*big.Int, keyShare2s [][4]*big.Int) ([4]*big.Int, error)
- func GenerateShares(transportPrivateKey *big.Int, participants ParticipantList) ([]*big.Int, []*big.Int, [][2]*big.Int, error)
- func InverseArrayForUserCount(n int) ([]*big.Int, error)
- func SaveDkgState(monDB *db.Database, dkgState *DkgState) error
- func ThresholdForUserCount(n int) int
- func VerifyDistributedShares(dkgState *DkgState, participant *Participant) (bool, bool, error)
- type DkgState
- func (state *DkgState) GetSortedParticipants() ParticipantList
- func (state *DkgState) LoadState(txn *badger.Txn) error
- func (state *DkgState) OnAddressRegistered(account common.Address, index int, nonce uint64, publicKey [2]*big.Int)
- func (state *DkgState) OnCompletion()
- func (state *DkgState) OnGPKJSubmissionComplete(disputeGPKjStartBlock uint64)
- func (state *DkgState) OnGPKjSubmitted(account common.Address, gpkj [4]*big.Int)
- func (state *DkgState) OnKeyShareSubmissionComplete(mpkSubmissionStartBlock uint64)
- func (state *DkgState) OnKeyShareSubmitted(account common.Address, keyShareG1, keyShareG1CorrectnessProof [2]*big.Int, ...)
- func (state *DkgState) OnMPKSet(gpkjSubmissionStartBlock uint64)
- func (state *DkgState) OnRegistrationComplete(shareDistributionStartBlockNumber uint64)
- func (state *DkgState) OnRegistrationOpened(startBlock, phaseLength, confirmationLength, nonce uint64)
- func (state *DkgState) OnShareDistributionComplete(disputeShareDistributionStartBlock uint64)
- func (state *DkgState) OnSharesDistributed(logger *logrus.Entry, account common.Address, encryptedShares []*big.Int, ...) error
- func (state *DkgState) PersistState(txn *badger.Txn) error
- type EthDKGPhase
- type KeyShareStatus
- type Participant
- type ParticipantList
- type RegistrationStatus
Constants ¶
This section is empty.
Variables ¶
var ( ErrInsufficientGoodSigners = errors.New("insufficient non-malicious signers to identify malicious signers") ErrTooFew = errors.New("building array of size n with less than n required + optional") ErrTooMany = errors.New("building array of size n with more than n required") )
Distributed Key Generation related errors.
Functions ¶
func CategorizeGroupSigners ¶
func CategorizeGroupSigners(publishedPublicKeys [][4]*big.Int, participants ParticipantList, commitments [][][2]*big.Int) (ParticipantList, ParticipantList, ParticipantList, error)
CategorizeGroupSigners returns 0 based indices of honest participants, 0 based indices of dishonest participants.
func ComputeDistributedSharesHash ¶
func ComputeDistributedSharesHash(encryptedShares []*big.Int, commitments [][2]*big.Int) ([32]byte, [32]byte, [32]byte, error)
ComputeDistributedSharesHash computes the distributed shares hash, encrypted shares hash and commitments hash.
func GenerateGroupKeys ¶
func GenerateGroupKeys(transportPrivateKey *big.Int, privateCoefficients []*big.Int, encryptedShares [][]*big.Int, index int, participants ParticipantList) (*big.Int, [4]*big.Int, error)
GenerateGroupKeys returns the group private key, group public key, and a signature.
func GenerateKeyShare ¶
GenerateKeyShare returns G1 key share, G1 proof, and G2 key share.
func GenerateKeys ¶
GenerateKeys returns a private key and public key.
func GenerateMasterPublicKey ¶
func GenerateMasterPublicKey(keyShare1s [][2]*big.Int, keyShare2s [][4]*big.Int) ([4]*big.Int, error)
GenerateMasterPublicKey returns the master public key.
func GenerateShares ¶
func GenerateShares(transportPrivateKey *big.Int, participants ParticipantList) ([]*big.Int, []*big.Int, [][2]*big.Int, error)
GenerateShares returns encrypted shares, private coefficients, and commitments.
func InverseArrayForUserCount ¶
InverseArrayForUserCount pre-calculates an inverse array for use by ethereum contracts.
func ThresholdForUserCount ¶
ThresholdForUserCount returns the threshold user count; see crypto for full documentation and discussion.
func VerifyDistributedShares ¶
func VerifyDistributedShares(dkgState *DkgState, participant *Participant) (bool, bool, error)
VerifyDistributedShares verifies the distributed shares and returns
true/false if the share is valid/invalid; true/false if present/not present; error if raised
If an error is raised, then something unrecoverable has occurred.
Types ¶
type DkgState ¶
type DkgState struct { IsValidator bool `json:"isValidator"` Phase EthDKGPhase `json:"phase"` PhaseLength uint64 `json:"phaseLength"` ConfirmationLength uint64 `json:"confirmationLength"` PhaseStart uint64 `json:"phaseStart"` // Local validator info //////////////////////////////////////////////////////////////////////////// // Account is the Ethereum account corresponding to the Ethereum Public Key // of the local Validator Account accounts.Account `json:"account"` // Index is the Base-1 index of the local Validator which is used // during the Share Distribution phase for verifiable secret sharing. // REPEAT: THIS IS BASE-1 Index int `json:"index"` // ValidatorAddresses stores all validator addresses at the beginning of ETHDKG ValidatorAddresses []common.Address `json:"validatorAddresses"` // NumberOfValidators is equal to len(ValidatorAddresses) NumberOfValidators int `json:"numberOfValidators"` // ETHDKG nonce Nonce uint64 `json:"nonce"` // ValidatorThreshold is the threshold number of validators for the system. // If n = NumberOfValidators and t = threshold, then // t+1 > 2*n/3 ValidatorThreshold int `json:"validatorThreshold"` // TransportPrivateKey is the private key corresponding to TransportPublicKey. TransportPrivateKey *big.Int `json:"transportPrivateKey"` // TransportPublicKey is the public key used in EthDKG. // This public key is used for secret communication over the open channel // of Ethereum. TransportPublicKey [2]*big.Int `json:"transportPublicKey"` // SecretValue is the secret value which is to be shared during // the verifiable secret sharing. // The sum of all the secret values of all the participants // is the master secret key, the secret key of the master public key // (MasterPublicKey) SecretValue *big.Int `json:"secretValue"` // PrivateCoefficients is the private polynomial which is used to share // the shared secret. This is performed via Shamir Secret Sharing. PrivateCoefficients []*big.Int `json:"privateCoefficients"` // MasterPublicKey is the public key for the entire group. // As mentioned above, the secret key called the master secret key // and is the sum of all the shared secrets of all the participants. MasterPublicKey [4]*big.Int `json:"masterPublicKey"` // GroupPrivateKey is the local Validator's portion of the master secret key. // This is also denoted gskj. GroupPrivateKey *big.Int `json:"groupPrivateKey"` // Remote validator info //////////////////////////////////////////////////////////////////////////// // Participants is the list of Validators Participants map[common.Address]*Participant `json:"participants"` // Group Public Key (GPKj) Accusation Phase ////////////////////////////////////////////////// // DishonestValidatorsIndices stores the list indices of dishonest // validators DishonestValidators ParticipantList `json:"dishonestValidators"` // HonestValidatorsIndices stores the list indices of honest // validators HonestValidators ParticipantList `json:"honestValidators"` // Inverse stores the multiplicative inverses // of elements. This may be used in GPKJGroupAccusation logic. Inverse []*big.Int `json:"inverse"` }
DkgState is used to track the state of the ETHDKG.
func NewDkgState ¶
NewDkgState makes a new DkgState object.
func (*DkgState) GetSortedParticipants ¶
func (state *DkgState) GetSortedParticipants() ParticipantList
GetSortedParticipants returns the participant list sorted by Index field.
func (*DkgState) OnAddressRegistered ¶
func (state *DkgState) OnAddressRegistered(account common.Address, index int, nonce uint64, publicKey [2]*big.Int)
OnAddressRegistered processes data from AddressRegistered event.
func (*DkgState) OnCompletion ¶
func (state *DkgState) OnCompletion()
OnCompletion processes data from ValidatorSetCompleted event.
func (*DkgState) OnGPKJSubmissionComplete ¶
OnGPKJSubmissionComplete processes data from GPKJSubmissionComplete event.
func (*DkgState) OnGPKjSubmitted ¶
OnGPKjSubmitted processes data from GPKjSubmitted event.
func (*DkgState) OnKeyShareSubmissionComplete ¶
OnKeyShareSubmissionComplete processes data from KeyShareSubmissionComplete event.
func (*DkgState) OnKeyShareSubmitted ¶
func (state *DkgState) OnKeyShareSubmitted(account common.Address, keyShareG1, keyShareG1CorrectnessProof [2]*big.Int, keyShareG2 [4]*big.Int)
OnKeyShareSubmitted processes data from KeyShareSubmitted event.
func (*DkgState) OnRegistrationComplete ¶
OnRegistrationComplete processes data from RegistrationComplete event.
func (*DkgState) OnRegistrationOpened ¶
func (state *DkgState) OnRegistrationOpened(startBlock, phaseLength, confirmationLength, nonce uint64)
OnRegistrationOpened processes data from RegistrationOpened event.
func (*DkgState) OnShareDistributionComplete ¶
OnShareDistributionComplete processes data from ShareDistributionComplete event.
func (*DkgState) OnSharesDistributed ¶
func (state *DkgState) OnSharesDistributed(logger *logrus.Entry, account common.Address, encryptedShares []*big.Int, commitments [][2]*big.Int) error
OnSharesDistributed processes data from SharesDistributed event.
func (*DkgState) PersistState ¶
type EthDKGPhase ¶
type EthDKGPhase uint8
EthDKGPhase is used to indicate what phase we are currently in.
const ( RegistrationOpen EthDKGPhase = iota MPKSubmission GPKJSubmission DisputeGPKJSubmission Completion )
These are the valid phases of ETHDKG.
func (EthDKGPhase) String ¶
func (phase EthDKGPhase) String() string
type KeyShareStatus ¶
type KeyShareStatus int
KeyShareStatus is an enumeration indicated the current status of keyshare.
const ()
The possible key share statuses: * UnknownKeyShare - unknown if the address has shared a key * KeyShared - address has shared the expected key * NoKeyShared - address does not have a key share * BadKeyShared - address has an unexpected key share.
type Participant ¶
type Participant struct { // Address is the Ethereum address corresponding to the Ethereum Public Key // for the Participant. Address common.Address `json:"address"` // Index is the Base-1 index of the participant. // This is used during the Share Distribution phase to perform // verifyiable secret sharing. // REPEAT: THIS IS BASE-1 Index int `json:"index"` // PublicKey is the TransportPublicKey of Participant. PublicKey [2]*big.Int `json:"publicKey"` Nonce uint64 `json:"nonce"` Phase EthDKGPhase `json:"phase"` // Share Distribution Phase ////////////////////////////////////////////////// // Commitments stores the Public Coefficients // corresponding to public polynomial // in Shamir Secret Sharing protocol. // The first coefficient (constant term) is the public commitment // corresponding to the secret share (SecretValue). Commitments [][2]*big.Int `json:"commitments"` // EncryptedShares are the encrypted secret shares // in the Shamir Secret Sharing protocol. CommitmentsFirstCoefficient [2]*big.Int `json:"commitmentsFirstCoefficient"` ////////////////////////////////////////////////// // KeyShareG1s stores the key shares of G1 element // for each participant KeyShareG1s [2]*big.Int `json:"keyShareG1s"` // G1 element for each participant. KeyShareG1CorrectnessProofs [2]*big.Int `json:"keyShareG1CorrectnessProofs"` // for each participant. // Adding all the G2 shares together produces the // master public key (MasterPublicKey). KeyShareG2s [4]*big.Int `json:"keyShareG2s"` // GPKj is the local Validator's portion of the master public key. // This is also denoted GroupPublicKey. GPKj [4]*big.Int `json:"gpkj"` }
Participant contains what we know about other participants, i.e. public information.
func (*Participant) Copy ¶
func (p *Participant) Copy() *Participant
Copy makes returns a copy of Participant.
type ParticipantList ¶
type ParticipantList []*Participant
ParticipantList is a required type alias since the Sort interface is awful.
func (ParticipantList) ExtractIndices ¶
func (pl ParticipantList) ExtractIndices() []int
ExtractIndices returns the list of indices of ParticipantList.
func (ParticipantList) Len ¶
func (pl ParticipantList) Len() int
Len returns the len of the collection.
func (ParticipantList) Less ¶
func (pl ParticipantList) Less(i, j int) bool
Less decides if element i is 'Less' than element j -- less ~= before.
func (ParticipantList) Swap ¶
func (pl ParticipantList) Swap(i, j int)
Swap swaps elements i and j within the collection.
type RegistrationStatus ¶
type RegistrationStatus int
RegistrationStatus is an enumeration indicating the current status of a registration.
const ( Undefined RegistrationStatus = iota Registered NoRegistration BadRegistration )
The possible registration statuses: * Undefined - unknown if the address is registered * Registered - address is registered with expected public key * NoRegistration - address does not have a public key registered * BadRegistration - address is regisered with an unexpected public key.
func CheckRegistration ¶
func CheckRegistration(ethdkg bindings.IETHDKG, logger *logrus.Entry, callOpts *bind.CallOpts, addr common.Address, publicKey [2]*big.Int, ) (RegistrationStatus, error)
CheckRegistration checks if given address is registered as expected.
func (RegistrationStatus) String ¶
func (status RegistrationStatus) String() string