There is no concept of traditional wallets in blockchain as it has no balance values, there is just list and list of transactions. But when you login into your cryptocurrency wallet you see a balance value suppose 0.5 BTC, in your bitcoin wallet.
Now the question is where does this balancing amount come from is there any centralized system? does wallet store balance? The answer is “No”, wallet what does is that it basically calculates the total UTXO’S that is available to you and shows it as your balance.
Let’s understand how it happens for calculating your leftover UTXO’S a wallet will need to go and scan into blockchain for UTXO’S. Wallet goes into blockchain and scan for UTXO’S directed at you and then it filters out the UTXO’S that are not directed or given to anyone i.e, it filters out UTXO’S which are not spent by you and adds all those filtered out UTXO’S and shows it as your final balance.
In blockchain money does not exist like numbers as we see in banks rather it exists as a combination of UTXO’S that you have available to you.
Private and Public Keys
Now the question comes of privacy from what we learned till now we can clearly raise a question that anyone can impersonate anyone’s identity, let’s say “my identity” anyone by going into blockchain can calculate my UTXO’S and initiate a transaction but that does not happen right, we will see now why that does not happen in practical.
Privacy in blockchain is ensured by private and public keys they are the reason why someone cannot impersonate your identity. when you start in cryptocurrency you are assigned a private key that is like your unique identifier you are not supposed to tell your private key to anyone, and from you private key you can generate your public key which is like address of your wallet that you need to share to someone who is sending you cryptocurrency so a public key is like a bank account number.
How Private and Public keys work?
Suppose you want to send someone BTC, so you need to initiate transaction in frontend but in backend what happens is that your private key is combined with your transaction to produce a signature so basically private key is used to sign the transaction or message, and since only you know the private key as it is unique therefore signature is also unique, the transaction or message travels together with the signature now when someone encounters your transaction the only question left for them is to how to verify that it was you who was using your private key and has made this signature, that’s where the public key comes into the picture, In every blockchain there is a verification function in its algorithm in which when someone who has these three things public key, transaction and signature and when they put these three things into verification function it spits out yes/no if it is “yes” it means transaction is valid and done by you and if it is “no” it means someone else is trying to impersonate you. one more important thing to note here is that from public key you can not reverse engineer private key.
Bitcoin address vs Public key
Bitcoin address is basically the public key gone through the hashing function anyone who wants to send you bitcoins can send it to you either by your public key or by your bitcoin address, this hashing of public key is done to provide an extra layer of security to your public key.
Hierarchically Deterministic (HD) Wallets
Now if you send someone bitcoins they know your public key and by knowing your public key they can trace and track your activities by going and seeing transactions done your public key on blockchain, so to counter this there is a concept of “HD” wallets aka Hierarchically Deterministic wallets, what these wallets do is that they give you a master private key using which you can generate numerous pairs of private and public keys, this adds an extra layer of privacy as when you use different pairs of private and public keys it will become impossible for anyone to track or monitor you, these also helps organizations as they can give different pairs of private public keys to different department and when they want to analyze transactions of them separately they can easily do it and when they want to analyze departments as a whole they can do it by using master public key. Generally all wallet providers gives its user 12 words mnemonics to remember and keep it as a secret as it used to the generate the master private key.