uses public key to encrypt and private to decrypt. anyone can encrypt but only someone with the private key can decrypt

basically, anyone can send me a message securely

very expensive

used in https handshake (not transport though, switches to symmetric encryption)

walkthrough

Step 1: Key generation (done by Bob)

Bob secretly chooses two primes:

Compute:

Compute Euler’s totient:

Choose a public exponent:

Find a private exponent such that:

One solution is:

Keys:

  • Public key:
  • Private key:

Bob publishes and keeps secret.


Step 2: Encryption (done by Alice)

Alice wants to send the message:

She encrypts using Bob’s public key:

Compute:

So the ciphertext is:

Alice sends 13 to Bob.


Step 3: Decryption (done by Bob)

Bob decrypts using his private key:

Evaluating this (via modular exponentiation) yields:

The original message is recovered.


Why This Works (Short Theory Note)

The exponents and are chosen so that:

This means there exists an integer such that:

Because of this structure, exponentiating by and then by returns the original message:

The critical point is:

  • Computing requires knowing
  • Computing requires factoring into and
  • Factoring large is computationally infeasible

So:

  • Anyone can encrypt using
  • Only the holder of can decrypt

This is the core asymmetry behind RSA.