it verifies!
This commit is contained in:
parent
d2eb91b4e3
commit
45e760a7a3
|
@ -50,7 +50,7 @@ proc prove*[H](
|
||||||
without queue =? newSignalQueue[?!CircomProof](maxItems = 1), qerr:
|
without queue =? newSignalQueue[?!CircomProof](maxItems = 1), qerr:
|
||||||
return failure(qerr)
|
return failure(qerr)
|
||||||
|
|
||||||
var args = (ref ProverArgs[H])(circom: self.circom, data: input)
|
var args = (ref ProverArgs[H])(circom: self.circom.duplicate(), data: input)
|
||||||
GC_ref(args)
|
GC_ref(args)
|
||||||
|
|
||||||
proc spawnTask() =
|
proc spawnTask() =
|
||||||
|
@ -87,7 +87,7 @@ proc verify*[H](
|
||||||
without queue =? newSignalQueue[?!bool](maxItems = 1), qerr:
|
without queue =? newSignalQueue[?!bool](maxItems = 1), qerr:
|
||||||
return failure(qerr)
|
return failure(qerr)
|
||||||
|
|
||||||
var args = (ref VerifierArgs[H])(circom: self.circom, proof: proof, inputs: inputs)
|
var args = (ref VerifierArgs[H])(circom: self.circom.duplicate(), proof: proof, inputs: inputs)
|
||||||
GC_ref(args)
|
GC_ref(args)
|
||||||
|
|
||||||
proc spawnTask() =
|
proc spawnTask() =
|
||||||
|
@ -116,9 +116,9 @@ proc init*(
|
||||||
AsyncCircomCompat(circom: circom, tp: tp)
|
AsyncCircomCompat(circom: circom, tp: tp)
|
||||||
|
|
||||||
proc duplicate*(
|
proc duplicate*(
|
||||||
self: AsyncCircomCompat, tp: Taskpool
|
self: AsyncCircomCompat
|
||||||
): AsyncCircomCompat =
|
): AsyncCircomCompat =
|
||||||
## Create a new async circom
|
## Create a new async circom
|
||||||
##
|
##
|
||||||
let circom = self.circom.duplicate()
|
let circom = self.circom.duplicate()
|
||||||
AsyncCircomCompat(circom: circom, tp: tp)
|
AsyncCircomCompat(circom: circom, tp: self.tp)
|
||||||
|
|
|
@ -242,6 +242,7 @@ proc duplicate*(
|
||||||
## Create a new ctx
|
## Create a new ctx
|
||||||
var cfg: ptr CircomBn254Cfg
|
var cfg: ptr CircomBn254Cfg
|
||||||
if duplicateCircomConfig(self.backendCfg, cfg.addr) != ERR_OK or cfg == nil:
|
if duplicateCircomConfig(self.backendCfg, cfg.addr) != ERR_OK or cfg == nil:
|
||||||
if cfg != nil: cfg.addr.releaseCfg()
|
if cfg != nil:
|
||||||
raiseAssert("failed to initialize circom compat config")
|
cfg.addr.releaseCfg()
|
||||||
|
raiseAssert("failed to initialize circom compat config")
|
||||||
CircomCompat(params: self.params, backendCfg: cfg, vkp: self.vkp)
|
CircomCompat(params: self.params, backendCfg: cfg, vkp: self.vkp)
|
||||||
|
|
|
@ -91,32 +91,32 @@ suite "Test Prover":
|
||||||
|
|
||||||
let
|
let
|
||||||
taskpool2 = Taskpool.new(num_threads = 2)
|
taskpool2 = Taskpool.new(num_threads = 2)
|
||||||
circomVerifyBackend = circomBackend.duplicate(taskpool2)
|
circomVerifyBackend = circomBackend.duplicate()
|
||||||
proverVerify = Prover.new(store, circomVerifyBackend, samples)
|
proverVerify = Prover.new(store, circomVerifyBackend, samples)
|
||||||
check:
|
check:
|
||||||
(await proverVerify.verify(proof, inputs)).tryGet == true
|
(await proverVerify.verify(proof, inputs)).tryGet == true
|
||||||
|
|
||||||
# test "Should sample and prove many slot":
|
test "Should sample and prove many slot":
|
||||||
# let
|
let
|
||||||
# r1cs = "tests/circuits/fixtures/proof_main.r1cs"
|
r1cs = "tests/circuits/fixtures/proof_main.r1cs"
|
||||||
# wasm = "tests/circuits/fixtures/proof_main.wasm"
|
wasm = "tests/circuits/fixtures/proof_main.wasm"
|
||||||
|
|
||||||
# taskpool = Taskpool.new(num_threads = 6)
|
taskpool = Taskpool.new(num_threads = 6)
|
||||||
# params = CircomCompatParams.init(r1cs, wasm)
|
params = CircomCompatParams.init(r1cs, wasm)
|
||||||
# circomBackend = AsyncCircomCompat.init(params, taskpool)
|
circomBackend = AsyncCircomCompat.init(params, taskpool)
|
||||||
# prover = Prover.new(store, circomBackend, samples)
|
prover = Prover.new(store, circomBackend, samples)
|
||||||
|
|
||||||
# var proofs = newSeq[Future[?!(AnyProofInputs, AnyProof)]]()
|
var proofs = newSeq[Future[?!(AnyProofInputs, AnyProof)]]()
|
||||||
# for i in 1..50:
|
for i in 1..50:
|
||||||
# echo "PROVE: ", i
|
echo "PROVE: ", i
|
||||||
# let
|
let
|
||||||
# challenge = (1234567).toF.toBytes.toArray32
|
challenge = (1234567).toF.toBytes.toArray32
|
||||||
|
|
||||||
# proofs.add(prover.prove(1, verifiable, challenge))
|
proofs.add(prover.prove(1, verifiable, challenge))
|
||||||
|
|
||||||
# await allFutures(proofs)
|
await allFutures(proofs)
|
||||||
|
|
||||||
# for pf in proofs:
|
for pf in proofs:
|
||||||
# let (inputs, proof) = (await pf).tryGet
|
let (inputs, proof) = (await pf).tryGet
|
||||||
# check:
|
check:
|
||||||
# (await prover.verify(proof, inputs)).tryGet == true
|
(await prover.verify(proof, inputs)).tryGet == true
|
||||||
|
|
Loading…
Reference in New Issue