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

Add contains_recursive_proof to Recursive VK #268

Merged
merged 2 commits into from
Mar 25, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ template <typename Curve> struct verification_key {
key->n = witness_t<Composer>(ctx, barretenberg::fr(input_key->circuit_size));
key->num_public_inputs = witness_t<Composer>(ctx, input_key->num_public_inputs);
key->domain = evaluation_domain<Composer>::from_witness(ctx, input_key->domain);
key->contains_recursive_proof = witness_t<Composer>(ctx, input_key->contains_recursive_proof);

for (const auto& [tag, value] : input_key->commitments) {
key->commitments.insert({ tag, Curve::g1_ct::from_witness(ctx, value) });
Expand All @@ -136,6 +137,7 @@ template <typename Curve> struct verification_key {
key->base_key = input_key;
key->n = field_t<Composer>(ctx, input_key->circuit_size);
key->num_public_inputs = field_t<Composer>(ctx, input_key->num_public_inputs);
key->contains_recursive_proof = bool_t<Composer>(ctx, input_key->contains_recursive_proof);

key->domain = evaluation_domain<Composer>::from_constants(ctx, input_key->domain);

Expand Down Expand Up @@ -259,6 +261,10 @@ template <typename Curve> struct verification_key {
field_t<Composer> num_public_inputs;
field_t<Composer> z_pow_n;

// NOTE: This does not strictly need to be a circuit type. It can be used to check in the circuit
// if a proof contains any aggregated state.
bool_t<Composer> contains_recursive_proof;

evaluation_domain<Composer> domain;

std::map<std::string, typename Curve::g1_ct> commitments;
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/barretenberg/stdlib/recursion/verifier/verifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ recursion_output<Curve> verify_proof(typename Curve::Composer* context,
rhs_scalars.push_back(random_separator);
}

// Check if recursive proof information is correctly set.
key->contains_recursive_proof.assert_equal(key->base_key->contains_recursive_proof,
"contains_recursive_proof is incorrectly set");

/**
* N.B. if this key contains a recursive proof, then ALL potential verification keys being verified by the outer
*circuit must ALSO contain a recursive proof (this is not a concern if the key is being generated from circuit
Expand Down