# Calculating private keys in the RSA cryptosystem

The number $43733$ was chosen as base for an implementation of the RSA system. $M=19985$ is the message, that was encrypted with help of a public key $K=53$.

What is the plaintext text? What is the private key?

So far, my calculations are:

1. $n=pq$
2. $n=101*433$
3. $\phi(43733) = (101 − 1)*(433 − 1) = 43200$.
4. The public key is $(n = 43733, e = 53)$.
5. The private key is $(n = 43733, d = 12343)$.

However, I'm not sure if this is right? Where am I going wrong?

• How are you calculating d? It should satisfy d*e = 1 (mod phi), but (53 * 12343) % 43200 = 6179.
– Omri Barel
Jan 20 '12 at 19:25
• Most of all I`m not sure i understood the meaning of K=53, Public key is (n,e). e have to be: 1 < e < 43200. So that meaning that K=e? or K=(n, e)?
– Dima M
Jan 20 '12 at 19:36

The public key is $K = e = 53$, already given. $n$ (the modulus) must also be given, so you could say that $(e, n)$ is the actual key.

The private key is $d$ which must satisfy $d * e = 1 \mod \phi(n)$. So you're looking for $d$ for which $(53 * d) \mod 43200 == 1$. A quick brute-force search (with such small numbers it's not a problem) reveals that $17117$ satisfies this equation.

Now $N=43733$, and you're guaranteed that $(M^e)^d = (M^d)^e = M \mod n$.

Your message is $M=19985$:

• $19985^{53} \equiv 17195 \mod 43733$

• $17195^{17117} \equiv 19985 \mod 43733$

This shows that you can encrypt using the public key and decrypt using the private key. The opposite also works (for signing the message):

• $19985 ^{17117} \equiv 125 \mod 43733$

• $125 ^{53} \equiv 19985 \mod 43733$

There are better ways to find $d$ from $e$ if you know $\phi(n)$. But if you don't, you're in trouble, because you need to factorise $n$ to do that.

• Actually it is not strictly necessary that $d*e = 1 \mod \phi(n)$; it suffices that $d*e = 1 \mod (p-1)$ and $d*e = 1 \mod (q-1)$, which is a bit less restrictive. Here, this implies that $d = 17 \mod 100$ and $d = 269 \mod 432$. The smallest matching value is $d = 6317$, which can be verified to do the RSA thing properly -- and yet, it does not fulfill the $d*e = 1 \mod \phi(n)$ equation. Jan 22 '12 at 2:31