Vinit Gupta

Posted on

# Blockchain Basics : Public Key Cryptography

We have a basic idea of what encryption is.
Simply put :

Encryption is the conversion of data from a readable format into an encoded format

But how is this encryption done and what is the process of converting this encoded data into the actual data that is needed?

There have been a few ways of doing this. The oldest known way is the Caesar Cipher.

## Caesar Cipher

Yes, we are talking about that Democratically elected Dictator of Rome.
Yes, this method is more than 2000 years old.

In a Caesar Cipher, a character is assigned a numerical value and then rotated by a certain number of times.

For example, if I was Julius Caesar and tell my army to attack at sunrise, I have to send : `ATTACKATDAWN` order to my general.
But if I have an informer for the opposite side my army, he might intercept my message and alarm their army.

What I do is convert the above message to numbers from 1-26 and add 3 to each number and then convert to characters, I have the message : `DWWDFNDWGDZQ`

For someone else looking at this, he would think I have gone mad.
But if the general knows how to decode this message, and only he knows this secret, I have no risk of information leaking.

And I win the war!

But wait, after 2000 years and having such fast computers, isn't is easily breakable?

Well, yes it is. And Caesar Cipher is no longer used. 🛑

## Symmetric Key Encryption

Caesar Cipher is the earliest example of a Symmetric Key Encryption algorithm.
In symmetric key encryption, there a single key that is used to code and decode the message.
This key has to be shared to the receiving end as well. So, we need a secure channel to pass this key. But there are no secure channels.

This is why it is less secure ❌.

## Asymmetric Key Encryption

Asymmetric key encryption is another name for public key encryption, which encrypts and decrypts data using two separate keys. These two keys are a pair and have a mathematical connection. This process is referred to as asymetric key encryption. This serves as END-TO-END encryption in Whatsapp.

In asymetric encryption, the private key is kept by the person who produces both of these keys, but the public key is accessible to everyone.

The process for public key encryption is as follows:

• A public key created by the receiver has been stored in a server database.
• The recipient lets the sender know where to find the public key.
• The message is encrypted by the sender and sent to the recipient using the public key.
• The recipient obtains the plaintext message by using the private key to decode the message.