# How to store and use Bitcoin - The primary challenge is how to store secret keys - Goals: - Availability - security - convenience ## Simplest approach: store key in a file, on your device - Very convenient - As available as your device - device lost/wiped => key lost => coins lost - As secure as your device - device compromised => key leaked => coins stolen ## Wallet software - nice trick: use a seperate address/key for each coin - let wallet do the bookkeeping ### Encoding addresses - Encode as test string: base58 notation - QR code ## Hot storage / Cold storage - Hot storage: online - convenient but risky - Cold storage: offline - archival but safer ### Problem: - We want to use a new address (and key) for each coin sent to cold storage. But how can hot wallet learn new addresses if cold wallet is offline? - Hierarchical wallet ## Hierarchical key generation ![](https://i.imgur.com/Om6VhdL.png) ## How to store cold info 1. Info stored in device, device locked in a safe 2. encrptt info under passphrase that user remembers 3. Paper wallet: print info on paper, lock up the paper 4. In "tamperproof" device: device will sign things for youm but won;t divulge keys ## Secret sharing - Idea: split secret into N pieces, such that fiven any K pieces, can reconstruct the secret given fewer than K pieces, don't learn anything - Example: N=2, K=2 - P = a large prime - S = secret in [0, P) - R = random in [0, P) - split: - $X_1=(S+R)mod\ P$ - $X_2=(S+2R)mod\ P$ - reconstruct: - $(2X_1-X_2)mod\ P=S$ ![](https://i.imgur.com/UcMI4BH.png) - Good: store shares separately, adversary must compromise several shares to get the key - Bad: to sign, need to bring shares together, an d reconstruct the key ![](https://i.imgur.com/lFVH7P8.png) ## Proof of Reserve - Prove that the bank have at least X amount of reserve currency - By creating a transaction of X amount to itself - Prove that customers have at most Y amount deposited - By exploring the merkel tree - So reserve fraction $\ge$ X / Y ## Making a payment with Bitcoin ![](https://i.imgur.com/T4RKMkm.jpg) ## Transaction fees - transaction fee = value of inputs - value of outputs - fee goes to miner who create the block - ![](https://i.imgur.com/HLxoviq.png) ## Supply & Demand ![](https://i.imgur.com/NcFHLGF.png) ![](https://i.imgur.com/uKFS8NK.jpg)