forked from 0xEigenLabs/eigen-zkvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_single.sh
executable file
·40 lines (28 loc) · 1.18 KB
/
test_single.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
# EigenZKit
set -ex
cargo build --release
CIRCUIT=${1-circuit} # use circuit or mnist as the first parameter
CUR_DIR=$(cd $(dirname $0);pwd)
POWER=${2-12} # 15 for zkMinist
ZKIT="${CUR_DIR}/../target/release/eigen-zkit"
WORKSPACE=/tmp/single
rm -rf $WORKSPACE && mkdir -p $WORKSPACE
SRS=${CUR_DIR}/../keys/setup_2^${POWER}.key
cd $CUR_DIR
if [ ! -f $SRS ]; then
${ZKIT} setup -p ${POWER} -s ${SRS}
fi
echo "1. Compile the circuit"
${ZKIT} compile -i ${CUR_DIR}/single/circuit/${CIRCUIT}.circom --O2=full -o $WORKSPACE
echo "2. Generate witness"
${ZKIT} calculate_witness -i ${CUR_DIR}/single/input/${CIRCUIT}.json -w ${WORKSPACE}/${CIRCUIT}_js/${CIRCUIT}.wasm -o $WORKSPACE/witness.wtns
echo "3. Export verification key"
${ZKIT} export_verification_key -s ${SRS} -c $WORKSPACE/$CIRCUIT.r1cs --v $WORKSPACE/vk.bin
echo "4. prove"
${ZKIT} prove -c $WORKSPACE/$CIRCUIT.r1cs -w $WORKSPACE/witness.wtns -s ${SRS} --b $WORKSPACE/proof.bin
echo "5. Verify the proof"
${ZKIT} verify -p $WORKSPACE/proof.bin -v $WORKSPACE/vk.bin
echo "6. Generate verifier"
${ZKIT} generate_verifier -v $WORKSPACE/vk.bin --s single/contracts/verifier.sol
echo "7. run verifier test"
cd $CUR_DIR/single && npm run test