Explicitly check Points against None
This commit is contained in:
parent
73b8401b9a
commit
196c317d89
|
@ -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
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue