From 898ed02880ffddcc4e6331eb074c04d2b6d9e109 Mon Sep 17 00:00:00 2001 From: zero Date: Wed, 10 Apr 2024 10:25:59 +0200 Subject: [PATCH] zkrunner: if (value := foo) can wrongly be false if value is 0, so be explicit with "is not None" --- bin/zkrunner/zkrunner.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/zkrunner/zkrunner.py b/bin/zkrunner/zkrunner.py index f9839ee03..abca91bcc 100755 --- a/bin/zkrunner/zkrunner.py +++ b/bin/zkrunner/zkrunner.py @@ -55,34 +55,35 @@ def load_circuit_witness(circuit, witness_file): # circuit and decide the code path for the prover. for witness in witness_data["witnesses"]: assert len(witness) == 1 - if value := witness.get("EcPoint"): + if (value := witness.get("EcPoint")) is not None: circuit.witness_ecpoint(Ep(value)) - elif value := witness.get("EcNiPoint"): + elif (value := witness.get("EcNiPoint")) is not None: assert len(value) == 2 xcoord, ycoord = Fp(value[0]), Fp(value[1]) circuit.witness_ecnipoint(Ep(xcoord, ycoord)) - elif value := witness.get("Base"): + elif (value := witness.get("Base")) is not None: circuit.witness_base(Fp(value)) - elif value := witness.get("Scalar"): + elif (value := witness.get("Scalar")) is not None: circuit.witness_scalar(Fq(value)) - elif value := witness.get("MerklePath"): + elif (value := witness.get("MerklePath")) is not None: path = [Fp(i) for i in value] assert len(path) == 32 circuit.witness_merklepath(path) - elif value := witness.get("SparseMerklePath"): + elif (value := witness.get("SparseMerklePath")) is not None: path = [Fp(i) for i in value] assert len(path) == 255 circuit.witness_sparsemerklepath(path) - elif value := witness.get("Uint32"): + elif (value := witness.get("Uint32")) is not None: + print("here") circuit.witness_uint32(value) - elif value := witness.get("Uint64"): + elif (value := witness.get("Uint64")) is not None: circuit.witness_uint64(value) else: