You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forcing both numerator and denominator to Bn works fine.
def lagrange_basis(indexes, o, x=0):
""" generates all lagrange basis polynomials """
l = []
for i in indexes:
numerator, denominator = Bn.from_num(1), Bn.from_num(1)
for j in indexes:
if j != i:
numerator = (numerator * (x - j)) % o
denominator = (denominator * (i - j)) % o
l.append((numerator * denominator.mod_inverse(o)) % o)
return l
Lagrange Basis function throws an Attribute Error at the line
return (numerator * denominator.mod_inverse(o)) % o
Specifically:
AttributeError: 'int' object has no attribute 'mod_inverse'
Attempts to solve this by forcing denominator to a Bn cause further errors.
The text was updated successfully, but these errors were encountered: