forked from hyperledger/indy-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_bls_keys
executable file
·40 lines (27 loc) · 1.1 KB
/
init_bls_keys
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/env python3
import argparse
from plenum.common.keygen_utils import init_bls_keys
from plenum.common.script_helper import buildKeepDirIfNotExists
from indy_common.config_util import getConfig
from indy_common.config_helper import NodeConfigHelper
def parse_args():
parser = argparse.ArgumentParser(
description="Generate BLS keys for a node "
"by taking the node's name and a seed")
parser.add_argument('--name', required=True, help='node name')
parser.add_argument('--seed', required=False, type=str,
help='seeds for keypair')
args = parser.parse_args()
return args.name, args.seed
def generate_and_store_bls_keys(keys_dir, node_name, seed):
try:
init_bls_keys(keys_dir, node_name, seed)
except Exception as ex:
print(ex)
exit()
if __name__ == "__main__":
node_name, seed = parse_args()
node_config_helper = NodeConfigHelper(node_name, getConfig())
keys_dir = node_config_helper.keys_dir
buildKeepDirIfNotExists(keys_dir)
generate_and_store_bls_keys(keys_dir, node_name, seed)