Skip to content

Commit

Permalink
Make compatible for old parties with no facProof
Browse files Browse the repository at this point in the history
  • Loading branch information
yycen committed Aug 9, 2023
1 parent a4977e3 commit 4c9fa88
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 47 deletions.
109 changes: 86 additions & 23 deletions ecdsa/keygen/ecdsa-keygen.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ecdsa/keygen/local_party.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ func (p *LocalParty) StoreMessage(msg tss.ParsedMessage) (bool, *tss.Error) {
p.temp.kgRound1Messages[fromPIdx] = msg
case *KGRound2Message1:
p.temp.kgRound2Message1s[fromPIdx] = msg
case *KGRound2Message1NoProof:
p.temp.kgRound2Message1s[fromPIdx] = msg
case *KGRound2Message2:
p.temp.kgRound2Message2s[fromPIdx] = msg
case *KGRound3Message:
Expand Down
26 changes: 26 additions & 0 deletions ecdsa/keygen/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
_ = []tss.MessageContent{
(*KGRound1Message)(nil),
(*KGRound2Message1)(nil),
(*KGRound2Message1NoProof)(nil),
(*KGRound2Message2)(nil),
(*KGRound3Message)(nil),
}
Expand Down Expand Up @@ -140,6 +141,31 @@ func (m *KGRound2Message1) UnmarshalFacProof() (*facproof.ProofFac, error) {
return facproof.NewProofFromBytes(m.GetFacProof())
}

func NewKGRound2Message1NoProof(
to, from *tss.PartyID,
share *vss.Share,
) tss.ParsedMessage {
meta := tss.MessageRouting{
From: from,
To: []*tss.PartyID{to},
IsBroadcast: false,
}
content := &KGRound2Message1NoProof{
Share: share.Share.Bytes(),
}
msg := tss.NewMessageWrapper(meta, content)
return tss.NewMessage(meta, content, msg)
}

func (m *KGRound2Message1NoProof) ValidateBasic() bool {
return m != nil &&
common.NonEmptyBytes(m.GetShare())
}

func (m *KGRound2Message1NoProof) UnmarshalShare() *big.Int {
return new(big.Int).SetBytes(m.Share)
}

// ----- //

func NewKGRound2Message2(
Expand Down
59 changes: 38 additions & 21 deletions ecdsa/keygen/round_3.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,45 @@ func (round *round3) Start() *tss.Error {
ch <- vssOut{err, nil}
return
}
r2msg1 := round.temp.kgRound2Message1s[j].Content().(*KGRound2Message1)
PjShare := vss.Share{
Threshold: round.Threshold(),
ID: round.PartyID().KeyInt(),
Share: r2msg1.UnmarshalShare(),
}
if ok = PjShare.Verify(round.Params().EC(), round.Threshold(), PjVs); !ok {
ch <- vssOut{errors.New("vss verify failed"), nil}
return
}
facProof, err := r2msg1.UnmarshalFacProof()
if err != nil {
ch <- vssOut{errors.New("facProof verify failed"), nil}
return
}
if ok = facProof.Verify(round.EC(), round.save.PaillierPKs[j].N, round.save.NTildei,
round.save.H1i, round.save.H2i); !ok {
ch <- vssOut{errors.New("facProof verify failed"), nil}
return
switch round.temp.kgRound2Message1s[j].Content().(type) {
case *KGRound2Message1NoProof:
r2msg1 := round.temp.kgRound2Message1s[j].Content().(*KGRound2Message1)
PjShare := vss.Share{
Threshold: round.Threshold(),
ID: round.PartyID().KeyInt(),
Share: r2msg1.UnmarshalShare(),
}
if ok = PjShare.Verify(round.Params().EC(), round.Threshold(), PjVs); !ok {
ch <- vssOut{errors.New("vss verify failed"), nil}
return
}
common.Logger.Fatalf("facProof not exist: %s", Ps[j])
// (9) handled above
ch <- vssOut{nil, PjVs}
case *KGRound2Message1:
r2msg1 := round.temp.kgRound2Message1s[j].Content().(*KGRound2Message1)
PjShare := vss.Share{
Threshold: round.Threshold(),
ID: round.PartyID().KeyInt(),
Share: r2msg1.UnmarshalShare(),
}
if ok = PjShare.Verify(round.Params().EC(), round.Threshold(), PjVs); !ok {
ch <- vssOut{errors.New("vss verify failed"), nil}
return
}
facProof, err := r2msg1.UnmarshalFacProof()
if err != nil {
ch <- vssOut{errors.New("facProof verify failed"), nil}
return
}
if ok = facProof.Verify(round.EC(), round.save.PaillierPKs[j].N, round.save.NTildei,
round.save.H1i, round.save.H2i); !ok {
ch <- vssOut{errors.New("facProof verify failed"), nil}
return
}
// (9) handled above
ch <- vssOut{nil, PjVs}
}
// (9) handled above
ch <- vssOut{nil, PjVs}
}(j, chs[j])
}

Expand Down
4 changes: 4 additions & 0 deletions protob/ecdsa-keygen.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ message KGRound2Message1 {
repeated bytes facProof = 2;
}

message KGRound2Message1NoProof {
bytes share = 1;
}

/*
* Represents a BROADCAST message sent to each party during Round 2 of the ECDSA TSS keygen protocol.
*/
Expand Down
5 changes: 2 additions & 3 deletions tss/message.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4c9fa88

Please sign in to comment.