From 196c317d894bcefebbeb7aaa76778a2f246a103e Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 22 Feb 2019 22:10:57 +0000 Subject: [PATCH] Explicitly check Points against None --- sapling_generators.py | 4 ++-- sapling_jubjub.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sapling_generators.py b/sapling_generators.py index 573383d..3b22097 100644 --- a/sapling_generators.py +++ b/sapling_generators.py @@ -23,7 +23,7 @@ def group_hash(D, M): digest.update(URS) digest.update(M) p = Point.from_bytes(digest.digest()) - if not p: + if p is None: return None q = p * JUBJUB_COFACTOR if q == Point.ZERO: @@ -34,7 +34,7 @@ def find_group_hash(D, M): i = 0 while True: p = group_hash(D, M + bytes([i])) - if p: + if p is not None: return p i += 1 assert i < 256 diff --git a/sapling_jubjub.py b/sapling_jubjub.py index b8d012b..655263b 100644 --- a/sapling_jubjub.py +++ b/sapling_jubjub.py @@ -147,7 +147,7 @@ class Point(object): while True: data = rand.b(32) p = Point.from_bytes(data) - if p: + if p is not None: return p @staticmethod @@ -164,7 +164,7 @@ class Point(object): u2 = (vv - Fq.ONE) / (vv * JUBJUB_D - JUBJUB_A) u = u2.sqrt() - if not u: + if u is None: return None if u.s % 2 != u_sign: