aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-15 15:19:27 +0800
committerGitHub <noreply@github.com>2018-10-15 15:19:27 +0800
commit508cf09792a35f0129df9b04efa471074e61a36f (patch)
tree19c7e23860c5e62b0c93acbb780da88066b2fa97 /core
parenta624d79f6bc1b3ca1567c6d16e143aa009f04764 (diff)
downloaddexon-consensus-508cf09792a35f0129df9b04efa471074e61a36f.tar
dexon-consensus-508cf09792a35f0129df9b04efa471074e61a36f.tar.gz
dexon-consensus-508cf09792a35f0129df9b04efa471074e61a36f.tar.bz2
dexon-consensus-508cf09792a35f0129df9b04efa471074e61a36f.tar.lz
dexon-consensus-508cf09792a35f0129df9b04efa471074e61a36f.tar.xz
dexon-consensus-508cf09792a35f0129df9b04efa471074e61a36f.tar.zst
dexon-consensus-508cf09792a35f0129df9b04efa471074e61a36f.zip
core: Change DKG threshold (#204)
Diffstat (limited to 'core')
-rw-r--r--core/consensus.go4
-rw-r--r--core/dkg-tsig-protocol.go4
-rw-r--r--core/dkg-tsig-protocol_test.go4
3 files changed, 6 insertions, 6 deletions
diff --git a/core/consensus.go b/core/consensus.go
index acdf1ad..526ced5 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -268,7 +268,7 @@ func NewConsensus(
gov)
// Register DKG for the initial round. This is a temporary function call for
// simulation.
- cfgModule.registerDKG(round, int(config.DKGSetSize)/3)
+ cfgModule.registerDKG(round, int(config.DKGSetSize)/3+1)
// Construct Consensus instance.
con := &Consensus{
ID: ID,
@@ -466,7 +466,7 @@ func (con *Consensus) initialRound(startTime time.Time) {
con.event.RegisterTime(startTime.Add(con.currentConfig.RoundInterval/2),
func(time.Time) {
con.cfgModule.registerDKG(
- con.round+1, int(con.currentConfig.DKGSetSize/3))
+ con.round+1, int(con.currentConfig.DKGSetSize/3)+1)
})
con.event.RegisterTime(startTime.Add(con.currentConfig.RoundInterval*2/3),
func(time.Time) {
diff --git a/core/dkg-tsig-protocol.go b/core/dkg-tsig-protocol.go
index 3be717f..795f6d3 100644
--- a/core/dkg-tsig-protocol.go
+++ b/core/dkg-tsig-protocol.go
@@ -311,7 +311,7 @@ func (d *dkgProtocol) proposeFinalize() {
func (d *dkgProtocol) recoverShareSecret(qualifyIDs dkg.IDs) (
*dkgShareSecret, error) {
- if len(qualifyIDs) <= d.threshold {
+ if len(qualifyIDs) < d.threshold {
return nil, ErrNotReachThreshold
}
prvKey, err := d.prvShares.RecoverPrivateKey(qualifyIDs)
@@ -455,7 +455,7 @@ func (tsig *tsigProtocol) processPartialSignature(
}
func (tsig *tsigProtocol) signature() (crypto.Signature, error) {
- if len(tsig.sigs) <= tsig.groupPublicKey.threshold {
+ if len(tsig.sigs) < tsig.groupPublicKey.threshold {
return crypto.Signature{}, ErrNotEnoughtPartialSignatures
}
ids := make(dkg.IDs, 0, len(tsig.sigs))
diff --git a/core/dkg-tsig-protocol_test.go b/core/dkg-tsig-protocol_test.go
index 8822de3..d03d811 100644
--- a/core/dkg-tsig-protocol_test.go
+++ b/core/dkg-tsig-protocol_test.go
@@ -136,7 +136,7 @@ func (s *DKGTSIGProtocolTestSuite) newProtocols(k, n int, round uint64) (
// recovering threshold signature.
// All participants are good people in this test.
func (s *DKGTSIGProtocolTestSuite) TestDKGTSIGProtocol() {
- k := 3
+ k := 2
n := 10
round := uint64(1)
gov, err := test.NewGovernance(5, 100)
@@ -228,7 +228,7 @@ func (s *DKGTSIGProtocolTestSuite) TestDKGTSIGProtocol() {
psig.Signature, err = s.prvKeys[nID].Sign(hashDKGPartialSignature(psig))
s.Require().NoError(err)
s.Require().NoError(tsig.processPartialSignature(psig))
- if len(tsig.sigs) > k {
+ if len(tsig.sigs) >= k {
break
}
}