From 75403f8b229144ef48ec56f3a19e8416ca96c393 Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Wed, 29 May 2024 14:00:46 +0100 Subject: [PATCH] cleanup cli --- benchmarks/circomcompat_cli.nim | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/benchmarks/circomcompat_cli.nim b/benchmarks/circomcompat_cli.nim index 875edcd2..8520c401 100644 --- a/benchmarks/circomcompat_cli.nim +++ b/benchmarks/circomcompat_cli.nim @@ -122,9 +122,10 @@ proc prove*( # echo "Proof:" # echo proof - echo "\nProof:json: " + # echo "\nProof:json: " let g16proof: Groth16Proof = proof.toGroth16Proof() - echo pretty(%*(g16proof)) + let proofStr = pretty(%*(g16proof)) + writeFile(self.dir / "proof.json", proofStr) return proof proc verify*( @@ -134,7 +135,6 @@ proc verify*( ): bool = ## Verify a proof using a ctx - echo "inputs val: ", inputs.repr let res = verifyCircuit(proof.unsafeAddr, inputs, self.vkp) @@ -268,14 +268,17 @@ proc run*() = if ctx != nil: ctx.addr.releaseCircomCompat() - var pubInputs: ptr Inputs - defer: - if pubInputs != nil: - release_inputs(pubInputs.addr) - doAssert ctx.get_pub_inputs(pubInputs.addr) == ERR_OK + if "prove" in self.cmds or "verify" in self.cmds: + let proof = prove(self, ctx) - let proof = prove(self, ctx) - let verified = verify(self, pubInputs, proof) + var pubInputs: ptr Inputs + defer: + if pubInputs != nil: + release_inputs(pubInputs.addr) + doAssert ctx.get_pub_inputs(pubInputs.addr) == ERR_OK + + if "verify" in self.cmds: + let verified = verify(self, pubInputs, proof) when isMainModule: run()