Skip to content

Commit

Permalink
cmd/combine: allow threshold number of keys to combine (#2664)
Browse files Browse the repository at this point in the history
Allows threshold number of keys to combine private keyshares into single validator keystore.

category: refactor
ticket: #2663
  • Loading branch information
dB2510 authored Oct 30, 2023
1 parent 4632e21 commit 10c3ee0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cmd/combine/combine.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ func Combine(ctx context.Context, inputDir, outputDir string, force, noverify bo
for valIdx := 0; valIdx < len(privkeys); valIdx++ {
pkSet := privkeys[valIdx]

if len(pkSet) != len(cluster.Operators) {
if len(pkSet) < int(cluster.Threshold) {
return errors.New(
"not all private key shares found for validator",
"insufficient private key shares found for validator",
z.Int("validator_index", valIdx),
z.Int("expected", len(cluster.Operators)),
z.Int("expected", int(cluster.Threshold)),
z.Int("actual", len(pkSet)),
)
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/combine/combine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ func TestCombineCannotLoadKeystore(t *testing.T) {
}

require.NoError(t, os.RemoveAll(filepath.Join(dir, "node0")))
require.NoError(t, os.RemoveAll(filepath.Join(dir, "node1")))

err := combine.Combine(context.Background(), dir, od, false, false, combine.WithInsecureKeysForT(t))
require.Error(t, err)
require.ErrorContains(t, err, "insufficient private key shares found for validator")
}

func TestCombineAllManifest(t *testing.T) {
Expand Down

0 comments on commit 10c3ee0

Please sign in to comment.