4

I have some simple equations like:

A = (X AND 1779038349) XOR ((X AND 3144134329) XOR 7047511487)

Where A is some constant and X is unknown (all numbers are 32 bit unsigned integers).

How can I solve this for X?

user47523
  • 43
  • 4

1 Answers1

3

As the $x\mapsto x{\,\rm xor\,}s$ is the inverse of itself for all $s$, and that ${\rm and}$ is distributive over ${\rm xor}$, and ${\rm xor}$ is associative, we get

$\begin{align} A{\,\rm xor\,} 7047511487 &= X{\,\rm and\,}(1779038349{\,\rm xor\,}3144134329) \\ A' &= X{\,\rm and\,}3513669172 = X{\,\rm and\,}0b11010001011011100101011000110100 \end{align}$

where $A'$ is another constant ($A'=A{\,\rm xor\,} 7047511487$). So, we get a solution only if the constant $A'$ has no digit $1$ in binary where the right side has $0$ digit, and in that case, on these places $X$ can be arbitrary. In other words, $X$ is masked by the bits of 3513669172 above, and where it contains $0$, $X$ can be arbitrary, when it contains $1$, that digit of $X$ has to be the same as the digit on the same place in $A'$ (from the right).

Berci
  • 90,745