Get A⊕(B+1) from A⊕B

45 Views Asked by At

I have numbers A,B,C.D.

(⊕ is XOR)

C = A⊕B

D = A⊕(B+1)

Is there any way to get D from C, when I do not know A and B? How?

Thanks for help!

2

There are 2 best solutions below

3
On BEST ANSWER

This is not possible. For example, suppose $A=B=0$. Then $C=0\oplus 0=0$, while $D=0 \oplus 1=1$. But if $A=B=1$, then we still have $C=0$, but now $D=1 \oplus 10=11$. Since one value of $C$ can correspond to two different values of $D$, $D$ cannot be deduced from $C$.

1
On

As Chris explains, you cannot find $D$ exactly.

However, you can narrow down the possible values for $D$ considerably, which can be important in some contexts (such as cryptography).

$B+1$ always differs from $B$ in that a number of least significant bits have been flipped. No bit that is flipped is to the left of any bit that is preserved. This description carries over when you xor with the unknown $A$. So you can say that $D$ must be $C\oplus(2^n-1)$ for some $n\ge 1$.

(It is also easy to see that each of these values is in fact a possible value for $D$, given appropriate choice of $A$, no matter what $C$ is).