Asymmetric Cryptography: Public and Private Keys

1
0

Introduction

Asymmetric cryptography is a cryptographic technique that uses two related keys: a public key and a private key. It is also called public key cryptography because one key can be shared openly, while the other key must remain secret.

Unlike symmetric encryption, both parties do not need to share the same secret key beforehand. This makes asymmetric cryptography extremely important for secure communication over public networks.

Public Key and Private Key

Every user or system in asymmetric cryptography has a key pair.

  • Public key: Can be shared with anyone.

  • Private key: Must be kept secret by the owner.

  • Key pair: The public key and private key are mathematically related.

  • Security idea: Knowing the public key should not reveal the private key.

For example, if Bob wants people to send him secure messages, he can share his public key openly. Anyone can use Bob’s public key to encrypt data, but only Bob’s private key can decrypt it.

How Asymmetric Encryption Works

Asymmetric encryption is mainly used to provide confidentiality. It ensures that only the intended receiver can read the message.

A simple encryption flow looks like:

  • The sender starts with plaintext.

  • The plaintext is encrypted using the receiver's public key.

  • The encrypted data becomes ciphertext.

  • The ciphertext is decrypted using the receiver's private key.

  • The receiver obtains the original plaintext.

Suppose Alice wants to send a secret message to Bob. Alice encrypts the message using Bob’s public key. The encrypted message travels across the network as ciphertext.

Even if an attacker captures the ciphertext and knows Bob’s public key, the attacker still cannot decrypt the message. Only Bob’s private key can recover the original plaintext.

Asymmetric Encryption

Asymmetric Encryption

Why Encryption Alone Is Not Enough

Encryption protects secrecy, but it does not automatically prove who sent the message. Since Bob’s public key is available to everyone, an attacker can also use Bob’s public key to encrypt a message and send it to Bob.

Bob will be able to decrypt the message, but he still needs to know whether it actually came from Alice or from someone pretending to be Alice.

This is where digital signatures become important.

Digital Signatures and Verification

Digital signatures use asymmetric cryptography for authentication and integrity. Instead of using the receiver’s key pair, signing uses the sender’s key pair.

A simple signature flow looks like:

  • A hash of the message is generated.

  • The hash is signed using the sender's private key.

  • The digital signature is created.

  • The signature is verified using the sender's public key.

The sender signs the message using their private key. The receiver verifies the signature using the sender’s public key.

  • Authentication: Proves who created the signature.

  • Integrity: Helps detect whether the message was changed.

  • Non-repudiation: Helps prevent the sender from denying the signed action later.

If Alice signs a message using her private key, Bob can verify it using Alice’s public key. Since only Alice should have Alice’s private key, a valid signature gives Bob confidence that the message came from Alice and was not modified.

Encryption vs Digital Signature

Feature

Encryption

Digital Signature

Main Purpose

Confidentiality

Authentication and integrity

Key Used First

Receiver’s public key

Sender’s private key

Key Used Later

Receiver’s private key

Sender’s public key

Main Question Answered

Can only the receiver read it?

Did the real sender create it?

Simple Meaning

Protect secrecy

Prove identity

A simple way to remember it is: encryption protects the message, while signing proves the sender.

Public Key Verification and PKI

Public keys can be shared openly, but they still need to be trusted. If a user receives the wrong public key and assumes it belongs to a trusted server, communication can become unsafe.

For example, if a browser thinks it has received a bank server’s public key but actually receives an attacker’s public key, the browser may encrypt sensitive data for the attacker.

Public Key Infrastructure, or PKI, helps solve this trust problem. PKI uses digital certificates, Certificate Authorities, and certificate chains to connect a public key with a verified identity.

  • Certificate: Connects a public key to an identity such as a domain or organization.

  • Certificate Authority: A trusted entity that signs and issues certificates.

  • Chain of trust: A verification path used to decide whether a certificate should be trusted.

This is why HTTPS relies on certificates. The browser must verify that the public key really belongs to the website it is connecting to.

Symmetric vs Asymmetric Cryptography

Aspect

Symmetric Cryptography

Asymmetric Cryptography

Keys Used

One shared secret key

Public key and private key pair

Speed

Faster

Slower

Key Sharing

Secret key must be shared safely

Public key can be shared openly

Common Use

Bulk data encryption

Key exchange, certificates, signatures

Examples

AES, ChaCha20

RSA, ECC

In real systems, both are often used together. Asymmetric cryptography helps establish trust or exchange keys, and symmetric encryption is then used for fast data transfer.

Summary

Asymmetric cryptography uses a public key and private key pair instead of one shared secret key. The public key can be shared openly, while the private key must remain protected.

It provides two major functions: encryption and decryption for confidentiality, and digital signatures with verification for authentication and integrity. Since public keys must be trusted before use, PKI, certificates, Certificate Authorities, and chains of trust play an important role in secure systems such as HTTPS, TLS, and digital identity.

CS Core

Read Similar Blogs

Comments0