# Mina Docs｜Generate a key pair

By [MinaWallet](https://paragraph.com/@minawallet) · 2021-12-12

---

![](https://storage.googleapis.com/papyrus_images/d8e54fbb911518d5b1914e67a67f283b97f47557f26fc515fa37fa18fa2bf084.png)

In order to use the Mina main network or participate in the test network, you first need to generate a key pair, which consists of a public key and a private key. Currently, two key pair generation tools are supported: mina-generate-keypair and ledger-app-mina. We also have a tool to verify that your private key was created correctly.

Note that you may want to generate multiple key pairs. For example, if you want to run a block producer in the safest way, you will need to generate hot and cold wallets at the same time.

method

mina-generate-keypair

We have created a simple command line utility and called it mina-generate-keypair. This is the easiest method, and you can find instructions below.

Ledger hardware wallet

You can use your Ledger Nano S hardware wallet to safely store your Mina private keys. We are conducting an independent security audit, no loopholes have been found so far, and the development work is almost complete. Please refer to our ledger-app-mina documentation to start using this tool.

warn

Never give out your private keys and make sure they are kept properly. If you lose your private key, or a malicious participant gains access to your private key, then you will lose access to your account and you will lose the funds in your account. Please use your public key, Mina will never ask for your private key.

Use mina-generate-keypair

To simplify the process of creating a key pair, we created a simple command line utility called mina-generate-keypair. The mina-generate-Keypair tool is easy to use and you can create your own key pair to start participating in the Mina network. Please refer to the content below and learn how to install and use the key on your local system.

Install

We provide support for several different operating systems for the mina-generate-keypair tool. Please follow the instructions below to install the tool on your system.

macOS

If you are using macOS, install Docker and follow the basic Docker instructions below.

Ubuntu 18.04 / Debian 9

After adding the Mina repo, you can simply run the following command.

sudo apt-get install mina-generate-keypair=0.2.12-718eba4 Check whether the keygen tool is installed correctly by running mina-generate-keypair -version. The output should be Commit \[DIRTY\]718eba4826794f83d51c0d8dcf538e78b0259528 on branch HEAD.

Windows / other platforms

Install Docker and follow the instructions for Docker in step 3b below.

use

Creating a key pair is simple and can be completed in just a few steps.

1.First, make sure that there is a folder in your system where you can store the key file. We recommend using the ~/keys folder.

mkdir ~/keys

2.Next, make sure to set the permissions of the folder correctly, which will prevent unwanted processes from accessing these files.

chmod 700 ~/keys

3.Use step 3a on Debian/Ubuntu or step 3b on Docker to generate the key.

    3a. In Ubuntu/Debian: Use the mina-generate-keypair command to generate the key. When prompted, enter the password used to protect this key. If set, the tool will use the password from the CODA_PRIVKEY_PASS environment variable instead of prompting. Please don't forget this password.
    
    mina-generate-keypair -privkey-path ~/keys/my-wallet
    
    
    3b. In Docker on Windows/MacOS/Linux: use minaprotocol/generate-keypair docker image to generate keys. When prompted, enter the password used to protect this key. Please don't forget this password.
    
    cd ~
    docker run --interactive --tty --rm --volume $(pwd)/keys:/keys minaprotocol/generate-keypair:0.2.12-718eba4 -privkey-path /keys/my-wallet
    This will create two files on your system containing the encrypted private key ~/keys/my-wallet and the pub~/keys/my-wallet containing the public key in clear text. Please store the private key file and password in a safe place, such as a password manager.
    

    4. Finally, make sure that the permissions of the private key file are set correctly, which will prevent unwanted processes from accessing it.
    
    chmod 600 ~/keys/my-wallet
    
    
    
    
    Verify your private key
    
    
    
    Now you have created the key-you need to verify that it is valid. It is sufficient to verify whether the transaction can be signed. You can use the mina-validate-keypair tool to verify.
    
    
    
    Under Linux system, execute the following command:
    
    mina-validate-keypair -privkey-path <path-to-the-private-key-file>
    
    
    If using Docker, execute the following command:
    
    docker run --interactive --tty --rm --entrypoint=mina-validate-keypair --volume $(pwd)/keys:/keys minaprotocol/generate-keypair:0.2.12-718eba4 -privkey-path /keys/ my-wallet
    
    
    
    
    Next step
    
    
    
    Now that we have created a key pair, we can finally connect to the network or share your public key.

---

*Originally published on [MinaWallet](https://paragraph.com/@minawallet/mina-docs-generate-a-key-pair)*
