I have this equation:
y = a^N mod M
N and M are constant.
I want to reverse the equation and calculate a using y.
something like this:
a = ???
how can I do this?
assume I have N, M and y. Now I want to calculate a.
thanks
I have this equation:
y = a^N mod M
N and M are constant.
I want to reverse the equation and calculate a using y.
something like this:
a = ???
how can I do this?
assume I have N, M and y. Now I want to calculate a.
thanks
The simpler question of the existence of $a$, given $y$, $N=2$, $M=p$ (a prime) has an answer by the law of quadratic reciprocity and calculations via the Legendre symbol. It can be extended to the case when $M$ is square free (product of distinct primes), using the Chinese remainder theorem, since $y$ is a square modulo $p_1p_2\dotsm p_r$ if and only if it is a square modulo each of $p_1, p_2,\dots, p_r$.
Once you have a solution modulo $p_i$, you can recursively obtain a solution modulo $p_i^k$ for any $k$ via Hensel's lifting.
Note that the existence and uniqueness of $a$ satisfying the equation above given $y$, $N$, and $M$ is not, in general, guaranteed - there may be infinitely many such $a$, or none.
For example, take $y=0$, $N=1$, $M=2$. Your question in this particular case becomes: "I know that $a$ is even (i.e. $a^1 \equiv 0 \mod 2$); how can I compute $a$?"