diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-09-19 17:41:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-19 17:41:57 +0800 |
commit | a2a733e6f98018cb2ecc4b3982386be8892d7433 (patch) | |
tree | 1b894a5f57b89a63c2bc61fa950bd665837fd137 /core/dkg-tsig-protocol.go | |
parent | 54fa224dbbf1b1c0f8d54a3f10a81adb321ce1e4 (diff) | |
download | dexon-consensus-a2a733e6f98018cb2ecc4b3982386be8892d7433.tar dexon-consensus-a2a733e6f98018cb2ecc4b3982386be8892d7433.tar.gz dexon-consensus-a2a733e6f98018cb2ecc4b3982386be8892d7433.tar.bz2 dexon-consensus-a2a733e6f98018cb2ecc4b3982386be8892d7433.tar.lz dexon-consensus-a2a733e6f98018cb2ecc4b3982386be8892d7433.tar.xz dexon-consensus-a2a733e6f98018cb2ecc4b3982386be8892d7433.tar.zst dexon-consensus-a2a733e6f98018cb2ecc4b3982386be8892d7433.zip |
core: Nack Complaint (#116)
Diffstat (limited to 'core/dkg-tsig-protocol.go')
-rw-r--r-- | core/dkg-tsig-protocol.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/dkg-tsig-protocol.go b/core/dkg-tsig-protocol.go index c549ecb..2db18f1 100644 --- a/core/dkg-tsig-protocol.go +++ b/core/dkg-tsig-protocol.go @@ -67,6 +67,7 @@ type dkgProtocol struct { mpkMap map[types.ValidatorID]*dkg.PublicKeyShares masterPrivateShare *dkg.PrivateKeyShares prvShares *dkg.PrivateKeyShares + prvSharesReceived map[types.ValidatorID]struct{} } type dkgShareSecret struct { @@ -119,6 +120,7 @@ func newDKGProtocol( mpkMap: make(map[types.ValidatorID]*dkg.PublicKeyShares), masterPrivateShare: prvShare, prvShares: dkg.NewEmptyPrivateKeyShares(), + prvSharesReceived: make(map[types.ValidatorID]struct{}), } } @@ -126,6 +128,7 @@ func (d *dkgProtocol) processMasterPublicKeys( mpks []*types.DKGMasterPublicKey) error { d.idMap = make(map[types.ValidatorID]dkg.ID, len(mpks)) d.mpkMap = make(map[types.ValidatorID]*dkg.PublicKeyShares, len(mpks)) + d.prvSharesReceived = make(map[types.ValidatorID]struct{}, len(mpks)) ids := make(dkg.IDs, len(mpks)) for i := range mpks { vID := mpks[i].ProposerID @@ -148,6 +151,22 @@ func (d *dkgProtocol) processMasterPublicKeys( return nil } +func (d *dkgProtocol) proposeNackComplaints() { + for vID := range d.mpkMap { + if _, exist := d.prvSharesReceived[vID]; exist { + continue + } + d.recv.ProposeDKGComplaint(&types.DKGComplaint{ + ProposerID: d.ID, + Round: d.round, + PrivateShare: types.DKGPrivateShare{ + ProposerID: vID, + Round: d.round, + }, + }) + } +} + func (d *dkgProtocol) sanityCheck(prvShare *types.DKGPrivateShare) error { if _, exist := d.idMap[prvShare.ProposerID]; !exist { return ErrNotDKGParticipant @@ -180,6 +199,7 @@ func (d *dkgProtocol) processPrivateShare( if err != nil { return err } + d.prvSharesReceived[prvShare.ProposerID] = struct{}{} if !ok { complaint := &types.DKGComplaint{ ProposerID: d.ID, |