Bitcoin Wallet & Keys
Sun Sagong @ Microsoft - Singapore
Blockchain&DAPPs Technology meetup
(11Apr2018)
Key Roles of Bitcoin Wallet
• 1. Manage Public & Private Key pairs and
addresses that are necessary to make payments.
• 2. Manage UTXO amounts in the Bitcoin network
and check transaction histories.
Private Key => Public Key => Bitcoin Address
• Private Key is the the root of user control over
all funds associated with the corresponding
bitcoin address.
Private Key => Public Key
ECDSA
Elliptic Curve
(Secp256k1 )
Public Key => Bitcoin Address
UTXO - Unspent Transaction Output
• UTXO will be spent as an input in a new transaction.
Transaction 1 (TXID)
OUTPUT
(UTXO)
● Sequence Number
● Amount of Bitcoins
● ScriptPubkey
(locking script)
INPUT
Transaction 2 (TXID)
OUTPUT
(UTXO)
INPUT
● TXID of UTXO
● Sequence Number
● ScriptSig (unlocking
script)
Structure of a transaction (non-coinbase)
Previously Used Wallet Structures
Type-0 nondeterministic (random) wallet
A collection of randomly generated keys
Type-1 deterministic (seeded) wallet
A deterministic sequence of keys derived from a seed
Hierarchical Deterministic Wallet - BIP32
Type-2 HD wallet
A tree of keys generated from a single seed
Password
Salt
PBKDF2(HMAC-SHA512, Password, Salt, 2048, 512)
HMAC-SHA512
512-bits
From mnemonic to seed
Creating Master Keys and Chain Code
Type-2 HD wallet
A tree of keys generated from a single seed
HMAC-SHA512
512-bits
256-bits
Private Child Key Derivation
Type-2 HD wallet
A tree of keys generated from a single seed
512-bits
256-bits
HMAC-SHA512
256-bits
Multipurpose HD Wallet Structure - BIP43 & 44
BIP-43 & 44 specifies the structure as consisting of five predefined tree levels:
• m / purpose' / coin_type' / account' / change / address_index
1. The first-level "purpose" is always set to 44'. - BIP 43
2. The second-level "coin_type" specifies the type of cryptocurrency coin,
allowing for multicurrency HD wallets where each currency has its own
subtree under the second level. - BIP 44
Wallet Best Practices
● Mnemonic code words, based on BIP-39
● HD wallets, based on BIP-32
● Multipurpose HD wallet structure, based on BIP-43
● Multicurrency and multiaccount wallets, based on BIP-44
Mastering Bitcoin 2nd Edition - Chapter 5: Wallets
https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch05.asciidoc
Demo - Mnemonic Code Converter
Mnemonic Code Converter
https://iancoleman.io/bip39/
Bitcoin Wallet &amp Keys

Bitcoin Wallet &amp Keys

  • 1.
    Bitcoin Wallet &Keys Sun Sagong @ Microsoft - Singapore Blockchain&DAPPs Technology meetup (11Apr2018)
  • 2.
    Key Roles ofBitcoin Wallet • 1. Manage Public & Private Key pairs and addresses that are necessary to make payments. • 2. Manage UTXO amounts in the Bitcoin network and check transaction histories.
  • 3.
    Private Key =>Public Key => Bitcoin Address • Private Key is the the root of user control over all funds associated with the corresponding bitcoin address.
  • 4.
    Private Key =>Public Key ECDSA Elliptic Curve (Secp256k1 )
  • 5.
    Public Key =>Bitcoin Address
  • 6.
    UTXO - UnspentTransaction Output • UTXO will be spent as an input in a new transaction. Transaction 1 (TXID) OUTPUT (UTXO) ● Sequence Number ● Amount of Bitcoins ● ScriptPubkey (locking script) INPUT Transaction 2 (TXID) OUTPUT (UTXO) INPUT ● TXID of UTXO ● Sequence Number ● ScriptSig (unlocking script) Structure of a transaction (non-coinbase)
  • 7.
    Previously Used WalletStructures Type-0 nondeterministic (random) wallet A collection of randomly generated keys Type-1 deterministic (seeded) wallet A deterministic sequence of keys derived from a seed
  • 8.
    Hierarchical Deterministic Wallet- BIP32 Type-2 HD wallet A tree of keys generated from a single seed Password Salt PBKDF2(HMAC-SHA512, Password, Salt, 2048, 512) HMAC-SHA512 512-bits From mnemonic to seed
  • 9.
    Creating Master Keysand Chain Code Type-2 HD wallet A tree of keys generated from a single seed HMAC-SHA512 512-bits 256-bits
  • 10.
    Private Child KeyDerivation Type-2 HD wallet A tree of keys generated from a single seed 512-bits 256-bits HMAC-SHA512 256-bits
  • 11.
    Multipurpose HD WalletStructure - BIP43 & 44 BIP-43 & 44 specifies the structure as consisting of five predefined tree levels: • m / purpose' / coin_type' / account' / change / address_index 1. The first-level "purpose" is always set to 44'. - BIP 43 2. The second-level "coin_type" specifies the type of cryptocurrency coin, allowing for multicurrency HD wallets where each currency has its own subtree under the second level. - BIP 44
  • 12.
    Wallet Best Practices ●Mnemonic code words, based on BIP-39 ● HD wallets, based on BIP-32 ● Multipurpose HD wallet structure, based on BIP-43 ● Multicurrency and multiaccount wallets, based on BIP-44 Mastering Bitcoin 2nd Edition - Chapter 5: Wallets https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch05.asciidoc
  • 13.
    Demo - MnemonicCode Converter Mnemonic Code Converter https://iancoleman.io/bip39/