Last active
August 4, 2016 15:33
-
-
Save daira/4c486d0d443a6901a8c1d62d8c1e5123 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://eprint.iacr.org/2012/254 | |
def random(K): | |
ctr = 0 | |
while True: | |
yield AES(K, ctr) | |
ctr += 1 | |
def PRP(K, x): | |
return (x, 0, N, 0, random(K)) | |
def Permute(x, alpha, l, d, R) | |
if l == 1: | |
return alpha | |
if beta_d(alpha+x) == 0: | |
xdash = C0(beta_d, alpha, x) | |
return Permute(xdash, alpha, C0(beta_d, alpha, l), d+1, R) | |
else: | |
xdash = C1(beta_d, alpha, x) | |
return Permute(xdash, alpha + C0(beta_d, alpha, l), C1(beta_d, alpha, l), d+1, R) | |
def Unpermute(y, alpha, l, d, R) | |
if l == 1: | |
return 0 | |
if y < C0(alpha, l, d): | |
ydash = y | |
xdash = Unpermute(ydash, alpha, C0(beta_d, alpha, l), d+1, R) | |
return C0inv(beta_d, alpha, xdash+1) | |
else: | |
ydash = y - C0(beta_d, alpha, l) | |
xdash = Unpermute(ydash, alpha + C0(beta_d, alpha, l), C1(beta_d, alpha, l), d+1, R) | |
return C1inv(beta_d, alpha, xdash+1) | |
def C0(...): | |
... | |
def C0inv(...): | |
... | |
def C1(...): | |
... | |
def C1inv(...): | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment