Skip to content

Commit

Permalink
add ipa claim/proof to tube
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasxia01 committed Nov 15, 2024
1 parent 3c83148 commit ee98551
Show file tree
Hide file tree
Showing 27 changed files with 83 additions and 40 deletions.
2 changes: 1 addition & 1 deletion barretenberg/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ endif(DOXYGEN_FOUND)

option(DISABLE_ASM "Disable custom assembly" OFF)
option(DISABLE_ADX "Disable ADX assembly variant" OFF)
option(DISABLE_AZTEC_VM "Don't build Aztec VM (acceptable if iterating on core proving)" OFF)
option(DISABLE_AZTEC_VM "Don't build Aztec VM (acceptable if iterating on core proving)" ON)
option(MULTITHREADING "Enable multi-threading" ON)
option(OMP_MULTITHREADING "Enable OMP multi-threading" OFF)
option(FUZZING "Build ONLY fuzzing harnesses" OFF)
Expand Down
7 changes: 6 additions & 1 deletion barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ void prove_tube(const std::string& output_path)
}
ClientIVC verifier{ builder, input };

verifier.verify(proof);
stdlib::recursion::honk::ClientIVCRecursiveVerifier::ClientIVCRecursiveVerifierOutput
client_ivc_rec_verifier_output = verifier.verify(proof);

PairingPointAccumulatorIndices current_aggregation_object =
stdlib::recursion::init_default_agg_obj_indices<Builder>(*builder);
Expand All @@ -605,6 +606,10 @@ void prove_tube(const std::string& output_path)
// This is currently just setting the aggregation object to the default one.
builder->add_pairing_point_accumulator(current_aggregation_object);

// The tube only calls an IPA recursive verifier once, so we can just add this IPA claim and proof
builder->add_ipa_claim(client_ivc_rec_verifier_output.opening_claim.get_witness_indices());
builder->ipa_proof = convert_stdlib_proof_to_native(client_ivc_rec_verifier_output.ipa_transcript->proof_data);

using Prover = UltraProver_<UltraFlavor>;
using Verifier = UltraVerifier_<UltraFlavor>;
Prover tube_prover{ *builder };
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void ClientIVC::instantiate_stdlib_verification_queue(
size_t key_idx = 0;
for (auto& [proof, vkey, type] : verification_queue) {
// Construct stdlib proof directly from the internal native queue data
auto stdlib_proof = bb::convert_proof_to_witness(&circuit, proof);
auto stdlib_proof = bb::convert_native_proof_to_stdlib(&circuit, proof);

// Use the provided stdlib vkey if present, otherwise construct one from the internal native queue
auto stdlib_vkey =
Expand Down Expand Up @@ -261,7 +261,7 @@ HonkProof ClientIVC::construct_and_prove_hiding_circuit()
auto stdlib_decider_vk =
std::make_shared<RecursiveVerificationKey>(&builder, verification_queue[0].honk_verification_key);

auto stdlib_proof = bb::convert_proof_to_witness(&builder, fold_proof);
auto stdlib_proof = bb::convert_native_proof_to_stdlib(&builder, fold_proof);

// Perform recursive folding verification of the last folding proof
FoldingRecursiveVerifier folding_verifier{ &builder, stdlib_verifier_accumulator, { stdlib_decider_vk } };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class IPARecursiveTests : public CommitmentTest<NativeCurve> {
OpeningClaim<Curve> stdlib_opening_claim{ { stdlib_x, stdlib_eval }, stdlib_comm };

// Construct stdlib verifier transcript
auto recursive_verifier_transcript =
std::make_shared<StdlibTranscript>(bb::convert_proof_to_witness(&builder, prover_transcript->proof_data));
auto recursive_verifier_transcript = std::make_shared<StdlibTranscript>(
bb::convert_native_proof_to_stdlib(&builder, prover_transcript->proof_data));
return { recursive_verifier_transcript, stdlib_opening_claim };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ TEST(ShpleminiRecursionTest, ProveAndVerifySingle)
N, RefVector(f_polynomials), RefVector(g_polynomials), u_challenge, commitment_key, prover_transcript);
KZG<NativeCurve>::compute_opening_proof(commitment_key, prover_opening_claims, prover_transcript);
Builder builder;
StdlibProof<Builder> stdlib_proof = bb::convert_proof_to_witness(&builder, prover_transcript->proof_data);
StdlibProof<Builder> stdlib_proof = bb::convert_native_proof_to_stdlib(&builder, prover_transcript->proof_data);
auto stdlib_verifier_transcript = std::make_shared<Transcript>(stdlib_proof);
stdlib_verifier_transcript->template receive_from_prover<Fr>("Init");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ TEST(ZeroMorphRecursionTest, ProveAndVerifySingle)
prover_transcript);

Builder builder;
StdlibProof<Builder> stdlib_proof = bb::convert_proof_to_witness(&builder, prover_transcript->proof_data);
StdlibProof<Builder> stdlib_proof = bb::convert_native_proof_to_stdlib(&builder, prover_transcript->proof_data);
auto stdlib_verifier_transcript = std::make_shared<Transcript>(stdlib_proof);
[[maybe_unused]] auto _ = stdlib_verifier_transcript->template receive_from_prover<Fr>("Init");

Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/goblin/mock_circuits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class GoblinMockCircuits {

// Execute recursive aggregation of function proof
auto verification_key = std::make_shared<RecursiveVerificationKey>(&builder, function_accum.verification_key);
auto proof = bb::convert_proof_to_witness(&builder, function_accum.proof);
auto proof = bb::convert_native_proof_to_stdlib(&builder, function_accum.proof);
RecursiveVerifier verifier1{ &builder, verification_key };
verifier1.verify_proof(
proof, stdlib::recursion::init_default_aggregation_state<MegaBuilder, RecursiveFlavor::Curve>(builder));
Expand All @@ -221,7 +221,7 @@ class GoblinMockCircuits {
if (!prev_kernel_accum.proof.empty()) {
auto verification_key =
std::make_shared<RecursiveVerificationKey>(&builder, prev_kernel_accum.verification_key);
auto proof = bb::convert_proof_to_witness(&builder, prev_kernel_accum.proof);
auto proof = bb::convert_native_proof_to_stdlib(&builder, prev_kernel_accum.proof);
RecursiveVerifier verifier2{ &builder, verification_key };
verifier2.verify_proof(
proof, stdlib::recursion::init_default_aggregation_state<MegaBuilder, RecursiveFlavor::Curve>(builder));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace bb::stdlib::recursion::honk {
* @todo (https://github.com/AztecProtocol/barretenberg/issues/934): Add logic for accumulating the pairing points
* produced by the verifiers (and potentially IPA accumulators for ECCVM verifier)
*/
void ClientIVCRecursiveVerifier::verify(const ClientIVC::Proof& proof)
ClientIVCRecursiveVerifier::ClientIVCRecursiveVerifierOutput ClientIVCRecursiveVerifier::verify(
const ClientIVC::Proof& proof)
{
// Construct stdlib Mega verification key
auto stdlib_mega_vk =
Expand All @@ -24,7 +25,9 @@ void ClientIVCRecursiveVerifier::verify(const ClientIVC::Proof& proof)

// Perform Goblin recursive verification
GoblinVerifier goblin_verifier{ builder.get(), verifier_input.goblin_input };
goblin_verifier.verify(proof.goblin_proof);
GoblinRecursiveVerifierOutput output = goblin_verifier.verify(proof.goblin_proof);

return output;
}

} // namespace bb::stdlib::recursion::honk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ClientIVCRecursiveVerifier {
using Proof = ClientIVC::Proof;
using FoldVerifierInput = FoldingVerifier::VerifierInput;
using GoblinVerifierInput = GoblinVerifier::VerifierInput;
using ClientIVCRecursiveVerifierOutput = GoblinRecursiveVerifierOutput;

struct VerifierInput {
std::shared_ptr<VerificationKey> mega_verification_key;
GoblinVerifierInput goblin_input;
Expand All @@ -30,7 +32,7 @@ class ClientIVCRecursiveVerifier {
: builder(builder)
, verifier_input(verifier_input){};

void verify(const ClientIVC::Proof&);
ClientIVCRecursiveVerifierOutput verify(const ClientIVC::Proof&);

private:
std::shared_ptr<Builder> builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ TEST_F(ClientIVCRecursionTests, Basic)
ClientIVCVerifier verifier{ builder, verifier_input };

// Generate the recursive verification circuit
verifier.verify(proof);
ClientIVCRecursiveVerifier::ClientIVCRecursiveVerifierOutput output = verifier.verify(proof);

EXPECT_EQ(builder->failed(), false) << builder->err();

Expand All @@ -107,10 +107,16 @@ TEST_F(ClientIVCRecursionTests, ClientTubeBase)
ClientIVCVerifier verifier{ tube_builder, verifier_input };

// Generate the recursive verification circuit
verifier.verify(proof);
ClientIVCRecursiveVerifier::ClientIVCRecursiveVerifierOutput client_ivc_rec_verifier_output =
verifier.verify(proof);

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1069): fix this by taking it from the output instead of
// just using default.
tube_builder->add_pairing_point_accumulator(
stdlib::recursion::init_default_agg_obj_indices<Builder>(*tube_builder));
// The tube only calls an IPA recursive verifier once, so we can just add this IPA claim and proof
tube_builder->add_ipa_claim(client_ivc_rec_verifier_output.opening_claim.get_witness_indices());
tube_builder->ipa_proof = convert_stdlib_proof_to_native(client_ivc_rec_verifier_output.ipa_transcript->proof_data);

info("ClientIVC Recursive Verifier: num prefinalized gates = ", tube_builder->num_gates);

Expand All @@ -126,7 +132,7 @@ TEST_F(ClientIVCRecursionTests, ClientTubeBase)
Builder base_builder;
auto native_vk = std::make_shared<NativeFlavor::VerificationKey>(proving_key->proving_key);
auto vk = std::make_shared<Flavor::VerificationKey>(&base_builder, native_vk);
auto tube_proof = bb::convert_proof_to_witness(&base_builder, native_tube_proof);
auto tube_proof = bb::convert_native_proof_to_stdlib(&base_builder, native_tube_proof);
UltraRecursiveVerifier base_verifier{ &base_builder, vk };
base_verifier.verify_proof(tube_proof,
stdlib::recursion::init_default_aggregation_state<Builder, Flavor::Curve>(base_builder));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ ECCVMRecursiveVerifier_<Flavor>::verify_proof(const ECCVMProof& proof)

RelationParameters<FF> relation_parameters;

StdlibProof<Builder> stdlib_proof = bb::convert_proof_to_witness(builder, proof.pre_ipa_proof);
StdlibProof<Builder> stdlib_ipa_proof = bb::convert_proof_to_witness(builder, proof.ipa_proof);
StdlibProof<Builder> stdlib_proof = bb::convert_native_proof_to_stdlib(builder, proof.pre_ipa_proof);
StdlibProof<Builder> stdlib_ipa_proof = bb::convert_native_proof_to_stdlib(builder, proof.ipa_proof);
transcript = std::make_shared<Transcript>(stdlib_proof);
ipa_transcript = std::make_shared<Transcript>(stdlib_ipa_proof);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ template <typename RecursiveFlavor> class ECCVMRecursiveTests : public ::testing
info("ECCVM Recursive Verifier");
OuterBuilder outer_circuit;
RecursiveVerifier verifier{ &outer_circuit, verification_key };
verifier.verify_proof(proof);
auto [opening_claim, ipa_transcript] = verifier.verify_proof(proof);

info("Recursive Verifier: num gates = ", outer_circuit.get_estimated_num_finalized_gates());

// Check for a failure flag in the recursive verifier circuit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ namespace bb::stdlib::recursion::honk {
* @todo https://github.com/AztecProtocol/barretenberg/issues/934: Add logic for accumulating the pairing points
* produced by the translator and merge verifier (and potentially IPA accumulators for ECCVM verifier)
*/
void GoblinRecursiveVerifier::verify(const GoblinProof& proof)
GoblinRecursiveVerifierOutput GoblinRecursiveVerifier::verify(const GoblinProof& proof)
{
// Run the ECCVM recursive verifier
ECCVMVerifier eccvm_verifier{ builder, verification_keys.eccvm_verification_key };
auto [opening_claim, ipa_transcript] = eccvm_verifier.verify_proof(proof.eccvm_proof);

// Assuming the GoblinRecursiveVerifier can only be called at most once per circuit, we can add the claim to the
// builder.
builder->add_ipa_claim(opening_claim.get_witness_indices());
// Run the Translator recursive verifier
TranslatorVerifier translator_verifier{ builder,
verification_keys.translator_verification_key,
Expand All @@ -39,5 +36,6 @@ void GoblinRecursiveVerifier::verify(const GoblinProof& proof)

MergeVerifier merge_verifier{ builder };
merge_verifier.verify_proof(proof.merge_proof);
return { opening_claim, ipa_transcript };
}
} // namespace bb::stdlib::recursion::honk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
#include "barretenberg/stdlib/translator_vm_verifier/translator_recursive_verifier.hpp"

namespace bb::stdlib::recursion::honk {

struct GoblinRecursiveVerifierOutput {
using Builder = UltraCircuitBuilder;
using ECCVMFlavor = ECCVMRecursiveFlavor_<Builder>;
using Curve = grumpkin<Builder>;
using Transcript = bb::BaseTranscript<bb::stdlib::recursion::honk::StdlibTranscriptParams<Builder>>;
OpeningClaim<Curve> opening_claim;
std::shared_ptr<Transcript> ipa_transcript;
};

class GoblinRecursiveVerifier {
public:
// Goblin Recursive Verifier circuit is using Ultra arithmetisation
Expand Down Expand Up @@ -35,7 +45,7 @@ class GoblinRecursiveVerifier {
*
* @todo(https://github.com/AztecProtocol/barretenberg/issues/991): The GoblinProof should aleady be a stdlib proof
*/
void verify(const GoblinProof&);
GoblinRecursiveVerifierOutput verify(const GoblinProof&);

private:
Builder* builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ TEST_F(GoblinRecursiveVerifierTests, ECCVMFailure)

Builder builder;
GoblinRecursiveVerifier verifier{ &builder, verifier_input };
verifier.verify(proof);
GoblinRecursiveVerifierOutput goblin_rec_verifier_output = verifier.verify(proof);

static_cast<void>(goblin_rec_verifier_output);
// EXPECT_DEBUG_DEATH(verifier.verify(proof), "(ipa_relation.get_value.* ==
// -opening_claim.commitment.get_value.*)");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ std::array<typename bn254<CircuitBuilder>::Element, 2> MergeRecursiveVerifier_<C
const HonkProof& proof)
{
// transform it into stdlib proof
StdlibProof<CircuitBuilder> stdlib_proof = bb::convert_proof_to_witness(builder, proof);
StdlibProof<CircuitBuilder> stdlib_proof = bb::convert_native_proof_to_stdlib(builder, proof);
transcript = std::make_shared<Transcript>(stdlib_proof);

// Receive commitments [t_i^{shift}], [T_{i-1}], and [T_i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ std::array<typename Flavor::GroupElement, 2> DeciderRecursiveVerifier_<Flavor>::
using VerifierCommitments = typename Flavor::VerifierCommitments;
using Transcript = typename Flavor::Transcript;

StdlibProof<Builder> stdlib_proof = bb::convert_proof_to_witness(builder, proof);
StdlibProof<Builder> stdlib_proof = bb::convert_native_proof_to_stdlib(builder, proof);
transcript = std::make_shared<Transcript>(stdlib_proof);

VerifierCommitments commitments{ accumulator->verification_key, accumulator->witness_commitments };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ template <typename Flavor>
UltraRecursiveVerifier_<Flavor>::AggregationObject UltraRecursiveVerifier_<Flavor>::verify_proof(
const HonkProof& proof, AggregationObject agg_obj)
{
StdlibProof<Builder> stdlib_proof = bb::convert_proof_to_witness(builder, proof);
StdlibProof<Builder> stdlib_proof = bb::convert_native_proof_to_stdlib(builder, proof);
return verify_proof(stdlib_proof, agg_obj);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ template <typename RecursiveFlavor> class ProtogalaxyRecursiveTests : public tes
auto recursive_decider_vk_1 = std::make_shared<RecursiveDeciderVerificationKey>(&folding_circuit, decider_vk_1);
auto recursive_decider_vk_2 =
std::make_shared<RecursiveVerificationKey>(&folding_circuit, decider_vk_2->verification_key);
StdlibProof<OuterBuilder> stdlib_proof = bb::convert_proof_to_witness(&folding_circuit, folding_proof.proof);
StdlibProof<OuterBuilder> stdlib_proof =
bb::convert_native_proof_to_stdlib(&folding_circuit, folding_proof.proof);

auto verifier =
FoldingRecursiveVerifier{ &folding_circuit, recursive_decider_vk_1, { recursive_decider_vk_2 } };
Expand Down Expand Up @@ -292,7 +293,8 @@ template <typename RecursiveFlavor> class ProtogalaxyRecursiveTests : public tes
auto recursive_decider_vk_1 = std::make_shared<RecursiveDeciderVerificationKey>(&folding_circuit, decider_vk_1);
auto recursive_decider_vk_2 =
std::make_shared<RecursiveVerificationKey>(&folding_circuit, decider_vk_2->verification_key);
StdlibProof<OuterBuilder> stdlib_proof = bb::convert_proof_to_witness(&folding_circuit, folding_proof.proof);
StdlibProof<OuterBuilder> stdlib_proof =
bb::convert_native_proof_to_stdlib(&folding_circuit, folding_proof.proof);

auto verifier =
FoldingRecursiveVerifier{ &folding_circuit, recursive_decider_vk_1, { recursive_decider_vk_2 } };
Expand Down Expand Up @@ -398,7 +400,8 @@ template <typename RecursiveFlavor> class ProtogalaxyRecursiveTests : public tes
std::make_shared<RecursiveDeciderVerificationKey>(&folding_circuit, verifier_accumulator);
auto recursive_decider_vk_2 =
std::make_shared<RecursiveVerificationKey>(&folding_circuit, verifier_inst->verification_key);
StdlibProof<OuterBuilder> stdlib_proof = bb::convert_proof_to_witness(&folding_circuit, folding_proof.proof);
StdlibProof<OuterBuilder> stdlib_proof =
bb::convert_native_proof_to_stdlib(&folding_circuit, folding_proof.proof);

auto verifier =
FoldingRecursiveVerifier{ &folding_circuit, recursive_decider_vk_1, { recursive_decider_vk_2 } };
Expand Down Expand Up @@ -436,7 +439,8 @@ template <typename RecursiveFlavor> class ProtogalaxyRecursiveTests : public tes
auto recursive_decider_vk_1 =
std::make_shared<RecursiveDeciderVerificationKey>(&verifier_circuit, honk_vk_1);
auto recursive_decider_vk_2 = std::make_shared<RecursiveVerificationKey>(&verifier_circuit, honk_vk_2);
StdlibProof<OuterBuilder> stdlib_proof = bb::convert_proof_to_witness(&verifier_circuit, fold_result.proof);
StdlibProof<OuterBuilder> stdlib_proof =
bb::convert_native_proof_to_stdlib(&verifier_circuit, fold_result.proof);

auto verifier =
FoldingRecursiveVerifier{ &verifier_circuit, recursive_decider_vk_1, { recursive_decider_vk_2 } };
Expand Down
Loading

0 comments on commit ee98551

Please sign in to comment.