A bitcoin private key is nothing but a 32 byte (256-bit) entropy that is might just as well be SHA256 hash of your name! But that’s not secure nor ideal way to generate a private key. Two most commonly used methods to generate a private key or a master key (in hierarchical deterministic implementations) is use of a either PRNG or Mnemonic.
BIP 39 is the specification for implementation of mnemonic codes for generating private or master keys. It is infact a pre-defined list of 2048 words (in multiple languages) which may be picked in any order to generate a secure but deterministic entropy.
A proper BIP 39 implementation works both ways, which means a generated entropy can easily be reversed to mnemonic codes. A simple example would be, let’s say a user chooses these 24 words from the wordlist:
virtual wear number paddle spike usage degree august buffalo layer high pelican basic duty gate uphold offer reopen favorite please acoustic version clay leader
will generate following entropy:
- This 256-bit entropy may now directly be used as a Bitcoin private key or a master key for HD wallets.
- These mnemonic codes are memorable and easy to write down.
- Writting down mnemonic codes is simpler and safer as compared to manually writting down strings in hexadecimal or other encodings.
- Generating a private key using mnemonic is safe as there are as much as 2^256 possibilites which makes odds of successful brute forcing and/or random collision are simply astronomical.
On a side note, I want to elaborate that use of mnemonic should not be just limited to bitcoin private keys, in fact this can be implemented for example in user account recovery aspects of a project/website.