Key Management

A mnemonic phrase, also known as a seed phrase, is a sequence of words used to recover or restore a cryptocurrency wallet. It serves as a backup mechanism, allowing users to regain access to their funds if they lose access to their original wallet.

When creating a wallet, a 12- or 24-word mnemonic phrase is generated, which should be kept secure and private.


Importance of Mnemonic Phrases

Cryptocurrencies are stored in a decentralized manner, meaning no central authority can restore access to lost funds. If you lose access to your wallet (e.g., forget your password or lose your device), your mnemonic phrase is the only way to recover your account.

To protect your mnemonic phrase:

  • Store it securely on a physical medium (e.g., written on paper) or in a secure digital format.

  • Make multiple copies and store them in different locations to prevent total loss.


Mnemonic Phrase vs. Private Key

Feature

Mnemonic Phrase (Seed Phrase)

Private Key

Purpose

Generates multiple private keys

Grants direct access to a single address

Format

12 or 24 words

Long alphanumeric string

Recoverability

Can restore multiple accounts

If lost, funds cannot be recovered

Security Risk

Losing it means losing all associated accounts

Losing it affects only one address

A mnemonic phrase is used to derive multiple private keys, whereas a private key is specific to a single cryptocurrency address. Since the mnemonic phrase is the root of all private keys, losing it has severe consequences.


Managing Keys with LagomChain CLI

1. Creating a New Key (Generates Mnemonic Phrase)

When you create a new key, you receive a mnemonic phrase for backup.

lagomd keys add mykey

Example Output:

{
  "name": "mykey",
  "type": "local",
  "address": "lagom1n253dl2tgyhxjm592p580c38r4dn8023ctv28d",
  "pubkey": '{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"ArJhve4v5HkLm+F7ViASU/rAGx7YrwU4+XKV2MNJt+Cq"}',
  "mnemonic": "<12 or 24-word mnemonic phrase>"
}

Important: Write down the mnemonic phrase and store it securely.


2. Restoring a Key from a Mnemonic Phrase

If a key is lost, restore it using the mnemonic phrase:

lagomd keys add mykey-restored --recover

You will be prompted to enter the mnemonic phrase.

Example Output:

{
  "name": "mykey-restored",
  "type": "local",
  "address": "lagom1n253dl2tgyhxjm592p580c38r4dn8023ctv28d",
  "pubkey": '{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"ArJhve4v5HkLm+F7ViASU/rAGx7YrwU4+XKV2MNJt+Cq"}'
}

Exporting and Importing Private Keys

If you need to back up or transfer a key without using the mnemonic phrase, you can export and import private keys.

Tendermint-Formatted Private Keys

1. Export a Private Key

lagomd keys export mykey

You will be prompted to enter a decryption passphrase.

Example Output:

-----BEGIN TENDERMINT PRIVATE KEY-----
kdf: bcrypt
salt: 14559BB13D881A86E0F4D3872B8B2C82
type: secp256k1

# <Tendermint private key>
-----END TENDERMINT PRIVATE KEY-----

Save this output to a secure file:

echo "-----BEGIN TENDERMINT PRIVATE KEY-----
# <Tendermint private key>
-----END TENDERMINT PRIVATE KEY-----" > mykey.export

2. Import a Private Key

To restore an exported key:

lagomd keys import mykey-imported ./mykey.export

Ethereum-Formatted Private Keys

1. Export a MetaMask-Compatible Private Key

LagomChain allows exporting Ethereum-compatible private keys for use in MetaMask and other wallets.

lagomd keys unsafe-export-eth-key mykey > mykey.export

Warning: This method exports the unencrypted private key, which should be stored securely.

You will be prompted with:

**WARNING** this is an unsafe way to export your unencrypted private key, are you sure? [y/N]: y

Enter your keyring passphrase to proceed.

2. Import an Ethereum-Formatted Private Key

lagomd keys unsafe-import-eth-key mykey-imported ./mykey.export

You will be prompted to enter a new encryption passphrase for the imported key.


Verifying Stored Keys

To check that your keys have been correctly restored, imported, or created, list all stored keys:

lagomd keys list

📌 Example Output:

[
  {
    "name": "mykey-imported",
    "type": "local",
    "address": "lagom1n253dl2tgyhxjm592p580c38r4dn8023ctv28d",
    "pubkey": '{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"ArJhve4v5HkLm+F7ViASU/rAGx7YrwU4+XKV2MNJt+Cq"}'
  },
  {
    "name": "mykey-restored",
    "type": "local",
    "address": "lagom1n253dl2tgyhxjm592p580c38r4dn8023ctv28d",
    "pubkey": '{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"ArJhve4v5HkLm+F7ViASU/rAGx7YrwU4+XKV2MNJt+Cq"}'
  },
  {
    "name": "mykey",
    "type": "local",
    "address": "lagom1n253dl2tgyhxjm592p580c38r4dn8023ctv28d",
    "pubkey": '{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"ArJhve4v5HkLm+F7ViASU/rAGx7YrwU4+XKV2MNJt+Cq"}'
  }
]

Security Considerations

  • Never share your mnemonic phrase or private key. Anyone with access can control your funds.

  • Store multiple copies of your mnemonic phrase securely. Losing it means you cannot recover your wallet.

  • Avoid exporting private keys unless necessary. If needed, encrypt them securely.

Last updated