Figuring out a factor of modulo multiplication knowing other factors

1.7k Views Asked by At

So the problem is this - we have a simple equation:

(A * B) % N = X

All numbers are large integers.

We know B, N and X, is it possible for us to figure out the last factor A without checking every single integer from 0 to N?

Does N being prime change the answer?

1

There are 1 best solutions below

0
On

Suppose $\gcd(B, N) = 1$. Then $AB = X \pmod N$ has the solution $A = XB^{-1}$ where $B^{-1}$ is the multiplicative inverse modulo $N$. If $\gcd(B,N) \neq 1$ Then let $M$ be the order of $B$, i.e. $M$ is the smallest positive integer such that $MB = 0 \pmod N$.

Then if you have one solution $A$, then $A + KM$ are other solutions for all $K \in \mathbb{Z}$. But there's only a finite number of them $\pmod N$.

If $X = 0$ then $A_0$ (the first solution) is simply $M$, the order of $B$. If $X \neq 0$, then if there is a first solution then it's less than $M$ since if $A_0 \geq M$, then $A_0 = K + M$ for some $K \geq 0$, $K \lt A_0$. But then $A_0 B = (K+M)B = KB$ so $K$ is a smaller solution than $A_0$. Thus for $X \neq 0$ the first solution (smallest solution) is less than $M$.

If $A', A$ are two solutions then $AB = A'B = X$ so $(A - A')B = 0$, this means that the integer value of $(A-A')$ is divisible by $M$. Prove that. In an abelian group $G$, if $m = ord(x)$ and $n x = 0$, then $m | n$. So $A' - A = MK \implies A' = A + MK$ for some $K \in \mathbb{Z}$. Thus once you have one solution you effectively have the rest.

So find your first solution, by checking integers $A$ until $AB = 0$. Something like that.