mirror of
https://github.com/status-im/nim-codex.git
synced 2025-02-21 15:08:33 +00:00
add asynccircom backend
This commit is contained in:
parent
aa9f2d2a1f
commit
0ac9750308
@ -1,3 +1,4 @@
|
|||||||
import ./backends/circomcompat
|
import ./backends/circomcompat
|
||||||
|
import ./backends/asynccircoms
|
||||||
|
|
||||||
export circomcompat
|
export circomcompat, asynccircoms
|
||||||
|
@ -7,6 +7,7 @@ import pkg/chronos
|
|||||||
import pkg/chronos/threadsync
|
import pkg/chronos/threadsync
|
||||||
import pkg/questionable/results
|
import pkg/questionable/results
|
||||||
|
|
||||||
|
import ./circomcompat
|
||||||
|
|
||||||
const
|
const
|
||||||
CompletitionTimeout = 1.seconds # Maximum await time for completition after receiving a signal
|
CompletitionTimeout = 1.seconds # Maximum await time for completition after receiving a signal
|
||||||
@ -17,12 +18,23 @@ type
|
|||||||
params*: CircomCompatParams
|
params*: CircomCompatParams
|
||||||
|
|
||||||
# Args objects are missing seq[seq[byte]] field, to avoid unnecessary data copy
|
# Args objects are missing seq[seq[byte]] field, to avoid unnecessary data copy
|
||||||
EncodeTaskArgs = object
|
ProveTaskArgs = object
|
||||||
signal: ThreadSignalPtr
|
signal: ThreadSignalPtr
|
||||||
backend: EncoderBackendPtr
|
params: CircomCompatParams
|
||||||
blockSize: int
|
|
||||||
ecM: int
|
|
||||||
|
|
||||||
proc prove*[H](
|
proc prove*[H](
|
||||||
self: CircomCompat,
|
self: AsyncCircomCompat,
|
||||||
input: ProofInputs[H]): ?!CircomProof =
|
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"
|
topics = "codex prover"
|
||||||
|
|
||||||
type
|
type
|
||||||
AnyBackend* = CircomCompat
|
AnyBackend* = AsyncCircomCompat
|
||||||
AnyProof* = CircomProof
|
AnyProof* = CircomProof
|
||||||
|
|
||||||
AnySampler* = Poseidon2Sampler
|
AnySampler* = Poseidon2Sampler
|
||||||
@ -75,7 +75,7 @@ proc prove*(
|
|||||||
return failure(err)
|
return failure(err)
|
||||||
|
|
||||||
# prove slot
|
# 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
|
error "Unable to prove slot", err = err.msg
|
||||||
return failure(err)
|
return failure(err)
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ proc verify*(
|
|||||||
## Prove a statement using backend.
|
## Prove a statement using backend.
|
||||||
## Returns a future that resolves to a proof.
|
## Returns a future that resolves to a proof.
|
||||||
|
|
||||||
self.backend.verify(proof, inputs)
|
await self.backend.verify(proof, inputs)
|
||||||
|
|
||||||
proc new*(
|
proc new*(
|
||||||
_: type Prover,
|
_: type Prover,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user