diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/consensus.go | 4 | ||||
-rw-r--r-- | core/dkg-tsig-protocol.go | 7 | ||||
-rw-r--r-- | core/interfaces.go | 2 | ||||
-rw-r--r-- | core/test/governance.go | 2 |
4 files changed, 11 insertions, 4 deletions
diff --git a/core/consensus.go b/core/consensus.go index f9b8b37..18294ef 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -540,9 +540,9 @@ func (con *Consensus) runCRS() { con.logger.Error("Failed to run CRS Tsig", "error", err) } else { con.logger.Debug("Calling Governance.ProposeCRS", - "round", con.round, + "round", con.round+1, "crs", crs) - con.gov.ProposeCRS(crs) + con.gov.ProposeCRS(con.round+1, crs) } } } diff --git a/core/dkg-tsig-protocol.go b/core/dkg-tsig-protocol.go index 1b5f547..bb41931 100644 --- a/core/dkg-tsig-protocol.go +++ b/core/dkg-tsig-protocol.go @@ -37,6 +37,8 @@ var ( "private share not found for specific ID") ErrNotReachThreshold = fmt.Errorf( "threshold not reach") + ErrInvalidThreshold = fmt.Errorf( + "invalid threshold") ErrIncorrectPrivateShareSignature = fmt.Errorf( "incorrect private share signature") ErrMismatchPartialSignatureHash = fmt.Errorf( @@ -352,6 +354,11 @@ func NewDKGGroupPublicKey( mpks []*types.DKGMasterPublicKey, complaints []*types.DKGComplaint, threshold int) ( *DKGGroupPublicKey, error) { + + if len(mpks) < threshold { + return nil, ErrInvalidThreshold + } + // Calculate qualify members. disqualifyIDs := map[types.NodeID]struct{}{} complaintsByID := map[types.NodeID]int{} diff --git a/core/interfaces.go b/core/interfaces.go index 97ab0a3..7b985cf 100644 --- a/core/interfaces.go +++ b/core/interfaces.go @@ -97,7 +97,7 @@ type Governance interface { CRS(round uint64) common.Hash // Propose a CRS of round. - ProposeCRS(signedCRS []byte) + ProposeCRS(round uint64, signedCRS []byte) // NodeSet returns the node set at a given round. // Return the genesis node set if round == 0. diff --git a/core/test/governance.go b/core/test/governance.go index 88aab37..21c04f6 100644 --- a/core/test/governance.go +++ b/core/test/governance.go @@ -120,7 +120,7 @@ func (g *Governance) NotifyRoundHeight(round, height uint64) { } // ProposeCRS propose a CRS. -func (g *Governance) ProposeCRS(signedCRS []byte) { +func (g *Governance) ProposeCRS(round uint64, signedCRS []byte) { g.lock.Lock() defer g.lock.Unlock() crs := crypto.Keccak256Hash(signedCRS) |