Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #25 from okx/develop
Browse files Browse the repository at this point in the history
update refresh
  • Loading branch information
debuggor authored Aug 17, 2023
2 parents de1431b + 48a3350 commit 761e1db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 deletions.
7 changes: 1 addition & 6 deletions tss/key/reshare/update_round.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
40 changes: 16 additions & 24 deletions tss/key/reshare/update_round3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
}
}

Expand Down

0 comments on commit 761e1db

Please sign in to comment.