Rivest–Shamir–Adleman (RSA) Cryptosystem

RSA is a public-key scheme that turns a pair of large primes into a trapdoor for modular exponentiation.

Let and be distinct 512-bit (or larger) primes that are kept secret and set . Also, let be any number that is relatively prime to , such that . Then the public key is the tuple , and the private key is the inverse . Note that is guaranteed to exist since and are coprime.

With the keys in place, RSA communication reduces to two mirror-image steps:

  • The sender encrypts a message as the ciphertext .
  • The receiver decrypts by computing .

The security of RSA hinges upon the fact that and are kept private by the correspondents. Given only , and , there is no efficient algorithm to compute .

Correctness

The premise of RSA boils down to one simple fact:

  • For every possible message , it holds that .
    We will now go ahead and prove this fact using Fermat’s Little Theorem, described in 4.2. We restate it here for convenience:
  • Fermat’ Little Theorem: For all primes , if , and for all .

Examples

(Very Easy) RSA Warm-Up

Consider an RSA scheme with modulus , where and are distinct prime numbers larger than .

Now suppose that , , and .

(Easy) RSA Security with Multiple Keys

A secret society repeatedly sends the same secret (with ) using RSA keys that all share the same exponent but have pair-wise distinct moduli . Eve hears every ciphertext and the public keys; she knows the RSA setup but cannot factor large numbers.

Eve observes two keys and and their own distinct messages and , where are 1024-bit primes.

The secret society sniffs Eve out and switches to a new word and to three keys , , with six distinct primes and three distinct messages . 

Now, assume the secret stays the same and the public exponent is still .

(Medium) RSA for Concert Tickets

Alice’s concert ticket number is an integer . She wishes to tell Bob this number over an insecure channel that Eve can monitor, but she does not want Eve to learn .

Bob first announces his RSA public key, which consists of a 512-bit modulus and an exponent . Alice encrypts her ticket number with and transmits the resulting ciphertext to Bob. Eve sees the encrypted message, and she is able to deduce .

Alice now adopts a more elaborate approach. She chooses a random 256-bit integer that is coprime to . She then sends Bob two separate ciphertexts, both encrypted with the same public key as before . The first ciphertext is , and the second ciphertext is . Eve knows the protocol in use and can observe both and but she does not know the value of .

(Hard) RSA with CRT Optimization

Alice wants to decrypt faster, so after generating an ordinary RSA key with private exponent , she pre-computes the reduced exponents:
  Given a ciphertext from Bob, she also forms the expressions:

a

Start out by expressing , and per CRT there is a unique such that and .

Similarly, we can express which is recovered using , and per CRT this becomes and ,

Now, to evaluate and , notice that

RSA with Just One Prime