Public and Private Keys in Bitcoin
There are several cryptic terms such as private keys, public keys, mnemonic sentences, seed phrases, etc. However, if you haven’t dealt with crypto, it would be a bit confusing with the terms. But this page hopes to give you the solid foundational knowledge of cryptic terms viz., public and private keys.
What are public and private keys?
Public and private keys make up public-key cryptography. In general, ‘private’ keys are used to encrypt data; while ‘public’ key is used to decrypt the data. Public and private key cryptography has been used in many applications and networks such as End-to-End (E2E) encryption which is used in messaging applications like Signal.
Private Key
In Bitcoin, the private key is used to prove unique ownership of your bitcoins. The key is used to create the signature which authorizes the spending of the funds, and the key should be kept secret at all times. While anyone can view bitcoin funds, only those with the unique private key can spend them.
Without the private keys, you will not have any control over anything. Therefore, allowing someone else to custody or hold the private keys to your funds (like centralized exchanges do), means you own ‘ZERO’ bitcoins.
“Never ever share your private keys with anyone”
Public Key
While private keys are used to ‘spend’ your funds, public keys are used to ‘receive’ funds.
Now the flow-Public keys are generated from the private keys, and then from that public key a ‘bitcoin address’ is generated. This is where the funds are then sent to in the Bitcoin network. Public keys can be shared with anyone and do not need to be kept secret. And it is important to note the important property of private/public key pair allows easy creation of public key from the private key, but not the reverse. In other words, the ‘reverse engineering’ of creating private keys from public key is not at all possible.
How are public and private keys generated in Bitcoin?
A bitcoin private key is as large as 256 bits, randomly generated number. The industry standard uses a secure random number generator, known as ‘entropy’ to generate private key. Entropy is a scientific concept that is most commonly associated with a state of disorder, randomness, or uncertainty.
For instance, a truly random set of binary numbers generated, using sufficient amount of entropy can be seen below:
…10110110101010101011011010101111010101101011101011………
These number are then split into groups of 11 bits and converted to decimal numbers as follows:
…900 1202 689 1586 604 1390………
Those decimal numbers are then used to select the corresponding word from the standard BIP39 wordlist:
… today Monday tiger lion punch them … …
This group of 12 or 24 words is known as ‘mnemonic sentence’ or ‘seed phrase’, and this mnemonic sentence is actually shown to the user by the Bitcoin Wallet software.
NOTE: - NEVER LOSE THE WORD/MNEOMIC SENTENCE AND ENSURE YOU TAKE THE BACKUP OF THIS WORD, IN CASE YOU DEAL WITH THE BITCOIN.
BIP describes the implementation of a mnemonic code or mnemonic sentence -- a group of easy to remember words -- for the generation of deterministic wallets.
Bitcoin Private Keys
Once any bitcoin wallet has your mnemonic sentence, it continues to derive even more keys. The mnemonic sentence generates the ‘Master Extended Key (MEK)’. The MEK is also referred to as your Private Keys (as it contains your Private Key + the Chain Code) and is often confused with the mnemonic sentence. Thus, it is important to note that Mnemonic Sentence is used to generate the MEK. The MEK then is used to generate private key (also called Master Node) which is then used to generate unlimited private/public key pairs. Though this is very complex, we, the users are lucky to have given the task of ‘remembering and backing up those 12 or 24 words or the mnemonic sentence’.
Your private keys will be represented as either 12 or 24 words and should be in your wallet software. The wallet software should be able to display you the private keys anytime. For example, Sparrow Wallet can be used to display the keys.
If you have a hardware wallet, then your software should be able to display your private keys on the device itself.
In the world of Bitcoin network, private key is used to ‘spend’ your funds while public keys are used to ‘receive’ funds. When someone wants to send the fund, their wallet takes their private key and signs the transaction. Since the private key is owned by this very person (someone), the Bitcoin network knows that the this ‘someone’ is authorized to spend those funds.
The wallet broadcasts the transaction to the network for the confirmation. The confirmation/validation is carried out by the process of ‘mining’, and once the transaction is confirmed, the funds are ‘spent’. The transaction once confirmed, the funds are in the ownership of the new private key (the receiver).
Example: -
1. Yonten wants to send 0.5 BTC to Karma
2. Yonten enters Karma’s Bitcoin Address (derived from Karma’s public key) into his wallet to send the BTC
3. Yonten’s wallet signs the transaction with his private key and broadcasts it to the network
4. If Yonten’s signature is valid, the Bitcoin Network accepts the transaction and the 0.5 BTC will now be owned by Karma
Note: It is to be noted that the ‘wallet’ will not contain/store any bitcoins. The Bitcoins only exist on the Bitcoin Network, while wallet holds your private/public keys.
Will review your comment and get back!