Skip to content

Commit

Permalink
fix input parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
zargarzadehm committed Jan 12, 2024
1 parent d6e2aa9 commit 6b92e7d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 44 deletions.
21 changes: 8 additions & 13 deletions ecdsa/signing/local_party.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,13 @@ type (
)

func NewLocalParty(
msg *big.Int,
params *tss.Parameters,
key keygen.LocalPartySaveData,
out chan<- tss.Message,
end chan<- *common.SignatureData) tss.Party {
return NewLocalPartyWithKDD(msg, params, key, nil, out, end, 0)
}

func NewLocalPartyWithLength(
msg *big.Int,
params *tss.Parameters,
key keygen.LocalPartySaveData,
out chan<- tss.Message,
end chan<- *common.SignatureData,
fullBytesLen int) tss.Party {
return NewLocalPartyWithKDD(msg, params, key, nil, out, end, fullBytesLen)
fullBytesLen ...int) tss.Party {
return NewLocalPartyWithKDD(msg, params, key, nil, out, end, fullBytesLen...)
}

// NewLocalPartyWithKDD returns a party with key derivation delta for HD support
Expand All @@ -127,7 +118,7 @@ func NewLocalPartyWithKDD(
keyDerivationDelta *big.Int,
out chan<- tss.Message,
end chan<- *common.SignatureData,
fullBytesLen int,
fullBytesLen ...int,
) tss.Party {
partyCount := len(params.Parties().IDs())
p := &LocalParty{
Expand All @@ -153,7 +144,11 @@ func NewLocalPartyWithKDD(
// temp data init
p.temp.keyDerivationDelta = keyDerivationDelta
p.temp.m = msg
p.temp.fullBytesLen = fullBytesLen
if len(fullBytesLen) > 0 {
p.temp.fullBytesLen = fullBytesLen[0]
} else {
p.temp.fullBytesLen = 0
}
p.temp.cis = make([]*big.Int, partyCount)
p.temp.bigWs = make([]*crypto.ECPoint, partyCount)
p.temp.betas = make([]*big.Int, partyCount)
Expand Down
2 changes: 1 addition & 1 deletion ecdsa/signing/local_party_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestE2EConcurrentWithLeadingZeroInMSG(t *testing.T) {
// init the parties
for i := 0; i < len(signPIDs); i++ {
params := tss.NewParameters(tss.S256(), p2pCtx, signPIDs[i], len(signPIDs), threshold)
P := NewLocalPartyWithLength(new(big.Int).SetBytes(msgData), params, keys[i], outCh, endCh, len(msgData)).(*LocalParty)
P := NewLocalParty(new(big.Int).SetBytes(msgData), params, keys[i], outCh, endCh, len(msgData)).(*LocalParty)
parties = append(parties, P)
go func(P *LocalParty) {
if err := P.Start(); err != nil {
Expand Down
29 changes: 6 additions & 23 deletions eddsa/signing/local_party.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,7 @@ func NewLocalParty(
key keygen.LocalPartySaveData,
out chan<- tss.Message,
end chan<- *common.SignatureData,
) tss.Party {
return SetupNewLocalParty(msg, params, key, out, end, 0)
}

func NewLocalPartyWithLength(
msg *big.Int,
params *tss.Parameters,
key keygen.LocalPartySaveData,
out chan<- tss.Message,
end chan<- *common.SignatureData,
fullBytesLen int,
) tss.Party {
return SetupNewLocalParty(msg, params, key, out, end, fullBytesLen)
}

func SetupNewLocalParty(
msg *big.Int,
params *tss.Parameters,
key keygen.LocalPartySaveData,
out chan<- tss.Message,
end chan<- *common.SignatureData,
fullBytesLen int,
fullBytesLen ...int,
) tss.Party {
partyCount := len(params.Parties().IDs())
p := &LocalParty{
Expand All @@ -112,7 +91,11 @@ func SetupNewLocalParty(

// temp data init
p.temp.m = msg
p.temp.fullBytesLen = fullBytesLen
if len(fullBytesLen) > 0 {
p.temp.fullBytesLen = fullBytesLen[0]
} else {
p.temp.fullBytesLen = 0
}
p.temp.cjs = make([]*big.Int, partyCount)
return p
}
Expand Down
8 changes: 1 addition & 7 deletions eddsa/signing/local_party_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,7 @@ func TestE2EConcurrentWithLeadingZeroInMSG(t *testing.T) {
// init the parties
for i := 0; i < len(signPIDs); i++ {
params := tss.NewParameters(tss.Edwards(), p2pCtx, signPIDs[i], len(signPIDs), threshold)
P := NewLocalPartyWithLength(
new(big.Int).SetBytes(msg),
params,
keys[i],
outCh,
endCh,
len(msg)).(*LocalParty)
P := NewLocalParty(new(big.Int).SetBytes(msg), params, keys[i], outCh, endCh, len(msg)).(*LocalParty)
parties = append(parties, P)
go func(P *LocalParty) {
if err := P.Start(); err != nil {
Expand Down

0 comments on commit 6b92e7d

Please sign in to comment.