# 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, num, num, num ^^ num]
return int("".join(str(x) for x in out), 2)

def MDS(in16):
nibbles = in16
a = nibbles
b = nibbles
c = nibbles
d = nibbles

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 = a
out = b
out = c
out = d

return out
def s16(in16):
nibbles = [(in16 >> 4*i) & 0b1111 for i in range(3,-1,-1)]
nibbles = SATURNIN_1[nibbles]
nibbles = SATURNIN_0[nibbles]
nibbles = SATURNIN_1[nibbles]
nibbles = SATURNIN_0[nibbles]
nibbles = MDS(nibbles)
nibbles = SATURNIN_1[nibbles]
nibbles = SATURNIN_0[nibbles]
nibbles = SATURNIN_1[nibbles]
nibbles = SATURNIN_0[nibbles]
return int(f"{nibbles:04b}{nibbles:04b}{nibbles:04b}{nibbles:04b}",2)

x = [s16(i) for i in range(0,65536)]
ss16 = SBox(x)
ss16.differential_uniformity()

edit retag close merge delete