# Public-key cryptography

**Public-key cryptography** uses pairs of keys for encrypting and decrypting information. A public key for encryption and a private key for decryption. It is important to keep the private key safe and *private*, anyone with the key will be able to decrypt your information.

If I want to send you some information that only you will be able to decrypt, I can encrypt it using your public key. When you receive the information, you can use your private key to decrypt it.

If you loose your private key, there is no way to decrypt and retrieve the information and it is lost forever.

This is quite a different paradigm from the classic centralized authentication system using a username/email and password. In such a system there’s a central unit governing your security, and there are usually mechanisms to retrieve or reset a lost password.

It is probably unhelpful to compare a private key to a password, because lost passwords can usually be retrieved or reset. A lost private key cannot.

In the crypto-currency space, a private key is sometimes referred to as ‘a wallet’. When dealing with currencies or money, this analogy works quite well. It could even translate to identity (driver’s license, membership cards etc).

When you loose your wallet in real life, the contents is lost forever. But you’re usually able to get new copies of your driver’s license, your passport and your credit and debit cards. If you loose your private key, you probably won’t be able to restore what’s encrypted with it.

‘Public-key cryptography, or asymmetric cryptography, is a cryptographic system that uses pairs of keys. Each pair consists of a public key (which may be known to others) and a private key (which may not be known by anyone except the owner). The generation of such key pairs depends on cryptographic algorithms which are based on mathematical problems termed one-way functions. Effective security requires keeping the private key private; the public key can be openly distributed without compromising security.’

From Wikipedia

## References

https://www.scottbrady91.com/openssl/creating-rsa-keys-using-openssl

https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key

https://en.wikipedia.org/wiki/Public-key_cryptography