nimbus-eth2/beacon_chain/validator_keygen.nim
Dustin Brody 46cfce652d
initial new get_beacon_proposer_index and dependencies (get_shuffled_index, get_shard_delta, get_epoch_start_shard, get_crosslink_committee) (#266)
* initial new get_beacon_proposer_index and dependencies (get_shuffled_index, get_shard_delta, get_epoch_start_shard, get_crosslink_committee)

* more 0.6.1 updates

* clean up debugEchos and fix validator keygen to create correct indices
2019-05-23 11:13:02 +00:00

54 lines
1.5 KiB
Nim

import
os, ospaths, strutils, strformat,
chronos, blscurve, nimcrypto, json_serialization, confutils,
spec/[datatypes, digest, crypto], conf, time, ssz,
../tests/testutil
proc writeTextFile(filename: string, contents: string) =
writeFile(filename, contents)
echo "Wrote ", filename
proc writeFile(filename: string, value: auto) =
Json.saveFile(filename, value, pretty = true)
echo "Wrote ", filename
cli do (totalValidators: int = 125000,
outputDir: string = "validators",
generateFakeKeys = false):
for i in 0 ..< totalValidators:
let
v = validatorFileBaseName(i)
depositFn = outputDir / v & ".deposit.json"
privKeyFn = outputDir / v & ".privkey"
if existsFile(depositFn) and existsFile(privKeyFn):
continue
let
privKey = if generateFakeKeys: makeFakeValidatorPrivKey(i)
else: ValidatorPrivKey.random
pubKey = privKey.pubKey()
let
withdrawalCredentials = makeFakeHash(i)
domain = 3'u64
var
deposit = Deposit(
data: DepositData(
amount: MAX_EFFECTIVE_BALANCE,
pubkey: pubKey,
withdrawal_credentials: withdrawalCredentials),
index: i.uint64)
deposit.data.signature =
bls_sign(privkey, signing_root(deposit.data).data,
domain)
writeTextFile(privKeyFn, $privKey)
writeFile(depositFn, deposit)
if generateFakeKeys:
echo "Keys generated by this tool are only for testing!"