Use Start Index Flag in Unencrypted Key Gen (#3506)

* use start idx

* fix tests
This commit is contained in:
Raul Jordan
2019-09-18 12:15:26 -05:00
committed by Preston Van Loon
parent b919429801
commit 6f25e4ce81
2 changed files with 5 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ import (
var (
numKeys = flag.Int("num-keys", 0, "Number of validator private/withdrawal keys to generate")
startIndex = flag.Uint64("start-index", 0, "Start index for the determinstic keygen algorithm")
outputJSON = flag.String("output-json", "", "JSON file to write output to")
overwrite = flag.Bool("overwrite", false, "If the key file exists, it will be overwritten")
)
@@ -53,18 +54,18 @@ func main() {
}
}()
ctnr := generateUnencryptedKeys()
ctnr := generateUnencryptedKeys(*startIndex)
if err := SaveUnencryptedKeysToFile(file, ctnr); err != nil {
log.Fatal(err)
}
}
func generateUnencryptedKeys() *UnencryptedKeysContainer {
func generateUnencryptedKeys(startIndex uint64) *UnencryptedKeysContainer {
ctnr := &UnencryptedKeysContainer{
Keys: make([]*UnencryptedKeys, *numKeys),
}
sks, _, err := interop.DeterministicallyGenerateKeys(0 /*startIndex*/, uint64(*numKeys))
sks, _, err := interop.DeterministicallyGenerateKeys(startIndex, uint64(*numKeys))
if err != nil {
panic(err)

View File

@@ -8,7 +8,7 @@ import (
)
func TestSavesUnencryptedKeys(t *testing.T) {
ctnr := generateUnencryptedKeys()
ctnr := generateUnencryptedKeys(0 /* start index */)
buf := new(bytes.Buffer)
if err := SaveUnencryptedKeysToFile(buf, ctnr); err != nil {
t.Fatal(err)