Skip to main content

keygen

Generate keys

The keygen command (chr keygen) generates public and private key pairs for Chromia CLI operations.

Basic usage

Generate a key pair with a custom key ID:

chr keygen --key-id=<value>

This creates three files in the ~/.chromia directory:

  • key-id - Contains the private key
  • key-id.pubkey - Contains the public key
  • key-id_mnemonic - Contains the mnemonic phrase for recovery

Generate with file path

Generate a key pair and save it to a specific file:

chr keygen --file=<path>

This creates two files at the specified location:

  • file_name - Contains the keypair
  • file_name_mnemonic - Contains the mnemonic phrase

Recover from mnemonic

Recover a key pair from a mnemonic phrase:

chr keygen --mnemonic "lift employ roast rotate liar holiday sun fever output magnet..."

Use the --key-id or --file option along with --mnemonic to specify where to save the recovered key:

chr keygen --mnemonic "your mnemonic phrase" --key-id=recovered_key

Dry run

See what keys would be generated without saving to disk:

chr keygen --dry

Default behavior

By default, keys are generated with the default key ID chromia_key and saved in the .chromia folder as chromia_key.pubkey and chromia_key:

chr keygen

Next steps

After generating your key pair, learn how to manage and configure it.


Command reference

Usage: chr keygen [<options>]

Generates public/private key pair

File format:
-f, --file=<path> Set file to save keypair to explicitly
--get-pubkey[=<key-id>] Print the active public key. If no key-id is
specified, the key is determined from your
configuration; otherwise, retrieves the public key
for the given key-id.
--dry Perform dry run, prints keys in terminal and does
not save keys to disk
--key-id=<value> Name the generated key with an id

Options:
-m, --mnemonic=<text> Mnemonic word list, words separated by space, e.g:
"lift employ roast rotate liar holiday sun fever
output magnet...""
-h, --help Show this message and exit

Using your key pair

To use a key pair by its key ID, set the property key.id = <key_id> in your configuration file (.chromia/config).

If your TEXT string is myKey then the public key is stored as myKey.pubkey and private key as myKey. To use a key pair by its key ID, set the property key.id = <key_id> in your Chromia configuration (.chromia/config) file. If the config file does not exist, then you can create one in the .chromia folder.

  • Windows: C:\Users\<YourUsername>\.chromia\config
  • macOS and Linux: /Users/<YourUsername>/.chromia/config or /home/<YourUsername>/.chromia/config