mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-02-22 11:28:22 +00:00
adding verification
This commit is contained in:
parent
6b3e3d20b6
commit
85f7c6bb6f
@ -127,18 +127,14 @@ proc prove*(
|
|||||||
|
|
||||||
proc verify*(
|
proc verify*(
|
||||||
self: CircomCircuit,
|
self: CircomCircuit,
|
||||||
ctx: ptr CircomCompatCtx,
|
inputs: ptr Inputs,
|
||||||
proof: CircomProof,
|
proof: CircomProof,
|
||||||
): bool =
|
): bool =
|
||||||
## Verify a proof using a ctx
|
## Verify a proof using a ctx
|
||||||
|
|
||||||
var inputs: ptr Inputs
|
|
||||||
|
|
||||||
doAssert ctx.get_pub_inputs(inputs.addr) == ERR_OK
|
|
||||||
|
|
||||||
echo "inputs val: ", inputs.repr
|
echo "inputs val: ", inputs.repr
|
||||||
|
|
||||||
try:
|
|
||||||
let res = verifyCircuit(proof.unsafeAddr, inputs, self.vkp)
|
let res = verifyCircuit(proof.unsafeAddr, inputs, self.vkp)
|
||||||
|
|
||||||
if res == ERR_OK:
|
if res == ERR_OK:
|
||||||
@ -149,8 +145,6 @@ proc verify*(
|
|||||||
raise newException(ValueError, "Failed to verify proof - err code: " & $res)
|
raise newException(ValueError, "Failed to verify proof - err code: " & $res)
|
||||||
|
|
||||||
echo "proof verification result: ", result
|
echo "proof verification result: ", result
|
||||||
finally:
|
|
||||||
release_inputs(inputs.addr)
|
|
||||||
|
|
||||||
|
|
||||||
proc printHelp() =
|
proc printHelp() =
|
||||||
@ -274,8 +268,13 @@ proc run*() =
|
|||||||
if ctx != nil:
|
if ctx != nil:
|
||||||
ctx.addr.releaseCircomCompat()
|
ctx.addr.releaseCircomCompat()
|
||||||
|
|
||||||
|
var pubInputs: ptr Inputs
|
||||||
|
doAssert ctx.get_pub_inputs(pubInputs.addr) == ERR_OK
|
||||||
|
defer:
|
||||||
|
release_inputs(pubInputs.addr)
|
||||||
|
|
||||||
let proof = prove(self, ctx)
|
let proof = prove(self, ctx)
|
||||||
let verified = verify(self, ctx, proof)
|
let verified = verify(self, pubInputs, proof)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
run()
|
run()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user