Make use of short-circuit logic

pull/128/head
David Nuñez 2018-04-24 00:37:48 +02:00
parent 7d9bc19fc4
commit 12c6b5edd9
1 changed files with 4 additions and 7 deletions

View File

@ -105,9 +105,7 @@ class CorrectnessProof(object):
kfrag_sig2 = BigNum.from_bytes(data.read(key_size), curve)
sig = BigNum.from_bytes(data.read(key_size), curve)
metadata = data.read()
if metadata == bytes(0):
metadata = None
metadata = data.read() or None
return cls(e2, v2, kfrag_commitment, kfrag_pok,
kfrag_sig1, kfrag_sig2, sig, metadata=metadata)
@ -132,8 +130,7 @@ class CorrectnessProof(object):
+ kfrag_sig2 \
+ sig
if self.metadata is not None:
result = result + self.metadata
result += self.metadata or b''
return result
@ -165,8 +162,8 @@ class CapsuleFrag(object):
kfrag_id = BigNum.from_bytes(data.read(key_size), curve)
eph_ni = Point.from_bytes(data.read(key_size + 1), curve)
proof = data.read()
proof = CorrectnessProof.from_bytes(proof, curve) if proof != bytes(0) else None
proof = data.read() or None
proof = CorrectnessProof.from_bytes(proof, curve) if proof else None
return cls(e1, v1, kfrag_id, eph_ni, proof)