Skip to content

Commit

Permalink
Remove decider prover and verifier construction from composer.
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed Mar 1, 2024
1 parent 7c2178d commit fcbb0ac
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 49 deletions.
5 changes: 2 additions & 3 deletions barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool ClientIVC::verify(Proof& proof, const std::vector<VerifierAccumulator>& ver
auto folding_verifier = composer.create_folding_verifier({ verifier_instances[0], verifier_instances[1] });
auto verifier_accumulator = folding_verifier.verify_folding_proof(proof.fold_proof);

auto decider_verifier = composer.create_decider_verifier(verifier_accumulator);
ClientIVC::DeciderVerifier decider_verifier(verifier_accumulator);
bool decision = decider_verifier.verify_proof(proof.decider_proof);
return goblin_verified && decision;
}
Expand All @@ -75,8 +75,7 @@ bool ClientIVC::verify(Proof& proof, const std::vector<VerifierAccumulator>& ver
*/
HonkProof ClientIVC::decider_prove() const
{
Composer composer;
auto decider_prover = composer.create_decider_prover(prover_fold_output.accumulator);
GoblinUltraDeciderProver decider_prover(prover_fold_output.accumulator);
return decider_prover.construct_proof();
}

Expand Down
2 changes: 2 additions & 0 deletions barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class ClientIVC {
using ProverInstance = ProverInstance_<GoblinUltraFlavor>;
using VerifierInstance = VerifierInstance_<GoblinUltraFlavor>;
using ClientCircuit = GoblinUltraCircuitBuilder; // can only be GoblinUltra
using DeciderProver = DeciderProver_<Flavor>;
using DeciderVerifier = DeciderVerifier_<Flavor>;

// A full proof for the IVC scheme
struct Proof {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ClientIVCTests : public ::testing::Test {
using RecursiveVerifierInstances = ::bb::stdlib::recursion::honk::RecursiveVerifierInstances_<GURecursiveFlavor, 2>;
using FoldingRecursiveVerifier =
bb::stdlib::recursion::honk::ProtoGalaxyRecursiveVerifier_<RecursiveVerifierInstances>;
using DeciderProver = ClientIVC::DeciderProver;
using DeciderVerifier = ClientIVC::DeciderVerifier;

/**
* @brief Construct mock circuit with arithmetic gates and goblin ops
Expand Down Expand Up @@ -89,8 +91,8 @@ class ClientIVCTests : public ::testing::Test {
auto verifier_accumulator = folding_verifier.verify_folding_proof(fold_proof);

// Run decider
auto decider_prover = composer.create_decider_prover(prover_accumulator);
auto decider_verifier = composer.create_decider_verifier(verifier_accumulator);
DeciderProver decider_prover(prover_accumulator);
DeciderVerifier decider_verifier(verifier_accumulator);
auto decider_proof = decider_prover.construct_proof();
bool decision = decider_verifier.verify_proof(decider_proof);
EXPECT_TRUE(decision);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ template <IsUltraFlavor Flavor> class DeciderProver_ {
HonkProof proof;
};

using DeciderProver = DeciderProver_<UltraFlavor>;
using UltraDeciderProver = DeciderProver_<UltraFlavor>;
using GoblinUltraDeciderProver = DeciderProver_<GoblinUltraFlavor>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ DeciderVerifier_<Flavor>::DeciderVerifier_(const std::shared_ptr<Transcript>& tr
, transcript(transcript)
{}

template <typename Flavor>
DeciderVerifier_<Flavor>::DeciderVerifier_(const std::shared_ptr<VerifierInstance>& accumulator,
const std::shared_ptr<Transcript>& transcript)
: accumulator(accumulator)
, pcs_verification_key(accumulator->verification_key->pcs_verification_key)
, transcript(transcript)
{}

template <typename Flavor>
DeciderVerifier_<Flavor>::DeciderVerifier_()
: pcs_verification_key(std::make_unique<VerifierCommitmentKey>())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ template <typename Flavor> class DeciderVerifier_ {
explicit DeciderVerifier_();
explicit DeciderVerifier_(const std::shared_ptr<Transcript>& transcript,
const std::shared_ptr<VerifierInstance>& accumulator = nullptr);
explicit DeciderVerifier_(const std::shared_ptr<VerifierInstance>& accumulator,
const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>());

bool verify_proof(const HonkProof& proof);

Expand All @@ -30,6 +32,7 @@ template <typename Flavor> class DeciderVerifier_ {
std::shared_ptr<Transcript> transcript;
};

using DeciderVerifier = DeciderVerifier_<UltraFlavor>;
using UltraDeciderVerifier = DeciderVerifier_<UltraFlavor>;
using GoblinUltraDeciderVerifier = DeciderVerifier_<GoblinUltraFlavor>;

} // namespace bb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes
using Curve = bn254<Builder>;
using Commitment = typename NativeFlavor::Commitment;
using FF = typename NativeFlavor::FF;
using DeciderProver = DeciderProver_<NativeFlavor>;

using RecursiveVerifierInstances = ::bb::stdlib::recursion::honk::RecursiveVerifierInstances_<RecursiveFlavor, 2>;
using FoldingRecursiveVerifier = ProtoGalaxyRecursiveVerifier_<RecursiveVerifierInstances>;
using DeciderRecursiveVerifier = DeciderRecursiveVerifier_<RecursiveFlavor>;
using DeciderVerifier = DeciderVerifier_<NativeFlavor>;
using NativeDeciderVerifier = DeciderVerifier_<NativeFlavor>;
using NativeVerifierInstances = VerifierInstances_<NativeFlavor, 2>;
using NativeFoldingVerifier = ProtoGalaxyVerifier_<NativeVerifierInstances>;

Expand Down Expand Up @@ -265,7 +266,7 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes
EXPECT_EQ(recursive_folding_manifest[i], native_folding_manifest[i]);
}

auto decider_prover = composer.create_decider_prover(folding_proof.accumulator);
DeciderProver decider_prover(folding_proof.accumulator);
auto decider_proof = decider_prover.construct_proof();

Builder decider_circuit;
Expand All @@ -275,9 +276,9 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes
// Check for a failure flag in the recursive verifier circuit
EXPECT_EQ(decider_circuit.failed(), false) << decider_circuit.err();

// Perform native verification then perform the pairing on the outputs of the recursive
// decider verifier and check that the result agrees.
DeciderVerifier native_decider_verifier = composer.create_decider_verifier(verifier_accumulator);
// Perform native verification then perform the pairing on the outputs of the recursive decider verifier and
// check that the result agrees.
NativeDeciderVerifier native_decider_verifier(verifier_accumulator);
auto native_result = native_decider_verifier.verify_proof(decider_proof);
auto recursive_result = native_decider_verifier.accumulator->pcs_verification_key->pairing_check(
pairing_points[0].get_value(), pairing_points[1].get_value());
Expand Down Expand Up @@ -313,7 +314,7 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes
verifier_accumulator->target_sum = FF::random_element();

// Create a decider proof for the relaxed instance obtained through folding
auto decider_prover = composer.create_decider_prover(prover_accumulator);
DeciderProver decider_prover(prover_accumulator);
auto decider_proof = decider_prover.construct_proof();

// Create a decider verifier circuit for recursively verifying the decider proof
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ template <typename Flavor> class ProtoGalaxyTests : public testing::Test {
using WitnessCommitments = typename Flavor::WitnessCommitments;
using CommitmentKey = typename Flavor::CommitmentKey;
using PowPolynomial = bb::PowPolynomial<FF>;
using DeciderProver = DeciderProver_<Flavor>;
using DeciderVerifier = DeciderVerifier_<Flavor>;

static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); }

Expand Down Expand Up @@ -93,13 +95,13 @@ template <typename Flavor> class ProtoGalaxyTests : public testing::Test {

static void decide_and_verify(std::shared_ptr<ProverInstance>& prover_accumulator,
std::shared_ptr<VerifierInstance>& verifier_accumulator,
Composer& composer,
[[maybe_unused]] Composer& composer,
bool expected_result)
{
auto decider_prover = composer.create_decider_prover(prover_accumulator);
auto decider_verifier = composer.create_decider_verifier(verifier_accumulator);
auto decider_proof = decider_prover.construct_proof();
auto verified = decider_verifier.verify_proof(decider_proof);
DeciderProver decider_prover(prover_accumulator);
DeciderVerifier decider_verifier(verifier_accumulator);
HonkProof decider_proof = decider_prover.construct_proof();
bool verified = decider_verifier.verify_proof(decider_proof);
EXPECT_EQ(verified, expected_result);
}

Expand Down
20 changes: 0 additions & 20 deletions barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
#include "barretenberg/ultra_honk/ultra_composer.hpp"
#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp"
#include "barretenberg/proof_system/composer/composer_lib.hpp"
#include "barretenberg/proof_system/composer/permutation_lib.hpp"
#include "barretenberg/proof_system/library/grand_product_library.hpp"

namespace bb {

template <IsUltraFlavor Flavor>
DeciderProver_<Flavor> UltraComposer_<Flavor>::create_decider_prover(const std::shared_ptr<ProverInstance>& accumulator,
const std::shared_ptr<Transcript>& transcript)
{
return DeciderProver_<Flavor>(accumulator, transcript);
;
}

template <IsUltraFlavor Flavor>
DeciderVerifier_<Flavor> UltraComposer_<Flavor>::create_decider_verifier(
const std::shared_ptr<VerifierInstance>& accumulator, const std::shared_ptr<Transcript>& transcript)
{
return DeciderVerifier_<Flavor>(transcript, accumulator);
}

template class UltraComposer_<UltraFlavor>;
template class UltraComposer_<GoblinUltraFlavor>;
} // namespace bb
11 changes: 0 additions & 11 deletions barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ template <IsUltraFlavor Flavor_> class UltraComposer_ {
using ProverInstances = ProverInstances_<Flavor>;
using VerifierInstances = VerifierInstances_<Flavor>;

DeciderProver_<Flavor> create_decider_prover(
const std::shared_ptr<ProverInstance>&,
const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>());

DeciderVerifier_<Flavor> create_decider_verifier(
const std::shared_ptr<VerifierInstance>&,
const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>());
UltraVerifier_<Flavor> create_verifier(CircuitBuilder& circuit);

UltraVerifier_<Flavor> create_ultra_with_keccak_verifier(CircuitBuilder& circuit);

ProtoGalaxyProver_<ProverInstances> create_folding_prover(
const std::vector<std::shared_ptr<ProverInstance>>& instances)
{
Expand Down
Loading

0 comments on commit fcbb0ac

Please sign in to comment.