2020-09-01 13:44:40 +00:00
|
|
|
# beacon_chain
|
2021-03-26 06:52:01 +00:00
|
|
|
# Copyright (c) 2018-2021 Status Research & Development GmbH
|
2020-09-01 13:44:40 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2021-03-26 06:52:01 +00:00
|
|
|
{.push raises: [Defect].}
|
|
|
|
|
2021-10-04 19:08:31 +00:00
|
|
|
import std/[os, strutils, tables]
|
|
|
|
import "."/spec/[digest, crypto],
|
|
|
|
"."/validators/keystore_management,
|
|
|
|
"."/beacon_node_types
|
2020-09-01 13:44:40 +00:00
|
|
|
|
2021-03-26 06:52:01 +00:00
|
|
|
{.pop.} # TODO moduletests exceptions
|
|
|
|
|
2020-09-01 13:44:40 +00:00
|
|
|
programMain:
|
2021-10-04 19:08:31 +00:00
|
|
|
var validators: Table[ValidatorPubKey, ValidatorPrivateItem]
|
2020-09-01 13:44:40 +00:00
|
|
|
# load and send all public keys so the BN knows for which ones to ping us
|
|
|
|
doAssert paramCount() == 2
|
|
|
|
for curr in validatorKeysFromDirs(paramStr(1), paramStr(2)):
|
2021-10-04 19:08:31 +00:00
|
|
|
validators[curr.privateKey.toPubKey().toPubKey()] = curr
|
|
|
|
echo curr.privateKey.toPubKey
|
2020-09-01 13:44:40 +00:00
|
|
|
echo "end"
|
|
|
|
|
|
|
|
# simple format: `<pubkey> <eth2digest_to_sign>` => `<signature>`
|
|
|
|
while true:
|
|
|
|
let args = stdin.readLine.split(" ")
|
|
|
|
doAssert args.len == 2
|
|
|
|
|
2021-10-04 19:08:31 +00:00
|
|
|
let item = validators[ValidatorPubKey.fromHex(args[0]).get()]
|
2020-09-01 13:44:40 +00:00
|
|
|
|
2021-10-04 19:08:31 +00:00
|
|
|
echo blsSign(item.privateKey,
|
|
|
|
Eth2Digest.fromHex(args[1]).data).toValidatorSig()
|