diff --git a/tss/key/reshare/update_round.go b/tss/key/reshare/update_round.go index 1b98bdd..cbd7573 100644 --- a/tss/key/reshare/update_round.go +++ b/tss/key/reshare/update_round.go @@ -5,7 +5,6 @@ import ( "fmt" "math/big" - "github.com/okx/threshold-lib/crypto" "github.com/okx/threshold-lib/crypto/commitment" "github.com/okx/threshold-lib/crypto/curves" "github.com/okx/threshold-lib/crypto/vss" @@ -19,7 +18,6 @@ type RefreshInfo struct { curve elliptic.Curve devoteList [2]int // 2 contributors reset the key share - isDevotee bool // contributors and non-contributors count differently ui *big.Int shareI *big.Int publicKey *curves.ECPoint @@ -47,13 +45,10 @@ func NewRefresh(deviceNumber, total int, devoteList [2]int, ShareI *big.Int, Pub } if deviceNumber == devoteList[0] || deviceNumber == devoteList[1] { - info.isDevotee = true ints := []*big.Int{big.NewInt(int64(devoteList[0])), big.NewInt(int64(devoteList[1]))} info.ui = vss.CalLagrangian(curve, big.NewInt(int64(deviceNumber)), ShareI, ints) } else { - // Useless, consistent with dkg - info.ui = crypto.RandomNum(curve.Params().N) - info.isDevotee = false + info.ui = big.NewInt(0) } return info } diff --git a/tss/key/reshare/update_round3.go b/tss/key/reshare/update_round3.go index 446c58e..00727af 100644 --- a/tss/key/reshare/update_round3.go +++ b/tss/key/reshare/update_round3.go @@ -29,12 +29,8 @@ func (info *RefreshInfo) DKGStep3(msgs []*tss.Message) (*tss.KeyStep3Data, error } verifiers := make(map[int][]*curves.ECPoint, len(msgs)) + verifiers[info.DeviceNumber] = info.verifiers xi := info.secretShares[info.DeviceNumber-1] - if info.isDevotee { - verifiers[info.DeviceNumber] = info.verifiers - } else { - xi.Y = big.NewInt(0) - } for _, msg := range msgs { if msg.To != info.DeviceNumber { return nil, fmt.Errorf("message sending error") @@ -52,28 +48,24 @@ func (info *RefreshInfo) DKGStep3(msgs []*tss.Message) (*tss.KeyStep3Data, error return nil, fmt.Errorf("commitment DeCommit fail") } - // only add the values of the contributors - if msg.From == info.devoteList[0] || msg.From == info.devoteList[1] { - xi.Y = new(big.Int).Add(xi.Y, content.Share.Y) - - verifiers[msg.From], err = dkg.UnmarshalVerifiers(curve, D, info.Threshold) - if ok, err := feldman.Verify(content.Share, verifiers[msg.From]); !ok { - if err != nil { - return nil, err - } else { - return nil, fmt.Errorf("invalid share for participant ") - } - } - - ujPoint := verifiers[msg.From][0] - point, err := curves.NewECPoint(curve, ujPoint.X, ujPoint.Y) + verifiers[msg.From], err = dkg.UnmarshalVerifiers(curve, D, info.Threshold) + if ok, err := feldman.Verify(content.Share, verifiers[msg.From]); !ok { if err != nil { return nil, err + } else { + return nil, fmt.Errorf("invalid share for participant ") } - verify := schnorr.Verify(content.Proof, point) - if !verify { - return nil, fmt.Errorf("schnorr verify fail") - } + } + xi.Y = new(big.Int).Add(xi.Y, content.Share.Y) + + ujPoint := verifiers[msg.From][0] + point, err := curves.NewECPoint(curve, ujPoint.X, ujPoint.Y) + if err != nil { + return nil, err + } + verify := schnorr.Verify(content.Proof, point) + if !verify { + return nil, fmt.Errorf("schnorr verify fail") } }