-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_new_scalar.sh
executable file
·79 lines (65 loc) · 3.01 KB
/
build_new_scalar.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
yarn
yarn --cwd circuits/circom-ecdsa
PHASE1=./data/powersOfTau28_hez_final_25.ptau
BUILD_DIR=./build/batch_ecdsa
CIRCUIT_NAME=test_new_scalar
TEST_DIR=./test
OUTPUT_DIR="$BUILD_DIR"/"$CIRCUIT_NAME"_cpp
NODE_PATH=
SNARKJS_PATH=
RAPIDSNARK_PATH=
if [ ! -d "$BUILD_DIR" ]; then
echo "No build directory found. Creating build directory..."
mkdir -p "$BUILD_DIR"
fi
echo "****COMPILING CIRCUIT****"
start=`date +%s`
circom "$TEST_DIR"/circuits/"$CIRCUIT_NAME".circom --r1cs --sym --c --output "$BUILD_DIR"
end=`date +%s`
echo "DONE ($((end-start))s)"
#echo "****Running make to make witness generation binary****"
#start=`date +%s`
#make -C "$OUTPUT_DIR"
#end=`date +%s`
#echo "DONE ($((end-start))s)"
#echo "****Executing witness generation****"
#start=`date +%s`
#./"$OUTPUT_DIR"/"$CIRCUIT_NAME" "$TEST_DIR"/input_2.json "$OUTPUT_DIR"/witness.wtns
#end=`date +%s`
#echo "DONE ($((end-start))s)"
# echo "****Converting witness to json****"
# start=`date +%s`
# $NODE_PATH $SNARKJS_PATH wej "$OUTPUT_DIR"/witness.wtns "$OUTPUT_DIR"/witness.json
# end=`date +%s`
# echo "DONE ($((end-start))s)"
#echo "****GENERATING ZKEY 0****"
#start=`date +%s`
#$NODE_PATH --trace-gc --trace-gc-ignore-scavenger --max-old-space-size=2048000 --initial-old-space-size=2048000 --no-global-gc-scheduling --no-incremental-marking --max-semi-space-size=1024 --initial-heap-size=2048000 --expose-gc $SNARKJS_PATH zkey new "$BUILD_DIR"/"$CIRCUIT_NAME".r1cs "$PHASE1" "$OUTPUT_DIR"/"$CIRCUIT_NAME"_p1.zkey
#end=`date +%s`
#echo "DONE ($((end-start))s)"
#echo "****CONTRIBUTE TO PHASE 2 CEREMONY****"
#start=`date +%s`
#$NODE_PATH $SNARKJS_PATH zkey contribute "$OUTPUT_DIR"/"$CIRCUIT_NAME"_p1.zkey "$OUTPUT_DIR"/"$CIRCUIT_NAME"_p2.zkey -n="First phase2 contribution" -e="some random text for entropy"
#end=`date +%s`
#echo "DONE ($((end-start))s)"
#echo "****VERIFYING FINAL ZKEY****"
#start=`date +%s`
#$NODE_PATH --trace-gc --trace-gc-ignore-scavenger --max-old-space-size=2048000 --initial-old-space-size=2048000 --no-global-gc-scheduling --no-incremental-marking --max-semi-space-size=1024 --initial-heap-size=2048000 --expose-gc $SNARKJS_PATH zkey verify "$BUILD_DIR"/"$CIRCUIT_NAME".r1cs "$PHASE1" "$OUTPUT_DIR"/"$CIRCUIT_NAME"_p2.zkey
#end=`date +%s`
#echo "DONE ($((end-start))s)"
#echo "****EXPORTING VKEY****"
#start=`date +%s`
#$NODE_PATH $SNARKJS_PATH zkey export verificationkey "$OUTPUT_DIR"/"$CIRCUIT_NAME"_p2.zkey "$OUTPUT_DIR"/"$CIRCUIT_NAME"_vkey.json
#end=`date +%s`
#echo "DONE ($((end-start))s)"
#echo "****GENERATING PROOF FOR SAMPLE INPUT****"
#start=`date +%s`
#$RAPIDSNARK_PATH "$OUTPUT_DIR"/"$CIRCUIT_NAME"_p2.zkey "$OUTPUT_DIR"/witness.wtns "$OUTPUT_DIR"/"$CIRCUIT_NAME"_proof.json "$OUTPUT_DIR"/"$CIRCUIT_NAME"_public.json
#end=`date +%s`
#echo "DONE ($((end-start))s)"
#echo "****VERIFYING PROOF FOR SAMPLE INPUT****"
#start=`date +%s`
#$NODE_PATH $SNARKJS_PATH groth16 verify "$OUTPUT_DIR"/"$CIRCUIT_NAME"_vkey.json "$OUTPUT_DIR"/"$CIRCUIT_NAME"_public.json "$OUTPUT_DIR"/"$CIRCUIT_NAME"_proof.json
#end=`date +%s`
#echo "DONE ($((end-start))s)"