Blockchain tutorial 29: Hierarchical Deterministic wallet - BIP32 and BIP44

in #blockchain7 years ago

Blockchain tutorial 29: Hierarchical Deterministic wallet - BIP32 and BIP44

This is part 29 of the Blockchain tutorial.

In this video series different topics will be explained which will help you to understand blockchain.
It is recommended to watch each video sequentially as I may refer to certain Blockchain topics explained earlier.

DETERMINISTIC WALLET

BIP-39 describes how the mnemonic words are created.
These mnemonic words together with a password (optionally) are used to generate a 512 bit seed.
The 512 bit seed is also called the "BIP-39 seed".
This seed is used to create deterministic wallets.
There are two types of deterministic wallets:

  • Sequential deterministic wallets.
  • Hierarchical deterministic wallets.

SEQUENTIAL DETERMINISTIC WALLET

Sequential deterministic wallets generates private keys for example by taking SHA256(seed + n)

HIERARCHICAL DETERMINISTIC WALLET

Nowadays most wallets are Hierarchical Deterministic (HD) wallets.
More information:
https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki

Most HD wallet vendors have implemented BIP-32, BIP-39 and BIP-44.
These 3 Bitcoin Improvement Proposals are becoming an industry standard.

BIP-39

BIP-39 describes the implementation of mnemonic words to generate a 512 bit seed.
More information:
https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

BIP-32

BIP-32 describes how you can build a general hierarchical deterministic wallet.
More information:
https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
https://bitcoin.org/en/developer-guide#hierarchical-deterministic-key-creation
If you want to see how BIP32 is implemented in the bitcoinjs library, see:
https://raw.githubusercontent.com/bitcoinjs/bitcoinjs-lib/master/src/hdnode.js

Online web application:
https://www.mobilefish.com/download/ethereum/hd_wallet.html

BIP-32 explains how master keys and master chain code are created from a BIP-39 seed.
The chain code is used as entropy in the Child Key Derivation function.

Using different index numbers will create different unlinkable child keys from the same parent keys.
Repeating the procedure for the child keys using the child chain code will create unlinkable grandchild keys.
By changing the chain code, a new node (aka wallet) is created.

Extended private (xprv) keys can create a complete branch with child private keys and child public keys
Extended public (xpub) keys can only generate public keys.

BIP-44

BIP-44 defines a specific logical hierarchy for deterministic wallets based on an algorithm described in BIP-32.
More information:
https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki

BIP-44 uses the following derivation path: m/purpose'/coin_type'/account'/change/address_index
The letter m denotes the master node and all hierarchical levels are separated with slashes (/).
m is level 0, purpose is level 1, coin_type is level 2 etc.
The purpose scheme is described in BIP-43.
Because we are using BIP44 scheme we should use 44'.
The apostrophe (for example in purpose') indicates hardened derivation.
More information:
https://github.com/satoshilabs/slips/blob/master/slip-0044.md

Account level can be seen as bank account types, for example payment account, savings account etc.
change level is also known as "external / internal level" where external (0) is used for addresses that are meant to be visible outside of the wallet (receiving payments) and internal (1) is used for addresses which are not meant to be visible outside of the wallet (signing transactions).
address_index is a sequence of addresses starting at 0.

BIP-44 XPRV AND XPUB DEMONSTRATION

Suppose a webshop wants to receive payments in only in ETH.
For each payment received a different Ethereum address must be used.
The webshop should use a wallet containing only public keys.
The webshop wallet uses a xpub key with derivation path: m/44'/60'/0'/0
This wallet creates the following addresses:
m/44'/60'/0'/0/0
m/44'/60'/0'/0/..
The accounting department uses another wallet containing the same public keys AND accompanied private keys.
The accounting department can transfer payments made on these public addresses and transfer it to a separate accounting address.
This is possible because they have access to the private keys.
The accounting department wallet uses a xprv key with the same derivation path:
m/44'/60'/0'/0

BIP-32 RISK

If a hacker gets it hands on any child private key and the account xpub key, the hacker can recompute the account xprv key and thus have access to every private and public key descending from the account level.
More information:
https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#implications

The presentation used in this video tutorial can be found at:
https://www.mobilefish.com/developer/blockchain/blockchain_quickguide_tutorial.html

Sort:  

Following you!

Congratulations @mobilefish! You received a personal award!

1 Year on Steemit

Click here to view your Board

Do not miss the last post from @steemitboard:

SteemWhales has officially moved to SteemitBoard Ranking
SteemitBoard - Witness Update

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @mobilefish! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.20
TRX 0.14
JST 0.030
BTC 64785.95
ETH 3471.44
USDT 1.00
SBD 2.51