Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: prove_then_verify_ultra_honk on all existing acir tests #9042

Merged
merged 7 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions barretenberg/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ barretenberg-acir-tests-bb:
# Run every acir test through native bb build prove_then_verify flow for UltraPlonk.
# This ensures we test independent pk construction through real/garbage witness data paths.
RUN FLOW=prove_then_verify ./run_acir_tests.sh
# Construct and separately verify a UltraHonk proof for a single program
RUN FLOW=prove_then_verify_ultra_honk ./run_acir_tests.sh sha256

# Run the acir test through native bb build prove_then_verify_ultra_honk flow
# Note that the script will skip the Plonk related tests
RUN FLOW=prove_then_verify_ultra_honk HONK=true ./run_acir_tests.sh

# Construct and separately verify a MegaHonk proof for all acir programs
RUN FLOW=prove_then_verify_mega_honk ./run_acir_tests.sh
# Construct and verify a UltraHonk proof for a single program
Expand Down
16 changes: 13 additions & 3 deletions barretenberg/acir_tests/run_acir_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,23 @@ export BIN CRS_PATH VERBOSE BRANCH
cd acir_tests

# Convert them to array
# There are no issues witht the tests below but as they check proper handling of dependencies or circuits that are part of a workspace
# running these require extra gluecode so they are skipped for the purpose of this script
SKIP_ARRAY=(diamond_deps_0 workspace workspace_default_member)

# TODO(https://github.com/AztecProtocol/barretenberg/issues/1108): problem regardless the proof system used
SKIP_ARRAY+=(regression_5045)


# if HONK is false, we should skip verify_honk_proof
if [ "$HONK" = false ]; then
# Insert the new item into the array
# TODO https://github.com/AztecProtocol/barretenberg/issues/1108
SKIP_ARRAY+=(verify_honk_proof regression_5045)
# Don't run programs with Honk recursive verifier
SKIP_ARRAY+=(verify_honk_proof double_verify_honk_proof double_verify_honk_proof_recursive)
fi

if [ "$HONK" = true ]; then
# Don't run programs with Plonk recursive verifier(s)
SKIP_ARRAY+=(single_verify_proof double_verify_proof double_verify_proof_recursive double_verify_nested_proof)
fi

function test() {
Expand Down
3 changes: 2 additions & 1 deletion barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@ template <typename Builder = UltraCircuitBuilder> void gateCount(const std::stri
for (auto constraint_system : constraint_systems) {
auto builder = acir_format::create_circuit<Builder>(
constraint_system, 0, {}, honk_recursion, std::make_shared<bb::ECCOpQueue>(), true);
auto circuit_size = builder.get_total_circuit_size();
builder.finalize_circuit();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also include the ensure_nonzero gates as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that happens in finalisation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, does this fix the regression acir test?

size_t circuit_size = builder.num_gates;

// Build individual circuit report
std::string gates_per_opcode_str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,10 @@ INSTANTIATE_TEST_SUITE_P(AcirTests,
"brillig_pedersen",
"brillig_recursion",
"brillig_references",
// "brillig_scalar_mul",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of these tests are not part of execution_success so not relevant for proving/verifying

"brillig_schnorr",
"brillig_sha256",
"brillig_signed_cmp",
"brillig_signed_div",
// "brillig_slice_input",
"brillig_slices",
"brillig_to_be_bytes",
"brillig_to_bits",
Expand All @@ -259,7 +257,6 @@ INSTANTIATE_TEST_SUITE_P(AcirTests,
"databus",
"debug_logs",
"diamond_deps_0",
// "distinct_keyword",
"double_verify_nested_proof",
"double_verify_proof",
"double_verify_proof_recursive",
Expand Down Expand Up @@ -311,16 +308,13 @@ INSTANTIATE_TEST_SUITE_P(AcirTests,
"regression_4088",
"regression_4124",
"regression_4202",
// "regression_4383",
// "regression_4436",
"regression_4449",
"regression_4709",
//"regression_5045",
"regression_capacity_tracker",
"regression_mem_op_predicate",
"regression_method_cannot_be_found",
// "regression_sha256_slice",
"regression_struct_array_conditional",
// "scalar_mul",
"schnorr",
"sha256",
"sha2_byte",
Expand All @@ -342,7 +336,6 @@ INSTANTIATE_TEST_SUITE_P(AcirTests,
"simple_shift_left_right",
"slice_coercion",
"slice_dynamic_index",
// "slice_init_with_complex_type",
"slice_loop",
"slices",
"strings",
Expand All @@ -368,6 +361,8 @@ INSTANTIATE_TEST_SUITE_P(AcirTests,
"unit_value",
"unsafe_range_constraint",
"witness_compression",
// "workspace",
// "workspace_default_member",
"xor"));

TEST_P(AcirIntegrationFoldingTest, DISABLED_ProveAndVerifyProgramStack)
Expand Down Expand Up @@ -556,6 +551,8 @@ TEST_F(AcirIntegrationTest, DISABLED_HonkRecursion)
std::string test_name = "verify_honk_proof"; // arbitrary program with RAM gates
// Note: honk_recursion set to false here because the selection of the honk recursive verifier is indicated by the
// proof_type field of the constraint generated from noir.
// The honk_recursion flag determines whether a noir program will be recursively verified via Honk in a Noir
// program.
auto acir_program = get_program_data_from_test_file(test_name,
/*honk_recursion=*/false);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "double_verify_honk_proof"
type = "bin"
authors = [""]

[dependencies]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

// This circuit aggregates two Honk proof from `assert_statement_recursive`.
global SIZE_OF_PROOF_IF_LOGN_IS_28 : u32 = 463;
global HONK_IDENTIFIER : u32 = 1;
fn main(
verification_key: [Field; 128],
// This is the proof without public inputs attached.
// This means: the size of this does not change with the number of public inputs.
proof: [Field; SIZE_OF_PROOF_IF_LOGN_IS_28],
public_inputs: pub [Field; 1],
key_hash: Field,
// The second proof, currently set to be identical
proof_b: [Field; SIZE_OF_PROOF_IF_LOGN_IS_28]
) {
std::verify_proof_with_type(
verification_key,
proof,
public_inputs,
key_hash,
HONK_IDENTIFIER
);
std::verify_proof_with_type(
verification_key,
proof_b,
public_inputs,
key_hash,
HONK_IDENTIFIER
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "double_verify_honk_proof_recursive"
type = "bin"
authors = [""]

[dependencies]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

// This circuit aggregates two Honk proofs from `assert_statement_recursive`.
global SIZE_OF_PROOF_IF_LOGN_IS_28 : u32 = 463;
global HONK_IDENTIFIER : u32 = 1;
#[recursive]
fn main(
verification_key: [Field; 128],
// This is the proof without public inputs attached.
// This means: the size of this does not change with the number of public inputs.
proof: [Field; SIZE_OF_PROOF_IF_LOGN_IS_28],
public_inputs: pub [Field; 1],
key_hash: Field,
// The second proof, currently set to be identical to the first proof
proof_b: [Field; SIZE_OF_PROOF_IF_LOGN_IS_28]
) {
std::verify_proof_with_type(
verification_key,
proof,
public_inputs,
key_hash,
HONK_IDENTIFIER
);
std::verify_proof_with_type(
verification_key,
proof_b,
public_inputs,
key_hash,
HONK_IDENTIFIER
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ global HONK_IDENTIFIER : u32 = 1;
fn main(
verification_key: [Field; 128],
// This is the proof without public inputs attached.
//
// This means: the size of this does not change with the number of public inputs.
proof: [Field; SIZE_OF_PROOF_IF_LOGN_IS_28],
public_inputs: pub [Field; 1],
Expand Down
Loading