What is an Ethereum keystore file?

$ geth account new
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat passphrase:
Address: {008aeeda4d805471df9b2a5b0f38a0c3bcba786b}
$ geth account list
Account #0: {8a1c4d573cc29a96547816522cfe0b266e88abac} keystore:~/.ethereum/keystore/UTC--<created_date_time>-- 008aeeda4d805471df9b2a5b0f38a0c3bcba786b
  1. You’ve lost your keystore file;
  2. You’ve forgotten the password associated with the file;
  3. Both.

What is a keystore file?

What do keystore files look like?

$ cat ~/.ethereum/keystore/UTC--<created_date_time>--  008aeeda4d805471df9b2a5b0f38a0c3bcba786b
{
"crypto" : {
"cipher" : "aes-128-ctr",
"cipherparams" : {
"iv" : "83dbcc02d8ccb40e466191a123791e0e"
},
"ciphertext" : "d172bf743a674da9cdad04534d56926ef8358534d458fffccd4e6ad2fbde479c",
"kdf" : "scrypt",
"kdfparams" : {
"dklen" : 32,
"n" : 262144,
"r" : 1,
"p" : 8,
"salt" : "ab0c7876052600dd703518d6fc3fe8984592145b591fc8fb5c6d43190334ba19"
},
"mac" : "2103ac29920d71da29f15d75b4a16dbe95cfd7ff8faea1056c33131d846e3097"
},
"id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6",
"version" : 3
}

Let’s dig a little deeper

"crypto" : {
"cipher" : "aes-128-ctr",
"cipherparams" : {
"iv" : "83dbcc02d8ccb40e466191a123791e0e"
},
"ciphertext" : "d172bf743a674da9cdad04534d56926ef8358534d458fffccd4e6ad2fbde479c",
"kdf" : "scrypt",
"kdfparams" : {
"dklen" : 32,
"n" : 262144,
"r" : 1,
"p" : 8,
"salt" : "ab0c7876052600dd703518d6fc3fe8984592145b591fc8fb5c6d43190334ba19"
},
"mac" : "2103ac29920d71da29f15d75b4a16dbe95cfd7ff8faea1056c33131d846e3097"
},
  • cipher: The name of a symmetric AES algorithm;
  • cipherparams: The parameters required for the “cipher” algorithm above;
  • ciphertext: Your Ethereum private key encrypted using the “cipher” algorithm above;
  • kdf: A Key Derivation Function used to let you encrypt your keystore file with a password;
  • kdfparams: The parameters required for the “kdf” algorithm above;
  • mac: A code used to verify your password;

1. Encrypting your private key

  • cipher is the symmetric algorithm used to encrypt the Ethereum private key. Here, the value of cipher is aes-128-ctr.
  • cipherparams are the parameters required for the aes-128-ctr algorithm. Here, the only parameter is iv, an “initialisation vector” consumed by the aes-128-ctr algorithm.
  • ciphertext is the encrypted input of the aes-128-ctr function.
Symmetric decryption of ciphertext

2. Protecting it with your passphrase

  • kdf is the Key Derivation Function used to compute (or “derive”) the decryption-key from your passphrase. Here, the value of kdf is scrypt.
  • kdfparams are the parameters required for the scrypt function. Here, without going into too much detail, dklen, n, r, p and salt are the parameters of the kdf function. More information on the scrypt function can be found here.
Key Derivation Function from passphrase

3. Make sure your passphrase is right

Putting everything together

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Synack’s Jay Kaplan Has a White Hat Hacker Army: Interview

Horizon Protocol Mainnet Deployment and Staking Pools

Introducing Gnosis Safe, Manage DAO Assets Through Multi Signature Wallet Contracts On BSC

{UPDATE} Scary Granny Return Hack Free Resources Generator

Alert to smartphones tracking us

smartphone-spy

STIR/SHAKEN didn’t stop your Spam labeling, did it?

SquidGame Online Test Tutorial

Employee cybersecurity habits: When will companies learn?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Julien M

Julien M

More from Medium

HYDN Security- Blockchain Security and Smart Contract Audit Experts

The Blockchain Trilemma

Uniswap Clone — Instantly launch your Decentralized Exchange like Uniswap

what is De-Fi ?