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