-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/build scripts for circuit #211
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1a18dd7
fix script for build-dsc-circuit
motemotech b7c69d6
lint
motemotech c49215b
add build script for dislose circuits
motemotech 72fde0e
fix readme
motemotech 727abb8
fix lint
motemotech 3ae600f
Merge branch 'dev' into feat/build-scripts-for-circuit
motemotech 729985e
add build_disclose_circuit.sh and fix each build scripts
motemotech ef9956e
delete not ideal files
motemotech fb77493
change circuit list for build_disclose
motemotech bfb0a42
delete all dsc 2048
motemotech f5e2a43
Merge branch 'dev' into feat/build-scripts-for-circuit
motemotech 038b76a
delte dsc 2048 instances after merge dev
motemotech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
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" | ||
mkdir -p build/${CIRCUIT_TYPE}/${CIRCUIT_NAME}/ | ||
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/${CIRCUIT_TYPE}/${CIRCUIT_NAME}/ | ||
|
||
echo "building zkey" | ||
yarn snarkjs groth16 setup build/${CIRCUIT_TYPE}/${CIRCUIT_NAME}/${CIRCUIT_NAME}.r1cs build/powersOfTau28_hez_final_20.ptau build/${CIRCUIT_TYPE}/${CIRCUIT_NAME}/${CIRCUIT_NAME}.zkey | ||
|
||
echo "building vkey" | ||
yarn snarkjs zkey contribute build/${CIRCUIT_TYPE}/${CIRCUIT_NAME}/${CIRCUIT_NAME}.zkey build/${CIRCUIT_TYPE}/${CIRCUIT_NAME}/${CIRCUIT_NAME}_final.zkey -e="random text" | ||
yarn snarkjs zkey export verificationkey build/${CIRCUIT_TYPE}/${CIRCUIT_NAME}/${CIRCUIT_NAME}_final.zkey build/${CIRCUIT_TYPE}/${CIRCUIT_NAME}/${CIRCUIT_NAME}_vkey.json | ||
|
||
yarn snarkjs zkey export solidityverifier build/${CIRCUIT_TYPE}/${CIRCUIT_NAME}/${CIRCUIT_NAME}_final.zkey build/${CIRCUIT_TYPE}/Verifier_${CIRCUIT_NAME}.sol | ||
sed -i '' "s/Groth16Verifier/Verifier_${CIRCUIT_NAME}/g" build/${CIRCUIT_TYPE}/Verifier_${CIRCUIT_NAME}.sol | ||
mkdir -p ../contracts/contracts/verifiers/local/${CIRCUIT_TYPE}/ | ||
cp build/${CIRCUIT_TYPE}/${CIRCUIT_NAME}/Verifier_${CIRCUIT_NAME}.sol ../contracts/contracts/verifiers/local/${CIRCUIT_TYPE}/Verifier_${CIRCUIT_NAME}.sol | ||
echo "copied Verifier_${CIRCUIT_NAME}.sol to contracts" | ||
|
||
echo "Build of $CIRCUIT_NAME completed in $(($(date +%s) - START_TIME)) seconds" | ||
echo "Size of ${CIRCUIT_NAME}.r1cs: $(wc -c <build/${CIRCUIT_NAME}.r1cs) bytes" | ||
echo "Size of ${CIRCUIT_NAME}.wasm: $(wc -c <build/${CIRCUIT_NAME}_js/${CIRCUIT_NAME}.wasm) bytes" | ||
echo "Size of ${CIRCUIT_NAME}_final.zkey: $(wc -c <build/${CIRCUIT_NAME}_final.zkey) bytes" | ||
} | ||
|
||
# Define circuits and their types | ||
# name:folder:build_flag | ||
# set build_flag to false if you want to skip the build | ||
CIRCUITS=( | ||
"vc_and_disclose:disclose:20:true" | ||
"disclose:disclose:20:false" | ||
"proveCountryIsNotInList:disclose:20:false" | ||
"verify_commitment:disclose:22:false" | ||
) | ||
|
||
TOTAL_START_TIME=$(date +%s) | ||
for circuit in "${CIRCUITS[@]}"; do | ||
IFS=':' read -r CIRCUIT_NAME CIRCUIT_TYPE POWEROFTAU 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" |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we actually want to delete all instances of dsc circuits with 2048 bits key length (and this script), we are no longer using these anymore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we only want to build vc_and_disclose circuit here, others don't have "component main" statement