it verifies!
This commit is contained in:
parent
ba114425c9
commit
d2eb91b4e3
|
@ -114,3 +114,11 @@ proc init*(
|
||||||
##
|
##
|
||||||
let circom = CircomCompat.init(params)
|
let circom = CircomCompat.init(params)
|
||||||
AsyncCircomCompat(circom: circom, tp: tp)
|
AsyncCircomCompat(circom: circom, tp: tp)
|
||||||
|
|
||||||
|
proc duplicate*(
|
||||||
|
self: AsyncCircomCompat, tp: Taskpool
|
||||||
|
): AsyncCircomCompat =
|
||||||
|
## Create a new async circom
|
||||||
|
##
|
||||||
|
let circom = self.circom.duplicate()
|
||||||
|
AsyncCircomCompat(circom: circom, tp: tp)
|
||||||
|
|
|
@ -235,3 +235,13 @@ proc init*(
|
||||||
raiseAssert("Failed to get verifying key")
|
raiseAssert("Failed to get verifying key")
|
||||||
|
|
||||||
CircomCompat(params: params, backendCfg: cfg, vkp: vkpPtr)
|
CircomCompat(params: params, backendCfg: cfg, vkp: vkpPtr)
|
||||||
|
|
||||||
|
proc duplicate*(
|
||||||
|
self: CircomCompat,
|
||||||
|
): CircomCompat =
|
||||||
|
## Create a new ctx
|
||||||
|
var cfg: ptr CircomBn254Cfg
|
||||||
|
if duplicateCircomConfig(self.backendCfg, cfg.addr) != ERR_OK or cfg == nil:
|
||||||
|
if cfg != nil: cfg.addr.releaseCfg()
|
||||||
|
raiseAssert("failed to initialize circom compat config")
|
||||||
|
CircomCompat(params: self.params, backendCfg: cfg, vkp: self.vkp)
|
||||||
|
|
|
@ -77,27 +77,46 @@ suite "Test Prover":
|
||||||
check:
|
check:
|
||||||
(await prover.verify(proof, inputs)).tryGet == true
|
(await prover.verify(proof, inputs)).tryGet == true
|
||||||
|
|
||||||
test "Should sample and prove many slot":
|
test "Should sample and prove a slot with another circom":
|
||||||
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 = 2)
|
||||||
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)
|
||||||
|
challenge = 1234567.toF.toBytes.toArray32
|
||||||
|
(inputs, proof) = (await prover.prove(1, verifiable, challenge)).tryGet
|
||||||
|
|
||||||
var proofs = newSeq[Future[?!(AnyProofInputs, AnyProof)]]()
|
let
|
||||||
for i in 1..50:
|
taskpool2 = Taskpool.new(num_threads = 2)
|
||||||
echo "PROVE: ", i
|
circomVerifyBackend = circomBackend.duplicate(taskpool2)
|
||||||
let
|
proverVerify = Prover.new(store, circomVerifyBackend, samples)
|
||||||
challenge = (1234567).toF.toBytes.toArray32
|
check:
|
||||||
|
(await proverVerify.verify(proof, inputs)).tryGet == true
|
||||||
|
|
||||||
proofs.add(prover.prove(1, verifiable, challenge))
|
# test "Should sample and prove many slot":
|
||||||
|
# let
|
||||||
|
# r1cs = "tests/circuits/fixtures/proof_main.r1cs"
|
||||||
|
# wasm = "tests/circuits/fixtures/proof_main.wasm"
|
||||||
|
|
||||||
await allFutures(proofs)
|
# taskpool = Taskpool.new(num_threads = 6)
|
||||||
|
# params = CircomCompatParams.init(r1cs, wasm)
|
||||||
|
# circomBackend = AsyncCircomCompat.init(params, taskpool)
|
||||||
|
# prover = Prover.new(store, circomBackend, samples)
|
||||||
|
|
||||||
for pf in proofs:
|
# var proofs = newSeq[Future[?!(AnyProofInputs, AnyProof)]]()
|
||||||
let (inputs, proof) = (await pf).tryGet
|
# for i in 1..50:
|
||||||
check:
|
# echo "PROVE: ", i
|
||||||
(await prover.verify(proof, inputs)).tryGet == true
|
# let
|
||||||
|
# challenge = (1234567).toF.toBytes.toArray32
|
||||||
|
|
||||||
|
# proofs.add(prover.prove(1, verifiable, challenge))
|
||||||
|
|
||||||
|
# await allFutures(proofs)
|
||||||
|
|
||||||
|
# for pf in proofs:
|
||||||
|
# let (inputs, proof) = (await pf).tryGet
|
||||||
|
# check:
|
||||||
|
# (await prover.verify(proof, inputs)).tryGet == true
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit cc2e742b7ac7a0fdf273b6bebdb9b5b42e3dc722
|
Subproject commit 7c1105bb77f0ce7b1b3cc0cb3e78db89265ba05f
|
Loading…
Reference in New Issue