diff --git a/beacon_chain/spec/crypto.nim b/beacon_chain/spec/crypto.nim index 322927ea5..ee8b8c623 100644 --- a/beacon_chain/spec/crypto.nim +++ b/beacon_chain/spec/crypto.nim @@ -102,3 +102,4 @@ proc writeValue*(writer: var JsonWriter, value: ValidatorPrivKey) {.inline.} = proc readValue*(reader: var JsonReader, value: var ValidatorPrivKey) {.inline.} = value = SigKey.init(reader.readValue(string)) +proc newPrivKey*(): ValidatorPrivKey = SigKey.random() diff --git a/beacon_chain/validator_keygen.nim b/beacon_chain/validator_keygen.nim index 2d40d6f2b..e83bdc31a 100644 --- a/beacon_chain/validator_keygen.nim +++ b/beacon_chain/validator_keygen.nim @@ -12,12 +12,13 @@ proc genSingleValidator(path: string): (ValidatorPubKey, ValidatorPrivKey, Eth2Digest) = var v: PrivateValidatorData - # v.privKey = newSigKey() + v.privKey = newPrivKey() if randomBytes(v.randao.seed.data) != sizeof(v.randao.seed.data): raise newException(Exception, "Could not generate randao seed") writeFile(path, v) + assert v.privKey != ValidatorPrivKey(), "Private key shouldn't be zero" return (v.privKey.pubKey(), v.privKey, v.randao.initialCommitment) # TODO: Make these more comprehensive and find them a new home