Check for incomplete addition exceptional cases in Sinsemilla

This commit is contained in:
Taylor Hornby 2021-04-26 18:21:01 -06:00
parent fb45bda972
commit a2bf6c5a04
2 changed files with 10 additions and 3 deletions

View File

@ -182,6 +182,13 @@ class Point(object):
else:
return self.double()
def checked_incomplete_add(self, a):
assert self != a
assert self != -a
assert self != Point.identity()
assert self != Point.identity()
return self + a
def __sub__(self, a):
return (-a) + self

View File

@ -155,11 +155,11 @@ def sinsemilla_hash_to_point(d, m):
n = cldiv(m.len, SINSEMILLA_K)
m = pad(n, m)
acc = group_hash(b"z.cash:SinsemillaQ", d)
#print("acc", acc)
for m_i in m:
acc = acc + group_hash(b"z.cash:SinsemillaS", i2leosp(32, m_i)) + acc
#print("acc", acc)
acc = acc.checked_incomplete_add(
group_hash(b"z.cash:SinsemillaS", i2leosp(32, m_i))
).checked_incomplete_add(acc)
return acc