I have the equation de ( mod x ) = 1
I currently have the values for e
and x
. Is there a way that I can get the value for d? I tried doing (x + e) + 1
but when I insert it into the equation, I get an answer that isn't 1.
I have the equation de ( mod x ) = 1
I currently have the values for e
and x
. Is there a way that I can get the value for d? I tried doing (x + e) + 1
but when I insert it into the equation, I get an answer that isn't 1.
A solution $d$ may or may not exist (actually it can only exist if $e$ and $x$ are relatively prime.)
You need to solve $de \equiv 1 \pmod x$ which is to say, that there is an integer $k$ so that $de = 1 + kx$.
Which in turn is equivalent to $de - kx = 1$ which by Bezout's lemma has solutions if $1$ is the greatest common divisor of $x$ and $e$ (or in other words, if $x,e$ are relatively prime).
We do not care what $k$ is but we do care what $d$ is. And we can solve that with the Euclidean Algorithm.
For example to solve $d16 \equiv 1\pmod {21}$ we note:
$21 = 16 + 5$
$16 = 3\cdot 5 + 1$ so
$1 = 16- 3\cdot 5 = 16 - 3(21-16) = 4\cdot 16 - 3\cdot 21$ so $4\cdot 16 \equiv 1 \pmod {21}$ and $d\equiv 4 \pmod {21}$ is a solution do $16d \equiv 1 \pmod {21}$.
[Verify: $4\cdot 16 = 64 = 1 + 3\cdot 21 \equiv 1 \pmod {21}$.]
(we need some more work to show that $d\equiv 4\pmod {21}$ is the only solution [up to congruence $\mod 21$... That is to say, all $4 + 21k$ will also be solutions but the only solutions will be $\equiv 4 \pmod{21}$ and $4+21k\equiv 4 \pmod {21}$ so the are considered to be the same solution].)
We call $d$ the multiplicative inverse of $16\pmod {21}$ and we are allowed to write $d \equiv 16^{-1} \pmod {21}$. SOme text will even allow you to write $d \equiv \frac 1{16} \pmod{21}$ but if you do that it is very important that you don't confuse it with the rational fraction $\frac 1{16} = 0.0625$. That just doesn't have meaning in modular arithmetic which is about congruences of integers.
Just bear in mind that $\frac 1{16}$, in this context, refers to the congruence class of integers so that $16 d \equiv 1 \pmod {21}$ i.e. $\frac 1{16}\equiv 4 \pmod {21}$ because $4\cdot 16\equiv 1 \pmod{21} $ and that is how $\frac 1{16}$ would behave, $\frac 1{16}\cdot 16 \equiv 1 \pmod {21}$, if $\frac 1{16}$ where an integer.