Skip to content

Commit

Permalink
Add contains_recursive_proof to Recursive VK (#268)
Browse files Browse the repository at this point in the history
* Add `contains_recursive_proof` to recursive vk.

* Fix constructors.
  • Loading branch information
suyash67 authored and codygunton committed Apr 6, 2023
1 parent 0b7b72a commit 4e14e43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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 @@ -353,6 +353,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

0 comments on commit 4e14e43

Please sign in to comment.