GUIDE: how to generate a Base58 private key on Ubuntu / macOS

Since there was no guide on how to generate any private key, I decided to write one for a Base58 variant :slight_smile:

:exclamation: 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.
:exclamation: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.

  1. Open Terminal, create a folder named test & cd into it: mkdir test && cd test
  2. Create a Python virtual environment & activate it: python3 -m venv venv && source venv/bin/activate
  3. Install base58 library: pip install base58
  4. 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.

:exclamation: Make sure to save echoed private key in a SUPER reliable place & do not share it with anyone.

:question: How do I import this generated key into my node?
If you are running the node using aios-cli binary, follow these steps:

  1. Enter the folder your binary is located at & create a .base58 file, let’s say, key.base58: touch key.base58
  2. Paste the private key that you got from steps above: echo "YOUR_KEY" > key.base58
  3. Import the key using aios-cli: aios-cli hive import-keys key.base58
  4. Make sure that everything’s imported correctly: aios-cli hive whoami – you should see the public key & your private key. It’s better to save public key in some place too for convenience.

If you are running the node using Docker image, steps are the same but you need to execute commands inside of aios Docker container.

Connect to your Docker container to get into Bash: docker exec -it CONTAINER_NAME "bash", then proceed with step 2 from above.
To return to your machine shell, press Ctrl + P then swiftly press Ctrl + Q.

:question: How do I get the container name?
Use docker ps command to get a list of running containers & search for a container name that’s using aios image. Mine is stoic_engelbart as shown below:
Container name

:question:bash: aios-cli: command not found: I get this error when entering commands
Try adding ./ in front of aios-cli commands.