Multiplying two primes
\begin{equation} 7 \times 13 = 91 \text{(Easy)} \end{equation}
Factoring a product of two primes
\begin{equation} a \times b = 68 \text{(Hard)} \end{equation}
Modulus is the remainder
Like a clock
\begin{equation} 13 \mod 12 = 1 \end{equation}
\begin{equation} 16 \mod 12 = 4 \end{equation}
Doing reverse is hard
\begin{equation} a \mod 10 = 5 \end{equation}
what is a?
5, 15, 25, 55, 105, or 900000005?
Choose two distinct prime numbers
\begin{equation}
p=61
\
q=51
\end{equation}
Compute n = pq
\begin{equation} n = 61 \times 53 = 3233 \end{equation}
Compute the Carmichael’s totient function of the product as λ(n) = lcm(p − 1, q − 1)
\begin{equation} \lambda(n) = \text{lcm}(60, 52) = 780 \end{equation}
Choose any number 1 < e < 780 that is coprime to 780. Choosing a prime number for e leaves us only to check that e is not a divisor of 780.
\begin{equation} e = 17 \end{equation}
Compute d, the modular multiplicative inverse of e (mod λ(n))
\begin{equation}
d \times e \mod \lambda(n) = 1
\
413 \times 17 \mod 780 = 1
\end{equation}
public key is (n = 3233, e = 17), with message m, encryption function is
\begin{equation}
c(m) = m^{17} \mod 3233
\
c = 65^{17} \mod 3233 = 2790
\end{equation}
private key is (n = 3233, d = 413), with ciphertext c, decryption function is
\begin{equation}
m(c) = c^{413} \mod 3233
\
m = 2790^{413} \mod 3233 = 65
\end{equation}