Explicitly check Points against None

This commit is contained in:
Jack Grigg 2019-02-22 22:10:57 +00:00
parent 73b8401b9a
commit 196c317d89
No known key found for this signature in database
GPG Key ID: 1B8D649257DB0829
2 changed files with 4 additions and 4 deletions

View File

@ -23,7 +23,7 @@ def group_hash(D, M):
digest.update(URS) digest.update(URS)
digest.update(M) digest.update(M)
p = Point.from_bytes(digest.digest()) p = Point.from_bytes(digest.digest())
if not p: if p is None:
return None return None
q = p * JUBJUB_COFACTOR q = p * JUBJUB_COFACTOR
if q == Point.ZERO: if q == Point.ZERO:
@ -34,7 +34,7 @@ def find_group_hash(D, M):
i = 0 i = 0
while True: while True:
p = group_hash(D, M + bytes([i])) p = group_hash(D, M + bytes([i]))
if p: if p is not None:
return p return p
i += 1 i += 1
assert i < 256 assert i < 256

View File

@ -147,7 +147,7 @@ class Point(object):
while True: while True:
data = rand.b(32) data = rand.b(32)
p = Point.from_bytes(data) p = Point.from_bytes(data)
if p: if p is not None:
return p return p
@staticmethod @staticmethod
@ -164,7 +164,7 @@ class Point(object):
u2 = (vv - Fq.ONE) / (vv * JUBJUB_D - JUBJUB_A) u2 = (vv - Fq.ONE) / (vv * JUBJUB_D - JUBJUB_A)
u = u2.sqrt() u = u2.sqrt()
if not u: if u is None:
return None return None
if u.s % 2 != u_sign: if u.s % 2 != u_sign: