[Ethereum] Generating a private key from a single mnemonic

mnemonicprivate-key

I want to generate an Ethereum private key from a single word mnemonic. For example,

(1) I could use keccack256 online tool to transform a word to a private key. Would this be a valid key? Are there any other ways this could have been done?

(2) In the case of a 12-24 word mnemonic it is possible to generate a 512-seed from the mnemonic sentence which is used to generate a private key. How might this be done with only one word as seed ‘’phrase’’? I know this is possible since it has been done but I do not understand how. Would it be done in the exact same way the seed from the 12 word mnemonic is derived from?

So how is it possible to generate a private key from a single word. Is it possible only using case (1) or also case (2) and other?

Best Answer

(1) I could use keccack256 online tool to transform a word to a private key. Would this be a valid key ?

Any 256-bit number is a valid private key, so yes, it would be a valid key. But this isn't enough entropy to generate a secure private key. I could just run every word in the dictionary through keccak256() (and every other widely used hash function that generates 256-bit numbers) and check whether there are any funds associated with each private key until I find yours.

The whole idea behind using 12-24 dictionary words as the seed is to make the entropy sufficient to make it secure.

https://xkcd.com/936/

You can't have both the seed and the hash function known or easy-to-guess. (keccak256() is known, dictionary words are easy to guess.)

So how is it possible to generate a private key from a single word.

You have 2 choices:

  1. Use a difficult-to-guess seed with a known hash function, or
  2. Use a difficult-to-guess hash function with an easy-to-guess seed

For the first option, you could use a password manager to generate a secure password, then run that through keccak256() or any other hash function that can give you a 256-bit number. However, your secure password (high entropy) doesn't come under your definition of "mnemonic".

For the second option, you would need to run your chosen dictionary word (low entropy) through a hash function you had written yourself (or, alternatively, a series of known hash functions in an order only you know).

Related Topic