The public exponent encrypts, and the private exponent is its modular inverse. The table recomputes d and the final inverse check from p, q, and e.

highlighted = computed this step

Why there are two exponents

RSA uses a public exponent for encryption and a private exponent for decryption. The table recomputes the private exponent as the inverse of e modulo phi.

ed1(modϕ)ed\equiv1\pmod{\phi}
Public and private exponentsRSA key derivation recomputed from the toy primes and public exponent.Public and private exponents - n=55quantityvaluep5q11n=p*q55phi=(p-1)(q-1)40e3d=e^-1 mod phi27e*d mod phi1

Choose the public exponent

The public exponent is e=3. It must be coprime to phi so an inverse exists.

e=3e=3
Public and private exponentsRSA key derivation recomputed from the toy primes and public exponent.Public and private exponents - n=55quantityvaluep5q11n=p*q55phi=(p-1)(q-1)40e3d=e^-1 mod phi27e*d mod phi1

Compute the private exponent

The private exponent is d=27, because it is the inverse of e modulo phi.

d=27d=27
Public and private exponentsRSA key derivation recomputed from the toy primes and public exponent.Public and private exponents - n=55quantityvaluep5q11n=p*q55phi=(p-1)(q-1)40e3d=e^-1 mod phi27e*d mod phi1

Check the inverse

Multiplying e and d gives 81, which is 2 times phi plus 1.

327=81=240+13\cdot27=81=2\cdot40+1
Public and private exponentsRSA key derivation recomputed from the toy primes and public exponent.Public and private exponents - n=55quantityvaluep5q11n=p*q55phi=(p-1)(q-1)40e3d=e^-1 mod phi27e*d mod phi1

Summary

The key check is e times d leaves remainder 1 modulo phi. Exact arithmetic on deliberately tiny toy keys; real RSA uses 2048+ bit primes with padding, and timing/side-channels are not modeled here.

edmodϕ=1ed\bmod\phi=1
Public and private exponentsRSA key derivation recomputed from the toy primes and public exponent.Public and private exponents - n=55quantityvaluep5q11n=p*q55phi=(p-1)(q-1)40e3d=e^-1 mod phi27e*d mod phi1