This commit is contained in:
Erhan Tezcan
2023-03-27 22:17:29 +03:00
parent cc17763aa5
commit 0ff445fef3
10 changed files with 45 additions and 64 deletions

View File

@@ -1,10 +1,10 @@
## Clean build files
clean() {
echo -e "\n${TITLE_COLOR}=== Cleaning artifacts ===${RESET}"
echo -e "\n${CLIENV_COLOR_TITLE}=== Cleaning artifacts ===${CLIENV_COLOR_RESET}"
local CIRCUIT=$1
local CIRCUIT_DIR=./build/$CIRCUIT
rm -rf $CIRCUIT_DIR
echo -e "${LOG_COLOR}Deleted $CIRCUIT_DIR${RESET}"
echo -e "${CLIENV_COLOR_LOG}Deleted $CIRCUIT_DIR${CLIENV_COLOR_RESET}"
}

View File

@@ -1,6 +1,6 @@
## Compile the circuit, outputting R1CS and JS files
compile() {
echo -e "\n${TITLE_COLOR}=== Compiling the circuit ===${RESET}"
echo -e "\n${CLIENV_COLOR_TITLE}=== Compiling the circuit ===${CLIENV_COLOR_RESET}"
local CIRCUIT=$1
local CIRCOM_IN=./circuits/main/$CIRCUIT.circom
local CIRCOM_OUT=./build/$CIRCUIT
@@ -13,5 +13,5 @@ compile() {
# compile with circom
circom $CIRCOM_IN -o $CIRCOM_OUT --r1cs --sym --wasm
echo -e "${LOG_COLOR}Built artifacts under $CIRCOM_OUT${RESET}"
echo -e "${CLIENV_COLOR_LOG}Built artifacts under $CIRCOM_OUT${CLIENV_COLOR_RESET}"
}

View File

@@ -1,6 +1,6 @@
## Generate a proof
prove() {
echo -e "\n${TITLE_COLOR}=== Generating proof ===${RESET}"
echo -e "\n${CLIENV_COLOR_TITLE}=== Generating proof ===${CLIENV_COLOR_RESET}"
local CIRCUIT=$1
local INPUT=$2
local CIRCUIT_DIR=./build/$CIRCUIT
@@ -12,5 +12,5 @@ prove() {
$OUTPUT_DIR/proof.json \
$OUTPUT_DIR/public.json
echo -e "${LOG_COLOR}Generated under $OUTPUT_DIR${RESET}"
echo -e "${CLIENV_COLOR_LOG}Generated under $OUTPUT_DIR${CLIENV_COLOR_RESET}"
}

View File

@@ -1,7 +1,7 @@
## Commence a circuit-specific phase-2 powers-of-tau ceremony
ptau() {
echo -e "\n${TITLE_COLOR}=== Phase-2 Powers of Tau ===${RESET}"
echo -e "${LOG_COLOR}this may take a while...${RESET}"
echo -e "\n${CLIENV_COLOR_TITLE}=== Phase-2 Powers of Tau ===${CLIENV_COLOR_RESET}"
echo -e "${CLIENV_COLOR_LOG}this may take a while...${CLIENV_COLOR_RESET}"
local CIRCUIT=$1 # circuit name
local NUM_CONTRIBS=$2 # number of contributions
local P1_PTAU=$3 # path to phase-1 ptau
@@ -43,5 +43,5 @@ ptau() {
# export
snarkjs zkey export verificationkey $PROVER_KEY $VERIFICATION_KEY
echo -e "${LOG_COLOR}Generated keys\n\tProver key: $PROVER_KEY\n\tVerification key: $VERIFICATION_KEY${RESET}"
echo -e "${CLIENV_COLOR_LOG}Generated keys\n\tProver key: $PROVER_KEY\n\tVerification key: $VERIFICATION_KEY${CLIENV_COLOR_RESET}"
}

View File

@@ -1,11 +1,11 @@
## Parse the symbols file and generate types for TypeScript
type() {
echo -e "\n${TITLE_COLOR}=== Generating types ===${RESET}"
echo -e "\n${CLIENV_COLOR_TITLE}=== Generating types ===${CLIENV_COLOR_RESET}"
CIRCUIT=$1
SYM=./build/$CIRCUIT/$CIRCUIT.sym
# choose lines with 1 dot only (these are the signals in main file), extract their names
cat $SYM | grep -E '^.+main[^.]*\.[^.]*$'
echo -e "\n${LOG_COLOR}Types generated!${RESET}"
echo -e "\n${CLIENV_COLOR_LOG}Types generated!${CLIENV_COLOR_RESET}"
}

View File

@@ -1,6 +1,6 @@
## Verify a witness & proof
verify() {
echo -e "\n${TITLE_COLOR}=== Verifying proof ===${RESET}"
echo -e "\n${CLIENV_COLOR_TITLE}=== Verifying proof ===${CLIENV_COLOR_RESET}"
local CIRCUIT=$1
local INPUT=$2
local CIRCUIT_DIR=./build/${CIRCUIT}
@@ -10,5 +10,5 @@ verify() {
$CIRCUIT_DIR/$INPUT/public.json \
$CIRCUIT_DIR/$INPUT/proof.json
echo -e "${LOG_COLOR}Verification complete.${RESET}"
echo -e "${CLIENV_COLOR_LOG}Verification complete.${CLIENV_COLOR_RESET}"
}

View File

@@ -1,6 +1,6 @@
## Computes the witness for the given circuit and input
witness() {
echo -e "\n${TITLE_COLOR}=== Computing witness ===${RESET}"
echo -e "\n${CLIENV_COLOR_TITLE}=== Computing witness ===${CLIENV_COLOR_RESET}"
local CIRCUIT=$1
local INPUT=$2
local JS_DIR=./build/$CIRCUIT/${CIRCUIT}_js # JS files for the circuit
@@ -15,5 +15,5 @@ witness() {
$INPUT_DIR/$INPUT.json \
$WITNESS
echo -e "${LOG_COLOR}Generated\n\tWitness: $WITNESS${RESET}"
echo -e "${CLIENV_COLOR_LOG}Generated\n\tWitness: $WITNESS${CLIENV_COLOR_RESET}"
}