Back
Public Key and Private Key: How They Work and Pair Together
Shailee Adinolfi
&
Annie Pei
General Wallet Use
Public and private keys are cryptography codes that work together in crypto wallets to encrypt and decrypt transactions, verify identities, and validate transactions.
Understanding public and private keys is crucial for wallet users since they serve as the literal keys to your assets.
Public Keys vs Private Keys Explained
When you create an account on a crypto wallet, it generates a pair of public and private keys.
The public key is a cryptography-generated code that enables users to receive encrypted messages and transactions. It serves as a public wallet address that users can share with anyone to receive crypto in their account.
The private key is also a cryptographically generated code that enables users to decrypt messages or transactions with a corresponding public key. The private key serves as the proof of ownership of funds and thus used to sign transactions when sending money to someone.
As the name suggests, the private key should not be shared with anyone as it will mean losing control over the user's funds.
How are Public and Private Keys Generated?
The public key is generated from the private key using Public Key Cryptography (PKC) to encrypt and decrypt transactions.
PKC is a method for encrypting data with two different keys and making the public key available for everyone. Data encrypted with the public key can only be decrypted with the associated private key pair.
Since PKC uses two keys for verifying data authenticity, it is also known as asymmetric cryptography or encryption technology. PKC leverages the Trapdoor function, a mathematical concept that facilitates one-way functions but is almost impossible to do in reverse.
Thus, when public keys are generated from private keys, users know that no one can reverse-engineer a public key to find the private key.
Example of Public and Private Keys
In cryptography, keys scramble data into a random string of numbers and letters so that attackers cannot access sensitive information.
The unencrypted data, also known as plaintext, becomes a ciphertext or random-looking dataset when it is encrypted with a key. Thus, only the person with the right key can decrypt the ciphertext and put it back into its plaintext or original form.
Let’s take an example of symmetric cryptography where only one key is used to demonstrate the point.
Consider a plaintext message, “money” which is encrypted with a key “3be694aj”. After encryption, “money” now reads “H7Gx43kb02” which is random data or the ciphertext. However, if someone has the same key, they can decrypt the data to get the original message “money” back.
Plaintext + Key = Ciphertext
Money + 3be694aj = H7Gx43kb02
Ciphertext + Key = Plaintext
H7Gx43kb02 + 3be694aj = Money
However, crypto wallets use Public Key Cryptography (PKC) or asymmetric cryptography which consists of a public-private key pair. Thus, crypto wallets use a public key to encrypt data and a private key to decrypt data.
How Do Public and Private Keys Work?
Public keys allow users to receive transactions in their wallet thus making them comparable to bank account numbers. Users that are conducting a transaction with you can refer to this public key when they send and trade assets.
The crypto wallet address is actually a readable form of your public key.
However, private keys must always remain a secret to the user and must never be shared with anyone. The private key helps users prove that they own the assets involved in a transaction and authorize the transaction itself.
Since private keys represent user’s ownership over their funds, sharing your private key means essentially giving up control of your assets.
Additionally, users must remember that although a private key is similar to a password, it isn't like a password. Thus, private keys can’t be changed or retrieved if it gets compromised or lost.
Uses of Public and Private Key Encryption
The traditional computing industry has been using Public Key Cryptography (PKC) long before it came to be used in the cryptocurrency domain.
The public-private key encryption technology is used in websites to protect important user data like login information or credit/debit card details. It is also used for email encryption, connecting to remote servers, and Virtual Private Networks (VPNs).
In crypto, the public-private key pair’s most important use case is digital signatures. When someone sends crypto to a recipient wallet, the sender needs to sign the transaction with their private keys.
Benefits of Public and Private Keys Using Bitcoin
The primary benefit of using a public-private key pair while interacting with the Bitcoin network is to ensure safety for everyone.
The key pair helps in communicating between transacting parties in a trustless and secure manner, even if they don’t know each other. The public and private key offers data confidentiality, authenticity, and transaction integrity.
The private key ensures only the intended recipient decrypts the transaction and the counterparty’s details can be verified using the public key. Moreover, the key pair provides robust data encryption-decryption to prevent data tampering.
Differences Between Public and Private Keys
Although the public key is generated from the private key, they are not the same.
A public key:
Is a cryptographic code that is used publicly
Identifies the recipient of a transaction and used for receiving crypto securely
Can be shared with anyone to receive funds
Has no direct risk of exposure but it allows others to see incoming transactions on that wallet address
Whereas a private key:
A secret cryptographic code that is only known to the owner
Signs transactions to prove ownership of funds and authorize crypto transfers
Should never be shared with anyone
Exposure leads to a direct risk of losing control over the owner’s funds
How to Create Secret Key with Leather
The Secret Key is a randomly generated cryptographic key that protects a Leather user’s wallet and its assets. Leather’s Secret Key is a 24 word phrase and is popularly known as seed phrase or recovery phrase.
When you create a new wallet with Leather, the wallet automatically generates your Secret Key. Before finishing your account creation, you’ll be asked to back up your Secret Key to safeguard the account.
Remember that Leather is a self-custodial wallet and doesn’t store the Secret Keys or help users to recover their lost keys. Thus, users are responsible for the safe storage of their Secret Keys.
How To Store Your Private Keys?
You always need to keep your private key secure. The private key should never exist in digital form on any unsafe hardware like desktops or phones.
One of the best ways to secure your private key is using a hardware wallet like Ledger. These wallets offer robust key protection by keeping them in ‘cold storage’ which means they remain offline in encrypted physical devices.
Many users also store the private key on paper backups. These backups are often sealed in a secure location like a safe that only the user can access.