Mnemonic Seed Phrases (BIP39)

When you set up a Metamask wallet (other options are available), you will be asked to note down and then re-enter 12 words. These words are your mnemonic seed phrase and can be used to recover access to your wallet if you forget your password or need to restore on another device.

In this piece I’ll look at where these words come from and the maths behind the magic…

BIP39

The implementation of the mnemonic seed phrase was introduced within BIP39 (N.B Bitcoin Improvement Proposals are suggested upgrades to bitcoin’s functionality which are peer reviewed and can be implemented with consensus from the wider community) in September 2013 and aimed to provide an easier to remember way for bitcoin users to back up access to their wallets.

Generating the Mnemonic

To create the mnemonic phrase;

1) Generate 128–256 bits of entropy (a random hash). The longer the entropy the more secure it is however using 256 bits of entropy will require 24 words in the mnemonic seed phrase vs 12 for 128 bits.

Example of 128 bit entropy: da9d114afde92daf44a36c55bdb05787

2) Each character can then be represented in binary form

3) We then generate a check sum by running our above entropy through the SHA256 algorithm (this hashing algorithm is also used in bitcoin address generation)

result: fe4eed23f29e9eb256a2fbce9a07a230589ded811f3ea8031c8a57c403fe8d93

and taking the first ` n` bits where n is calculated as ` the length of our entropy/32`. So as 128/32=4 we’re taking the first 4 bits which is equivalent to the first character ` f`. This is represented as ` 1111` in binary, so we append this to the end of our entropy:

1101 1010 1001 1101 0001 0001 0100 1010 1111 1101 1110 1001 0010 1101 1010 1111 01 00 0100 1010 0011 0110 1100 0101 0101 1011 1101 1011 0000 0101 0111 1000 0111 1111

4) We then need to split into groups of 11 and convert to decimal as this is going to allow us to match these up to our wordlist!

Each of these 12 11-bit groups are now represented by a number between 0 and 2047 which acts as an index to a word list of 2048 unique words which make up the seed phrase.

The english wordlist can be found here: https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt

We have therefore created the 12 word mnemonic which can be used to restore access to our wallet. In the case that we need to regenerate the entropy from the seed phrase we simply do the whole process backwards!

Other Language Wordlists

Although BIP39 originally had an English word list only, over the years there have been community contributions to make the process more accessible for non-native English speakers. In Aug 2014 the Japanese wordlist was added, with the Spanish and Chinese ( simplified and traditional) versions quickly following. Then in March 2015 the French wordlist was added and expanded to include Italian in January 2016. 2017 saw two new additions with Czech added in February and Korean following in Aug. The latest addition to the wordlist options was Portuguese in September 2020.

However it’s worth noting that these additional language lists are not simply a translation of the original 2048 english words but unique word sets each with language specific rules such as:

French Wordlist:

16. No embarrassing words (in a very, very large scope) or belonging to a particular religion.

Italian Wordlist:

9. No words with double vocals (like: lineetta).

Czech Wordlist

5. No personal names or geographical names.

Portuguese Wordlist

16. No words that remind negative/sad/bad things.

Fun fact: There are no words in common between the Spanish wordlist and any other language wordlist, therefore it is possible to detect the language with just one word.

If you want to generate your own mnemonic seed phrase then this is a handy online tool: https://iancoleman.io/bip39/#english

You can also select `show entropy details` to follow the above generation steps.

Originally published at https://www.linkedin.com.

--

--

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