Skip to content
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 @@ -23,17 +23,16 @@ class BoomerangGoblinRecursiveVerifierTests : public testing::Test {
using OuterDeciderProvingKey = DeciderProvingKey_<OuterFlavor>;

using Commitment = MergeVerifier::Commitment;
using TableCommitment = MergeVerifier::TableCommitments;
using MergeCommitments = MergeVerifier::InputCommitments;
using RecursiveCommitment = GoblinRecursiveVerifier::MergeVerifier::Commitment;
using RecursiveTableCommitment = GoblinRecursiveVerifier::MergeVerifier::TableCommitments;
using RecursiveMergeCommitments = GoblinRecursiveVerifier::MergeVerifier::InputCommitments;

static void SetUpTestSuite() { bb::srs::init_file_crs_factory(bb::srs::bb_crs_path()); }

struct ProverOutput {
GoblinProof proof;
Goblin::VerificationKey verifier_input;
TableCommitment t_commitments;
TableCommitment T_prev_commitments;
MergeCommitments merge_commitments;
};

/**
Expand All @@ -60,21 +59,19 @@ class BoomerangGoblinRecursiveVerifierTests : public testing::Test {
GoblinMockCircuits::construct_simple_circuit(builder);
goblin_final.op_queue->merge();
// Subtable values and commitments - needed for (Recursive)MergeVerifier
TableCommitment t_commitments;
TableCommitment T_prev_commitments;
MergeCommitments merge_commitments;
auto t_current = goblin_final.op_queue->construct_current_ultra_ops_subtable_columns();
auto T_prev = goblin_final.op_queue->construct_previous_ultra_ops_table_columns();
CommitmentKey<curve::BN254> pcs_commitment_key(goblin_final.op_queue->get_ultra_ops_table_num_rows());
for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
t_commitments[idx] = pcs_commitment_key.commit(t_current[idx]);
T_prev_commitments[idx] = pcs_commitment_key.commit(T_prev[idx]);
merge_commitments.t_commitments[idx] = pcs_commitment_key.commit(t_current[idx]);
merge_commitments.T_prev_commitments[idx] = pcs_commitment_key.commit(T_prev[idx]);
}

// Output is a goblin proof plus ECCVM/Translator verification keys
return { goblin_final.prove(),
{ std::make_shared<ECCVMVK>(), std::make_shared<TranslatorVK>() },
t_commitments,
T_prev_commitments };
merge_commitments };
}
};

Expand All @@ -84,21 +81,21 @@ class BoomerangGoblinRecursiveVerifierTests : public testing::Test {
*/
TEST_F(BoomerangGoblinRecursiveVerifierTests, graph_description_basic)
{
auto [proof, verifier_input, t_commitments, T_prev_commitments] = create_goblin_prover_output();
auto [proof, verifier_input, merge_commitments] = create_goblin_prover_output();

Builder builder;

// Merge commitments
RecursiveTableCommitment recursive_t_commitments;
RecursiveTableCommitment recursive_T_prev_commitments;
RecursiveMergeCommitments recursive_merge_commitments;
for (size_t idx = 0; idx < MegaFlavor::NUM_WIRES; idx++) {
recursive_t_commitments[idx] = RecursiveCommitment::from_witness(&builder, t_commitments[idx]);
recursive_T_prev_commitments[idx] = RecursiveCommitment::from_witness(&builder, T_prev_commitments[idx]);
recursive_merge_commitments.t_commitments[idx] =
RecursiveCommitment::from_witness(&builder, merge_commitments.t_commitments[idx]);
recursive_merge_commitments.T_prev_commitments[idx] =
RecursiveCommitment::from_witness(&builder, merge_commitments.T_prev_commitments[idx]);
}

GoblinRecursiveVerifier verifier{ &builder, verifier_input };
GoblinRecursiveVerifierOutput output =
verifier.verify(proof, recursive_t_commitments, recursive_T_prev_commitments);
GoblinRecursiveVerifierOutput output = verifier.verify(proof, recursive_merge_commitments);
output.points_accumulator.set_public();
// Construct and verify a proof for the Goblin Recursive Verifier circuit
{
Expand Down
40 changes: 21 additions & 19 deletions barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ std::pair<ClientIVC::PairingPoints, ClientIVC::TableCommitments> ClientIVC::
const TableCommitments& T_prev_commitments,
const std::shared_ptr<RecursiveTranscript>& accumulation_recursive_transcript)
{
using MergeCommitments = Goblin::MergeRecursiveVerifier::InputCommitments;

// Witness commitments and public inputs corresponding to the incoming instance
WitnessCommitments witness_commitments;
std::vector<StdlibFF> public_inputs;

// Commitments to the previous status of the op_queue, to be finalized according to the recursive verification we
// are performing
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1492): Change Merge verifier API and improve the name
// of the following variable.
TableCommitments finalised_T_prev_commitments = T_prev_commitments;
// Input commitments to be passed to the merge recursive verification
MergeCommitments merge_commitments;
merge_commitments.T_prev_commitments = T_prev_commitments;

switch (verifier_inputs.type) {
case QUEUE_TYPE::PG: {
Expand Down Expand Up @@ -146,7 +146,7 @@ std::pair<ClientIVC::PairingPoints, ClientIVC::TableCommitments> ClientIVC::
public_inputs = std::move(verifier.public_inputs);

// T_prev = 0 in the first recursive verification
finalised_T_prev_commitments = HidingKernelIO::empty_ecc_op_tables(circuit);
merge_commitments.T_prev_commitments = HidingKernelIO::empty_ecc_op_tables(circuit);

break;
}
Expand All @@ -173,7 +173,7 @@ std::pair<ClientIVC::PairingPoints, ClientIVC::TableCommitments> ClientIVC::
// T_prev is read by the public input of the previous kernel K_{i-1} at the beginning of the recursive
// verification of of the folding of K_{i-1} (kernel), A_{i,1} (app), .., A_{i, n} (app). This verification
// happens in K_{i}
finalised_T_prev_commitments = kernel_input.ecc_op_tables;
merge_commitments.T_prev_commitments = kernel_input.ecc_op_tables;

// Perform databus consistency checks
kernel_input.kernel_return_data.assert_equal(witness_commitments.calldata);
Expand All @@ -192,11 +192,11 @@ std::pair<ClientIVC::PairingPoints, ClientIVC::TableCommitments> ClientIVC::
}

// Extract the commitments to the subtable corresponding to the incoming circuit
TableCommitments t_commitments = witness_commitments.get_ecc_op_wires().get_copy();
merge_commitments.t_commitments = witness_commitments.get_ecc_op_wires().get_copy();

// Recursively verify the corresponding merge proof
auto [pairing_points, merged_table_commitments] = goblin.recursively_verify_merge(
circuit, t_commitments, finalised_T_prev_commitments, accumulation_recursive_transcript);
auto [pairing_points, merged_table_commitments] =
goblin.recursively_verify_merge(circuit, merge_commitments, accumulation_recursive_transcript);

pairing_points.aggregate(nested_pairing_points);

Expand Down Expand Up @@ -381,6 +381,8 @@ std::pair<ClientIVC::PairingPoints, ClientIVC::TableCommitments> ClientIVC::comp
const std::shared_ptr<RecursiveVKAndHash>& stdlib_vk_and_hash,
ClientCircuit& circuit)
{
using MergeCommitments = Goblin::MergeRecursiveVerifier::InputCommitments;

// Shared transcript between PG and Merge
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1453): Investigate whether Decider/PG/Merge need to
// share a transcript
Expand Down Expand Up @@ -421,13 +423,13 @@ std::pair<ClientIVC::PairingPoints, ClientIVC::TableCommitments> ClientIVC::comp
kernel_input.app_return_data.assert_equal(witness_commitments.secondary_calldata);

// Extract the commitments to the subtable corresponding to the incoming circuit
TableCommitments t_commitments = witness_commitments.get_ecc_op_wires().get_copy();
MergeCommitments merge_commitments;
merge_commitments.t_commitments = witness_commitments.get_ecc_op_wires().get_copy();
merge_commitments.T_prev_commitments = std::move(
kernel_input.ecc_op_tables); // Commitment to the status of the op_queue before folding the tail kernel
// Perform recursive verification of the last merge proof
auto [points_accumulator, merged_table_commitments] = goblin.recursively_verify_merge(
circuit,
t_commitments,
kernel_input.ecc_op_tables, // Commitment to the status of the op_queue before folding the tail kernel
pg_merge_transcript);
auto [points_accumulator, merged_table_commitments] =
goblin.recursively_verify_merge(circuit, merge_commitments, pg_merge_transcript);

points_accumulator.aggregate(kernel_input.pairing_inputs);

Expand Down Expand Up @@ -509,6 +511,7 @@ ClientIVC::Proof ClientIVC::prove()

bool ClientIVC::verify(const Proof& proof, const VerificationKey& vk)
{
using TableCommitments = Goblin::TableCommitments;
// Create a transcript to be shared by MegaZK-, Merge-, ECCVM-, and Translator- Verifiers.
std::shared_ptr<Goblin::Transcript> civc_verifier_transcript = std::make_shared<Goblin::Transcript>();
// Verify the hiding circuit proof
Expand All @@ -517,12 +520,11 @@ bool ClientIVC::verify(const Proof& proof, const VerificationKey& vk)
vinfo("Mega verified: ", mega_verified);

// Extract the commitments to the subtable corresponding to the incoming circuit
MergeVerifier::TableCommitments t_commitments =
verifier.verification_key->witness_commitments.get_ecc_op_wires().get_copy();
TableCommitments t_commitments = verifier.verification_key->witness_commitments.get_ecc_op_wires().get_copy();

// Goblin verification (final merge, eccvm, translator)
bool goblin_verified =
Goblin::verify(proof.goblin_proof, t_commitments, T_prev_commitments, civc_verifier_transcript);
Goblin::verify(proof.goblin_proof, { t_commitments, T_prev_commitments }, civc_verifier_transcript);
vinfo("Goblin verified: ", goblin_verified);

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1396): State tracking in CIVC verifiers.
Expand Down
11 changes: 4 additions & 7 deletions barretenberg/cpp/src/barretenberg/goblin/goblin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ GoblinProof Goblin::prove()

std::pair<Goblin::PairingPoints, Goblin::RecursiveTableCommitments> Goblin::recursively_verify_merge(
MegaBuilder& builder,
const RecursiveTableCommitments& t_commitments,
const RecursiveTableCommitments& T_prev_commitments,
const RecursiveMergeCommitments& merge_commitments,
const std::shared_ptr<RecursiveTranscript>& transcript)
{
ASSERT(!merge_verification_queue.empty());
Expand All @@ -87,21 +86,19 @@ std::pair<Goblin::PairingPoints, Goblin::RecursiveTableCommitments> Goblin::recu

MergeRecursiveVerifier merge_verifier{ &builder, MergeSettings::PREPEND, transcript };
auto [pairing_points, merged_table_commitments] =
merge_verifier.verify_proof(stdlib_merge_proof, t_commitments, T_prev_commitments);
merge_verifier.verify_proof(stdlib_merge_proof, merge_commitments);

merge_verification_queue.pop_front(); // remove the processed proof from the queue

return { pairing_points, merged_table_commitments };
}

bool Goblin::verify(const GoblinProof& proof,
const TableCommitments& t_commitments,
const TableCommitments& T_prev_commitments,
const MergeCommitments& merge_commitments,
const std::shared_ptr<Transcript>& transcript)
{
MergeVerifier merge_verifier(MergeSettings::PREPEND, transcript);
auto [merge_verified, merged_table_commitments] =
merge_verifier.verify_proof(proof.merge_proof, t_commitments, T_prev_commitments);
auto [merge_verified, merged_table_commitments] = merge_verifier.verify_proof(proof.merge_proof, merge_commitments);

ECCVMVerifier eccvm_verifier(transcript);
bool eccvm_verified = eccvm_verifier.verify_proof(proof.eccvm_proof);
Expand Down
16 changes: 6 additions & 10 deletions barretenberg/cpp/src/barretenberg/goblin/goblin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Goblin {
using PairingPoints = MergeRecursiveVerifier::PairingPoints;
using TableCommitments = MergeVerifier::TableCommitments;
using RecursiveTableCommitments = MergeRecursiveVerifier::TableCommitments;
using MergeCommitments = MergeVerifier::InputCommitments;
using RecursiveMergeCommitments = MergeRecursiveVerifier::InputCommitments;
using RecursiveCommitment = MergeRecursiveVerifier::Commitment;
using RecursiveTranscript = bb::BaseTranscript<bb::stdlib::recursion::honk::StdlibTranscriptParams<MegaBuilder>>;

Expand Down Expand Up @@ -94,34 +96,28 @@ class Goblin {
* @details Proofs are verified in a FIFO manner
*
* @param builder The circuit in which the recursive verification will be performed.
* @param subtable_commitments The subtable commitments data, containing the commitments to t_j read from the
* transcript by the PG verifier with which the Merge verifier shares a transcript
* @param T_prev_commitments The full op_queue table commitments after the previous iteration of merge
* @param inputs_commitments The commitment used by the Merge verifier
* @param transcript The transcript to be passed to the MergeRecursiveVerifier.
* @return Pair of PairingPoints and commitments to the merged tables as read from the proof by the Merge verifier
*/
std::pair<PairingPoints, RecursiveTableCommitments> recursively_verify_merge(
MegaBuilder& builder,
const RecursiveTableCommitments& t_commitments,
const RecursiveTableCommitments& T_prev_commitments,
const RecursiveMergeCommitments& merge_commitments,
const std::shared_ptr<RecursiveTranscript>& transcript);

/**
* @brief Verify a full Goblin proof (ECCVM, Translator, merge)
*
* @param proof
* @param subtable_commitments The subtable commitments data, containing the commitments to t_j read from the
* transcript by the PG verifier with which the Merge verifier shares a transcript
* @param T_prev_commitments The full op_queue table commitments after the previous iteration of merge
* @param inputs_commitments The commitments used by the Merge verifier
* @param merged_table_commitment The commitment to the merged table as read from the proof
* @param transcript
*
* @return Pair of verification result and commitments to the merged tables as read from the proof by the Merge
* verifier
*/
static bool verify(const GoblinProof& proof,
const TableCommitments& t_commitments,
const TableCommitments& T_prev_commitments,
const MergeCommitments& merge_commitments,
const std::shared_ptr<Transcript>& transcript);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace bb::stdlib::recursion::honk {
*/
ClientIVCRecursiveVerifier::Output ClientIVCRecursiveVerifier::verify(const StdlibProof& proof)
{
using TableCommitments = GoblinVerifier::MergeVerifier::TableCommitments;
using MergeCommitments = GoblinVerifier::MergeVerifier::InputCommitments;
std::shared_ptr<Transcript> civc_rec_verifier_transcript(std::make_shared<Transcript>());
// Construct stdlib Mega verification key
auto stdlib_mega_vk_and_hash = std::make_shared<RecursiveVKAndHash>(*builder, ivc_verification_key.mega);
Expand All @@ -27,14 +27,14 @@ ClientIVCRecursiveVerifier::Output ClientIVCRecursiveVerifier::verify(const Stdl

// Perform Goblin recursive verification
GoblinVerificationKey goblin_verification_key{};
TableCommitments t_commitments = verifier.key->witness_commitments.get_ecc_op_wires()
.get_copy(); // Commitments to subtables added by the hiding kernel
MergeCommitments merge_commitments{
.t_commitments = verifier.key->witness_commitments.get_ecc_op_wires()
.get_copy(), // Commitments to subtables added by the hiding kernel
.T_prev_commitments = std::move(mega_output.ecc_op_tables) // Commitments to the state of the ecc op_queue as
// computed insided the hiding kernel
};
GoblinVerifier goblin_verifier{ builder.get(), goblin_verification_key, civc_rec_verifier_transcript };
GoblinRecursiveVerifierOutput output = goblin_verifier.verify(
proof.goblin_proof,
t_commitments,
mega_output.ecc_op_tables // Commitments to the state of the ecc op_queue as computed insided the hiding kernel
);
GoblinRecursiveVerifierOutput output = goblin_verifier.verify(proof.goblin_proof, merge_commitments);
output.points_accumulator.aggregate(mega_output.points_accumulator);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1396): State tracking in CIVC verifiers
return { output };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ namespace bb::stdlib::recursion::honk {
*
*/
GoblinRecursiveVerifierOutput GoblinRecursiveVerifier::verify(const GoblinProof& proof,
const TableCommitments& t_commitments,
const TableCommitments& T_prev_commitments)
const MergeCommitments& merge_commitments)
{
StdlibProof stdlib_proof(*builder, proof);
return verify(stdlib_proof, t_commitments, T_prev_commitments);
return verify(stdlib_proof, merge_commitments);
}

/**
Expand All @@ -30,16 +29,13 @@ GoblinRecursiveVerifierOutput GoblinRecursiveVerifier::verify(const GoblinProof&
* @param t_commitments The commitments to the subtable for the merge being verified
*
*/
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1492): Modify Merge verifier API and package inputs in a
// single struct
GoblinRecursiveVerifierOutput GoblinRecursiveVerifier::verify(const StdlibProof& proof,
const TableCommitments& t_commitments,
const TableCommitments& T_prev_commitments)
const MergeCommitments& merge_commitments)
{
// Verify the final merge step
MergeVerifier merge_verifier{ builder, MergeSettings::PREPEND, transcript };
auto [merge_pairing_points, merged_table_commitments] =
merge_verifier.verify_proof(proof.merge_proof, t_commitments, T_prev_commitments);
merge_verifier.verify_proof(proof.merge_proof, merge_commitments);

// Run the ECCVM recursive verifier
ECCVMVerifier eccvm_verifier{ builder, verification_keys.eccvm_verification_key, transcript };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace bb::stdlib::recursion::honk {
struct GoblinRecursiveVerifierOutput {
using Builder = UltraCircuitBuilder;
using Curve = grumpkin<Builder>;
using Transcript = bb::BaseTranscript<bb::stdlib::recursion::honk::StdlibTranscriptParams<Builder>>;
using PairingAccumulator = PairingPoints<Builder>;
using TableCommitments = goblin::MergeRecursiveVerifier_<Builder>::TableCommitments;
PairingAccumulator points_accumulator;
OpeningClaim<Curve> opening_claim;
stdlib::Proof<Builder> ipa_proof;
Expand All @@ -40,7 +38,7 @@ class GoblinRecursiveVerifier {
using VerificationKey = Goblin::VerificationKey;

// Merge commitments
using TableCommitments = MergeVerifier::TableCommitments;
using MergeCommitments = MergeVerifier::InputCommitments;

struct StdlibProof {
using StdlibHonkProof = bb::stdlib::Proof<Builder>;
Expand All @@ -66,9 +64,9 @@ class GoblinRecursiveVerifier {
, transcript(transcript){};

[[nodiscard("IPA claim and Pairing points should be accumulated")]] GoblinRecursiveVerifierOutput verify(
const GoblinProof&, const TableCommitments& t_commitments, const TableCommitments& T_prev_commitments);
const GoblinProof&, const MergeCommitments& merge_commitments);
[[nodiscard("IPA claim and Pairing points should be accumulated")]] GoblinRecursiveVerifierOutput verify(
const StdlibProof&, const TableCommitments& t_commitments, const TableCommitments& T_prev_commitments);
const StdlibProof&, const MergeCommitments& merge_commitments);

private:
Builder* builder;
Expand Down
Loading
Loading