diff --git a/codex/slots/proofs/backends.nim b/codex/slots/proofs/backends.nim index 477ba140..5b88f11c 100644 --- a/codex/slots/proofs/backends.nim +++ b/codex/slots/proofs/backends.nim @@ -1,3 +1,4 @@ import ./backends/circomcompat +import ./backends/asynccircoms -export circomcompat +export circomcompat, asynccircoms diff --git a/codex/slots/proofs/backends/asynccircoms.nim b/codex/slots/proofs/backends/asynccircoms.nim index 4dfc1f95..32ac8df0 100644 --- a/codex/slots/proofs/backends/asynccircoms.nim +++ b/codex/slots/proofs/backends/asynccircoms.nim @@ -7,6 +7,7 @@ import pkg/chronos import pkg/chronos/threadsync import pkg/questionable/results +import ./circomcompat const CompletitionTimeout = 1.seconds # Maximum await time for completition after receiving a signal @@ -17,12 +18,23 @@ type params*: CircomCompatParams # Args objects are missing seq[seq[byte]] field, to avoid unnecessary data copy - EncodeTaskArgs = object + ProveTaskArgs = object signal: ThreadSignalPtr - backend: EncoderBackendPtr - blockSize: int - ecM: int + params: CircomCompatParams proc prove*[H]( - self: CircomCompat, - input: ProofInputs[H]): ?!CircomProof = \ No newline at end of file + self: AsyncCircomCompat, + input: ProofInputs[H] +): Future[?!CircomProof] {.async.} = + ## Generates proof using circom-compat asynchronously + ## + discard + +proc verify*[H]( + self: AsyncCircomCompat, + proof: CircomProof, + inputs: ProofInputs[H] +): Future[?!bool] {.async.} = + ## Verify a proof using a ctx + ## + discard diff --git a/codex/slots/proofs/prover.nim b/codex/slots/proofs/prover.nim index 72ec0161..8f82f436 100644 --- a/codex/slots/proofs/prover.nim +++ b/codex/slots/proofs/prover.nim @@ -34,7 +34,7 @@ logScope: topics = "codex prover" type - AnyBackend* = CircomCompat + AnyBackend* = AsyncCircomCompat AnyProof* = CircomProof AnySampler* = Poseidon2Sampler @@ -75,7 +75,7 @@ proc prove*( return failure(err) # prove slot - without proof =? self.backend.prove(proofInput), err: + without proof =? await self.backend.prove(proofInput), err: error "Unable to prove slot", err = err.msg return failure(err) @@ -89,7 +89,7 @@ proc verify*( ## Prove a statement using backend. ## Returns a future that resolves to a proof. - self.backend.verify(proof, inputs) + await self.backend.verify(proof, inputs) proc new*( _: type Prover,