From 88e4923ee64308a0084d67cdd9ed838feca14175 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Tue, 24 Oct 2023 14:54:34 +0000 Subject: [PATCH 1/2] add regenerate double_verify_proof temp script --- barretenberg/acir_tests/README.md | 16 ++++ .../acir_tests/flows/proof_as_fields.sh | 8 ++ barretenberg/acir_tests/flows/prove.sh | 21 +++++ barretenberg/acir_tests/flows/vk_as_fields.sh | 8 ++ barretenberg/acir_tests/flows/write_vk.sh | 8 ++ .../acir_tests/gen_inner_proof_inputs.sh | 78 +++++++++++++++++++ 6 files changed, 139 insertions(+) create mode 100755 barretenberg/acir_tests/flows/proof_as_fields.sh create mode 100755 barretenberg/acir_tests/flows/prove.sh create mode 100755 barretenberg/acir_tests/flows/vk_as_fields.sh create mode 100755 barretenberg/acir_tests/flows/write_vk.sh create mode 100755 barretenberg/acir_tests/gen_inner_proof_inputs.sh diff --git a/barretenberg/acir_tests/README.md b/barretenberg/acir_tests/README.md index a85d92b7cd5..8bdf7fa6585 100644 --- a/barretenberg/acir_tests/README.md +++ b/barretenberg/acir_tests/README.md @@ -42,3 +42,19 @@ The `all_cmds` flow tests all the supported commands on the binary. Slower, but ``` $ FLOW=all_cmds ./run_acir_tests.sh 1_mul ``` + +## Regenerating witness for `double_verify_proof` + +`double_verify_proof` has inputs that are proof system specific such as the circuit verification key and the proofs themselves which are being recursively verified. Certain proof system changes can sometimes lead to the key or inner proofs now being invalid. + +This means we have to generate the proof specific inputs using our backend and pass it back into `double_verify_proof` to regenerate the accurate witness. The following is a temporary solution to manually regenerate the inputs for `double_verify_proof` on a specific Noir branch. + +First find `acir_tests/gen_inner_proof_inputs.sh`. Change the $BRANCH env var to your working branch and $PROOF_NAME to your first input you want to recursively verify. The script is going to generate the proof system specific verification key output and proof for the `assert_statement` test. + +To run: +``` +./gen_inner_proof_inputs.sh +``` +To generate a new input you can run the script again. To generate a new file under `assert_statement/proofs/` be sure to change the $PROOF_NAME inside of the script. + +You can then copy these inputs over to your working branch in Noir and regenerate the witness for `double_verify_proof`. You can then change the branch in `run_acir_tests.sh` to this Noir working branch as well and `double_verify_proof` should pass. \ No newline at end of file diff --git a/barretenberg/acir_tests/flows/proof_as_fields.sh b/barretenberg/acir_tests/flows/proof_as_fields.sh new file mode 100755 index 00000000000..ce5772263ca --- /dev/null +++ b/barretenberg/acir_tests/flows/proof_as_fields.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu + +if [ -n "$VERBOSE" ]; then + $BIN proof_as_fields -v -c $CRS_PATH -p "./proofs/$PROOF_NAME" +else + $BIN proof_as_fields -c $CRS_PATH -p "./proofs/$PROOF_NAME" +fi \ No newline at end of file diff --git a/barretenberg/acir_tests/flows/prove.sh b/barretenberg/acir_tests/flows/prove.sh new file mode 100755 index 00000000000..e6a1d818761 --- /dev/null +++ b/barretenberg/acir_tests/flows/prove.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -eu + +echo -n "INSIDE PROVE SCRIPT" +echo -n "$RECURSIVE" + +if [ -n "$VERBOSE" ]; then + if [ -n "$RECURSIVE" ]; then + $BIN prove -v -c $CRS_PATH -b ./target/acir.gz -o "./proofs/$PROOF_NAME" -r + else + $BIN prove -v -c $CRS_PATH -b ./target/acir.gz -o "./proofs/$PROOF_NAME" + fi +else + if [ -n "$RECURSIVE" ]; then + echo -n "HERE" + + $BIN prove -v -c $CRS_PATH -b ./target/acir.gz -o "./proofs/$PROOF_NAME" -r + else + $BIN prove -c $CRS_PATH -b ./target/acir.gz -o "./proofs/$PROOF_NAME" + fi +fi \ No newline at end of file diff --git a/barretenberg/acir_tests/flows/vk_as_fields.sh b/barretenberg/acir_tests/flows/vk_as_fields.sh new file mode 100755 index 00000000000..e982ff6e354 --- /dev/null +++ b/barretenberg/acir_tests/flows/vk_as_fields.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu + +if [ -n "$VERBOSE" ]; then + $BIN vk_as_fields -v -c $CRS_PATH +else + $BIN vk_as_fields -c $CRS_PATH +fi \ No newline at end of file diff --git a/barretenberg/acir_tests/flows/write_vk.sh b/barretenberg/acir_tests/flows/write_vk.sh new file mode 100755 index 00000000000..e8dadf5e94a --- /dev/null +++ b/barretenberg/acir_tests/flows/write_vk.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu + +if [ -n "$VERBOSE" ]; then + $BIN write_vk -v -c $CRS_PATH -o +else + $BIN write_vk -c $CRS_PATH +fi \ No newline at end of file diff --git a/barretenberg/acir_tests/gen_inner_proof_inputs.sh b/barretenberg/acir_tests/gen_inner_proof_inputs.sh new file mode 100755 index 00000000000..7b64b463f87 --- /dev/null +++ b/barretenberg/acir_tests/gen_inner_proof_inputs.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Env var overrides: +# BIN: to specify a different binary to test with (e.g. bb.js or bb.js-dev). +set -eu + +BIN=${BIN:-../cpp/build/bin/bb} +WRITE_VK_FLOW=${FLOW:-write_vk} +VK_FIELDS_FLOW=${FLOW:-vk_as_fields} +PROVE_FLOW=${FLOW:-prove} +PROOF_FIELDS_FLOW=${FLOW:-proof_as_fields} +CRS_PATH=~/.bb-crs +BRANCH=arv/pedersen_hash +VERBOSE=${VERBOSE:-} +RECURSIVE=true +PROOF_NAME="proof_a" + +WRITE_VK_FLOW_SCRIPT=$(realpath ./flows/${WRITE_VK_FLOW}.sh) +VK_FIELDS_FLOW_SCRIPT=$(realpath ./flows/${VK_FIELDS_FLOW}.sh) +PROVE_FLOW_SCRIPT=$(realpath ./flows/${PROVE_FLOW}.sh) +PROOF_FIELDS_FLOW_SCRIPT=$(realpath ./flows/${PROOF_FIELDS_FLOW}.sh) + +if [ -f $BIN ]; then + BIN=$(realpath $BIN) +else + BIN=$(realpath $(which $BIN)) +fi + +export BIN CRS_PATH VERBOSE RECURSIVE PROOF_NAME + +# Pull down the test vectors from the noir repo, if we don't have the folder already. +if [ ! -d acir_tests ]; then + if [ -n "${TEST_SRC:-}" ]; then + cp -R $TEST_SRC acir_tests + else + rm -rf noir + git clone -b $BRANCH --filter=blob:none --no-checkout https://github.com/noir-lang/noir.git + cd noir + git sparse-checkout init --cone + git sparse-checkout set tooling/nargo_cli/tests/acir_artifacts + git checkout + cd .. + mv noir/tooling/nargo_cli/tests/acir_artifacts acir_tests + rm -rf noir + fi +fi + +cd acir_tests + +cd assert_statement + +PROOF_DIR=$PWD/proofs +PROOF_PATH=$PROOF_DIR/$PROOF_NAME + +echo -e "Write VK to file for assert_statement..\n" +set +e +$WRITE_VK_FLOW_SCRIPT +set -eu + +echo -e "Write VK as fields for recursion...\n" +set +e +$VK_FIELDS_FLOW_SCRIPT +set -eu + +echo -e "Generate proof to file...\n" +set +e +if [ ! -d "$PROOF_DIR" ]; then + mkdir $PWD/proofs +fi +if [ ! -e "$PROOF_PATH" ]; then + touch $PROOF_PATH +fi +$PROVE_FLOW_SCRIPT +set -eu + +echo -e "Write proof as fields for recursion...\n" +set +e +$PROOF_FIELDS_FLOW_SCRIPT +set -eu From 8360c3ad0d247c1ca6470edf975eb2c36d39d7d2 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Tue, 24 Oct 2023 14:56:39 +0000 Subject: [PATCH 2/2] set gen_inner_proof_inputs branch to master --- barretenberg/acir_tests/gen_inner_proof_inputs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/acir_tests/gen_inner_proof_inputs.sh b/barretenberg/acir_tests/gen_inner_proof_inputs.sh index 7b64b463f87..70b02d320ac 100755 --- a/barretenberg/acir_tests/gen_inner_proof_inputs.sh +++ b/barretenberg/acir_tests/gen_inner_proof_inputs.sh @@ -9,7 +9,7 @@ VK_FIELDS_FLOW=${FLOW:-vk_as_fields} PROVE_FLOW=${FLOW:-prove} PROOF_FIELDS_FLOW=${FLOW:-proof_as_fields} CRS_PATH=~/.bb-crs -BRANCH=arv/pedersen_hash +BRANCH=master VERBOSE=${VERBOSE:-} RECURSIVE=true PROOF_NAME="proof_a"