Skip to content

Commit b5d1436

Browse files
committed
Allow mixed signing thresholds for multisign.
1 parent ddd7a46 commit b5d1436

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

grpc.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ func (a *distributedAccount) thresholdSign(ctx context.Context, req *pb.SignRequ
959959
errored := 0
960960
ids := make([]bls.ID, a.signingThreshold)
961961
signatures := make([]bls.Sign, a.signingThreshold)
962-
for signed != int(a.signingThreshold) && signed+denied+failed+errored != len(clients) {
962+
for signed < int(a.signingThreshold) && signed+denied+failed+errored != len(clients) {
963963
select {
964964
case <-ctx.Done():
965965
return nil, errors.New("context done")
@@ -989,7 +989,7 @@ func (a *distributedAccount) thresholdSign(ctx context.Context, req *pb.SignRequ
989989
attribute.Int("failed", failed),
990990
attribute.Int("errored", errored),
991991
))
992-
if signed != int(a.signingThreshold) {
992+
if signed < int(a.signingThreshold) {
993993
return nil, fmt.Errorf("not enough signatures: %d signed, %d denied, %d failed, %d errored", signed, denied, failed, errored)
994994
}
995995

@@ -1095,7 +1095,7 @@ func (a *distributedAccount) thresholdMultiSign(ctx context.Context, req *pb.Mul
10951095
// We could be done early if we have enough signatures.
10961096
done := true
10971097
for i := range ids {
1098-
if len(ids[i]) != int(thresholds[i]) {
1098+
if len(ids[i]) < int(thresholds[i]) {
10991099
done = false
11001100
break
11011101
}
@@ -1116,8 +1116,8 @@ func (a *distributedAccount) thresholdMultiSign(ctx context.Context, req *pb.Mul
11161116
wg.Add(1)
11171117
go func(_ context.Context, _ *semaphore.Weighted, wg *sync.WaitGroup, i int) {
11181118
defer wg.Done()
1119-
if signed[i] != int(thresholds[i]) {
1120-
// Not enough components to make the composite signature.
1119+
1120+
if signed[i] < int(thresholds[i]) {
11211121
return
11221122
}
11231123

@@ -1196,7 +1196,7 @@ func (a *distributedAccount) thresholdSignBeaconAttestation(ctx context.Context,
11961196
errored := 0
11971197
ids := make([]bls.ID, a.signingThreshold)
11981198
signatures := make([]bls.Sign, a.signingThreshold)
1199-
for signed != int(a.signingThreshold) && signed+denied+failed+errored != len(clients) {
1199+
for signed < int(a.signingThreshold) && signed+denied+failed+errored != len(clients) {
12001200
select {
12011201
case <-ctx.Done():
12021202
return nil, errors.New("context done")
@@ -1332,7 +1332,7 @@ func (a *distributedAccount) thresholdSignBeaconAttestations(ctx context.Context
13321332
// We could be done early if we have enough signatures.
13331333
done := true
13341334
for i := range ids {
1335-
if len(ids[i]) != int(thresholds[i]) {
1335+
if len(ids[i]) < int(thresholds[i]) {
13361336
done = false
13371337
break
13381338
}
@@ -1353,8 +1353,7 @@ func (a *distributedAccount) thresholdSignBeaconAttestations(ctx context.Context
13531353
wg.Add(1)
13541354
go func(_ context.Context, _ *semaphore.Weighted, wg *sync.WaitGroup, i int) {
13551355
defer wg.Done()
1356-
if signed[i] != int(thresholds[i]) {
1357-
// Not enough components to make the composite signature.
1356+
if signed[i] < int(thresholds[i]) {
13581357
return
13591358
}
13601359

@@ -1433,7 +1432,7 @@ func (a *distributedAccount) thresholdSignBeaconProposal(ctx context.Context, re
14331432
errored := 0
14341433
ids := make([]bls.ID, a.signingThreshold)
14351434
signatures := make([]bls.Sign, a.signingThreshold)
1436-
for signed != int(a.signingThreshold) && signed+denied+failed+errored != len(clients) {
1435+
for signed < int(a.signingThreshold) && signed+denied+failed+errored != len(clients) {
14371436
select {
14381437
case <-ctx.Done():
14391438
return nil, errors.New("context done")
@@ -1463,7 +1462,7 @@ func (a *distributedAccount) thresholdSignBeaconProposal(ctx context.Context, re
14631462
attribute.Int("failed", failed),
14641463
attribute.Int("errored", errored),
14651464
))
1466-
if signed != int(a.signingThreshold) {
1465+
if signed < int(a.signingThreshold) {
14671466
return nil, fmt.Errorf("not enough signatures: %d signed, %d denied, %d failed, %d errored", signed, denied, failed, errored)
14681467
}
14691468

0 commit comments

Comments
 (0)