Explainer Series: Asymmetric Encryption
I want to attempt to explain concepts that trip me up. Maybe this will become a series.
Asymmetric encryption — also known as public-key encryption — relies on mathematical functions to encrypt and decrypt data. This method involves 2 keys: a public key and private key.
The public key is an input for the encryption function, and the private key is an input for the decryption function. The diagram below outlines this:
![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff98f163f-28c7-46ee-9c86-0a63cfa6a4ff_1228x658.png)
Key Generation
The public key and private key are linked together and are generated from the same function.
The function used to generate a public key and private key work in a way that makes it computationally infeasible to determine the private key given only the public key.
Why is this computationally infeasible? The encryption function involves multiplying 2 big prime numbers together to make a very big number. The hypothetical reverse engineering function requires factoring that very big number back into the original 2 prime numbers — this is extremely difficult for computers today because of the many possible combinations.
Characteristics of public and private keys
Here are some important characteristics of public keys and private keys:
Public and private keys exist as key pairs
Each public key has its own corresponding private key
Public keys are shareable and are for encrypting messages
Private keys are not to be shared and are for decrypting messages that were encrypted using its corresponding public key
In the context of client-server communication, the client has a public-private key pair, and the server has it’s own different public-private key pair.
Pulling it all together
The below diagram outlines the process for a user securely communicating with a server. Note that the diagram references 4 separate keys (because there are 2 distinct key-pairs — one for the client, and one for the server).
![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63ffbc08-fca3-47ec-b2d5-a637ecd6d250_1492x778.png)
I hope this explainer gives you a functional overview of how asymmetrical encryption works at a high-level!