solving mod equation

139 Views Asked by At

I am attempting to solve $r_1$ in this equation:

$$m + xr \equiv m_1 + xr_1 \pmod q$$

This is what I derived at:

$$m-m_1 + xr / x \equiv r_1 \pmod q$$

I proceed to sub these with the necessary value but stuck at solving $r_1$ eventually because of the $\pmod q$. Presumably, I have $q$ too and other values, only $r_1$ is unknown.

Appreciate if anyone can shed some light.

regards, Ken

1

There are 1 best solutions below

1
On BEST ANSWER

From your original equation we can get

$$m-m_1 \equiv x(r_1-r) \pmod q$$

If $x$ is relatively prime to $q$ then $x$ has a multiplicative inverse modulo $q$. Let's call it $x^{-1}$. We then get

$$x^{-1}(m-m_1) \equiv r_1-r \pmod q$$

$$x^{-1}(m-m_1) + r \equiv r_1 \pmod q$$

However, if $x$ is not relatively prime to $q$ things get more complicated: for example, there may be no solution at all. Do you know anything about the common divisors of $x$ and $q$?