mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-20 17:58:53 +00:00
it runs now?
This commit is contained in:
parent
caaeba8781
commit
ad9d1c39d5
@ -27,8 +27,8 @@ proc proveTask(
|
||||
params: CircomCompatParams, data: ProofInputs[Poseidon2Hash], results: SignalQueuePtr[?!CircomProof]
|
||||
) =
|
||||
|
||||
var data = data.deepCopy()
|
||||
var params = params.deepCopy()
|
||||
var data = data
|
||||
var params = params
|
||||
try:
|
||||
echo "TASK: task: "
|
||||
echo "TASK: task: params: ", params.r1csPath.cstring.pointer.repr
|
||||
@ -42,8 +42,8 @@ proc proveTask(
|
||||
# echo "TASK: task: proof: ", proof.get.hash
|
||||
echo "TASK: task: proof: ", proof
|
||||
echo "TASK: task: params POST: ", params
|
||||
let fake = CircomProof.failure("failed")
|
||||
if (let sent = results.send(fake); sent.isErr()):
|
||||
# let fake = CircomProof.failure("failed")
|
||||
if (let sent = results.send(proof); sent.isErr()):
|
||||
error "Error sending proof results", msg = sent.error().msg
|
||||
except Exception:
|
||||
echo "PROVER DIED"
|
||||
@ -81,12 +81,18 @@ proc prove*[H](
|
||||
success(proof)
|
||||
|
||||
proc verifyTask[H](
|
||||
circom: CircomCompat,
|
||||
params: CircomCompatParams,
|
||||
proof: CircomProof,
|
||||
inputs: ProofInputs[H],
|
||||
results: SignalQueuePtr[?!bool],
|
||||
) =
|
||||
let verified = circom.verify(proof, inputs)
|
||||
echo "VERIFY: task: proof: ", proof
|
||||
|
||||
var params = params
|
||||
if localCircom.isNone:
|
||||
localCircom = some CircomCompat.init(params)
|
||||
|
||||
let verified = localCircom.get().verify(proof, inputs)
|
||||
|
||||
echo "VERIFY: task: result: ", verified
|
||||
if (let sent = results.send(verified); sent.isErr()):
|
||||
@ -101,7 +107,7 @@ proc verify*[H](
|
||||
return failure(qerr)
|
||||
|
||||
proc spawnTask() =
|
||||
self.tp.spawn verifyTask(self.circom, proof, inputs, queue)
|
||||
self.tp.spawn verifyTask(self.params, proof, inputs, queue)
|
||||
|
||||
spawnTask()
|
||||
|
||||
|
@ -176,11 +176,11 @@ proc verify*[H](
|
||||
##
|
||||
|
||||
var
|
||||
proofPtr = unsafeAddr proof
|
||||
proof = proof
|
||||
inputs = inputs.toCircomInputs()
|
||||
|
||||
try:
|
||||
let res = verifyCircuit(proofPtr, inputs.addr, self.vkp)
|
||||
let res = verifyCircuit(proof.addr, inputs.addr, self.vkp)
|
||||
if res == ERR_OK:
|
||||
success true
|
||||
elif res == ERR_FAILED_TO_VERIFY_PROOF:
|
||||
|
@ -67,10 +67,11 @@ suite "Test Prover":
|
||||
prover = Prover.new(store, circomBackend, samples)
|
||||
challenge = 1234567.toF.toBytes.toArray32
|
||||
(inputs, proof) = (await prover.prove(1, verifiable, challenge)).tryGet
|
||||
|
||||
# res = (await prover.prove(1, verifiable, challenge))
|
||||
echo "TEST PROOF: result: ", proof
|
||||
echo "TEST PROOF: state: ", params
|
||||
# check:
|
||||
# (await prover.verify(proof, inputs)).tryGet == true
|
||||
check:
|
||||
(await prover.verify(proof, inputs)).tryGet == true
|
||||
|
||||
test "Should sample and prove many slot":
|
||||
let
|
||||
@ -84,7 +85,7 @@ suite "Test Prover":
|
||||
prover = Prover.new(store, circomBackend, samples)
|
||||
|
||||
var proofs = newSeq[Future[?!(AnyProofInputs, AnyProof)]]()
|
||||
for i in 1..50:
|
||||
for i in 1..20:
|
||||
echo "PROVE: ", i
|
||||
let
|
||||
challenge = (1234567).toF.toBytes.toArray32
|
||||
@ -94,9 +95,8 @@ suite "Test Prover":
|
||||
await allFutures(proofs)
|
||||
echo "done"
|
||||
|
||||
|
||||
# for pf in proofs:
|
||||
# let (inputs, proof) = (await pf).tryGet
|
||||
# check:
|
||||
# (await prover.verify(proof, inputs)).tryGet == true
|
||||
for pf in proofs:
|
||||
let (inputs, proof) = (await pf).tryGet
|
||||
check:
|
||||
(await prover.verify(proof, inputs)).tryGet == true
|
||||
echo "done done"
|
||||
|
Loading…
x
Reference in New Issue
Block a user