Files
@ 438dcebc9c63
Branch filter:
Location: Shamira/src/gf256.py - annotation
438dcebc9c63
474 B
text/x-python
splitting the secret
86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 86a5417085ef 438dcebc9c63 438dcebc9c63 438dcebc9c63 438dcebc9c63 438dcebc9c63 438dcebc9c63 438dcebc9c63 438dcebc9c63 438dcebc9c63 | def _ffmul(a, b):
r=0
while a!=0:
if (a&1)!=0: r^=b
t=b&0x80
b=(b<<1)&255
if t!=0: b^=0x1b
a>>=1
return r
g=3
E=[None]*256
L=[None]*256
acc=1
for i in range(256):
E[i]=acc
L[acc]=i
acc=_ffmul(acc, g)
L[1]=0
inv=[E[255-L[i]] if i!=0 else None for i in range(256)]
def ffmul(a, b):
if a==0 or b==0: return 0
t=L[a]+L[b]
if t>255: t-=255
return E[t]
def evaluate(coefs,x):
res=0
xK=1
for a in coefs:
res^=ffmul(a,xK)
xK=ffmul(xK,x)
return res
|