-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoriginal-sphincs-parameter-search.sage
More file actions
55 lines (48 loc) · 1.88 KB
/
original-sphincs-parameter-search.sage
File metadata and controls
55 lines (48 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
tsec,hashbytes = 125,16
#tsec,hashbytes = 192,24
#tsec,hashbytes = 253,32
maxsigs=2**64
F = RealField(100)
def ld(r):
return -F(log(1/F(2**(8*hashbytes))+F(r)) / log2)
def pow(p,e):
return F(p)**e
def qhitprob(qs,r):
p = F(1/leaves)
return binomial(qs,r)*(pow(p,r))*(pow(1-p,qs-r))
def la(m,w):
return ceil(m / log(w,2))
def lb(m,w):
return floor( log(la(m,w)*(w-1), 2) / log(w,2)) + 1
def lc(m,w):
return la(m,w) + lb(m,w)
for h in range(35,74,2):
leaves = 2**h
for b in range(4,17):
for k in range(30,32):
sigma=0
r = 1
while True:
r = F(r)
p = min(1,F((r/F(2**b)))**k)
q = qhitprob(maxsigs,int(r))*p
sigma += q
r += 1
if(r > maxsigs/leaves and q < F(2)**(-10*tsec)): # beyond expected number of collisions and
break
if(sigma<2**-tsec):
for d in range(4,h):
if(h % d == 0 and h <= 64+(h/d)):
for w in [16,256]:
wots = lc(8*hashbytes,w)
sigsize = ((b+1)*k+h+wots*d+1)*hashbytes
if(sigsize < 50000):
print(h, end=' ') # total tree height
print(d, end=' ') # number of tree layers, subtree height is h/d
print(b, end=' ') # height of FORS trees
print(k, end=' ') # number of trees for FORS
print(w, end=' ') # Winternitz parameter
print(round(ld(sigma)), end=' ')
print(sigsize, end=' ')
# Speed estimate based on (rough) hash count
print(k*2**(b+1) + d*(2**(h/d)*(wots*w+1)))