# Revision history [back]

### 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) + 2P3(b + P2(a + P1(b)))) + P2(a + P1(b))) + P1(b) + 2P3(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.

Thanks is advance!!! 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)

 2 No.2 Revision tmonteil 14608 ●19 ●100 ●263 http://wiki.sagemath.o...

### 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) LR('a','b',3)

LRinv(a,b,3)


is

(a + P1(b + P2(a + P1(b) + 2P3(b 2*P3(b + P2(a + P1(b)))) + P2(a + P1(b))) + P1(b) + 2P3(b 2*P3(b + P2(a + P1(b))), b + P2(a + P1(b) + 2*P3(b + P2(a + P1(b)))) + P2(a + P1(b)))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) 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)return(R,L)

 3 retagged FrédéricC 1666 ●1 ●20 ●30

### 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)