integrate setup and proving

This commit is contained in:
Jaremy Creechley 2024-04-24 15:17:16 +03:00
parent 682d03b989
commit 91c695cb0e
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 19 additions and 20 deletions

View File

@ -1,5 +1,7 @@
import std/sequtils
import std/strutils
import std/strformat
import std/os
import std/options
import std/importutils
@ -58,27 +60,25 @@ when isMainModule:
ncells: 512, # number of cells in this slot
)
let benchenv = createCircuit(args)
let env = createCircuit(args)
## TODO: copy over testcircomcompat proving
when false:
let
r1cs = "tests/circuits/fixtures/proof_main.r1cs"
wasm = "tests/circuits/fixtures/proof_main.wasm"
zkey = "tests/circuits/fixtures/proof_main.zkey"
r1cs = env.dir / fmt"{env.name}.r1cs"
wasm = env.dir / fmt"{env.name}.wasm"
zkey = env.dir / fmt"{env.name}.zkey"
inputs = env.dir / fmt"inputs.json"
var
circom: CircomCompat
proofInputs: ProofInputs[Poseidon2Hash]
let
inputData = readFile("tests/circuits/fixtures/input.json")
inputData = inputs.readFile()
inputJson = !JsonNode.parse(inputData)
proofInputs = Poseidon2Hash.jsonToProofInput(inputJson)
circom = CircomCompat.init(r1cs, wasm, zkey)
let proof = circom.prove(proofInputs).tryGet
circom.verify(proof, proofInputs).tryGet
let verRes = circom.verify(proof, proofInputs).tryGet
echo "verify: ", verRes
circom.release() # this comes from the rust FFI

View File

@ -129,10 +129,9 @@ proc createCircuit*(
for f, v in fieldPairs(args):
cliCmd &= " --" & f & "=" & $v
if not "input.json".fileExists:
if not "inputs.json".fileExists:
echo "Generating Circom Files..."
# ${NIMCLI_DIR}/cli $CLI_ARGS -v --circom=${CIRCUIT_MAIN}.circom --output=input.json
cliCmd &= fmt" -v --circom={name}.circom --output=input.json"
cliCmd &= fmt" -v --circom={name}.circom --output=inputs.json"
echo "CWD: ", getCurrentDir()
echo "CLI_CMD: ", cliCmd