For example, let $p = 3$ and $q= 11$, choose $e = 3$. What computation I have to apply in order to find the corresponding $d$? I know it's 7, but I want to know the exact process to be applied to find it.

  • 2
    $\begingroup$ There are an incalculable number of threads on this site alone, let alone the whole internet, that address the process of deriving $d$ from $e$. Have you tried searching for them? Hint, there are at least two in the related questions list on the right. $\endgroup$
    – Thomas
    Aug 3, 2015 at 11:29
  • 2
    $\begingroup$ This is not exactly a duplicate because the linked question does not address how $d$ is found (only which property it satisfies). I think a good answer to this question should mention the extended Euclidean algorithm. Maybe it would be a good idea to add it to the answer in the linked question... $\endgroup$
    – fkraiem
    Aug 3, 2015 at 12:34
  • $\begingroup$ @fkraiem I see your point. I've now closed it as a duplicate of a different question. Let me know what you think of this one. $\endgroup$
    – mikeazo
    Aug 3, 2015 at 12:50
  • $\begingroup$ @mikeazo Yes this one is excellent. $\endgroup$
    – fkraiem
    Aug 3, 2015 at 12:52
  • $\begingroup$ @fkraiem thanks for pointing it out. After looking at it close, you were definitely right that the first "duplicate" wasn't good enough. $\endgroup$
    – mikeazo
    Aug 3, 2015 at 12:54

1 Answer 1


Ok, RSA is a asymmetric crypto system. Which means you have a separate key for encryption and decryption.

Remember RSA is based on cyclic groups. So don't forget the modulo.

Here are the basic equations. $n$ is the product of $p$ and $q$. $\varphi(n) = (p-1)*(q-1)$

$gcd (e, \varphi(n)) = 1$ - for calculating the e. e is random but must fit this equation.

$d = e^{-1} \bmod{\varphi(N)}$ And now you can calculate d.

Hope I could help you. But this would only take 2 minutes to google

  • $\begingroup$ You had a typo in the original. You had $d=e\bmod{\varphi(N)}$ instead of $d=e^{-1}\bmod{\varphi(N)}$. I also added tex formatting. $\endgroup$
    – mikeazo
    Aug 3, 2015 at 12:06
  • $\begingroup$ Also, $e$ is typically not random. Usually $e=65537$ is used. There are a few other popular choices for $e$. $\endgroup$
    – mikeazo
    Aug 3, 2015 at 12:23
  • $\begingroup$ Oh thank you. According to e: Yes in real life its not random. But for learning and with small numbers it is. As long as the equation above is true. Also you would never choose three and eleven for p and q $\endgroup$
    – user281874
    Aug 3, 2015 at 12:31
  • $\begingroup$ I know what RSA is, I just don't understand how $3^{-1}\bmod{20}$ could be $7$. That's it. It's not a duplicate question because my question is focused only on finding $d$. I'm not asking what RSA is for god's sake. $\endgroup$
    – pa5h1nh0
    Aug 3, 2015 at 12:46
  • 2
    $\begingroup$ @pa5h1nh0: 3^-1 is 7. Use the extended euclidean algorithm $\endgroup$
    – user281874
    Aug 3, 2015 at 13:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.