Understanding the Role of Public and Private Keys in Encryption and Cryptocurrencies

What is Private Key?

A secret or a cypher used to encrypt and decrypt message between two parties is a Private Key.

For practical purposes a private key is an extremely large random number.

If the same key is used for encryption and decryption then it is called symmetric encryption.

If one key is used to encrypt the message, and another to decrypt the message then it is called asymmetric encryption.

In the context of Cryptocurrencies, a private key is a secret number that permits the expenditure of the coins.

A cryptowallet contains private keys saved in the wallet file.

How does a Private Key Work?

Alice and Bob share a secret key.

When Alice wants to send Bob a message, she ecrypts with the secret key, and then sends it across.

When Bob wants to read the message, he decrypts with the same key, converts the encrypted key into plain text and reads the message.

What is a Public Key?

A public key like the private key is a large number used to encrypt or decrypt data.

A public key can be generated by a software program, but usually they are made availabe from a certificate authority through a publicly accessible directory.

The public key is often held on a public key infrastructure server and is used to secure data transmission over the internet.

Public keys in the context of cryptocurrencies are used to challenge ownership of coins.

How does a Public Key Work?

Asymmetric encryption is the foundation of how public key works. Both a public key and a private key are necessary for the operation of an asymmetric encryption.

The message is encrypted by the messenger using the public key, and the message is decrypted by the recipient using their private key. Only the owner of the appropriate private key can decode the message, guaranteeing security. As a result, even if a third party has access to the information, the data is still private.

Let us simplify with the following example :

Alice wants to receive message from Bob.

Alice creates a private-public key pair.

She keeps the private key to herself, and sends the public key to Bob.

Bob encrypts his message with public key, and sends it over to Alice.

Alice uses her Private key to decrypt the message and read it.

What is the difference between Public Key and Private Key?

Imagine a safe which has two keys. One key is used for locking, and another for unlocking. Public key is the one used to lock the safe and private key is used to unlock the safe.

As the name implies public key is open to all. The private key remains private.

Both public and private keys are very large random numbers, the only relation between them is that, whatever has been encrypted by the public key, will be decrypted by the private key of the pair only. Hence, Public key is used to encrypt data before sending. Private key is used to decrypt data after receiving.

The mailbox analogy further simplifies the concept of public and private key. The address of the mailbox is open to all and anyone can access it to drop a mail. This is the public key.

The mailbox however needs a special key to open it. The key that can open the mailbox is the secret key. The secret key ensures protection of the mails in the mailbox. Together these keys ensure the security of the exchanged data.

How to generate Public Key and Private Key? Some well-respected ways to generate key pairs are Rivest-Shamir-Adleman (RSA) algorithm, Digital Signature Standard (DSS), or elliptic curve cryptography.

Some well-respected examples of public private key encryption are RSA, DSS (Digital Signature Standard) and various elliptic curve techniques.

How can Public Private Key Pair be used to generate Digital Signature? The purpose of a digital signature is to verify the authenticity of a source or person.

For instance, When Alice receives a message from Bob, it is Bob who has sent her a message.

Also that, When Bob wants to send a message to Alice, it is not Mike impersonating Bob, who sends the message to Alice.

Public and Private keys can be used to create digital signature.

Let us understand with an example :

When Bob wants to send message to Alice.

Bob uses his private key to sign the message.

He then uses Alice’s public key to encrypt the message.

When Alice receives the message.

She uses Bob’s public key to validate the signature on the message.

She further uses her private key to decrypt the message and read it.

The message in transit passes through the exchange servers, but since they do not have the private key, they can’t read the message.

What are examples of Public Private Key Encryption? The basis of public-private encryption is asymmetry. One would need the private key to decrypt that which has been encrypted with the public key.

Sending message relies on signing with public key.

Digital signature relies on signing with private key.

In recent years secure messaging tools have implemented end to end encryption for voice, video, chats and file sharing. These tools make it difficult for the eavesdroppers and service providers to listen to the message.

PGP is another example of symmetric and asymmetric cryptography.