|
from __future__ import nested_scopes |
|
1 |
from fractions import fraction |
from fractions import fraction |
2 |
import math |
import math |
3 |
from math import log, log10, ceil |
from math import log, log10, ceil |
5 |
def lamport(h, b): |
def lamport(h, b): |
6 |
return (1, b, b*h, 2*b*h, h, 2*b, 0, b) |
return (1, b, b*h, 2*b*h, h, 2*b, 0, b) |
7 |
|
|
8 |
|
def merkleI(h, b): |
9 |
|
return (1, b, h*(b+ceil(log2(b))), h, h, |
10 |
|
b + ceil(log2(b)) + 1, 0, b + ceil(log2(b))) |
11 |
|
|
12 |
def merkle_winternitz(h, b, n): |
def merkle_winternitz(h, b, n): |
13 |
return (1, b, fraction(b*h+h*n, n), h, h, |
return (1, b, fraction(b*h+h*n, n), h, h, |
14 |
fraction(2*b*(2L**n-1)+n, n), |
fraction(2*b*(2L**n-1)+n, n), |
20 |
3*(n+1)*h, h, h, |
3*(n+1)*h, h, h, |
21 |
9*n+2, 0, 9*n+2) |
9*n+2, 0, 9*n+2) |
22 |
|
|
23 |
|
def times(j, S): |
24 |
|
return (j*S[0], S[1], S[2], j*S[3], S[4], j*S[5], S[6], S[7]) |
25 |
|
|
26 |
def merkle_hashtree(n, S): |
def merkle_hashtree(n, S): |
27 |
return (2L**n * S[0], S[1], |
return (2L**n * S[0], S[1], |
28 |
S[2] + S[3] + n * S[4], |
S[2] + S[3] + n * S[4], |
63 |
|
|
64 |
schemes = [] |
schemes = [] |
65 |
|
|
66 |
if 1: |
if __name__ == '__main__': |
67 |
for t in range(1, 40): |
for t in range(1, 40): |
68 |
n = ceil(160.0 / t ) |
n = ceil(160.0 / t ) |
69 |
#print "\n N = ",t, " n = ", n |
#print "\n N = ",t, " n = ", n |