Skip to content

Python helper to generate new private/public keys pair to run RChain node as validator

License

Notifications You must be signed in to change notification settings

pdonorio/rchain-keys-generator

Repository files navigation

rchain-keys-generator

Python helper to generate new private/public keys pair to run RChain node as validator

implementation

Current implemented workflow:

  1. run RNode in standalone mode for one validator with a temporary data folder
  2. a thread interrupt the node process running when keys have been generated
  3. copy and parse the .sk key file from data folder
  4. remove temporary data folder

quick start

Here's a brief overview on how to use the package

prerequisites

  • rnode package installed (see official instructions)
  • rnode binary in PATH
  • python3.5+ installed (together with pip package system)

install

Installation is done via the official Python package manager:

pip3 install rchain-keygen

generate keys

After installing you will be able to use the binary as:

$ rchain-keygen --help
usage: rchain-keygen [-h] [--save-as-source]

RChain 'ed25519' signed keys generator

optional arguments:
  -h, --help        show this help message and exit
  --save-as-source  enable saving variables for bash env sourcing

Having rnode installed you just need to run:

rchain-keygen

[...]
Launching: rnode.
[...]

VALIDATOR_PUBLIC_KEY=...
VALIDATOR_PRIVATE_KEY=...

use inside official RChain node docker images

That would be as easy as:

docker run --rm -it --entrypoint /bin/bash rchain/rnode:release-rnode-v0.7
# container shell
export PATH=/opt/docker/bin:$PATH
apt update && apt install -y python3-pip
pip3 install rchain-keygen
cd $HOME
rchain-keygen

troubleshooting

  1. missing rnode installation (or not being found in PATH) would end up execution with Exception:
$ rchain-keygen
Temporary dir: ...
Launching: rnode.

[...]
FileNotFoundError: [Errno 2] No such file or directory: 'rnode'
  1. changed data dir parameter

This happened in last docker testing image. Fix is:

sed -i '79s/data_dir/data-dir/' /usr/local/lib/python3.6/dist-packages/rchain_keygen/app.py

development

  • implement it
docker-compose build --pull
docker-compose up -d 
docker-compose exec rchain bash
pip3 install -e .
rchain-keygen
# [...]

# when finished
docker-compose down --volumes --remove-orphans
  • black formatter:
docker run --rm -it \
    -v (pwd):/code -w /code \
    unibeautify/black -S ./rchain_keygen

todo

  • working first version based only on standard library
  • parameter to output to file to be sourced
  • setup as package
  • formatter
  • docs
  • publish manually on pypi + first tag
  • better options support with backwards compatibility
  • unittests
  • travis ci
  • automatic pypi publishing from tags

About

Python helper to generate new private/public keys pair to run RChain node as validator

Resources

License

Stars

Watchers

Forks

Packages

No packages published