From 180e00434c546e3a8011b3fd4d06d3268b3727ca Mon Sep 17 00:00:00 2001 From: Balazs Komuves Date: Fri, 14 Mar 2025 17:52:38 +0100 Subject: [PATCH] add witness computation graph extraction to the workflow --- workflow/README.md | 8 +++++++- workflow/prove.sh | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/workflow/README.md b/workflow/README.md index 5304a5b..321e8b4 100644 --- a/workflow/README.md +++ b/workflow/README.md @@ -61,6 +61,7 @@ TODO: ### Preliminaries - install `circom`, `snarkjs`, `rapidsnark`: +- optionally install `circom-witnesscalc`: - install Nim: Build the Nim cli proof input generator: @@ -105,7 +106,12 @@ After that, the first real step is to create the main component: Then compile the circuit: - $ circom --r1cs --wasm --O2 -l../../circuit proof_main.circom + $ export CIRCUIT_LIBDIRS="-l../../circuit/lib -l../../circuit/poseidon2 -l../../circuit/codex" + $ circom --r1cs --wasm --O2 ${CIRCUIT_LIBDIRS} proof_main.circom + +### Optionally extract the witness computation graph + + $ build-circuit proof_main.circom proof_main_graph.bin ${CIRCUIT_LIBDIRS} ### Do the circuit-specific setup diff --git a/workflow/prove.sh b/workflow/prove.sh index cfd66c8..02faf10 100755 --- a/workflow/prove.sh +++ b/workflow/prove.sh @@ -8,6 +8,17 @@ source ./cli_args.sh mkdir -p build cd build +# --- export the witness computation graph --- + +if command -v build-circuit +then + CIRCUIT_INCLUDES="-l${CIRCUIT_LIB_DIR} -l${CIRCUIT_POS_DIR} -l${CIRCUIT_PRF_DIR}" + build-circuit ${CIRCUIT_MAIN}.circom ${CIRCUIT_MAIN}_graph.bin ${CIRCUIT_INCLUDES} +else + echo " " + echo "\`circom-witnesscalc\` not found; skipping graph extraction" +fi + # --- generate input for the circuit --- echo ""