Skip to content

Commit

Permalink
update build_circuits.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
remicolin committed Jul 14, 2024
1 parent 8e3be17 commit e1f518a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions circuits/scripts/build_circuits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ source "scripts/download_ptau.sh"

build_circuit() {
local CIRCUIT_NAME=$1
local CIRCUIT_TYPE=$2
local START_TIME=$(date +%s)

echo "compiling circuit: $CIRCUIT_NAME"
circom circuits/${CIRCUIT_NAME}.circom -l node_modules -l ./node_modules/@zk-kit/binary-merkle-root.circom/src -l ./node_modules/circomlib/circuits --r1cs --O1 --wasm -c --output build
circom circuits/${CIRCUIT_TYPE}/${CIRCUIT_NAME}.circom -l node_modules -l ./node_modules/@zk-kit/binary-merkle-root.circom/src -l ./node_modules/circomlib/circuits --r1cs --O1 --wasm -c --output build

echo "building zkey"
yarn snarkjs groth16 setup build/${CIRCUIT_NAME}.r1cs build/powersOfTau28_hez_final_20.ptau build/${CIRCUIT_NAME}.zkey
Expand All @@ -27,11 +28,23 @@ build_circuit() {
echo "Size of ${CIRCUIT_NAME}_final.zkey: $(wc -c <build/${CIRCUIT_NAME}_final.zkey) bytes"
}

#declare -a CIRCUITS=("register_sha256WithRSAEncryption_65537" "register_sha1WithRSAEncryption_65537" "register_sha256WithRSAEncryption_65537" "disclose")
declare -a CIRCUITS=("register_sha256WithRSAEncryption_65537")
# Define circuits and their types
# name:folder:build_flag
# set build_flag to false if you want to skip the build
CIRCUITS=(
"register_sha256WithRSAEncryption_65537:register:true"
"register_sha1WithRSAEncryption_65537:register:true"
"disclose:disclose:true"
)

TOTAL_START_TIME=$(date +%s)
for CIRCUIT_NAME in "${CIRCUITS[@]}"; do
build_circuit "$CIRCUIT_NAME"
for circuit in "${CIRCUITS[@]}"; do
IFS=':' read -r CIRCUIT_NAME CIRCUIT_TYPE BUILD_FLAG <<< "$circuit"
if [ "$BUILD_FLAG" = "true" ]; then
echo "Debug: Building circuit $CIRCUIT_NAME of type $CIRCUIT_TYPE"
build_circuit "$CIRCUIT_NAME" "$CIRCUIT_TYPE"
else
echo "Skipping build for $CIRCUIT_NAME"
fi
done
echo "Total completed in $(($(date +%s) - TOTAL_START_TIME)) seconds"

0 comments on commit e1f518a

Please sign in to comment.