Skip to content

Commit

Permalink
7790: additional clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Aug 28, 2024
1 parent 01c6027 commit 18e2cc4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Notes:
// We want the recursive verifier for this proof to be an ultra honk type proof
// that will be aggregated in the rolup circuits
//
// We also want noir to be able to absorb these proofs

#pragma once
#include "barretenberg/flavor/flavor.hpp"
#include "barretenberg/stdlib/transcript/transcript.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ std::array<typename Flavor::GroupElement, 2> AvmRecursiveVerifier_<Flavor>::veri
comm = transcript->template receive_from_prover<Commitment>(label);
}

// // Note(md): inherited from eccvm recursion
// // TODO(https://github.com/AztecProtocol/barretenberg/issues/1017): This is a hack to ensure zero commitments
// // are still on curve as the transcript doesn't currently support a point at infinity representation for
// // cycle_group
// if (!comm.get_value().on_curve()) {
// comm.set_point_at_infinity(true);
// }
// }

auto [beta, gamma] = transcript->template get_challenges<FF>("beta", "gamma");
relation_parameters.beta = beta;
relation_parameters.gamma = gamma;
Expand All @@ -63,8 +54,6 @@ std::array<typename Flavor::GroupElement, 2> AvmRecursiveVerifier_<Flavor>::veri
commitment = transcript->template receive_from_prover<Commitment>(label);
}

// TODO(md): do we not need to hash the counts columns until the sumcheck rounds?

// unconstrained
const size_t log_circuit_size = numeric::get_msb(static_cast<uint32_t>(circuit_size.get_value()));
auto sumcheck = SumcheckVerifier<Flavor>(log_circuit_size, transcript);
Expand All @@ -79,10 +68,11 @@ std::array<typename Flavor::GroupElement, 2> AvmRecursiveVerifier_<Flavor>::veri
auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] =
sumcheck.verify(relation_parameters, alpha, gate_challenges);

info("verified sumcheck: ", (sumcheck_verified.has_value() && sumcheck_verified.value()));

// TODO(md): when calling `get_commitments` do the values get constrained in their origin? check that the zip_view
// does in fact use the verifier type to get it?
// TODO(md): call assert true on the builder type to lay down the positive boolean constraint?
// using bool_ct = stdlib::bool_t<Builder>;
// bool_ct is_true = bool_ct(1);
// sumcheck_verified.must_imply(is_true, "sumcheck verification failed");
vinfo("verified sumcheck: ", (sumcheck_verified.has_value() && sumcheck_verified.value()));

auto multivariate_to_univariate_opening_claim = Zeromorph::verify(circuit_size,
commitments.get_unshifted(),
Expand All @@ -96,7 +86,9 @@ std::array<typename Flavor::GroupElement, 2> AvmRecursiveVerifier_<Flavor>::veri
auto pairing_points = PCS::reduce_verify(multivariate_to_univariate_opening_claim, transcript);

return pairing_points;
// TODO(md): call assert true on the builder type to lay down the positive boolean constraint?

// Probably we will have to return an aggregation object (see ultra_recursive_verifier.cpp) once we interface
// with noir for public_kernel integration. Follow, the same recipe as in ultra_recursive_verifier.cpp in this case.
}

template class AvmRecursiveVerifier_<AvmRecursiveFlavor_<UltraCircuitBuilder>>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
// As this adds the honk_stdlib_recursion module to the cmake lists, we probably
// want to make vm recursion its own module

#include "barretenberg/vm/avm/recursion/avm_recursive_verifier.hpp"
#include "barretenberg/circuit_checker/circuit_checker.hpp"

#include "barretenberg/numeric/random/engine.hpp"
#include "barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp"
#include "barretenberg/stdlib_circuit_builders/ultra_flavor.hpp"
#include "barretenberg/sumcheck/instance/prover_instance.hpp"
#include "barretenberg/ultra_honk/ultra_prover.hpp"
#include "barretenberg/ultra_honk/ultra_verifier.hpp"
#include "barretenberg/vm/avm/generated/circuit_builder.hpp"
#include "barretenberg/vm/avm/generated/composer.hpp"
#include "barretenberg/vm/avm/recursion/avm_recursive_flavor.hpp"
#include "barretenberg/vm/avm/recursion/avm_recursive_verifier.hpp"
#include "barretenberg/vm/avm/tests/helpers.test.hpp"
#include "barretenberg/vm/avm/trace/common.hpp"
#include "barretenberg/vm/avm/trace/helper.hpp"
Expand Down Expand Up @@ -61,11 +56,11 @@ class AvmRecursiveTests : public ::testing::Test {
trace_builder.op_set(0, 1, 2, AvmMemoryTag::U8);
trace_builder.op_add(0, 1, 2, 3, AvmMemoryTag::U8);
trace_builder.op_return(0, 0, 0);
auto trace = trace_builder.finalize(true);
auto trace = trace_builder.finalize(); // Passing true enables a longer trace with lookups

builder.set_trace(std::move(trace));
builder.check_circuit();
info("inner builder - num gates: ", builder.get_num_gates());
vinfo("inner builder - num gates: ", builder.get_num_gates());

return builder;
}
Expand All @@ -80,7 +75,6 @@ TEST_F(AvmRecursiveTests, recursion)

HonkProof proof = prover.construct_proof();

// NOTE(md): got to do something about these public inputs
auto public_inputs = generate_base_public_inputs();
std::vector<std::vector<InnerFF>> public_inputs_vec =
bb::avm_trace::copy_public_inputs_columns(public_inputs, {}, {});
Expand All @@ -93,17 +87,14 @@ TEST_F(AvmRecursiveTests, recursion)
OuterBuilder outer_circuit;
RecursiveVerifier recursive_verifier{ &outer_circuit, verification_key };

// Note(md): no inputs are provided here - so the verifier is under-constrained in respect to public inputs
// If we return the pairing points then potentially they can be recursively verified nicely?? - but it is not clear
// how aggregation will work unless we make sure the avm has the same circuit size as other things
auto pairing_points = recursive_verifier.verify_proof(proof);

bool pairing_points_valid = verification_key->pcs_verification_key->pairing_check(pairing_points[0].get_value(),
pairing_points[1].get_value());

ASSERT_TRUE(pairing_points_valid) << "Pairing points are not valid.";

info("Recursive verifier: num gates = ", outer_circuit.num_gates);
vinfo("Recursive verifier: num gates = ", outer_circuit.num_gates);
ASSERT_FALSE(outer_circuit.failed()) << "Outer circuit has failed.";

bool outer_circuit_checked = CircuitChecker::check(outer_circuit);
Expand Down

0 comments on commit 18e2cc4

Please sign in to comment.