# How to build a Crypto wallet
Repo: https://github.com/Rashmi-278/crypto-wallet
This is a basic wallet which aims to demonstrate simple features of a blockchain wallet
Spec is just trying to figure out how would you be implemeting the project in detail and noting it down.
Features:
- [x] - Generating keys
- [ ] - Signing messages
- [ ] - Verifying signatures
- [x] - Encrypting messages
- [x] - Decrypting messages
- [ ] - Compatible with Bitcoin (optional)
- [ ] - Compatible with Ethereum (optional)
- [ ] - HD wallet (optional)
## Implementation guide
#### Deterministic wallet
We will generate a random seed phrase for ex: "little red riding hood was eaten by bad fox"
this seed phrase will be used to generate a key.
#### Wallet UI
Desktop wallet with React/Nextjs frontend
#### Blockchain network and compatible
Ethereum network compatible along with Rinkerby testnet
Generating keys would e done with a crytograpic hash function , AES-256 or SHA-256
Signing messages is done implementing public-private key exchange
Encrypting and decrypting messages
## Blog
The merit is of the cryptography, in particular of the concept of the hierarchical deterministic wallet, which, thanks to the use of some mathematical functions, allows users, starting from the seed, to recover everything. In fact, it translates the seed into a Master Key, from which all the other keys will be derived in a deterministic order. Just as in the real world you are not bound to the use of a certain calculator to perform a mathematical operation, not even the seed is therefore bound to the specific software of a given wallet.
To build a cryptowallet , we need to learn about deterministic wallet cryptography
Here's an article https://www.investopedia.com/terms/h/hd-wallet-hierarchical-deterministic-wallet.asp
BIP stands for bitcoi impromentation protoccol
Understanding pubic ad private key


img src : https://www.youtube.com/channel/UCV11h-065WhqTDgHmyWiJDw/videos
http://bip32.org/
https://wolovim.medium.com/ethereum-201-mnemonics-bb01a9108c38
eth keys
https://wizardforcel.gitbooks.io/practical-cryptography-for-developers-book/content/digital-signatures/ecdsa-sign-verify-examples.
BIP 32 is used by Bitcoin, Ethereum, and other blockchains for creating not just one key pair from that seed, but rather virtually unlimited accounts — all of which can be recovered with just one mnemonic sentence or seed.
BIP 44 standardizes a path to describe the intention of a particular account. This will end up influencing how child keys are derived.
### Draft Article
alright, today we will be implementing a crypocurrency wallet
Cryptocurrency wallets that we know and use today are deterministic wallets, to be specific hierachical deterministic wallets, it means that we have one unique 15/12 word seed pharse which we use to generate our account on blockchain.
You can consider this similar to opening a bank account at a bank, execpt you are the person who manages all the bank operations of that account you created.
In-order to understand how to build a crypto wallet you need to know basics of blockchain and a bit of cryptography
Let me point you to some great resources where you can learn em, but dont worry we will be explaining concepts in detail as possible, so if you think you are familiar with the concepts, feel free to skip em.
[Blockchain basics](https://andersbrownworth.com/blockchain/)
[Practical cryptography for developers](https://wizardforcel.gitbooks.io/practical-cryptography-for-developers-book/content/)
When creating a wallet, we use public-private key cryptography and hashing functions.
we create a public and private key pair by using BIP39 mechanism, this uses eliptic curve cryptogrpahy to generate a private key and public key.

The cool part about this key pair is that we can derive public key using private key but not vice versa.

...... Practical implementation
Use web3.js to build an wallet.
Step 1 : implement
BIP 39 — “Mnemonic code for generating deterministic keys”
use https://github.com/bitcoinjs/bip39
step2 :
BIP 32 — “Hierarchical Deterministic Wallets”
use https://github.com/bitcoinjs/bip32
step3:
BIP 44 — “Multi-Account Hierarchy for Deterministic Wallets”
step4: use the geneated key to import wallet using web3.js
and implement sign transactions
another lib we can use to implement is hdkey lib
https://github.com/duyptit28111995/react-native-hdkey/blob/f37bc5254de08347c1c34bc7e6380f0bdd211b93/README.md
http://bip32.org/ for ref implementation
