cleanup cli
This commit is contained in:
parent
142c27e2b0
commit
75403f8b22
|
@ -122,9 +122,10 @@ proc prove*(
|
||||||
|
|
||||||
# echo "Proof:"
|
# echo "Proof:"
|
||||||
# echo proof
|
# echo proof
|
||||||
echo "\nProof:json: "
|
# echo "\nProof:json: "
|
||||||
let g16proof: Groth16Proof = proof.toGroth16Proof()
|
let g16proof: Groth16Proof = proof.toGroth16Proof()
|
||||||
echo pretty(%*(g16proof))
|
let proofStr = pretty(%*(g16proof))
|
||||||
|
writeFile(self.dir / "proof.json", proofStr)
|
||||||
return proof
|
return proof
|
||||||
|
|
||||||
proc verify*(
|
proc verify*(
|
||||||
|
@ -134,7 +135,6 @@ proc verify*(
|
||||||
): bool =
|
): bool =
|
||||||
## Verify a proof using a ctx
|
## Verify a proof using a ctx
|
||||||
|
|
||||||
|
|
||||||
echo "inputs val: ", inputs.repr
|
echo "inputs val: ", inputs.repr
|
||||||
|
|
||||||
let res = verifyCircuit(proof.unsafeAddr, inputs, self.vkp)
|
let res = verifyCircuit(proof.unsafeAddr, inputs, self.vkp)
|
||||||
|
@ -268,14 +268,17 @@ proc run*() =
|
||||||
if ctx != nil:
|
if ctx != nil:
|
||||||
ctx.addr.releaseCircomCompat()
|
ctx.addr.releaseCircomCompat()
|
||||||
|
|
||||||
var pubInputs: ptr Inputs
|
if "prove" in self.cmds or "verify" in self.cmds:
|
||||||
defer:
|
let proof = prove(self, ctx)
|
||||||
if pubInputs != nil:
|
|
||||||
release_inputs(pubInputs.addr)
|
|
||||||
doAssert ctx.get_pub_inputs(pubInputs.addr) == ERR_OK
|
|
||||||
|
|
||||||
let proof = prove(self, ctx)
|
var pubInputs: ptr Inputs
|
||||||
let verified = verify(self, pubInputs, proof)
|
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:
|
when isMainModule:
|
||||||
run()
|
run()
|
||||||
|
|
Loading…
Reference in New Issue