Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have been shown that DE is congruent to 1 mod phi(n). How do we arrive to the real equation for figuring out d that is d = e^-1 mod phi(n). I want to know the entire process. I am just curious, spending the night studying the workings of the RSA.

share|improve this question
it's because of definition of $\phi(n)$ in essence $x^{\phi(n)} = x \mod n \Rightarrow x^y=x^{y \mod \phi(n)} \mod n$. So you select an $e$ and $d$ such that $ed = 1 \mod \phi(n)$ – ratchet freak Dec 6 '13 at 9:56

Are you asking "given $e$ and $\phi(n)$, how do we find $d$ such that $de \equiv 1 \bmod \phi(n)$"? (which can also be written as $d = e^{-1} \bmod \phi(n)$

The standard way of find such a value is the Extended Euclidean Method; this is a relatively efficient method that results in $d$ given $e$ and $\phi(n)$ as inputs (assuming, of course, that $e$ and $\phi(n)$ are relatively prime; if they aren't, $e$ won't work as a public exponent anyways).

Now,I do have one minor nit which doesn't have anything to do with your actual question: actually, if $d$ and $e$ are RSA private/public exponents, it's not always true that $de \equiv 1 \bmod \phi(n)$. Now, such a $d$ and $e$ that satisfies that condition will work as RSA private/public exponents (and hence if you are constructing an RSA private/public keypair, using $\phi(n)$ won't break anything).

However it turns out that the weaker condition $de \equiv 1 \bmod \lambda(n)$ where $\lambda(n) = lcm(p-1, q-1)$ turns out to be both necessary and sufficient. This does not affect your question (because you end up giving $e$ and $\lambda(n)$ to the Extended Euclidean Method). You did mention that you were studying RSA; you should be aware of that.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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