diff --git a/src/gf256.py b/src/gf256.py --- a/src/gf256.py +++ b/src/gf256.py @@ -23,7 +23,7 @@ for i in range(256): L[acc] = i acc = _gfmul(acc, g) L[1] = 0 -inv = [E[255-L[i]] if i != 0 else None for i in range(256)] # multiplicative inverse +INV = [E[255-L[i]] if i!=0 else None for i in range(256)] # multiplicative inverse def gfmul(a, b): @@ -40,14 +40,14 @@ def evaluate(coefs, x): :param coefs: [a0, a1, ...].""" res = 0 - xK = 1 + xk = 1 for a in coefs: - res ^= gfmul(a, xK) - xK = gfmul(xK, x) + res ^= gfmul(a, xk) + xk = gfmul(xk, x) return res -def getConstantCoef(*points): +def get_constant_coef(*points): """Compute constant polynomial coefficient given the points. See https://en.wikipedia.org/wiki/Shamir's_Secret_Sharing#Computationally_Efficient_Approach""" @@ -59,6 +59,6 @@ def getConstantCoef(*points): for j in range(k): if i==j: continue (xj, yj) = points[j] - prod = gfmul(prod, (gfmul(xj, inv[xj^x]))) + prod = gfmul(prod, (gfmul(xj, INV[xj^x]))) res ^= gfmul(y, prod) return res