nim-codex/benchmarks/create_circuits.nim

39 lines
1.4 KiB
Nim
Raw Normal View History

2024-04-24 13:00:05 +03:00
import std/strutils
import std/os
proc createCircuits() =
let cmds = """
${NIMCLI_DIR}/cli $CLI_ARGS -v --circom=${CIRCUIT_MAIN}.circom --output=input.json
circom --r1cs --wasm --O2 -l${CIRCUIT_DIR} ${CIRCUIT_MAIN}.circom
NODE_OPTIONS="--max-old-space-size=8192" snarkjs groth16 setup ${CIRCUIT_MAIN}.r1cs $PTAU_PATH ${CIRCUIT_MAIN}_0000.zkey
echo "some_entropy_75289v3b7rcawcsyiur" | NODE_OPTIONS="--max-old-space-size=8192" snarkjs zkey contribute ${CIRCUIT_MAIN}_0000.zkey ${CIRCUIT_MAIN}_0001.zkey --name="1st Contributor Name"
""".splitLines()
# rm ${CIRCUIT_MAIN}_0000.zkey
# mv ${CIRCUIT_MAIN}_0001.zkey ${CIRCUIT_MAIN}.zkey
2024-04-24 13:09:34 +03:00
let nimCircuitRefFl = "vendor"/"codex-storage-proofs-circuits"/"reference"/"nim"/"proof_input"/"cli"
2024-04-24 13:00:05 +03:00
2024-04-24 13:09:34 +03:00
proc setProjDir(prev = getCurrentDir()): string =
2024-04-24 13:00:05 +03:00
if not "codex.nimble".fileExists():
setCurrentDir("..")
if prev == getCurrentDir():
echo "\nERROR: Codex project folder not found (could not find codex.nimble)"
echo "\nBenchmark must be run from within the Codex project folder"
quit 1
setProjDir()
2024-04-24 13:09:34 +03:00
else:
getCurrentDir()
2024-04-24 13:00:05 +03:00
2024-04-24 13:09:34 +03:00
let codexProjDir = setProjDir()
echo "\n\nFound project dir: ", codexProjDir
2024-04-24 13:00:05 +03:00
2024-04-24 13:09:34 +03:00
if not nimCircuitRefFl.fileExists:
echo "Nim Circuit reference cli not found: ", nimCircuitRefFl
echo "Building Circuit reference cli..."
setCurrentDir(nimCircuitRefFl.parentDir)
let res = execShellCmd("nimble build -d:release --styleCheck:off cli")
2024-04-24 13:00:05 +03:00
echo "huzzah"