Since there was no guide on how to generate any private key, I decided to write one for a Base58 variant
This method is for users who run their nodes on Ubuntu & macOS. Also your machine needs to have Python 3 installed – it was tested on macOS Catalina using Python 3.11.5
& Ubuntu 22.04 using Python 3.12.3
.
Make sure to have openssl
installed on your machine – it was tested on the same macOS version using OpenSSL 3.2.0
& on Ubuntu with OpenSSL 3.0.13
.
- Open Terminal, create a folder named
test
&cd
into it:mkdir test && cd test
- Create a Python virtual environment & activate it:
python3 -m venv venv && source venv/bin/activate
- Install
base58
library:pip install base58
- Copy & paste these lines into terminal:
openssl rand -hex 32 > private_key.hex
xxd -r -p private_key.hex private_key.bin
echo $(xxd -p private_key.bin | tr -d '\n' | python3 -c 'import sys, base58; print(base58.b58encode(bytes.fromhex(sys.stdin.read())).decode())')
These commands generate a random hex private key & save it into a file, then it’s converted into a .bin
format & encoded into base58
using installed base58
Python library.
Make sure to save echoed private key in a SUPER reliable place & do not share it with anyone.