Public Key and Private Key are two important aspects of Bitcoin and cryptocurrency ecosystem. Public Key as the name suggests is Public i.e, it can be shared with anyone while the Private Key must be kept as a secret. The keys are used to encrypt your cryptocurrency wallets. You need both the keys to spend your Bitcoins while the Public Key is enough to receive funds from others.
To further understand, encryption is of two types: Asymmetric Encryption and Symmetric Encryption. Asymmetric encryption or public key cryptography uses two pairs of keys i.e, public and private keys to encrypt and decrypt data. The keys are simply unidentical large numbers that have been mathematically paired together.
Symmetric encryption is the oldest form of encryption where only one key is used to decrypt and encrypt messages. As long as both sender and recipient know the secret key, they can encrypt and decrypt all messages that use this key. The primary demerit of symmetric encryption is that it always requires a secure exchange of secrets to work.
Bitcoins and the other offshoots use asymmetric encryption to encrypt your wallets. Although both the keys are mathematically paired it is infeasible to guess the public key from a private key and vice-versa. In Bitcoin, a private key is a 256-bit alpha-numeric character. In the initial days of Bitcoin, a private key is simply an integer between One (1) and about Ten to the power of seventy-seven. Later an alternative called Wallet Import Format (WIF) has been devised. The private key under WIF is an alpha-numeric character which always starts with 5.
Example of a private key under WIF:
A public key as said earlier is derived from private keys by complex mathematical operations. A public key of a Bitcoin wallet always begins with 1.
Example of a public key:
As you can see from above the Private Key is the longer of the two. The private key generates a signature for every blockchain transaction. This signature helps to confirm that the transaction has come from the user, and also prevents the transaction from being altered by anyone once it has been issued. In layman’s terms, a public key is your bank account number while a private key is a password to access it.
So to spend Bitcoins from your wallet you need the public Key and the private Key. To make the system even more secure, the public key is hashed into another form called public address. Both public key and public address can be used receive funds.