# Perform XOR over symbollic expression I have written the code for a function but rather than addition I want to perform XOR how can I do it.

current output of

a,b = LR('a','b',3)

LRinv(a,b,3)


is

(a + P1(b + P2(a + P1(b) + 2*P3(b + P2(a + P1(b)))) + P2(a + P1(b))) + P1(b) + 2*P3(b + P2(a + P1(b))), b + P2(a + P1(b) + 2*P3(b + P2(a + P1(b)))) + P2(a + P1(b)))


Rather it should be (a,b) if XORED.

def LR(L,R,rounds):
if(type(L)==type(R)==type('a')):
R = var(R)
L = var(L)
for r in range(0,rounds):
perm = DeprecatedSFunction("P"+str(r+1),1)
temp = R
R = L.__xor__(perm(R))
L = temp
return(L,R)

def LRinv(L,R,rounds):
if(type(L)==type(R)==type('a')):
R = var(L)
L = var(R)
else:
temp = R
R = L
L = temp
for r in range(0,rounds):
perm = DeprecatedSFunction("P"+str(rounds-r),1)
temp = R
R = L.__xor__(perm(R))
L = temp
return(R,L)

edit retag close merge delete

Sort by » oldest newest most voted

I am not sure about your objectives, but perhaps could you have a look at one of the following pages:

more