Skip to main content

Accounts and Cryptographic Keys

The Casper blockchain uses an on-chain account-based model, uniquely identified by an AccountHash derived from a specific PublicKey.

By default, a transactional interaction with the blockchain takes the form of a Deploy cryptographically signed by the key-pair corresponding to the PublicKey used to create the account.

The Casper platform supports two types of keys for creating accounts and signing transactions:

  • ed25519 keys, which use the Edwards-curve Digital Signature Algorithm (EdDSA)
  • secp256k1 keys, commonly known as Ethereum keys

You can generate keys using both formats, and it is also possible to work with existing Ethereum keys.

Creating Accounts and Keys

When you create an account on the Casper blockchain, a cryptographic key-pair will be created when using either the Casper command-line client or a block explorer.


SAVE your keys to a safe place, preferably offline.

Option 1: Generating Keys using the Casper Client

This option describes how you can use the Casper command-line client to set up your account with both key types.

EdDSA Keys

The command-line client generates EdDSA keys by default. Use the command below to create your account.

mkdir ed25519-keys
casper-client keygen ed25519-keys/
tree ed25519-keys/

Sample output of the tree command shows the contents of the ed25519-keys folder:

├── public_key.pem
├── public_key_hex
└── secret_key.pem

0 directories, 3 files

Here are some details about the files generated:

  1. public_key.pem is a PEM-encoded public key
  2. public_key_hex is a hexadecimal-encoded string of the public key
  3. secret_key.pem is the PEM-encoded secret key

The public-key-hex for ed25519 keys starts with 01:

cat ed25519-keys/public_key_hex

Ethereum Keys

To create secp256k1 keys with the Casper command-line client, commonly known as Ethereum keys, follow these steps:

mkdir secp256k1-keys
casper-client keygen -a secp256k1 secp256k1-keys/
tree secp256k1-keys/

Sample output of the tree command shows the contents of the secp256k1-keys folder:

├── public_key.pem
├── public_key_hex
└── secret_key.pem

0 directories, 3 files

The public-key-hex for secp256k1 keys starts with 02:

cat secp256k1-keys/public_key_hex

Account Hash

Responses from the node contain AccountHashes instead of the direct hexadecimal-encoded public key. To view the account hash for a public key, use the account-address option of the client. The argument for the public-key must be a properly formatted public key. The public key may also be read from a file, which should be one of the two files generated via the keygen command: public_key_hex or public_key.pem.

casper-client account-address --public-key <FORMATTED STRING or PATH>

Option 2: Generating Keys using a Block Explorer

This option is available on networks that have a block explorer.

For instance, on the official Testnet, the block explorer is available, and the following instructions assume you are using it.

Start by creating an account using the Casper Signer and download the secret key when prompted. You can choose the key type when creating your account.

Funding your Account

Once you create your account, you can fund the account to finish the process of setting it up.


Until you fund your account, it does not exist on the blockchain.

Working with Existing Ethereum Keys

You can also use existing Ethereum keys in Casper. Here is an example set of Ethereum keys and their corresponding address:

Public key:0470fecd1f7ae5c1cd53a52c4ca88cd5b76c2926d7e1d831addaa2a64bea9cc3ede6a8e9981c609ee7ab7e3fa37ba914f2fc52f6eea9b746b6fe663afa96750d66
Private key:29773906aef3ee1f5868371fd7c50f9092205df26f60e660cafacbf2b95fe086

To use existing Ethereum keys, the Casper virtual machine (VM) needs to know that the key is a secp256k1 type. To achieve this, we will prefix the public key hex with 02, as shown in the example below.

The Casper command-line client provides an example of how this works.


The following transaction sends 100 CSPR.

casper-client transfer \
--transfer-id 1234567 \
--node-address http://localhost:7777 \
--chain-name casper \
--target-account 020470fecd1f7ae5c1cd53a52c4ca88cd5b76c2926d7e1d831addaa2a64bea9cc3ede6a8e9981c609ee7ab7e3fa37ba914f2fc52f6eea9b746b6fe663afa96750d66 \
--amount 10000000000 \
--secret-key <path-to-secret_key.pem> \
--payment-amount 10000

The Casper command-line client requires the secret key in PEM format to send a transaction from this account. If you want to use existing Ethereum keys with the command-line client, a conversion to PEM format is needed.

The following example is a JS script that generates a PEM file, using a key encoder and Node.js. To install these components, do the following:

sudo apt install nodejs
npm install key-encoder

Then create the JS script convert-to-pem.js using vi or nano, and include this content:

var KeyEncoder = require("key-encoder"),
keyEncoder = new KeyEncoder.default("secp256k1");
let priv_hex = "THE SECRET KEY TO ENCODE";
let priv_pem = keyEncoder.encodePrivate(priv_hex, "raw", "pem");

Then run the script using Node.js and name the secret key.

node convert-to-pem.js > eth-secret.pem

To view the secret key, use cat <filename>:

cat eth-secret.pem

Below is the sample output showing the contents of the secret key.