mirror of
https://github.com/status-im/nim-codex.git
synced 2025-02-17 21:27:54 +00:00
add asynccircom backend
This commit is contained in:
parent
aa9f2d2a1f
commit
0ac9750308
@ -1,3 +1,4 @@
|
||||
import ./backends/circomcompat
|
||||
import ./backends/asynccircoms
|
||||
|
||||
export circomcompat
|
||||
export circomcompat, asynccircoms
|
||||
|
@ -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 =
|
||||
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
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user