aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/vm/oracle_contracts.go16
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go41
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go11
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go73
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/interfaces.go3
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go41
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/utils/crypto.go18
-rw-r--r--vendor/vendor.json46
8 files changed, 195 insertions, 54 deletions
diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go
index 56e82f7df..e58133990 100644
--- a/core/vm/oracle_contracts.go
+++ b/core/vm/oracle_contracts.go
@@ -1242,6 +1242,10 @@ func (g *GovernanceContract) addDKGComplaint(round *big.Int, comp []byte) ([]byt
return g.penalize()
}
+ if dkgComplaint.Reset != g.state.DKGResetCount(round).Uint64() {
+ return g.penalize()
+ }
+
// DKGComplaint must belongs to someone in DKG set.
if !g.inDKGSet(round, dkgComplaint.ProposerID) {
return g.penalize()
@@ -1324,6 +1328,10 @@ func (g *GovernanceContract) addDKGMasterPublicKey(round *big.Int, mpk []byte) (
return g.penalize()
}
+ if dkgMasterPK.Reset != g.state.DKGResetCount(round).Uint64() {
+ return g.penalize()
+ }
+
// DKGMasterPublicKey must belongs to someone in DKG set.
if !g.inDKGSet(round, dkgMasterPK.ProposerID) {
return g.penalize()
@@ -1350,6 +1358,10 @@ func (g *GovernanceContract) addDKGMPKReady(round *big.Int, ready []byte) ([]byt
return g.penalize()
}
+ if dkgReady.Reset != g.state.DKGResetCount(round).Uint64() {
+ return g.penalize()
+ }
+
// DKGFInalize must belongs to someone in DKG set.
if !g.inDKGSet(round, dkgReady.ProposerID) {
return g.penalize()
@@ -1380,6 +1392,10 @@ func (g *GovernanceContract) addDKGFinalize(round *big.Int, finalize []byte) ([]
return g.penalize()
}
+ if dkgFinalize.Reset != g.state.DKGResetCount(round).Uint64() {
+ return g.penalize()
+ }
+
// DKGFInalize must belongs to someone in DKG set.
if !g.inDKGSet(round, dkgFinalize.ProposerID) {
return g.penalize()
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go
index 9214cd97d..5c3226053 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/configuration-chain.go
@@ -86,7 +86,7 @@ func newConfigurationChain(
}
}
-func (cc *configurationChain) registerDKG(round uint64, threshold int) {
+func (cc *configurationChain) registerDKG(round, reset uint64, threshold int) {
cc.dkgLock.Lock()
defer cc.dkgLock.Unlock()
if cc.dkg != nil {
@@ -105,7 +105,9 @@ func (cc *configurationChain) registerDKG(round uint64, threshold int) {
cc.ID,
cc.recv,
round,
+ reset,
threshold)
+ // TODO(mission): should keep DKG resetCount along with DKG private share.
err = cc.db.PutOrUpdateDKGMasterPrivateShares(round, *cc.dkg.prvShares)
if err != nil {
cc.logger.Error("Error put or update DKG master private shares", "error",
@@ -122,20 +124,22 @@ func (cc *configurationChain) registerDKG(round uint64, threshold int) {
}()
}
-func (cc *configurationChain) runDKG(round uint64) error {
+func (cc *configurationChain) runDKG(round, reset uint64) error {
// Check if corresponding DKG signer is ready.
if _, _, err := cc.getDKGInfo(round); err == nil {
return nil
}
cc.dkgLock.Lock()
defer cc.dkgLock.Unlock()
- if cc.dkg == nil || cc.dkg.round != round {
- if cc.dkg != nil && cc.dkg.round > round {
- cc.logger.Warn("DKG canceled", "round", round)
- return nil
- }
+ if cc.dkg == nil ||
+ cc.dkg.round < round ||
+ (cc.dkg.round == round && cc.dkg.reset < reset) {
return ErrDKGNotRegistered
}
+ if cc.dkg.round != round || cc.dkg.reset != reset {
+ cc.logger.Warn("DKG canceled", "round", round, "reset", reset)
+ return nil
+ }
cc.logger.Debug("Calling Governance.IsDKGFinal", "round", round)
if cc.gov.IsDKGFinal(round) {
cc.logger.Warn("DKG already final", "round", round)
@@ -144,7 +148,9 @@ func (cc *configurationChain) runDKG(round uint64) error {
cc.logger.Debug("Calling Governance.IsDKGMPKReady", "round", round)
for !cc.gov.IsDKGMPKReady(round) {
cc.logger.Debug("DKG MPKs are not ready yet. Try again later...",
- "nodeID", cc.ID)
+ "nodeID", cc.ID.String()[:6],
+ "round", round,
+ "reset", reset)
cc.dkgLock.Unlock()
time.Sleep(500 * time.Millisecond)
cc.dkgLock.Lock()
@@ -165,18 +171,24 @@ func (cc *configurationChain) runDKG(round uint64) error {
}
}
if !inProtocol {
- cc.logger.Warn("Failed to join DKG protocol", "round", round)
+ cc.logger.Warn("Failed to join DKG protocol",
+ "round", round,
+ "reset", reset)
return nil
}
// Phase 2(T = 0): Exchange DKG secret key share.
if err := cc.dkg.processMasterPublicKeys(mpks); err != nil {
cc.logger.Error("Failed to process master public key",
+ "round", round,
+ "reset", reset,
"error", err)
}
cc.mpkReady = true
for _, prvShare := range cc.pendingPrvShare {
if err := cc.dkg.processPrivateShare(prvShare); err != nil {
cc.logger.Error("Failed to process private share",
+ "round", round,
+ "reset", reset,
"error", err)
}
}
@@ -195,6 +207,8 @@ func (cc *configurationChain) runDKG(round uint64) error {
complaints := cc.gov.DKGComplaints(round)
if err := cc.dkg.processNackComplaints(complaints); err != nil {
cc.logger.Error("Failed to process NackComplaint",
+ "round", round,
+ "reset", reset,
"error", err)
}
cc.dkgLock.Unlock()
@@ -222,7 +236,9 @@ func (cc *configurationChain) runDKG(round uint64) error {
cc.logger.Debug("Calling Governance.IsDKGFinal", "round", round)
for !cc.gov.IsDKGFinal(round) {
cc.logger.Debug("DKG is not ready yet. Try again later...",
- "nodeID", cc.ID)
+ "nodeID", cc.ID.String()[:6],
+ "round", round,
+ "reset", reset)
time.Sleep(500 * time.Millisecond)
}
cc.logger.Debug("Calling Governance.DKGMasterPublicKeys", "round", round)
@@ -241,10 +257,13 @@ func (cc *configurationChain) runDKG(round uint64) error {
cc.logger.Info("Qualify Nodes",
"nodeID", cc.ID,
"round", round,
+ "reset", reset,
"count", len(npks.QualifyIDs),
"qualifies", qualifies)
if _, exist := npks.QualifyNodeIDs[cc.ID]; !exist {
- cc.logger.Warn("Self is not in Qualify Nodes")
+ cc.logger.Warn("Self is not in Qualify Nodes",
+ "round", round,
+ "reset", reset)
return nil
}
signer, err := cc.dkg.recoverShareSecret(npks.QualifyIDs)
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
index 8529e4031..e0a6753a9 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/consensus.go
@@ -740,7 +740,7 @@ func (con *Consensus) prepare(
con.logger.Info("Selected as DKG set", "round", nextRound)
nextConfig := utils.GetConfigWithPanic(con.gov, nextRound,
con.logger)
- con.cfgModule.registerDKG(nextRound, utils.GetDKGThreshold(
+ con.cfgModule.registerDKG(nextRound, e.Reset, utils.GetDKGThreshold(
nextConfig))
con.event.RegisterHeight(e.NextDKGPreparationHeight(),
func(uint64) {
@@ -749,7 +749,7 @@ func (con *Consensus) prepare(
defer con.dkgReady.L.Unlock()
con.dkgRunning = 0
}()
- con.runDKG(nextRound, nextConfig)
+ con.runDKG(nextRound, e.Reset, nextConfig)
})
})
})
@@ -805,7 +805,7 @@ func (con *Consensus) Run() {
}
// runDKG starts running DKG protocol.
-func (con *Consensus) runDKG(round uint64, config *types.Config) {
+func (con *Consensus) runDKG(round, reset uint64, config *types.Config) {
con.dkgReady.L.Lock()
defer con.dkgReady.L.Unlock()
if con.dkgRunning != 0 {
@@ -819,7 +819,7 @@ func (con *Consensus) runDKG(round uint64, config *types.Config) {
con.dkgReady.Broadcast()
con.dkgRunning = 2
}()
- if err := con.cfgModule.runDKG(round); err != nil {
+ if err := con.cfgModule.runDKG(round, reset); err != nil {
con.logger.Error("Failed to runDKG", "error", err)
}
}()
@@ -841,8 +841,7 @@ func (con *Consensus) runCRS(round uint64, hash common.Hash) {
"hash", psig.Hash)
con.network.BroadcastDKGPartialSignature(psig)
con.logger.Debug("Calling Governance.CRS", "round", round)
- crs, err := con.cfgModule.runCRSTSig(
- round, utils.GetCRSWithPanic(con.gov, round, con.logger))
+ crs, err := con.cfgModule.runCRSTSig(round, hash)
if err != nil {
con.logger.Error("Failed to run CRS Tsig", "error", err)
} else {
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go
index 259d07a4b..82da6dc20 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/dkg-tsig-protocol.go
@@ -60,6 +60,30 @@ var (
"self privateShare does not match mpk registered")
)
+// ErrUnexpectedDKGResetCount represents receiving a DKG message with unexpected
+// DKG reset count.
+type ErrUnexpectedDKGResetCount struct {
+ expect, actual uint64
+ proposerID types.NodeID
+}
+
+func (e ErrUnexpectedDKGResetCount) Error() string {
+ return fmt.Sprintf(
+ "unexpected DKG reset count, from:%s expect:%d actual:%d",
+ e.proposerID.String()[:6], e.expect, e.actual)
+}
+
+// ErrUnexpectedRound represents receiving a DKG message with unexpected round.
+type ErrUnexpectedRound struct {
+ expect, actual uint64
+ proposerID types.NodeID
+}
+
+func (e ErrUnexpectedRound) Error() string {
+ return fmt.Sprintf("unexpected round, from:%s expect:%d actual:%d",
+ e.proposerID.String()[:6], e.expect, e.actual)
+}
+
type dkgReceiver interface {
// ProposeDKGComplaint proposes a DKGComplaint.
ProposeDKGComplaint(complaint *typesDKG.Complaint)
@@ -84,6 +108,7 @@ type dkgProtocol struct {
ID types.NodeID
recv dkgReceiver
round uint64
+ reset uint64
threshold int
idMap map[types.NodeID]dkg.ID
mpkMap map[types.NodeID]*dkg.PublicKeyShares
@@ -140,12 +165,14 @@ func newDKGProtocol(
ID types.NodeID,
recv dkgReceiver,
round uint64,
+ reset uint64,
threshold int) *dkgProtocol {
prvShare, pubShare := dkg.NewPrivateKeyShares(threshold)
recv.ProposeDKGMasterPublicKey(&typesDKG.MasterPublicKey{
Round: round,
+ Reset: reset,
DKGID: typesDKG.NewID(ID),
PublicKeyShares: *pubShare,
})
@@ -154,6 +181,7 @@ func newDKGProtocol(
ID: ID,
recv: recv,
round: round,
+ reset: reset,
threshold: threshold,
idMap: make(map[types.NodeID]dkg.ID),
mpkMap: make(map[types.NodeID]*dkg.PublicKeyShares),
@@ -176,13 +204,17 @@ func recoverDKGProtocol(
if err == db.ErrDKGMasterPrivateSharesDoesNotExist {
return nil, nil
}
-
return nil, err
}
+ // TODO(mission): taken resetCount into consideration, we should keep
+ // reset count of private shares from DB, and use it to init
+ // DKG protocol instance.
+ reset := uint64(0)
return &dkgProtocol{
ID: ID,
recv: recv,
round: round,
+ reset: reset,
threshold: threshold,
idMap: make(map[types.NodeID]dkg.ID),
mpkMap: make(map[types.NodeID]*dkg.PublicKeyShares),
@@ -201,6 +233,13 @@ func (d *dkgProtocol) processMasterPublicKeys(
d.prvSharesReceived = make(map[types.NodeID]struct{}, len(mpks))
ids := make(dkg.IDs, len(mpks))
for i := range mpks {
+ if mpks[i].Reset != d.reset {
+ return ErrUnexpectedDKGResetCount{
+ expect: d.reset,
+ actual: mpks[i].Reset,
+ proposerID: mpks[i].ProposerID,
+ }
+ }
nID := mpks[i].ProposerID
d.idMap[nID] = mpks[i].DKGID
d.mpkMap[nID] = &mpks[i].PublicKeyShares
@@ -219,6 +258,7 @@ func (d *dkgProtocol) processMasterPublicKeys(
d.recv.ProposeDKGPrivateShare(&typesDKG.PrivateShare{
ReceiverID: mpk.ProposerID,
Round: d.round,
+ Reset: d.reset,
PrivateShare: *share,
})
}
@@ -252,9 +292,11 @@ func (d *dkgProtocol) proposeNackComplaints() {
}
d.recv.ProposeDKGComplaint(&typesDKG.Complaint{
Round: d.round,
+ Reset: d.reset,
PrivateShare: typesDKG.PrivateShare{
ProposerID: nID,
Round: d.round,
+ Reset: d.reset,
},
})
}
@@ -269,6 +311,9 @@ func (d *dkgProtocol) processNackComplaints(complaints []*typesDKG.Complaint) (
if !complaint.IsNack() {
continue
}
+ if complaint.Reset != d.reset {
+ continue
+ }
if complaint.PrivateShare.ProposerID != d.ID {
continue
}
@@ -286,6 +331,7 @@ func (d *dkgProtocol) processNackComplaints(complaints []*typesDKG.Complaint) (
ProposerID: d.ID,
ReceiverID: complaint.ProposerID,
Round: d.round,
+ Reset: d.reset,
PrivateShare: *share,
})
}
@@ -297,6 +343,9 @@ func (d *dkgProtocol) enforceNackComplaints(complaints []*typesDKG.Complaint) {
if !complaint.IsNack() {
continue
}
+ if complaint.Reset != d.reset {
+ continue
+ }
to := complaint.PrivateShare.ProposerID
// Do not propose nack complaint to itself.
if to == d.ID {
@@ -311,9 +360,11 @@ func (d *dkgProtocol) enforceNackComplaints(complaints []*typesDKG.Complaint) {
d.antiComplaintReceived[from][to]; !exist {
d.recv.ProposeDKGComplaint(&typesDKG.Complaint{
Round: d.round,
+ Reset: d.reset,
PrivateShare: typesDKG.PrivateShare{
ProposerID: to,
Round: d.round,
+ Reset: d.reset,
},
})
}
@@ -321,6 +372,20 @@ func (d *dkgProtocol) enforceNackComplaints(complaints []*typesDKG.Complaint) {
}
func (d *dkgProtocol) sanityCheck(prvShare *typesDKG.PrivateShare) error {
+ if d.round != prvShare.Round {
+ return ErrUnexpectedRound{
+ expect: d.round,
+ actual: prvShare.Round,
+ proposerID: prvShare.ProposerID,
+ }
+ }
+ if d.reset != prvShare.Reset {
+ return ErrUnexpectedDKGResetCount{
+ expect: d.reset,
+ actual: prvShare.Reset,
+ proposerID: prvShare.ProposerID,
+ }
+ }
if _, exist := d.idMap[prvShare.ProposerID]; !exist {
return ErrNotDKGParticipant
}
@@ -336,9 +401,6 @@ func (d *dkgProtocol) sanityCheck(prvShare *typesDKG.PrivateShare) error {
func (d *dkgProtocol) processPrivateShare(
prvShare *typesDKG.PrivateShare) error {
- if d.round != prvShare.Round {
- return nil
- }
receiverID, exist := d.idMap[prvShare.ReceiverID]
// This node is not a DKG participant, ignore the private share.
if !exist {
@@ -361,6 +423,7 @@ func (d *dkgProtocol) processPrivateShare(
}
complaint := &typesDKG.Complaint{
Round: d.round,
+ Reset: d.reset,
PrivateShare: *prvShare,
}
d.nodeComplained[prvShare.ProposerID] = struct{}{}
@@ -387,6 +450,7 @@ func (d *dkgProtocol) proposeMPKReady() {
d.recv.ProposeDKGMPKReady(&typesDKG.MPKReady{
ProposerID: d.ID,
Round: d.round,
+ Reset: d.reset,
})
}
@@ -394,6 +458,7 @@ func (d *dkgProtocol) proposeFinalize() {
d.recv.ProposeDKGFinalize(&typesDKG.Finalize{
ProposerID: d.ID,
Round: d.round,
+ Reset: d.reset,
})
}
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/interfaces.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/interfaces.go
index ddd6c3bb9..707563f03 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/interfaces.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/interfaces.go
@@ -116,6 +116,9 @@ type Governance interface {
// Return the genesis node set if round == 0.
NodeSet(round uint64) []crypto.PublicKey
+ // Get the begin height of a round.
+ GetRoundHeight(round uint64) uint64
+
//// DKG-related methods.
// AddDKGComplaint adds a DKGComplaint.
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go
index 1052ccb9f..6572d1e9d 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/dkg/dkg.go
@@ -47,6 +47,7 @@ type PrivateShare struct {
ProposerID types.NodeID `json:"proposer_id"`
ReceiverID types.NodeID `json:"receiver_id"`
Round uint64 `json:"round"`
+ Reset uint64 `json:"reset"`
PrivateShare cryptoDKG.PrivateKey `json:"private_share"`
Signature crypto.Signature `json:"signature"`
}
@@ -56,6 +57,7 @@ func (p *PrivateShare) Equal(other *PrivateShare) bool {
return p.ProposerID.Equal(other.ProposerID) &&
p.ReceiverID.Equal(other.ReceiverID) &&
p.Round == other.Round &&
+ p.Reset == other.Reset &&
p.Signature.Type == other.Signature.Type &&
bytes.Compare(p.Signature.Signature, other.Signature.Signature) == 0 &&
bytes.Compare(
@@ -66,21 +68,24 @@ func (p *PrivateShare) Equal(other *PrivateShare) bool {
type MasterPublicKey struct {
ProposerID types.NodeID `json:"proposer_id"`
Round uint64 `json:"round"`
+ Reset uint64 `json:"reset"`
DKGID cryptoDKG.ID `json:"dkg_id"`
PublicKeyShares cryptoDKG.PublicKeyShares `json:"public_key_shares"`
Signature crypto.Signature `json:"signature"`
}
func (d *MasterPublicKey) String() string {
- return fmt.Sprintf("MasterPublicKey{KP:%s Round:%d}",
+ return fmt.Sprintf("MasterPublicKey{KP:%s Round:%d Reset:%d}",
d.ProposerID.String()[:6],
- d.Round)
+ d.Round,
+ d.Reset)
}
// Equal check equality of two DKG master public keys.
func (d *MasterPublicKey) Equal(other *MasterPublicKey) bool {
return d.ProposerID.Equal(other.ProposerID) &&
d.Round == other.Round &&
+ d.Reset == other.Reset &&
d.DKGID.GetHexString() == other.DKGID.GetHexString() &&
d.PublicKeyShares.Equal(&other.PublicKeyShares) &&
d.Signature.Type == other.Signature.Type &&
@@ -90,6 +95,7 @@ func (d *MasterPublicKey) Equal(other *MasterPublicKey) bool {
type rlpMasterPublicKey struct {
ProposerID types.NodeID
Round uint64
+ Reset uint64
DKGID []byte
PublicKeyShares *cryptoDKG.PublicKeyShares
Signature crypto.Signature
@@ -100,6 +106,7 @@ func (d *MasterPublicKey) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, rlpMasterPublicKey{
ProposerID: d.ProposerID,
Round: d.Round,
+ Reset: d.Reset,
DKGID: d.DKGID.GetLittleEndian(),
PublicKeyShares: &d.PublicKeyShares,
Signature: d.Signature,
@@ -121,6 +128,7 @@ func (d *MasterPublicKey) DecodeRLP(s *rlp.Stream) error {
*d = MasterPublicKey{
ProposerID: dec.ProposerID,
Round: dec.Round,
+ Reset: dec.Reset,
DKGID: id,
PublicKeyShares: *dec.PublicKeyShares,
Signature: dec.Signature,
@@ -146,24 +154,26 @@ func (d *MasterPublicKey) UnmarshalJSON(data []byte) error {
type Complaint struct {
ProposerID types.NodeID `json:"proposer_id"`
Round uint64 `json:"round"`
+ Reset uint64 `json:"reset"`
PrivateShare PrivateShare `json:"private_share"`
Signature crypto.Signature `json:"signature"`
}
func (c *Complaint) String() string {
if c.IsNack() {
- return fmt.Sprintf("DKGNackComplaint{CP:%s Round:%d PSP:%s}",
- c.ProposerID.String()[:6], c.Round,
+ return fmt.Sprintf("DKGNackComplaint{CP:%s Round:%d Reset %d PSP:%s}",
+ c.ProposerID.String()[:6], c.Round, c.Reset,
c.PrivateShare.ProposerID.String()[:6])
}
- return fmt.Sprintf("DKGComplaint{CP:%s Round:%d PrivateShare:%v}",
- c.ProposerID.String()[:6], c.Round, c.PrivateShare)
+ return fmt.Sprintf("DKGComplaint{CP:%s Round:%d Reset %d PrivateShare:%v}",
+ c.ProposerID.String()[:6], c.Round, c.Reset, c.PrivateShare)
}
// Equal checks equality between two Complaint instances.
func (c *Complaint) Equal(other *Complaint) bool {
return c.ProposerID.Equal(other.ProposerID) &&
c.Round == other.Round &&
+ c.Reset == other.Reset &&
c.PrivateShare.Equal(&other.PrivateShare) &&
c.Signature.Type == other.Signature.Type &&
bytes.Compare(c.Signature.Signature, other.Signature.Signature) == 0
@@ -172,6 +182,7 @@ func (c *Complaint) Equal(other *Complaint) bool {
type rlpComplaint struct {
ProposerID types.NodeID
Round uint64
+ Reset uint64
IsNack bool
PrivateShare []byte
Signature crypto.Signature
@@ -183,6 +194,7 @@ func (c *Complaint) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, rlpComplaint{
ProposerID: c.ProposerID,
Round: c.Round,
+ Reset: c.Reset,
IsNack: true,
PrivateShare: c.PrivateShare.ProposerID.Hash[:],
Signature: c.Signature,
@@ -195,6 +207,7 @@ func (c *Complaint) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, rlpComplaint{
ProposerID: c.ProposerID,
Round: c.Round,
+ Reset: c.Reset,
IsNack: false,
PrivateShare: prvShare,
Signature: c.Signature,
@@ -212,6 +225,7 @@ func (c *Complaint) DecodeRLP(s *rlp.Stream) error {
if dec.IsNack {
copy(prvShare.ProposerID.Hash[:], dec.PrivateShare)
prvShare.Round = dec.Round
+ prvShare.Reset = dec.Reset
} else {
if err := rlp.DecodeBytes(dec.PrivateShare, &prvShare); err != nil {
return err
@@ -221,6 +235,7 @@ func (c *Complaint) DecodeRLP(s *rlp.Stream) error {
*c = Complaint{
ProposerID: dec.ProposerID,
Round: dec.Round,
+ Reset: dec.Reset,
PrivateShare: prvShare,
Signature: dec.Signature,
}
@@ -240,19 +255,22 @@ type PartialSignature struct {
type MPKReady struct {
ProposerID types.NodeID `json:"proposer_id"`
Round uint64 `json:"round"`
+ Reset uint64 `json:"reset"`
Signature crypto.Signature `json:"signature"`
}
func (ready *MPKReady) String() string {
- return fmt.Sprintf("DKGMPKReady{RP:%s Round:%d}",
+ return fmt.Sprintf("DKGMPKReady{RP:%s Round:%d Reset:%d}",
ready.ProposerID.String()[:6],
- ready.Round)
+ ready.Round,
+ ready.Reset)
}
// Equal check equality of two MPKReady instances.
func (ready *MPKReady) Equal(other *MPKReady) bool {
return ready.ProposerID.Equal(other.ProposerID) &&
ready.Round == other.Round &&
+ ready.Reset == other.Reset &&
ready.Signature.Type == other.Signature.Type &&
bytes.Compare(ready.Signature.Signature, other.Signature.Signature) == 0
}
@@ -261,19 +279,22 @@ func (ready *MPKReady) Equal(other *MPKReady) bool {
type Finalize struct {
ProposerID types.NodeID `json:"proposer_id"`
Round uint64 `json:"round"`
+ Reset uint64 `json:"reset"`
Signature crypto.Signature `json:"signature"`
}
func (final *Finalize) String() string {
- return fmt.Sprintf("DKGFinal{FP:%s Round:%d}",
+ return fmt.Sprintf("DKGFinal{FP:%s Round:%d Reset:%d}",
final.ProposerID.String()[:6],
- final.Round)
+ final.Round,
+ final.Reset)
}
// Equal check equality of two Finalize instances.
func (final *Finalize) Equal(other *Finalize) bool {
return final.ProposerID.Equal(other.ProposerID) &&
final.Round == other.Round &&
+ final.Reset == other.Reset &&
final.Signature.Type == other.Signature.Type &&
bytes.Compare(final.Signature.Signature, other.Signature.Signature) == 0
}
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/crypto.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/crypto.go
index f5343ca38..7532d299e 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/crypto.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/crypto.go
@@ -148,11 +148,14 @@ func hashPosition(position types.Position) common.Hash {
func hashDKGPrivateShare(prvShare *typesDKG.PrivateShare) common.Hash {
binaryRound := make([]byte, 8)
binary.LittleEndian.PutUint64(binaryRound, prvShare.Round)
+ binaryReset := make([]byte, 8)
+ binary.LittleEndian.PutUint64(binaryReset, prvShare.Reset)
return crypto.Keccak256Hash(
prvShare.ProposerID.Hash[:],
prvShare.ReceiverID.Hash[:],
binaryRound,
+ binaryReset,
prvShare.PrivateShare.Bytes(),
)
}
@@ -175,12 +178,15 @@ func VerifyDKGPrivateShareSignature(
func hashDKGMasterPublicKey(mpk *typesDKG.MasterPublicKey) common.Hash {
binaryRound := make([]byte, 8)
binary.LittleEndian.PutUint64(binaryRound, mpk.Round)
+ binaryReset := make([]byte, 8)
+ binary.LittleEndian.PutUint64(binaryReset, mpk.Reset)
return crypto.Keccak256Hash(
mpk.ProposerID.Hash[:],
mpk.DKGID.GetLittleEndian(),
mpk.PublicKeyShares.MasterKeyBytes(),
binaryRound,
+ binaryReset,
)
}
@@ -201,12 +207,15 @@ func VerifyDKGMasterPublicKeySignature(
func hashDKGComplaint(complaint *typesDKG.Complaint) common.Hash {
binaryRound := make([]byte, 8)
binary.LittleEndian.PutUint64(binaryRound, complaint.Round)
+ binaryReset := make([]byte, 8)
+ binary.LittleEndian.PutUint64(binaryReset, complaint.Reset)
hashPrvShare := hashDKGPrivateShare(&complaint.PrivateShare)
return crypto.Keccak256Hash(
complaint.ProposerID.Hash[:],
binaryRound,
+ binaryReset,
hashPrvShare[:],
)
}
@@ -217,6 +226,9 @@ func VerifyDKGComplaintSignature(
if complaint.Round != complaint.PrivateShare.Round {
return false, nil
}
+ if complaint.Reset != complaint.PrivateShare.Reset {
+ return false, nil
+ }
hash := hashDKGComplaint(complaint)
pubKey, err := crypto.SigToPub(hash, complaint.Signature)
if err != nil {
@@ -261,10 +273,13 @@ func VerifyDKGPartialSignatureSignature(
func hashDKGMPKReady(ready *typesDKG.MPKReady) common.Hash {
binaryRound := make([]byte, 8)
binary.LittleEndian.PutUint64(binaryRound, ready.Round)
+ binaryReset := make([]byte, 8)
+ binary.LittleEndian.PutUint64(binaryReset, ready.Reset)
return crypto.Keccak256Hash(
ready.ProposerID.Hash[:],
binaryRound,
+ binaryReset,
)
}
@@ -285,10 +300,13 @@ func VerifyDKGMPKReadySignature(
func hashDKGFinalize(final *typesDKG.Finalize) common.Hash {
binaryRound := make([]byte, 8)
binary.LittleEndian.PutUint64(binaryRound, final.Round)
+ binaryReset := make([]byte, 8)
+ binary.LittleEndian.PutUint64(binaryReset, final.Reset)
return crypto.Keccak256Hash(
final.ProposerID.Hash[:],
binaryRound,
+ binaryReset,
)
}
diff --git a/vendor/vendor.json b/vendor/vendor.json
index aa7a3ff65..a9ccdbf29 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -141,16 +141,16 @@
{
"checksumSHA1": "8EuKVkP1v/w5fRuuvUaXX5k/F+I=",
"path": "github.com/dexon-foundation/dexon-consensus/common",
- "revision": "c0e1c45539fe882c4cd096a41e36f764d5ad2092",
- "revisionTime": "2019-03-16T10:51:30Z",
+ "revision": "4b40c1b8990d2a371a77018feea32d038163f2ec",
+ "revisionTime": "2019-03-17T01:56:23Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
- "checksumSHA1": "bYtL3br8SNzJRQzD0leNywoSo2M=",
+ "checksumSHA1": "Mww2DjHBDmD5YUzUSIwJTa53BIg=",
"path": "github.com/dexon-foundation/dexon-consensus/core",
- "revision": "c0e1c45539fe882c4cd096a41e36f764d5ad2092",
- "revisionTime": "2019-03-16T10:51:30Z",
+ "revision": "4b40c1b8990d2a371a77018feea32d038163f2ec",
+ "revisionTime": "2019-03-17T01:56:23Z",
"version": "single-chain",
"versionExact": "single-chain"
},
@@ -165,64 +165,64 @@
{
"checksumSHA1": "tQSbYCu5P00lUhKsx3IbBZCuSLY=",
"path": "github.com/dexon-foundation/dexon-consensus/core/crypto",
- "revision": "c0e1c45539fe882c4cd096a41e36f764d5ad2092",
- "revisionTime": "2019-03-16T10:51:30Z",
+ "revision": "4b40c1b8990d2a371a77018feea32d038163f2ec",
+ "revisionTime": "2019-03-17T01:56:23Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "kC/Tu4is9+jABI/EdvEv7VxwvEo=",
"path": "github.com/dexon-foundation/dexon-consensus/core/crypto/dkg",
- "revision": "c0e1c45539fe882c4cd096a41e36f764d5ad2092",
- "revisionTime": "2019-03-16T10:51:30Z",
+ "revision": "4b40c1b8990d2a371a77018feea32d038163f2ec",
+ "revisionTime": "2019-03-17T01:56:23Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "BhLKK8RveoLaeXc9UyUKMwQqchU=",
"path": "github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa",
- "revision": "c0e1c45539fe882c4cd096a41e36f764d5ad2092",
- "revisionTime": "2019-03-16T10:51:30Z",
+ "revision": "4b40c1b8990d2a371a77018feea32d038163f2ec",
+ "revisionTime": "2019-03-17T01:56:23Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "dQOZYmiikmjWhwkUJc0QmCJnO9o=",
"path": "github.com/dexon-foundation/dexon-consensus/core/db",
- "revision": "c0e1c45539fe882c4cd096a41e36f764d5ad2092",
- "revisionTime": "2019-03-16T10:51:30Z",
+ "revision": "4b40c1b8990d2a371a77018feea32d038163f2ec",
+ "revisionTime": "2019-03-17T01:56:23Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "H0+GIDijBmoic/0HSTZBUwEij5A=",
"path": "github.com/dexon-foundation/dexon-consensus/core/syncer",
- "revision": "c0e1c45539fe882c4cd096a41e36f764d5ad2092",
- "revisionTime": "2019-03-16T10:51:30Z",
+ "revision": "4b40c1b8990d2a371a77018feea32d038163f2ec",
+ "revisionTime": "2019-03-17T01:56:23Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
"checksumSHA1": "id8imcgp3SqYhIx0k3Chd0VZrUQ=",
"path": "github.com/dexon-foundation/dexon-consensus/core/types",
- "revision": "c0e1c45539fe882c4cd096a41e36f764d5ad2092",
- "revisionTime": "2019-03-16T10:51:30Z",
+ "revision": "4b40c1b8990d2a371a77018feea32d038163f2ec",
+ "revisionTime": "2019-03-17T01:56:23Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
- "checksumSHA1": "QXRBX9UmvX4wszA9qlyJtzYcTOw=",
+ "checksumSHA1": "yoVRmvJDCp/1jSfY7wMt2LBQ9e8=",
"path": "github.com/dexon-foundation/dexon-consensus/core/types/dkg",
- "revision": "c0e1c45539fe882c4cd096a41e36f764d5ad2092",
- "revisionTime": "2019-03-16T10:51:30Z",
+ "revision": "4b40c1b8990d2a371a77018feea32d038163f2ec",
+ "revisionTime": "2019-03-17T01:56:23Z",
"version": "single-chain",
"versionExact": "single-chain"
},
{
- "checksumSHA1": "D9I012bShlJM+rsYxG5sH5nvqXA=",
+ "checksumSHA1": "yoUeXa3YR9zZloqS9M08Ts8Ak1A=",
"path": "github.com/dexon-foundation/dexon-consensus/core/utils",
- "revision": "c0e1c45539fe882c4cd096a41e36f764d5ad2092",
- "revisionTime": "2019-03-16T10:51:30Z",
+ "revision": "4b40c1b8990d2a371a77018feea32d038163f2ec",
+ "revisionTime": "2019-03-17T01:56:23Z",
"version": "single-chain",
"versionExact": "single-chain"
},