I was recently introduced to XOR and other bitwise operators while reading up some articles on C++. The concept seems rather simple but can be confusing because it involves visualizing numbers in binary. I ran into an equation that involves XOR sometime while I was looking up some real-world examples people use for encryption.
I was baffled at the equation, and wanted to learn how to solve it.
Here is the equation:
$y = (x * (i+A)+B) \oplus (x*i+C)$
I am trying to solve for x in the equation, with all other variables being known at the time of the solve. Variables A, B, and C remain constant at all times, with y, x, and i changing. This can simplify the equation to:
$y = (x * (i+32757935)-29408451) \oplus (x*i-5512095)$
I would like to learn how to solve this equation for x, and many others similar to this in the future as well. As such, I want to have some pointers on how to solve it. I remember reading up that splitting the equation into a system of linear equations in modulo 2 is the way to go, but I do not know how to do that. I've read up about the rules about XOR and such, but I'm not sure how I should go about creating a system, and solving it.
Note:
- All variables are unsigned 32-bit integers
- $\oplus$ is the XOR operation
We know that
However, what are lacking are rules for dealing with
We can manipulate the equation as follows:
\begin{eqnarray} y &=& (x * (i+A)+B) \oplus (x*i+C)\\ y\oplus (x*i+C) &=& x * (i+A)+B\\ y\oplus (x*i+C)-B &=& x * (i+A)\\ x&=&\frac{y\oplus (x*i+C)-B}{i+A} \end{eqnarray}
This opens the possibility of using a recursion which hopefully converges to a solution for $x$:
\begin{equation} x_{n+1}=\frac{y\oplus (x_n*i+C)-B}{i+A} \end{equation}