Ask Your Question
1

Perform XOR over symbolic expression

asked 2016-03-24 22:11:24 +0100

Saurav gravatar image

updated 2024-07-18 20:45:18 +0100

FrédéricC gravatar image

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.

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)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2016-03-24 23:03:04 +0100

tmonteil gravatar image

updated 2016-03-31 10:07:04 +0100

slelievre gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-03-24 22:11:24 +0100

Seen: 1,957 times

Last updated: May 19 '23