From 7dd44484e257f895f8f6778be4d26d26e75adf92 Mon Sep 17 00:00:00 2001 From: poma Date: Wed, 8 Jan 2020 19:41:09 +0700 Subject: [PATCH] Change entropy to be the last command line arg, add test.sh file that demontstrates phase2 usage --- phase2/src/bin/contribute.rs | 6 +++--- phase2/test.sh | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100755 phase2/test.sh diff --git a/phase2/src/bin/contribute.rs b/phase2/src/bin/contribute.rs index d53f3db..5bd517e 100644 --- a/phase2/src/bin/contribute.rs +++ b/phase2/src/bin/contribute.rs @@ -16,12 +16,12 @@ use std::fs::OpenOptions; fn main() { let args: Vec = std::env::args().collect(); if args.len() != 4 { - println!("Usage: \n "); + println!("Usage: \n "); std::process::exit(exitcode::USAGE); } let in_params_filename = &args[1]; - let entropy = &args[2]; - let out_params_filename = &args[3]; + let out_params_filename = &args[2]; + let entropy = &args[3]; let disallow_points_at_infinity = false; diff --git a/phase2/test.sh b/phase2/test.sh new file mode 100755 index 0000000..24481ed --- /dev/null +++ b/phase2/test.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +rm -f pk.json vk.json transformed_vk.json transformed_pk.* proof.json + +set -e + +# 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 +npx snarkjs setup --protocol groth +# patch dummy keys with actual keys params +node patch_vk.js +# generate binary version of proving key +node node_modules/websnark/tools/buildpkey.js -i transformed_pk.json -o transformed_pk.bin + +# try to generate and verify proof +snarkjs calculatewitness +node node_modules/websnark/tools/buildwitness.js -i witness.json -o witness.bin +snarkjs proof # to get public inputs json only +./cli.js +snarkjs verify --vk transformed_vk.json --proof proof.json \ No newline at end of file