diff --git a/ecdsa/resharing/local_party_test.go b/ecdsa/resharing/local_party_test.go index 42ae7ed49..864116ac5 100644 --- a/ecdsa/resharing/local_party_test.go +++ b/ecdsa/resharing/local_party_test.go @@ -236,3 +236,17 @@ signing: } } } + +func TestRejectsPartyInBothCommittees(t *testing.T) { + keys, pIDs, err := keygen.LoadKeygenTestFixtures(testThreshold + 1) + assert.NoError(t, err) + p2pCtx := tss.NewPeerContext(pIDs) + params := tss.NewReSharingParameters(tss.S256(), p2pCtx, p2pCtx, pIDs[0], len(pIDs), testThreshold, len(pIDs), testThreshold) + out := make(chan tss.Message, len(pIDs)) + end := make(chan *keygen.LocalPartySaveData, 1) + P := NewLocalParty(params, keys[0], out, end) + tssErr := P.Start() + if assert.NotNil(t, tssErr) { + assert.Contains(t, tssErr.Error(), "both the old and new committees") + } +} diff --git a/ecdsa/resharing/round_1_old_step_1.go b/ecdsa/resharing/round_1_old_step_1.go index 9fdb4aa10..6b26c6e78 100644 --- a/ecdsa/resharing/round_1_old_step_1.go +++ b/ecdsa/resharing/round_1_old_step_1.go @@ -35,6 +35,9 @@ func (round *round1) Start() *tss.Error { round.resetOK() // resets both round.oldOK and round.newOK round.allNewOK() + if round.ReSharingParams().IsOldCommittee() && round.ReSharingParams().IsNewCommittee() { + return round.WrapError(errors.New("party is in both the old and new committees; new committee members need distinct party keys"), round.PartyID()) + } if !round.ReSharingParams().IsOldCommittee() { return nil } @@ -117,12 +120,7 @@ func (round *round1) Update() (bool, *tss.Error) { } round.oldOK[j] = true - // save the ecdsa pub received from the old committee - if round.temp.dgRound1Messages[0] == nil { - ret = false - continue - } - r1msg := round.temp.dgRound1Messages[0].Content().(*DGRound1Message) + r1msg := msg.Content().(*DGRound1Message) candidate, err := r1msg.UnmarshalECDSAPub(round.Params().EC()) if err != nil { return false, round.WrapError(errors.New("unable to unmarshal the ecdsa pub key"), msg.GetFrom()) diff --git a/eddsa/resharing/local_party_test.go b/eddsa/resharing/local_party_test.go index f57417b9e..9b872921d 100644 --- a/eddsa/resharing/local_party_test.go +++ b/eddsa/resharing/local_party_test.go @@ -228,3 +228,17 @@ signing: } } } + +func TestRejectsPartyInBothCommittees(t *testing.T) { + keys, pIDs, err := keygen.LoadKeygenTestFixtures(testThreshold + 1) + assert.NoError(t, err) + p2pCtx := tss.NewPeerContext(pIDs) + params := tss.NewReSharingParameters(tss.Edwards(), p2pCtx, p2pCtx, pIDs[0], len(pIDs), testThreshold, len(pIDs), testThreshold) + out := make(chan tss.Message, len(pIDs)) + end := make(chan *keygen.LocalPartySaveData, 1) + P := NewLocalParty(params, keys[0], out, end) + tssErr := P.Start() + if assert.NotNil(t, tssErr) { + assert.Contains(t, tssErr.Error(), "both the old and new committees") + } +} diff --git a/eddsa/resharing/round_1_old_step_1.go b/eddsa/resharing/round_1_old_step_1.go index cc1a6fbc9..4057dde9f 100644 --- a/eddsa/resharing/round_1_old_step_1.go +++ b/eddsa/resharing/round_1_old_step_1.go @@ -34,6 +34,9 @@ func (round *round1) Start() *tss.Error { round.resetOK() // resets both round.oldOK and round.newOK round.allNewOK() + if round.ReSharingParams().IsOldCommittee() && round.ReSharingParams().IsNewCommittee() { + return round.WrapError(errors.New("party is in both the old and new committees; new committee members need distinct party keys"), round.PartyID()) + } if !round.ReSharingParams().IsOldCommittee() { return nil } @@ -102,12 +105,7 @@ func (round *round1) Update() (bool, *tss.Error) { } round.oldOK[j] = true - if round.temp.dgRound1Messages[0] == nil { - ret = false - continue - } - // save the eddsa pub received from the old committee - r1msg := round.temp.dgRound1Messages[0].Content().(*DGRound1Message) + r1msg := msg.Content().(*DGRound1Message) candidate, err := r1msg.UnmarshalEDDSAPub(round.Params().EC()) if err != nil { return false, round.WrapError(errors.New("unable to unmarshal the eddsa pub key"), msg.GetFrom())