Last active
May 25, 2022 14:47
-
-
Save naps62/3465b8ebe23faf56ae5a5d49c416ca32 to your computer and use it in GitHub Desktop.
Justfile for compiling Circom circuits
This file contains hidden or 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
set positional-arguments | |
build_dir := "./build" | |
all: | |
just compile Hello | |
# TODO add other circuits | |
# | |
# Circom compilation | |
# | |
@compile c: build-dir powers-of-tau | |
echo -n Compiling {{c}}.circom... | |
mkdir -p {{build_dir}}/{{c}} | |
circom circuits/{{c}}.circom --r1cs --wasm --sym --output {{build_dir}}/{{c}} > /dev/null | |
snarkjs r1cs info {{build_dir}}/{{c}}/{{c}}.r1cs > /dev/null | |
snarkjs groth16 setup {{build_dir}}/{{c}}/{{c}}.r1cs {{powers_of_tau}} {{build_dir}}/{{c}}/init.zkey > /dev/null | |
snarkjs zkey contribute {{build_dir}}/{{c}}/init.zkey {{build_dir}}/{{c}}/final.zkey --name="1st Contributor Name" -v -e="random text" > /dev/null | |
snarkjs zkey export verificationkey {{build_dir}}/{{c}}/final.zkey {{build_dir}}/{{c}}/verification_key.json > /dev/null | |
snarkjs zkey export solidityverifier {{build_dir}}/{{c}}/final.zkey {{build_dir}}/{{c}}/{{c}}Verifier.sol > /dev/null | |
# TODO bump solidity version | |
sed -i 's/pragma solidity .*;/pragma solidity ^0.8.0;/' {{build_dir}}/{{c}}/{{c}}Verifier.sol | |
sed -i 's/contract Verifier/contract {{c}}Verifier/' {{build_dir}}/{{c}}/{{c}}Verifier.sol | |
echo Done | |
# | |
# Powers of Tau setup | |
# | |
powers_of_tau_size := "10" | |
powers_of_tau_filename := "powersOfTau28_hez_final_" + powers_of_tau_size + ".ptau" | |
powers_of_tau_url := "https://hermez.s3-eu-west-1.amazonaws.com/" + powers_of_tau_filename | |
powers_of_tau := build_dir + "/" + powers_of_tau_filename | |
@powers-of-tau: build-dir | |
[ -f {{powers_of_tau}} ] || wget {{powers_of_tau_url}} -O {{powers_of_tau}} | |
@build-dir: | |
mkdir -p build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment