Generating DDT for 16-bit sbox crashes Juypter kernel
Hi all,
I'm trying to generate the DDT for a 16-bit sbox, but it seems like it causes sage and juypter to crash with the following error:
Kernel Restarting
The kernel appears to have died. It will restart automatically.
Is there a way to prevent juypter from crashing for long running operations?
Here is my script:
from sage.crypto.sboxes import SATURNIN_0, SATURNIN_1
from sage.crypto.sbox import SBox
def MUL(x):
num = [(x >> i) & 0b1 for i in range(3,-1,-1)]
out = [num[1], num[2], num[3], num[0] ^^ num[1]]
return int("".join(str(x) for x in out), 2)
def MDS(in16):
nibbles = in16
a = nibbles[3]
b = nibbles[2]
c = nibbles[1]
d = nibbles[0]
out = [0,0,0,0]
a = a ^^ b
c = c ^^ d
b = MUL(b)
d = MUL(d)
b = b ^^ c
d = d ^^ a
a = MUL(MUL(a))
c = MUL(MUL(c))
c = c ^^ d
a = a ^^ b
b = b ^^ c
d = d ^^ a
out[3] = a
out[2] = b
out[1] = c
out[0] = d
return out
def s16(in16):
nibbles = [(in16 >> 4*i) & 0b1111 for i in range(3,-1,-1)]
nibbles[0] = SATURNIN_1[nibbles[0]]
nibbles[1] = SATURNIN_0[nibbles[1]]
nibbles[2] = SATURNIN_1[nibbles[2]]
nibbles[3] = SATURNIN_0[nibbles[3]]
nibbles = MDS(nibbles)
nibbles[0] = SATURNIN_1[nibbles[0]]
nibbles[1] = SATURNIN_0[nibbles[1]]
nibbles[2] = SATURNIN_1[nibbles[2]]
nibbles[3] = SATURNIN_0[nibbles[3]]
return int(f"{nibbles[0]:04b}{nibbles[1]:04b}{nibbles[2]:04b}{nibbles[3]:04b}",2)
x = [s16(i) for i in range(0,65536)]
ss16 = SBox(x)
ss16.differential_uniformity()