This commit is contained in:
Jaremy Creechley 2024-04-24 15:11:55 +03:00
parent 4146690899
commit 682d03b989
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 27 additions and 3 deletions

View File

@ -58,6 +58,27 @@ when isMainModule:
ncells: 512, # number of cells in this slot
)
createCircuit(args)
let benchenv = 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"
var
circom: CircomCompat
proofInputs: ProofInputs[Poseidon2Hash]
let
inputData = readFile("tests/circuits/fixtures/input.json")
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
circom.release() # this comes from the rust FFI

View File

@ -109,7 +109,7 @@ proc createCircuit*(
ptauPath = ptauDefPath,
ptauUrl = ptauDefUrl,
someEntropy = "some_entropy_75289v3b7rcawcsyiur",
) =
): tuple[dir: string, name: string] =
## Generates all the files needed for to run a proof circuit. Downloads the PTAU file if needed.
##
let circdir = circBenchDir
@ -170,6 +170,8 @@ proc createCircuit*(
moveFile(fmt"{name}_0001.zkey", fmt"{name}.zkey")
removeFile(fmt"{name}_0000.zkey")
return (circdir, name)
when isMainModule:
checkEnv()
@ -185,4 +187,5 @@ when isMainModule:
index: 3, # which slot we prove (0..NSLOTS-1)
ncells: 512, # number of cells in this slot
)
createCircuit(args)
let benchenv = createCircuit(args)
echo "\nBench dir:\n", benchenv