Skip to content

Commit

Permalink
Fix: update always round.ok
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhAnGeek committed Dec 1, 2023
1 parent b8d526d commit 1c4f921
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 47 deletions.
6 changes: 4 additions & 2 deletions ecdsa/keygen/round_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,19 @@ func (round *round1) CanAccept(msg tss.ParsedMessage) bool {
}

func (round *round1) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.kgRound1Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
// vss check is in round 2
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round1) NextRound() tss.Round {
Expand Down
9 changes: 6 additions & 3 deletions ecdsa/keygen/round_2.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,23 @@ func (round *round2) CanAccept(msg tss.ParsedMessage) bool {

func (round *round2) Update() (bool, *tss.Error) {
// guard - VERIFY de-commit for all Pj
ret := true
for j, msg := range round.temp.kgRound2Message1s {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
msg2 := round.temp.kgRound2Message2s[j]
if msg2 == nil || !round.CanAccept(msg2) {
return false, nil
ret = false
continue
}
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round2) NextRound() tss.Round {
Expand Down
6 changes: 4 additions & 2 deletions ecdsa/keygen/round_3.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,19 @@ func (round *round3) CanAccept(msg tss.ParsedMessage) bool {
}

func (round *round3) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.kgRound3Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
// proof check is in round 4
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round3) NextRound() tss.Round {
Expand Down
6 changes: 4 additions & 2 deletions ecdsa/resharing/round_1_old_step_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ func (round *round1) Update() (bool, *tss.Error) {
return true, nil
}
// accept messages from old -> new committee
ret := true
for j, msg := range round.temp.dgRound1Messages {
if round.oldOK[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.oldOK[j] = true

Expand All @@ -119,7 +121,7 @@ func (round *round1) Update() (bool, *tss.Error) {
}
round.save.ECDSAPub = candidate
}
return true, nil
return ret, nil
}

func (round *round1) NextRound() tss.Round {
Expand Down
15 changes: 10 additions & 5 deletions ecdsa/resharing/round_2_new_step_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,22 @@ func (round *round2) CanAccept(msg tss.ParsedMessage) bool {
}

func (round *round2) Update() (bool, *tss.Error) {
ret := true
if round.ReSharingParams().IsOldCommittee() && round.ReSharingParameters.IsNewCommittee() {
// accept messages from new -> old committee
for j, msg1 := range round.temp.dgRound2Message2s {
if round.newOK[j] {
continue
}
if msg1 == nil || !round.CanAccept(msg1) {
return false, nil
ret = false
continue
}
// accept message from new -> committee
msg2 := round.temp.dgRound2Message1s[j]
if msg2 == nil || !round.CanAccept(msg2) {
return false, nil
ret = false
continue
}
round.newOK[j] = true
}
Expand All @@ -158,7 +161,8 @@ func (round *round2) Update() (bool, *tss.Error) {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.newOK[j] = true
}
Expand All @@ -169,14 +173,15 @@ func (round *round2) Update() (bool, *tss.Error) {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.newOK[j] = true
}
} else {
return false, round.WrapError(errors.New("this party is not in the old or the new committee"), round.PartyID())
}
return true, nil
return ret, nil
}

func (round *round2) NextRound() tss.Round {
Expand Down
6 changes: 4 additions & 2 deletions ecdsa/signing/round_2.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,18 @@ func (round *round2) Start() *tss.Error {
}

func (round *round2) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.signRound2Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round2) CanAccept(msg tss.ParsedMessage) bool {
Expand Down
6 changes: 4 additions & 2 deletions ecdsa/signing/round_3.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,18 @@ func (round *round3) Start() *tss.Error {
}

func (round *round3) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.signRound3Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round3) CanAccept(msg tss.ParsedMessage) bool {
Expand Down
6 changes: 4 additions & 2 deletions ecdsa/signing/round_4.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,18 @@ func (round *round4) Start() *tss.Error {
}

func (round *round4) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.signRound4Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round4) CanAccept(msg tss.ParsedMessage) bool {
Expand Down
6 changes: 4 additions & 2 deletions ecdsa/signing/round_5.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,18 @@ func (round *round5) Start() *tss.Error {
}

func (round *round5) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.signRound5Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round5) CanAccept(msg tss.ParsedMessage) bool {
Expand Down
6 changes: 4 additions & 2 deletions ecdsa/signing/round_6.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ func (round *round6) Start() *tss.Error {
}

func (round *round6) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.signRound6Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round6) CanAccept(msg tss.ParsedMessage) bool {
Expand Down
6 changes: 4 additions & 2 deletions ecdsa/signing/round_7.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,18 @@ func (round *round7) Start() *tss.Error {
}

func (round *round7) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.signRound7Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round7) CanAccept(msg tss.ParsedMessage) bool {
Expand Down
6 changes: 4 additions & 2 deletions ecdsa/signing/round_8.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ func (round *round8) Start() *tss.Error {
}

func (round *round8) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.signRound8Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round8) CanAccept(msg tss.ParsedMessage) bool {
Expand Down
6 changes: 4 additions & 2 deletions ecdsa/signing/round_9.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@ func (round *round9) Start() *tss.Error {
}

func (round *round9) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.signRound9Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round9) CanAccept(msg tss.ParsedMessage) bool {
Expand Down
6 changes: 4 additions & 2 deletions eddsa/keygen/round_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,19 @@ func (round *round1) CanAccept(msg tss.ParsedMessage) bool {
}

func (round *round1) Update() (bool, *tss.Error) {
ret := true
for j, msg := range round.temp.kgRound1Messages {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
// vss check is in round 2
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round1) NextRound() tss.Round {
Expand Down
9 changes: 6 additions & 3 deletions eddsa/keygen/round_2.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,23 @@ func (round *round2) CanAccept(msg tss.ParsedMessage) bool {

func (round *round2) Update() (bool, *tss.Error) {
// guard - VERIFY de-commit for all Pj
ret := true
for j, msg := range round.temp.kgRound2Message1s {
if round.ok[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
msg2 := round.temp.kgRound2Message2s[j]
if msg2 == nil || !round.CanAccept(msg2) {
return false, nil
ret = false
continue
}
round.ok[j] = true
}
return true, nil
return ret, nil
}

func (round *round2) NextRound() tss.Round {
Expand Down
6 changes: 4 additions & 2 deletions eddsa/resharing/round_1_old_step_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ func (round *round1) Update() (bool, *tss.Error) {
return true, nil
}
// accept messages from old -> new committee
ret := true
for j, msg := range round.temp.dgRound1Messages {
if round.oldOK[j] {
continue
}
if msg == nil || !round.CanAccept(msg) {
return false, nil
ret = false
continue
}
round.oldOK[j] = true

Expand All @@ -112,7 +114,7 @@ func (round *round1) Update() (bool, *tss.Error) {
}
round.save.EDDSAPub = candidate
}
return true, nil
return ret, nil
}

func (round *round1) NextRound() tss.Round {
Expand Down
Loading

0 comments on commit 1c4f921

Please sign in to comment.