proving wiring
This commit is contained in:
parent
2fea35cecd
commit
472fbefc5f
|
@ -11,9 +11,7 @@ import pkg/poseidon2/io
|
||||||
import ./utils
|
import ./utils
|
||||||
import ./create_circuits
|
import ./create_circuits
|
||||||
|
|
||||||
type
|
type CircomCircuit* = object
|
||||||
|
|
||||||
CircomCircuit* = object
|
|
||||||
r1csPath*: string
|
r1csPath*: string
|
||||||
wasmPath*: string
|
wasmPath*: string
|
||||||
zkeyPath*: string
|
zkeyPath*: string
|
||||||
|
@ -31,20 +29,16 @@ proc release*(self: CircomCircuit) =
|
||||||
if not isNil(self.vkp):
|
if not isNil(self.vkp):
|
||||||
self.vkp.unsafeAddr.release_key()
|
self.vkp.unsafeAddr.release_key()
|
||||||
|
|
||||||
proc init*(
|
proc initialize*(self: var CircomCircuit) =
|
||||||
_: type CircomCircuit,
|
|
||||||
r1csPath: string,
|
|
||||||
wasmPath: string,
|
|
||||||
zkeyPath: string = "",
|
|
||||||
): CircomCircuit =
|
|
||||||
## Create a new ctx
|
## Create a new ctx
|
||||||
##
|
##
|
||||||
|
|
||||||
var cfg: ptr CircomBn254Cfg
|
var cfg: ptr CircomBn254Cfg
|
||||||
var zkey = if zkeyPath.len > 0: zkeyPath.cstring else: nil
|
var zkey = if self.zkeyPath.len > 0: self.zkeyPath.cstring else: nil
|
||||||
|
|
||||||
if initCircomConfig(r1csPath.cstring, wasmPath.cstring, zkey, cfg.addr) != ERR_OK or
|
if initCircomConfig(
|
||||||
cfg == nil:
|
self.r1csPath.cstring, self.wasmPath.cstring, self.zkeyPath.cstring, cfg.addr
|
||||||
|
) != ERR_OK or cfg == nil:
|
||||||
if cfg != nil:
|
if cfg != nil:
|
||||||
cfg.addr.releaseCfg()
|
cfg.addr.releaseCfg()
|
||||||
raiseAssert("failed to initialize circom compat config")
|
raiseAssert("failed to initialize circom compat config")
|
||||||
|
@ -56,13 +50,8 @@ proc init*(
|
||||||
vkpPtr.addr.releaseKey()
|
vkpPtr.addr.releaseKey()
|
||||||
raiseAssert("Failed to get verifying key")
|
raiseAssert("Failed to get verifying key")
|
||||||
|
|
||||||
CircomCircuit(
|
self.backendCfg = cfg
|
||||||
r1csPath: r1csPath,
|
self.vkp = vkpPtr
|
||||||
wasmPath: wasmPath,
|
|
||||||
zkeyPath: zkeyPath,
|
|
||||||
backendCfg: cfg,
|
|
||||||
vkp: vkpPtr,
|
|
||||||
)
|
|
||||||
|
|
||||||
proc prove*(self: CircomCircuit, input: JsonNode) =
|
proc prove*(self: CircomCircuit, input: JsonNode) =
|
||||||
## Encode buffers using a ctx
|
## Encode buffers using a ctx
|
||||||
|
@ -155,9 +144,10 @@ proc parseCliOptions(self: var CircomCircuit) =
|
||||||
printHelp()
|
printHelp()
|
||||||
val.absolutePath
|
val.absolutePath
|
||||||
|
|
||||||
let params = @[
|
let params =
|
||||||
|
@[
|
||||||
"--dir:benchmarks/circuit_bench_depth32_maxslots256_cellsize2048_blocksize65536_nsamples1_entropy1234567_seed12345_nslots11_ncells512_index3/",
|
"--dir:benchmarks/circuit_bench_depth32_maxslots256_cellsize2048_blocksize65536_nsamples1_entropy1234567_seed12345_nslots11_ncells512_index3/",
|
||||||
"--name:proof_main",
|
"--name:proof_main"
|
||||||
]
|
]
|
||||||
|
|
||||||
for kind, key, value in getOpt(params):
|
for kind, key, value in getOpt(params):
|
||||||
|
@ -199,8 +189,7 @@ proc run*() =
|
||||||
|
|
||||||
# prove wasm ${CIRCUIT_MAIN}.zkey witness.wtns proof.json public.json
|
# prove wasm ${CIRCUIT_MAIN}.zkey witness.wtns proof.json public.json
|
||||||
|
|
||||||
var
|
var self = CircomCircuit()
|
||||||
self = CircomCircuit()
|
|
||||||
|
|
||||||
parseCliOptions(self)
|
parseCliOptions(self)
|
||||||
|
|
||||||
|
@ -237,6 +226,8 @@ proc run*() =
|
||||||
echo "ERROR: couldn't find all files"
|
echo "ERROR: couldn't find all files"
|
||||||
printHelp()
|
printHelp()
|
||||||
|
|
||||||
|
self.initialize()
|
||||||
|
|
||||||
var
|
var
|
||||||
inputData = self.inputsPath.readFile()
|
inputData = self.inputsPath.readFile()
|
||||||
inputs: JsonNode = !JsonNode.parse(inputData)
|
inputs: JsonNode = !JsonNode.parse(inputData)
|
||||||
|
|
Loading…
Reference in New Issue