Skip to content

Check length of bits of NTildej #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 19, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions ecdsa/keygen/round_2.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import (
"github.com/binance-chain/tss-lib/tss"
)

const (
paillierBitsLen = 2048
)

func (round *round2) Start() *tss.Error {
if round.started {
return round.WrapError(errors.New("round already started"))
Expand All @@ -39,6 +43,9 @@ func (round *round2) Start() *tss.Error {
if H1j.Cmp(H2j) == 0 {
return round.WrapError(errors.New("h1j and h2j were equal for this party"), msg.GetFrom())
}
if NTildej.BitLen() != paillierBitsLen {
return round.WrapError(errors.New("NTildej do not have enought bits"), msg.GetFrom())
}
h1JHex, h2JHex := hex.EncodeToString(H1j.Bytes()), hex.EncodeToString(H2j.Bytes())
if _, found := h1H2Map[h1JHex]; found {
return round.WrapError(errors.New("this h1j was already used by another party"), msg.GetFrom())
Expand All @@ -47,18 +54,19 @@ func (round *round2) Start() *tss.Error {
return round.WrapError(errors.New("this h2j was already used by another party"), msg.GetFrom())
}
h1H2Map[h1JHex], h1H2Map[h2JHex] = struct{}{}, struct{}{}
wg.Add(2)
wg.Add(1)
go func(j int, msg tss.ParsedMessage, r1msg *KGRound1Message, H1j, H2j, NTildej *big.Int) {
defer wg.Done()
if dlnProof1, err := r1msg.UnmarshalDLNProof1(); err != nil || !dlnProof1.Verify(H1j, H2j, NTildej) {
dlnProof1FailCulprits[j] = msg.GetFrom()
}
wg.Done()
}(j, msg, r1msg, H1j, H2j, NTildej)
wg.Add(1)
go func(j int, msg tss.ParsedMessage, r1msg *KGRound1Message, H1j, H2j, NTildej *big.Int) {
defer wg.Done()
if dlnProof2, err := r1msg.UnmarshalDLNProof2(); err != nil || !dlnProof2.Verify(H2j, H1j, NTildej) {
dlnProof2FailCulprits[j] = msg.GetFrom()
}
wg.Done()
}(j, msg, r1msg, H1j, H2j, NTildej)
}
wg.Wait()
Expand Down