The Magic Behind a Mnemonic Phrase and HD Wallets — Let Us Explain.

David Park
Cosmostation
Published in
8 min readApr 26, 2019

Accessing Cosmostation wallet( iOS / Android ) for Cosmos(ATOM) with a mnemonic phrase gives you the ability to interact with multiple addresses from a single seed phrase. This blog post explains where mnemonic words come from and how it all works from behind the scenes.

The magic behind a mnemonic phrase and HD wallets— Cosmostation

The Cosmos Hub Mainnet has been running smoothly without a hiccup, and we are very proud to be part of this amazing journey! As a Cosmos validator & ecosystem provider, Cosmostation is committed to operating a stable validator node as a well as providing useful tools for the Cosmos community.

Updates

Cosmostation mobile wallet( iOS / Android ) is available in both the iTunes store and Google Play store. Enjoy secure & easy transactions on the Cosmos Hub with local-signing and HD wallet support.

Token transfers are now rolling following the upgrade to cosmoshub-2! You can monitor network conditions and see these transfers on Mintscan, a Cosmos block explorer powered by Cosmostation:

TL;DR

  • Cosmostation mobile wallet is designed with heavy focus on security and intuitive UI/UX.
  • There are a lot of functions and development that goes behind providing an application that is both secure and convenient for the end user.
  • We prepared this blog post to specifically explain what the underlying mechanism for a Mnemonic Phrase and HD Wallets are, and how the Cosmostation application handles these complicated but necessary steps for you behind the scenes.
  • If you want to understand the magic behind a mnemonic phrase and HD wallets, you should continue reading this post.

Before I explain what a mnemonic phrase is, let us begin by acknowledging the relationship between a Hierarchical Deterministic Wallet and a master seed.

Master Seed

A HD(Hierarchical Deterministic) Wallet is a wallet that can generate virtually infinite numbers of private/public key pairs with a single Master Seed.

With a master seed, you do not have to remember all the individual private keys for your wallets — all you have to remember(or write down) is the master seed to regenerate all the subkeys and restore the entire wallet.

A master seed is generated from a hexadecimal entropy that looks something like this.

0C1E24E5917779D297E14D45F14E1A1A

If an entropy is what I need in order to generate a master seed to access my master key, what is a mnemonic phrase?

Mnemonic Phrase

Because memorizing a hexadecimal entropy is an inconvenient way to access your wallet, Bitcoin developers came up with a way to translate an Entropy into a more readable and easily recognizable form. This is called BIP-0039.

A mnemonic phrase consists of readable words. A user can easily write down or memorize these words to import a wallet. Because of its convenience, the majority of cryptocurrency wallet providers support importing a wallet with a mnemonic phrase.

Cosmostation mobile wallet supports HD(Hierarchical Deterministic) wallets accessed by a mnemonic phrase. As mentioned above, an Entropy is transformed into a mnemonic phrase for readability and better accessibility. A a master key and an infinite number of sub private keys can be generated from this single mnemonic phrase when accessing HD wallets.

Simply put, individual private keys are “children” of a “parent” mnemonic phrase.

Now that we’ve covered what a master seed can do and what a mnemonic phrase is, let’s look at how exactly an entropy is turned into a mnemonic phrase.

Generating a Mnemonic Phrase

Below is a step-by-step explanation of how a mnemonic phrase is generated from an entropy.

How a mnemonic phrase is generated from an entropy.

Generating a mnemonic phrase begins with creating an entropy (128, 160, 192, 224, 256bits).

SHA256 hashing algorithm is applied to the entropy, and we create a checksum with the first 4 bits. The 4bit checksum is added to the entropy, which is then divided into 11bit length segments.

These 11 bit segments are then matched with words from the BIP39 English word list (2048 words).

Finally as a result, an entropy that looks something like this

FEE717B164F36BB660DE11B808842996

Turns into a 12 word mnemonic phrase that looks like this.

Year December Unable Size Cute Swamp Lock Season Retreat During Apology Code

So, now we have a mnemonic phrase derived from an entropy. When accessing your wallet on Cosmostation, this mnemonic phrase is used to generate a master seed which is then used to generate a master key.

This master key is the root private key to all of your wallets! Let’s look at the process below.

Generating a Master Seed/Key From a Mnemonic Phrase

In order to generate a master seed, a mnemonic phrase must go through the process of key stretching.

Accessing HD wallets with a mnemonic phrase, Cosmostation

Key stretching refers to a recursive repetition of generating a digest using a specific hash function for the password you enter(in this case, this password would be your mnemonic phrase). The majority of cryptocurrencies including Bitcoin uses a key stretching method called PBKDF2.

PBKDF2 uses these five parameters

Derived key = PBKDF2(
Pseudorandom function,
Password,
Salt,
The number of iteration,
length of Derived key)

Through this process, a master seed is generated from a mnemonic phrase. This master seed is then used to generate your master key. Voila! You now have the root key to all of your HD wallets.

Accessing HD Wallets For Cosmos(ATOM)

The above sections explained the way in which a Mnemonic Phrase is turned into a master key. This master key is the “parent” private key that gives you access to all of your “children” keys.

Above are derivation paths for Cosmos, Ethereum, and Bitcoin. With your mnemonic phrase, you can access wallets for the majority of cryptocurrencies.

For an easier understanding of what derivation paths are, think of a folder that contains numerous other folders inside, and these internal folders also have infinite numbers of folders inside of them. Derivation paths are specific pointers that lead you to your desired folder.

HD Wallet derivation path for Cosmos (ATOM)

Your master key is the key to unlock the uppermost folder, which then gives you access to all of the other folders inside! Pretty neat.

Now that you have access to the uppermost derivation, the Cosmostation application shows you the derivation path specific to the Cosmos Hub blockchain(m/44'/118'/0'/0).

(This is also how you can access your BTC, ETH, LTC, etc. wallet from a single mnemonic phrase! Just find the right derivation path for your desired cryptocurrency.)

When you import a wallet on the Cosmostation application, you will see that there are 5 different addresses you can access with a single mnemonic phrase. You can virtually generate an infinite number of wallets using your mnemonic phrase, but we chose to give you the option of choosing from these first 5 addresses for your convenience(as shown in the wallet screen shot above):

m/44'/118'/0'/0/0~4

Relationship between a Mnemonic Phrase and a Private Key.

A lot of people may misunderstand the relationship between a mnemonic phrase and a private key. Some even say that a mnemonic phrase can be derived from a private key — this is absolutely the opposite of what’s true.

Once more, let’s look at the process in which a private key is generated in a HD wallet.

  1. Generating an entropy (128, 160, 192, 224, or 256bits)
  2. Generating a mnemonic phrase from the entropy
  3. Generating a master seed from the mnemonic phrase
  4. Generating private key from the master seed

As you can see in the steps above, a private key is generated from a mnemonic phrase, not the other way around — this process cannot be reversed.

Most cryptocurrencies are not managed or operated by centralized organizations. The end user must always take caution in taking every measure to best protect his or her assets. In order to do so, you must have a through understanding of the wallet you are using and the mechanism behind key management.

About Cosmostation

Welcome, Cosmonaut. FUEL UP on Atom at Cosmostation!

Cosmostation is a Cosmos Validator based in Seoul, South Korea. We are a team of 10 developers, engineers, and dreamers united with one objective — to provide a universe full of useful tools and solutions for Tendermint-based projects.

Unlike most blockchains, which require you to use an opinionated scripting language or environment, Tendermint makes no assumptions about the application, giving developers the utmost freedom to express their business logic using the tools right for them.

We make no assumptions about the power and potential of Tendermint-based networks can bring to the blockchain ecosystem, and we are ready to stay on the grind to do everything we can to contribute to the community.

Cosmostation’s operation philosophy is geared by and for the community. You’ve put your trust on us, and so should we. Along with high security, development of projects within the Cosmos ecosystem, and our promise to delegators, Cosmostation will constantly update and research better ways to fairly reward and protect our delegators to expand the Cosmos universe.

FUEL UP your wallet at Cosmostation to explore the Cosmos network.

Please visit the links below to begin this journey with Cosmostation!

E-mail: business@cosmostation.io
Official Website: https://www.cosmostation.io/
Cosmos Android Wallet: Android — Google Play Store
Cosmos iOS Wallet: iOS — iTunes App Store
Wallet User Guide: http://bit.ly/Cosmostation_Guide_EN
Block Explorer:
https://www.mintscan.io/
Medium:
https://medium.com/cosmostation/
Twitter: https://twitter.com/CosmostationVD
Telegram: https://t.me/cosmostation

--

--