0

Let $p$ be a value between $0 - 100$.

Let $k$ be any prime key less than $50,$ say $47$.

Let $n$ be any number, for this case say $200$.

I do the operation $$ p \leftarrow (p\cdot k)\pmod n $$ I have the new value of $p$ only. How would I reverse this operation i.e. get back the original value of $p$?

I know I have to think of multiplicative modular inverse, but how would I go about it?

amWhy
  • 210,739

1 Answers1

0

Let's say that the computed value is $x_0$ i.e. $$ x_0=(p\cdot k)\pmod n $$ Now assuming we only know $x_0,k$ and $n$, we need to find the value of $p$. Notice that we would have gotten the same value $x_0$ had we taken $p+m\cdot n$ for any $m\in\mathbb Z$ instead of $p$ in the computation. So we cannot get back the actual value of $p$ that we started with, unless additional information is given.

With the example constraints you gave for $p,k$ and $n,$ I'm guessing that $p\leq n$. If modular inverse of $k$ w.r.t $n$ exists i.e. $\gcd(k,n)=1,$ then $$ p=(x_0\cdot k^{-1})\pmod n $$ is the unique value $\leq n$.

Otherwise, if $\gcd(k,n)=d,$ then there are exactly $d$ values of $p\leq n$ given by $$ p=\left(p_0+\frac{n}{d}\cdot t\right)\pmod n\qquad t\in\mathbb Z,\;0\leq t\leq d-1 $$ where $p_0$ is any particular value satisfying the equation.

PS: Here is a link to a nice article on linear congruences if you're interested. linear-congruences

Jamāl
  • 604