Skip to content

Commit

Permalink
Fix a Pedersen DKG check to empty list
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilthoniel committed Jul 1, 2020
1 parent 6ff8f38 commit c346987
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.sum
Expand Up @@ -18,6 +18,7 @@ go.dedis.ch/protobuf v1.0.7 h1:wRUEiq3u0/vBhLjcw9CmAVrol+BnDyq2M0XLukdphyI=
go.dedis.ch/protobuf v1.0.7/go.mod h1:pv5ysfkDX/EawiPqcW3ikOxsL5t+BqnV6xHSmE79KI4=
go.dedis.ch/protobuf v1.0.10 h1:/8plWfioYRf9sBQdCvoNfLf+XHuQWF1ctC1gWzzmojk=
go.dedis.ch/protobuf v1.0.10/go.mod h1:oIXBd4PkP3jxrN9t/eslifGU2tTeG9JuMUjMFrgfcEc=
go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo=
go.dedis.ch/protobuf v1.0.11/go.mod h1:97QR256dnkimeNdfmURz0wAMNVbd1VmLXhG1CrTYrJ4=
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b h1:Elez2XeF2p9uyVj0yEUDqQ56NFcDtcBNkYP7yv8YbUE=
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down
4 changes: 2 additions & 2 deletions share/dkg/pedersen/dkg.go
Expand Up @@ -135,7 +135,7 @@ type DistKeyGenerator struct {
// NewDistKeyHandler takes a Config and returns a DistKeyGenerator that is able
// to drive the DKG or resharing protocol.
func NewDistKeyHandler(c *Config) (*DistKeyGenerator, error) {
if c.NewNodes == nil && c.OldNodes == nil {
if len(c.NewNodes) == 0 && len(c.OldNodes) == 0 {
return nil, errors.New("dkg: can't run with empty node list")
}

Expand All @@ -144,7 +144,7 @@ func NewDistKeyHandler(c *Config) (*DistKeyGenerator, error) {
isResharing = true
}
if isResharing {
if c.OldNodes == nil {
if len(c.OldNodes) == 0 {
return nil, errors.New("dkg: resharing config needs old nodes list")
}
if c.OldThreshold == 0 {
Expand Down
3 changes: 3 additions & 0 deletions share/dkg/pedersen/dkg_test.go
Expand Up @@ -60,6 +60,9 @@ func TestDKGNewDistKeyGenerator(t *testing.T) {
sec, _ := genPair()
_, err = NewDistKeyGenerator(suite, sec, partPubs, defaultT)
require.Error(t, err)

_, err = NewDistKeyGenerator(suite, sec, []kyber.Point{}, defaultT)
require.EqualError(t, err, "dkg: can't run with empty node list")
}

func TestDKGDeal(t *testing.T) {
Expand Down

0 comments on commit c346987

Please sign in to comment.