Note that this means that in the set {1,2,...,2700}, there are 2592 elements $a$ such that $gcd(a,2701) = 1$.

The value $\verb=phi_n=$, or $\phi(n)$, is a secret ingredient in the key generation process. Knowing $\phi(n)$ is actually "equivalent" to knowing the secret values $p$ and $q$ because of the relationship

$$\phi(pq) = (p-1)(q-1)$$

which holds whenever $p$ and $q$ are prime. To flesh things out a little bit more, we are saying that if we know

$$2592 = (p-1)(q-1)$$

and also that

$$2701 = pq$$

then these two equations in two unknowns can easily be solved to find $p$ and $q$.

In particular, we do $q = \frac{2701}{p}$ and then make this substitution in the first equation to yield

$$2592 = (p-1)(\frac{2701}{p}-1)$$

This equation, in turn, can be solved using the quadratic formula to give $p = 37$, from which point the value of $q$ is immediate via $q = \frac{2701}{p}$ .

Conversely, if we know $p$ and $q$ we can easily find $\phi(n)$. This is the sense in which knowing $\phi(n)$ is "equivalent" to knowing $p$ and $q$.

We have now arrived at a stage at which we can say what keys in RSA "really are". The public key in RSA is a pair of integers $(n,e)$ where $n$ is the modulus and $e$ is a value called the public exponent. There is some free choice in selecting $e$. For the math to work, we need only that $1 < e < \phi(n)$ and that $e$ and $\phi(n)$ are relatively prime.

For those who know a little group theory, the point of this condition on $e$ is to ensure that $e$ is a member of the multiplicative group of integers mod $\phi(n)$, and in particular that $e^{-1}$ exists.

In plain language, the condition guarantees that there is another number $d$ with $1 < d < \phi(n)$ such that $e\cdot d \equiv 1$ mod $\phi(n)$. In fact, the resulting $d$ not only exists, but is unique.

The number pair $(n,d)$ constitutes the private key in RSA. Note that the roles played by $e$ and $d$ are completely symmetric. The public key could be swapped for the private key, and all the constraints would still hold.

The following bit of code selects a public exponent $e$ through a random process. In a real implementation, $e$ would be selected slightly more carefully.