2020-01-08 15:41:09 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2020-01-22 19:23:39 +03:00
|
|
|
if [ ! -f ../powersoftau/phase1radix2m0 ]; then
|
|
|
|
echo "Please run powers of tau test first to generate radix files"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-01-08 15:41:09 +03:00
|
|
|
# move results of powers of tau here
|
|
|
|
cp ../powersoftau/phase1radix* .
|
|
|
|
|
|
|
|
# compile circuit
|
|
|
|
npx circom circuit.circom -o circuit.json && npx snarkjs info -c circuit.json
|
|
|
|
# npx snarkjs info -c circuit.json
|
|
|
|
|
|
|
|
# initialize ceremony
|
|
|
|
cargo run --release --bin new circuit.json circom1.params
|
|
|
|
|
|
|
|
cargo run --release --bin contribute circom1.params circom2.params asdajdzixcjlzxjczxlkcjzxlkcj
|
|
|
|
cargo run --release --bin verify_contribution circuit.json circom1.params circom2.params
|
|
|
|
|
|
|
|
cargo run --release --bin contribute circom2.params circom3.params dsfjkshdfakjhsdf
|
|
|
|
cargo run --release --bin verify_contribution circuit.json circom2.params circom3.params
|
|
|
|
|
|
|
|
cargo run --release --bin contribute circom3.params circom4.params askldfjklasdf
|
|
|
|
cargo run --release --bin verify_contribution circuit.json circom3.params circom4.params
|
|
|
|
|
|
|
|
# generate resulting keys
|
|
|
|
cargo run --release --bin export_keys circom4.params vk.json pk.json
|
|
|
|
# create dummy keys in circom format
|
2020-01-22 19:23:39 +03:00
|
|
|
echo "generating dummy key files..."
|
2020-01-08 15:41:09 +03:00
|
|
|
npx snarkjs setup --protocol groth
|
|
|
|
# patch dummy keys with actual keys params
|
2020-01-16 21:59:34 +03:00
|
|
|
cargo run --release --bin copy_json proving_key.json pk.json transformed_pk.json
|
|
|
|
cargo run --release --bin copy_json verification_key.json vk.json transformed_vk.json
|
2020-01-08 15:41:09 +03:00
|
|
|
|
2020-01-17 10:00:49 +03:00
|
|
|
# generate solidity verifier
|
|
|
|
cargo run --release --bin generate_verifier circom4.params verifier.sol
|
|
|
|
|
2020-01-08 15:41:09 +03:00
|
|
|
# try to generate and verify proof
|
2020-01-22 19:23:39 +03:00
|
|
|
npx snarkjs calculatewitness
|
|
|
|
cargo run --release --bin prove circuit.json witness.json circom4.params proof.json public.json
|
|
|
|
npx snarkjs verify --vk transformed_vk.json --proof proof.json
|