SlideShare a Scribd company logo
Crypto-Wallets:
A Technical Perspective
Wallets, Keystores, HD Wallets,
Technical Standards (BIP39, BIP32,
BIP44), Mnemonics, JS Examples
Software University (SoftUni)
https://softuni.org
Svetlin Nakov
Blockchain Engineer
and Technical Trainer crypto
wallet
2
 Software engineer, trainer, entrepreneur,
PhD, author of 13 books, blockchain expert
 3 successful tech educational initiatives (100,000+ students):
About Svetlin Nakov
3
 Technical advisor @ LockChain / LockTrip: https://locktrip.com
 Raised ~ 10.000 ETH in token sale (Sep-Nov 2017)
 Currently LOC token holders book hotels @ 20-30% better price
 Head of blockchain education (Jan-June 2018) @ Academy
School of Blockchain: https://academytoken.com
 Raised ~ 48M USD in token sale (Jan-Apr 2018)
 Tech advisor for blockchain crypto startups:
 Tokenize Exchange, Bountie, Weidex, IRIS Payments Solutions,
Aeternity Ventures
Nakov – Blockchain & Crypto Projects
4
Book "Practical Cryptography for Developers"
GitHub:
https://github.com
/nakov/practical-
cryptography-for-
developers-book
Official site:
https://cryptobook.
nakov.com
Table of Contents
5
1. Public Blockchains: Nano Introduction
2. Blockchain Wallets: Types, Functions, Concepts
3. Practice: Play with the Jaxx Wallet on the Ropsten Testnet
4. Simple Keystores: Encrypted Private Keys
5. Simple Keystores: JS Code Examples and Live Demo
6. HD Wallets: Mnemonics (BIP39), HD Wallets (BIP32, BIP44)
7. HD Wallets: JS Code Examples and Live Demo
6
Public Blockchains: Nano Introduction
Distributed ledger
Peer-to-Peer
network
Nodes hold
ledger of facts +
history of updates
Decentralized
(no owner)
Secure
Transactions are
verified by the
entire network
Immutable
7
Blockchain == Chain of Data Blocks
Demo: https://etherscan.io
timestamp block_hash
all_transactions_hash
transaction #1 hash
transaction #2 hash
transaction #3 hash
…
Block #0 (genesis block)
prev_hash nonce
timestamp block_hash
all_transactions_hash
transaction #1 hash
transaction #2 hash
transaction #3 hash
…
Block #1
nonceprev_hash
timestamp block_hash
all_transactions_hash
transaction #1 hash
transaction #2 hash
transaction #3 hash
…
Block #2
prev_hash nonce
8
 Crypto wallet == software that stores private keys along with their
respective blockchain addresses
 Enables users to send and receive crypto currency / tokens
 Communicates with the blockchain network (through API or by
running a blockchain node)
 Signs transactions and sends them to the blockchain network
What is a Cryptocurrency Wallet?
9
 Mobile wallet (mobile app)
 Desktop wallet (desktop app)
 Web-based wallet (web site)
 Hardware-based wallet
(USB stick, e.g. Ledger, Trezor)
 Paper wallet (private key
printed on a sheet of paper)
Types of Crypto Wallets
Practice
Play with Jaxx Wallet and Ethereum
11
Install the Jaxx Wallet
https://jaxx.io
Jaxx Wallet
Desktop / Mobile
12
Enable the Ethereum Testnet (ETHt)
http://sli.do
#nakov
13
Share Your Wallet Address to Get ETHt
14
Send ETHt to the People Around You
Request test ethers (ETHt) from the Faucets
 http://tiny.cc/ropsten-faucet
 https://faucet.metamask.io
 https://faucet.ropsten.be
 http://faucet.bitfwd.xyz
15
Ethereum Testnet Faucets
16
 Simple keystores
 Example: myetherwallet.com
 Keep a simple ECC private key, password protected
 Similar to OpenSSH and OpenSSL PEM keystores (see PKCS#8)
 HD wallets
 Example: https://iancoleman.io/bip39
 Hierarchical-deterministic (HD) wallet
 Keep a mnemonic phrase (12 or 24 words)
 Derive many private keys from the mnemonic
Simple Keystores vs. HD Wallets
17
Simple Keystores: Encrypted Private Keys
myetherwallet.com
18
JSON / UTC Keystore File – Example
{ "version": 3, "id": "…", "address": "2a90ef17a50f7e99387…c07fc",
"crypto": {
"ciphertext": "fa3315e31cba71df…2cd1", // the encrypted private key
"cipher": "aes-128-ctr", // AES, 128-bit encryption, CTR mode
"cipherparams": { "iv": "08c3f2ba1c…f6" }, // random initial vector
"kdf": "scrypt", "kdfparams": {
"dklen": 32, // key length (256-bit key for AES encryption)
"salt": "d48231c94b90c03018bf9f4…a1e0", // random-generated salt
"n": 1024, // iterations count (CPU + memory cost factor)
"r": 8, // block size (affects CPU + memory)
"p": 1 // parallelization factor (threads count)
},
"mac": "b0ee3cd7e0564acea…49e3" // msg integrity / auth key
} } Learn more at: https://github.com/ethers-io/ethers.js/blob/master/src.ts/utils/secret-storage.ts#L289
https://github.com/ethers-io/ethers.js
19
Creating a Simple Keystore in JavaScript
npm install --save ethers
let ethers = require('ethers');
let newWallet = ethers.Wallet.createRandom();
console.log("Address: " + newWallet.address);
console.log("Private key: " + newWallet.privateKey);
newWallet.encrypt('P@SS~12345a').then(walletJSON => {
console.log("Encrypted wallet JSON:", walletJSON);
});
20
Simple Keystore from Private Key in JS
let ethers = require('ethers');
let privKey =
"0x0e210eff4fc77ff086d81d646c94af42ec5b1bbaf3f1d525f5bf5b82af7056da";
let existingWallet = new ethers.Wallet(privKey);
console.log("Address: " + existingWallet.address);
// Address: 0xe25ACB5AaE29c38DABdc13Ea41177Aba1191D323
const provider =
ethers.providers.getDefaultProvider('ropsten');
provider.getBalance(existingWallet.address).then(balance =>
console.log('Balance:', ethers.utils.formatEther(balance)));
21
Mnemonics and HD Wallets (BIP39, BIP44)
 HD wallets keep a securely generated random seed
 And use a hierarchical deterministic (HD) key-derivation (see BIP-32)
 The seed (root key) can be represented as 12 or 24 words, e.g.
 Each word comes from a wordlist of 2048 words  1 word == 11 bits
 24 words  256-bit entropy  512-bits seed (see BIP-39)
 All private keys + addresses are derived from the seed (see BIP-44)
 See https://iancoleman.io/bip39 to understand the idea in practice
force moon book duck idle best sad net pelican deal dog close
22
 BIP-39 – Mnemonic Code for Generating Deterministic Keys
 BIP-32 – Hierarchical Deterministic Wallets (for Bitcoin)
 Seed  BIP32 extended private key  multiple private keys
 BIP-44 – Multi-Account Hierarchy for Deterministic Wallets
 Seed + coin type + account  BIP44 account extended private
key  multiple private keys
The BIP39, BIP32 and BIP44 Standards
seed = PKBDF2-HMAC-SHA-512(passwd = mnemonic_phrase,
salt = "mnemonic" + mnemonic_password,
iterations = 2014, keyLength = 512)
23
HD Wallets in JavaScript: From Mnemonics
let ethers = require('ethers');
let mnemonic = "summer silent settle explain cigar print
drift genius quarter smart subway humble";
let hdWallet = ethers.HDNode.fromMnemonic(mnemonic);
for (let index=0; index<5; index++) {
let key = hdWallet.derivePath(`m/44'/60'/0'/0/${index}`);
console.log(`Private key #${index}: ${key.privateKey}`);
}
24
HD Wallets in JavaScript: New HD Wallet
let ethers = require('ethers');
let rnd256Bits = ethers.utils.randomBytes(256 / 8);
let mnemonics = ethers.HDNode.entropyToMnemonic(rnd256Bits);
let hdWallet = ethers.HDNode.fromMnemonic(mnemonics);
console.log("Wallet mnemonics:", mnemonics);
console.log("Wallet private key:", hdWallet.privateKey);
for (let index=0; index<5; index++) {
let key = hdWallet.derivePath(`m/44'/60'/0'/0/${index}`);
console.log(`Private key #${index}: ${key.privateKey}`);
}
?
Crypto-Wallets: A Technical Perspective
https://softuni.org
License
 This course (slides, examples, demos, videos, homework, etc.)
is licensed under the "Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International" license
26
Trainings @ Software University (SoftUni)
 Software University – High-Quality Education,
Profession and Job for Software Developers
 softuni.org
 Software University Foundation
 softuni.foundation
 Software University @ Facebook
 facebook.com/SoftwareUniversity
 Software University Forums
 forum.softuni.bg

More Related Content

PDF
Blockchain Technology Fundamentals
PPTX
What is cryptocurrency - A complete Guide
PPTX
BITCOIN EXPLAINED
PPTX
Consensus Algorithms - Nakov @ jProfessionals - Jan 2018
PPTX
Blockchain Tutorial For Beginners - 2 | Blockchain Technology | Blockchain Tu...
PPTX
The Blockchain - The Technology behind Bitcoin
PPTX
Masterclass on Bitcoin, Ethereum & Cryptoassets
Blockchain Technology Fundamentals
What is cryptocurrency - A complete Guide
BITCOIN EXPLAINED
Consensus Algorithms - Nakov @ jProfessionals - Jan 2018
Blockchain Tutorial For Beginners - 2 | Blockchain Technology | Blockchain Tu...
The Blockchain - The Technology behind Bitcoin
Masterclass on Bitcoin, Ethereum & Cryptoassets

What's hot (20)

PPTX
Blockchain consensus algorithms
PPTX
Blockchain Explained | How Does A Blockchain Work | Blockchain Explained Simp...
KEY
Introduction to bitcoin
PPTX
Blockchain, Ethereum and ConsenSys
PDF
An Introduction to Blockchain Technology
PPTX
Crypto Currency
PDF
Vechicle collateralised loans
PPTX
Blockchain Technology
PDF
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
PPTX
Blockchain, Bitcoin, Mining - My Product School Presentation
PPTX
Develop a crypto wallet like Trust wallet
PPTX
Blockchain and Cryptocurrencies
PDF
An Overview of Stablecoin
PDF
Block chains & payment online
PPTX
Bitcoin
PDF
Basics of Zcash Cryptocurrency Protocol
PPTX
Introduction to Bitcoin's Scripting Language
PDF
ERC20 Step-by-Step - Creating Your First Ethereum Token
PDF
Distributed Ledger Technology (DLT) beyond blockchain #BlockchainSubmit
PPTX
Cryptocurrency
Blockchain consensus algorithms
Blockchain Explained | How Does A Blockchain Work | Blockchain Explained Simp...
Introduction to bitcoin
Blockchain, Ethereum and ConsenSys
An Introduction to Blockchain Technology
Crypto Currency
Vechicle collateralised loans
Blockchain Technology
Blockchain Explained | Blockchain Simplified | Blockchain Technology | Blockc...
Blockchain, Bitcoin, Mining - My Product School Presentation
Develop a crypto wallet like Trust wallet
Blockchain and Cryptocurrencies
An Overview of Stablecoin
Block chains & payment online
Bitcoin
Basics of Zcash Cryptocurrency Protocol
Introduction to Bitcoin's Scripting Language
ERC20 Step-by-Step - Creating Your First Ethereum Token
Distributed Ledger Technology (DLT) beyond blockchain #BlockchainSubmit
Cryptocurrency
Ad

Similar to Crypto Wallets: A Technical Perspective (Nakov at OpenFest 2018) (20)

PPTX
Client-Side Wallets in DApps - Nakov @ BlockWorld 2018 (San Jose)
PPTX
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
PPTX
Multi-Signature Crypto-Wallets: Nakov at SoftUnit Conf 2018
PPTX
EthereumBlockchainMarch3 (1).pptx
PPTX
Cryptography for Absolute Beginners (May 2019)
PDF
Metadata in the Blockchain: The OP_RETURN Explosion
PDF
10 Best Programming Languages for Blockchain in 2023.pdf
PDF
Wallet from noob to pro
PPTX
The Blockchain and JavaScript
PDF
Codetainer: a Docker-based browser code 'sandbox'
PDF
Hitcon badge 2018
PDF
New Business Models enabled by Blockchain
PPTX
Explain Ethereum smart contract hacking like i am a five
PPTX
Zoltán Balázs - Ethereum Smart Contract Hacking Explained like I’m Five
PPT
Security's Once and Future King
PDF
One library for all Java encryption
PDF
Blockchain, cryptography and tokens — NYC Bar presentation
PPTX
Kenneth simple bitcoinwebsite
PPTX
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
PDF
Getting Started in Blockchain Security and Smart Contract Auditing
Client-Side Wallets in DApps - Nakov @ BlockWorld 2018 (San Jose)
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
Multi-Signature Crypto-Wallets: Nakov at SoftUnit Conf 2018
EthereumBlockchainMarch3 (1).pptx
Cryptography for Absolute Beginners (May 2019)
Metadata in the Blockchain: The OP_RETURN Explosion
10 Best Programming Languages for Blockchain in 2023.pdf
Wallet from noob to pro
The Blockchain and JavaScript
Codetainer: a Docker-based browser code 'sandbox'
Hitcon badge 2018
New Business Models enabled by Blockchain
Explain Ethereum smart contract hacking like i am a five
Zoltán Balázs - Ethereum Smart Contract Hacking Explained like I’m Five
Security's Once and Future King
One library for all Java encryption
Blockchain, cryptography and tokens — NYC Bar presentation
Kenneth simple bitcoinwebsite
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
Getting Started in Blockchain Security and Smart Contract Auditing
Ad

More from Svetlin Nakov (20)

PPTX
AI and the Future of Devs: Nakov @ Techniverse (Nov 2024)
PPTX
AI за ежедневието - Наков @ Techniverse (Nov 2024)
PPTX
AI инструменти за бизнеса - Наков - Nov 2024
PPTX
AI Adoption in Business - Nakov at Forbes HR Forum - Sept 2024
PPTX
Software Engineers in the AI Era - Sept 2024
PPTX
Най-търсените направления в ИТ сферата за 2024
PPTX
BG-IT-Edu: отворено учебно съдържание за ИТ учители
PPTX
Programming World in 2024
PDF
AI Tools for Business and Startups
PPTX
AI Tools for Scientists - Nakov (Oct 2023)
PPTX
AI Tools for Entrepreneurs
PPTX
Bulgarian Tech Industry - Nakov at Dev.BG All in One Conference 2023
PPTX
AI Tools for Business and Personal Life
PDF
Дипломна работа: учебно съдържание по ООП - Светлин Наков
PPTX
Дипломна работа: учебно съдържание по ООП
PPTX
Свободно ИТ учебно съдържание за учители по програмиране и ИТ
PPTX
AI and the Professions of the Future
PPTX
Programming Languages Trends for 2023
PPTX
IT Professions and How to Become a Developer
PPTX
GitHub Actions (Nakov at RuseConf, Sept 2022)
AI and the Future of Devs: Nakov @ Techniverse (Nov 2024)
AI за ежедневието - Наков @ Techniverse (Nov 2024)
AI инструменти за бизнеса - Наков - Nov 2024
AI Adoption in Business - Nakov at Forbes HR Forum - Sept 2024
Software Engineers in the AI Era - Sept 2024
Най-търсените направления в ИТ сферата за 2024
BG-IT-Edu: отворено учебно съдържание за ИТ учители
Programming World in 2024
AI Tools for Business and Startups
AI Tools for Scientists - Nakov (Oct 2023)
AI Tools for Entrepreneurs
Bulgarian Tech Industry - Nakov at Dev.BG All in One Conference 2023
AI Tools for Business and Personal Life
Дипломна работа: учебно съдържание по ООП - Светлин Наков
Дипломна работа: учебно съдържание по ООП
Свободно ИТ учебно съдържание за учители по програмиране и ИТ
AI and the Professions of the Future
Programming Languages Trends for 2023
IT Professions and How to Become a Developer
GitHub Actions (Nakov at RuseConf, Sept 2022)

Recently uploaded (20)

PDF
advance database management system book.pdf
PDF
Empowerment Technology for Senior High School Guide
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PDF
Computing-Curriculum for Schools in Ghana
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PDF
Hazard Identification & Risk Assessment .pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
advance database management system book.pdf
Empowerment Technology for Senior High School Guide
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
UNIT III MENTAL HEALTH NURSING ASSESSMENT
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Indian roads congress 037 - 2012 Flexible pavement
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
Supply Chain Operations Speaking Notes -ICLT Program
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Unit 4 Skeletal System.ppt.pptxopresentatiom
Computing-Curriculum for Schools in Ghana
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Hazard Identification & Risk Assessment .pdf
Final Presentation General Medicine 03-08-2024.pptx
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Final Presentation General Medicine 03-08-2024.pptx
Orientation - ARALprogram of Deped to the Parents.pptx

Crypto Wallets: A Technical Perspective (Nakov at OpenFest 2018)

  • 1. Crypto-Wallets: A Technical Perspective Wallets, Keystores, HD Wallets, Technical Standards (BIP39, BIP32, BIP44), Mnemonics, JS Examples Software University (SoftUni) https://softuni.org Svetlin Nakov Blockchain Engineer and Technical Trainer crypto wallet
  • 2. 2  Software engineer, trainer, entrepreneur, PhD, author of 13 books, blockchain expert  3 successful tech educational initiatives (100,000+ students): About Svetlin Nakov
  • 3. 3  Technical advisor @ LockChain / LockTrip: https://locktrip.com  Raised ~ 10.000 ETH in token sale (Sep-Nov 2017)  Currently LOC token holders book hotels @ 20-30% better price  Head of blockchain education (Jan-June 2018) @ Academy School of Blockchain: https://academytoken.com  Raised ~ 48M USD in token sale (Jan-Apr 2018)  Tech advisor for blockchain crypto startups:  Tokenize Exchange, Bountie, Weidex, IRIS Payments Solutions, Aeternity Ventures Nakov – Blockchain & Crypto Projects
  • 4. 4 Book "Practical Cryptography for Developers" GitHub: https://github.com /nakov/practical- cryptography-for- developers-book Official site: https://cryptobook. nakov.com
  • 5. Table of Contents 5 1. Public Blockchains: Nano Introduction 2. Blockchain Wallets: Types, Functions, Concepts 3. Practice: Play with the Jaxx Wallet on the Ropsten Testnet 4. Simple Keystores: Encrypted Private Keys 5. Simple Keystores: JS Code Examples and Live Demo 6. HD Wallets: Mnemonics (BIP39), HD Wallets (BIP32, BIP44) 7. HD Wallets: JS Code Examples and Live Demo
  • 6. 6 Public Blockchains: Nano Introduction Distributed ledger Peer-to-Peer network Nodes hold ledger of facts + history of updates Decentralized (no owner) Secure Transactions are verified by the entire network Immutable
  • 7. 7 Blockchain == Chain of Data Blocks Demo: https://etherscan.io timestamp block_hash all_transactions_hash transaction #1 hash transaction #2 hash transaction #3 hash … Block #0 (genesis block) prev_hash nonce timestamp block_hash all_transactions_hash transaction #1 hash transaction #2 hash transaction #3 hash … Block #1 nonceprev_hash timestamp block_hash all_transactions_hash transaction #1 hash transaction #2 hash transaction #3 hash … Block #2 prev_hash nonce
  • 8. 8  Crypto wallet == software that stores private keys along with their respective blockchain addresses  Enables users to send and receive crypto currency / tokens  Communicates with the blockchain network (through API or by running a blockchain node)  Signs transactions and sends them to the blockchain network What is a Cryptocurrency Wallet?
  • 9. 9  Mobile wallet (mobile app)  Desktop wallet (desktop app)  Web-based wallet (web site)  Hardware-based wallet (USB stick, e.g. Ledger, Trezor)  Paper wallet (private key printed on a sheet of paper) Types of Crypto Wallets
  • 10. Practice Play with Jaxx Wallet and Ethereum
  • 11. 11 Install the Jaxx Wallet https://jaxx.io Jaxx Wallet Desktop / Mobile
  • 12. 12 Enable the Ethereum Testnet (ETHt)
  • 14. 14 Send ETHt to the People Around You
  • 15. Request test ethers (ETHt) from the Faucets  http://tiny.cc/ropsten-faucet  https://faucet.metamask.io  https://faucet.ropsten.be  http://faucet.bitfwd.xyz 15 Ethereum Testnet Faucets
  • 16. 16  Simple keystores  Example: myetherwallet.com  Keep a simple ECC private key, password protected  Similar to OpenSSH and OpenSSL PEM keystores (see PKCS#8)  HD wallets  Example: https://iancoleman.io/bip39  Hierarchical-deterministic (HD) wallet  Keep a mnemonic phrase (12 or 24 words)  Derive many private keys from the mnemonic Simple Keystores vs. HD Wallets
  • 17. 17 Simple Keystores: Encrypted Private Keys myetherwallet.com
  • 18. 18 JSON / UTC Keystore File – Example { "version": 3, "id": "…", "address": "2a90ef17a50f7e99387…c07fc", "crypto": { "ciphertext": "fa3315e31cba71df…2cd1", // the encrypted private key "cipher": "aes-128-ctr", // AES, 128-bit encryption, CTR mode "cipherparams": { "iv": "08c3f2ba1c…f6" }, // random initial vector "kdf": "scrypt", "kdfparams": { "dklen": 32, // key length (256-bit key for AES encryption) "salt": "d48231c94b90c03018bf9f4…a1e0", // random-generated salt "n": 1024, // iterations count (CPU + memory cost factor) "r": 8, // block size (affects CPU + memory) "p": 1 // parallelization factor (threads count) }, "mac": "b0ee3cd7e0564acea…49e3" // msg integrity / auth key } } Learn more at: https://github.com/ethers-io/ethers.js/blob/master/src.ts/utils/secret-storage.ts#L289
  • 19. https://github.com/ethers-io/ethers.js 19 Creating a Simple Keystore in JavaScript npm install --save ethers let ethers = require('ethers'); let newWallet = ethers.Wallet.createRandom(); console.log("Address: " + newWallet.address); console.log("Private key: " + newWallet.privateKey); newWallet.encrypt('P@SS~12345a').then(walletJSON => { console.log("Encrypted wallet JSON:", walletJSON); });
  • 20. 20 Simple Keystore from Private Key in JS let ethers = require('ethers'); let privKey = "0x0e210eff4fc77ff086d81d646c94af42ec5b1bbaf3f1d525f5bf5b82af7056da"; let existingWallet = new ethers.Wallet(privKey); console.log("Address: " + existingWallet.address); // Address: 0xe25ACB5AaE29c38DABdc13Ea41177Aba1191D323 const provider = ethers.providers.getDefaultProvider('ropsten'); provider.getBalance(existingWallet.address).then(balance => console.log('Balance:', ethers.utils.formatEther(balance)));
  • 21. 21 Mnemonics and HD Wallets (BIP39, BIP44)  HD wallets keep a securely generated random seed  And use a hierarchical deterministic (HD) key-derivation (see BIP-32)  The seed (root key) can be represented as 12 or 24 words, e.g.  Each word comes from a wordlist of 2048 words  1 word == 11 bits  24 words  256-bit entropy  512-bits seed (see BIP-39)  All private keys + addresses are derived from the seed (see BIP-44)  See https://iancoleman.io/bip39 to understand the idea in practice force moon book duck idle best sad net pelican deal dog close
  • 22. 22  BIP-39 – Mnemonic Code for Generating Deterministic Keys  BIP-32 – Hierarchical Deterministic Wallets (for Bitcoin)  Seed  BIP32 extended private key  multiple private keys  BIP-44 – Multi-Account Hierarchy for Deterministic Wallets  Seed + coin type + account  BIP44 account extended private key  multiple private keys The BIP39, BIP32 and BIP44 Standards seed = PKBDF2-HMAC-SHA-512(passwd = mnemonic_phrase, salt = "mnemonic" + mnemonic_password, iterations = 2014, keyLength = 512)
  • 23. 23 HD Wallets in JavaScript: From Mnemonics let ethers = require('ethers'); let mnemonic = "summer silent settle explain cigar print drift genius quarter smart subway humble"; let hdWallet = ethers.HDNode.fromMnemonic(mnemonic); for (let index=0; index<5; index++) { let key = hdWallet.derivePath(`m/44'/60'/0'/0/${index}`); console.log(`Private key #${index}: ${key.privateKey}`); }
  • 24. 24 HD Wallets in JavaScript: New HD Wallet let ethers = require('ethers'); let rnd256Bits = ethers.utils.randomBytes(256 / 8); let mnemonics = ethers.HDNode.entropyToMnemonic(rnd256Bits); let hdWallet = ethers.HDNode.fromMnemonic(mnemonics); console.log("Wallet mnemonics:", mnemonics); console.log("Wallet private key:", hdWallet.privateKey); for (let index=0; index<5; index++) { let key = hdWallet.derivePath(`m/44'/60'/0'/0/${index}`); console.log(`Private key #${index}: ${key.privateKey}`); }
  • 25. ? Crypto-Wallets: A Technical Perspective https://softuni.org
  • 26. License  This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" license 26
  • 27. Trainings @ Software University (SoftUni)  Software University – High-Quality Education, Profession and Job for Software Developers  softuni.org  Software University Foundation  softuni.foundation  Software University @ Facebook  facebook.com/SoftwareUniversity  Software University Forums  forum.softuni.bg

Editor's Notes

  • #9: a software program that stores private and public keys and interacts with various blockchains a program that enables users to send and receive digital currency and monitor their balance if you want to use Bitcoin or any other cryptocurrency you will need to have a cryptocurrency wallet