mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-02-23 11:58:17 +00:00
adding verification
This commit is contained in:
parent
50d3ab84ea
commit
ae01d061b7
@ -95,16 +95,11 @@ proc initCircomCtx*(
|
|||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
proc prove*(
|
proc prove*(
|
||||||
self: CircomCircuit, input: JsonNode
|
self: CircomCircuit, ctx: ptr CircomCompatCtx
|
||||||
): CircomProof =
|
): CircomProof =
|
||||||
## Encode buffers using a ctx
|
## Encode buffers using a ctx
|
||||||
##
|
##
|
||||||
|
|
||||||
var ctx = initCircomCtx(self, input)
|
|
||||||
defer:
|
|
||||||
if ctx != nil:
|
|
||||||
ctx.addr.releaseCircomCompat()
|
|
||||||
|
|
||||||
var proofPtr: ptr Proof = nil
|
var proofPtr: ptr Proof = nil
|
||||||
|
|
||||||
let proof: Proof =
|
let proof: Proof =
|
||||||
@ -127,16 +122,11 @@ proc prove*(
|
|||||||
|
|
||||||
proc verify*(
|
proc verify*(
|
||||||
self: CircomCircuit,
|
self: CircomCircuit,
|
||||||
jsonInput: JsonNode,
|
ctx: ptr CircomCompatCtx,
|
||||||
proof: CircomProof,
|
proof: CircomProof,
|
||||||
): bool =
|
): bool =
|
||||||
## Verify a proof using a ctx
|
## Verify a proof using a ctx
|
||||||
|
|
||||||
var ctx = initCircomCtx(self, jsonInput)
|
|
||||||
defer:
|
|
||||||
if ctx != nil:
|
|
||||||
ctx.addr.releaseCircomCompat()
|
|
||||||
|
|
||||||
var inputs: ptr Inputs
|
var inputs: ptr Inputs
|
||||||
|
|
||||||
doAssert ctx.get_pub_inputs(inputs.addr) == ERR_OK
|
doAssert ctx.get_pub_inputs(inputs.addr) == ERR_OK
|
||||||
@ -272,8 +262,13 @@ proc run*() =
|
|||||||
inputData = self.inputsPath.readFile()
|
inputData = self.inputsPath.readFile()
|
||||||
inputs: JsonNode = !JsonNode.parse(inputData)
|
inputs: JsonNode = !JsonNode.parse(inputData)
|
||||||
|
|
||||||
let proof = prove(self, inputs)
|
var ctx = initCircomCtx(self, inputs)
|
||||||
let verified = verify(self, inputs, proof)
|
defer:
|
||||||
|
if ctx != nil:
|
||||||
|
ctx.addr.releaseCircomCompat()
|
||||||
|
|
||||||
|
let proof = prove(self, ctx)
|
||||||
|
let verified = verify(self, ctx, proof)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
run()
|
run()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user