mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-01-21 02:09:19 +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]
|
params: CircomCompatParams, data: ProofInputs[Poseidon2Hash], results: SignalQueuePtr[?!CircomProof]
|
||||||
) =
|
) =
|
||||||
|
|
||||||
var data = data.deepCopy()
|
var data = data
|
||||||
var params = params.deepCopy()
|
var params = params
|
||||||
try:
|
try:
|
||||||
echo "TASK: task: "
|
echo "TASK: task: "
|
||||||
echo "TASK: task: params: ", params.r1csPath.cstring.pointer.repr
|
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.get.hash
|
||||||
echo "TASK: task: proof: ", proof
|
echo "TASK: task: proof: ", proof
|
||||||
echo "TASK: task: params POST: ", params
|
echo "TASK: task: params POST: ", params
|
||||||
let fake = CircomProof.failure("failed")
|
# let fake = CircomProof.failure("failed")
|
||||||
if (let sent = results.send(fake); sent.isErr()):
|
if (let sent = results.send(proof); sent.isErr()):
|
||||||
error "Error sending proof results", msg = sent.error().msg
|
error "Error sending proof results", msg = sent.error().msg
|
||||||
except Exception:
|
except Exception:
|
||||||
echo "PROVER DIED"
|
echo "PROVER DIED"
|
||||||
@ -81,12 +81,18 @@ proc prove*[H](
|
|||||||
success(proof)
|
success(proof)
|
||||||
|
|
||||||
proc verifyTask[H](
|
proc verifyTask[H](
|
||||||
circom: CircomCompat,
|
params: CircomCompatParams,
|
||||||
proof: CircomProof,
|
proof: CircomProof,
|
||||||
inputs: ProofInputs[H],
|
inputs: ProofInputs[H],
|
||||||
results: SignalQueuePtr[?!bool],
|
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
|
echo "VERIFY: task: result: ", verified
|
||||||
if (let sent = results.send(verified); sent.isErr()):
|
if (let sent = results.send(verified); sent.isErr()):
|
||||||
@ -101,7 +107,7 @@ proc verify*[H](
|
|||||||
return failure(qerr)
|
return failure(qerr)
|
||||||
|
|
||||||
proc spawnTask() =
|
proc spawnTask() =
|
||||||
self.tp.spawn verifyTask(self.circom, proof, inputs, queue)
|
self.tp.spawn verifyTask(self.params, proof, inputs, queue)
|
||||||
|
|
||||||
spawnTask()
|
spawnTask()
|
||||||
|
|
||||||
|
@ -176,11 +176,11 @@ proc verify*[H](
|
|||||||
##
|
##
|
||||||
|
|
||||||
var
|
var
|
||||||
proofPtr = unsafeAddr proof
|
proof = proof
|
||||||
inputs = inputs.toCircomInputs()
|
inputs = inputs.toCircomInputs()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
let res = verifyCircuit(proofPtr, inputs.addr, self.vkp)
|
let res = verifyCircuit(proof.addr, inputs.addr, self.vkp)
|
||||||
if res == ERR_OK:
|
if res == ERR_OK:
|
||||||
success true
|
success true
|
||||||
elif res == ERR_FAILED_TO_VERIFY_PROOF:
|
elif res == ERR_FAILED_TO_VERIFY_PROOF:
|
||||||
|
@ -67,10 +67,11 @@ suite "Test Prover":
|
|||||||
prover = Prover.new(store, circomBackend, samples)
|
prover = Prover.new(store, circomBackend, samples)
|
||||||
challenge = 1234567.toF.toBytes.toArray32
|
challenge = 1234567.toF.toBytes.toArray32
|
||||||
(inputs, proof) = (await prover.prove(1, verifiable, challenge)).tryGet
|
(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
|
echo "TEST PROOF: state: ", params
|
||||||
# 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 many slot":
|
||||||
let
|
let
|
||||||
@ -84,7 +85,7 @@ suite "Test Prover":
|
|||||||
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..20:
|
||||||
echo "PROVE: ", i
|
echo "PROVE: ", i
|
||||||
let
|
let
|
||||||
challenge = (1234567).toF.toBytes.toArray32
|
challenge = (1234567).toF.toBytes.toArray32
|
||||||
@ -94,9 +95,8 @@ suite "Test Prover":
|
|||||||
await allFutures(proofs)
|
await allFutures(proofs)
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
|
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
|
|
||||||
echo "done done"
|
echo "done done"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user