Log in

View Full Version : is XOR mathematically distributive ??


FoolFox
October 16th, 2002, 08:11
Hello,

First of all, i'm not natively speaking english, so i may use incorrect
terms... I've a little problem about mathematics related to logical
operation....

I'm working on a serial protection, which basically is the following check :

x is the registration serial
the program compute a value y by adding value a to x ( y = x + a )
the program compute a value z by xoring x by a value b ( z = x xor b )
the program check if y xor z result of a value c

So, in order to compute the serial, i would use the three equations i got :

(1) : y = x + a
(2) : z = x xor b
(3) : c = y xor z

as i'm seeking a way to compute x :

from (1) : x = y - a (1')
from (3) : y = c xor z
(2) in (3) : y = c xor x xor b

if i replace the last result in (1') i can extract x :

x = ( c xor x xor b ) - a
x + a = c xor x xor b
x xor ( x + a ) = c xor b
x xor x + x xor a = c xor b <== Is that right ???

if (i recall correctly), x xor x = 0 then :

x xor a = c xor b

can i say, x = a xor b xor c ???


I've tried to make some search on the subject but either i've to dig under
millions of results or others are not helping for me yet...

Regards
FoolFox

ZaiRoN
October 16th, 2002, 10:04
Hi FoolFox,

>x xor ( x + a ) = c xor b
>x xor x + x xor a = c xor b <== Is that right ???
no.
look at this simple example:
x =1
a = 1
x xor ( x + a ) = x xor x + x xor a
replacing:
3 = 0 <-- NO...

how to find the right serial?
at this moment i'm able to see only a brute approach...

regards,
ZaiRoN

DakienDX
October 16th, 2002, 10:08
Hello FoolFox !

Your calculations were right until your last step.

c xor b = x xor ( x + a )
c xor b = x xor x + x xor a


If we set the two expressions equal and reduce everything, we would get the following phrase:

x xor (x + a) = x xor x + x xor a
x xor (x + a) = x xor a
x + a = a
x = 0


You can tell either by just looking at it or by testing with numbers that this is not equal unless the serial number "0" is the only valid serial, which I doubt.

What are a, b and c? Are they all constants or is one or all of them somehow calculated?

Oh, ZaiRoN was first.

FoolFox
October 16th, 2002, 14:43
Hi,

Thanks for the point, at least i know where i'm stuck now....

as far as i've seen of the whole process, two of the three values (a,b & c) are constant and one is related to the username.

But i've still to dig that part, I'll focus on that now as it may
help to resolve the last step...

....otherwise i'll go on brute-force...

Regards
FoolFox

mike
October 18th, 2002, 05:15
check out the thread from naides in the crypto forum on this topic