Ask Your Question
1

Perform XOR over symbollic expression

asked 2016-03-24 16:11:24 -0600

Saurav gravatar image

updated 2017-04-06 12:07:18 -0600

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
1

answered 2016-03-24 17:03:04 -0600

tmonteil gravatar image

updated 2016-03-31 03:07:04 -0600

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 16:11:24 -0600

Seen: 317 times

Last updated: Mar 31 '16