Skip to content

Commit

Permalink
REmove create_verifier functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed Mar 1, 2024
1 parent ca2af83 commit 4ad0574
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ template <typename BuilderType> class GoblinRecursiveVerifierTest : public testi
using InnerFlavor = GoblinUltraFlavor;
using InnerComposer = GoblinUltraComposer;
using InnerProver = GoblinUltraProver;
using InnerVerifier = GoblinUltraVerifier;
using InnerBuilder = typename InnerComposer::CircuitBuilder;
using InnerProverInstance = ProverInstance_<InnerFlavor>;
using InnerCurve = bn254<InnerBuilder>;
Expand All @@ -37,6 +38,8 @@ template <typename BuilderType> class GoblinRecursiveVerifierTest : public testi
std::conditional_t<std::same_as<BuilderType, GoblinUltraCircuitBuilder>, GoblinUltraFlavor, UltraFlavor>;
using OuterProver =
std::conditional_t<std::same_as<BuilderType, GoblinUltraCircuitBuilder>, GoblinUltraProver, UltraProver>;
using OuterVerifier =
std::conditional_t<std::same_as<BuilderType, GoblinUltraCircuitBuilder>, GoblinUltraVerifier, UltraVerifier>;
using OuterProverInstance = ProverInstance_<OuterFlavor>;
using RecursiveFlavor = GoblinUltraRecursiveFlavor_<OuterBuilder>;
using RecursiveVerifier = UltraRecursiveVerifier_<RecursiveFlavor>;
Expand Down Expand Up @@ -181,7 +184,6 @@ template <typename BuilderType> class GoblinRecursiveVerifierTest : public testi
auto inner_circuit = create_inner_circuit();

// Generate a proof over the inner circuit
InnerComposer inner_composer;
auto instance = std::make_shared<InnerProverInstance>(inner_circuit);
InnerProver inner_prover(instance);
auto inner_proof = inner_prover.construct_proof();
Expand All @@ -197,7 +199,7 @@ template <typename BuilderType> class GoblinRecursiveVerifierTest : public testi

// Check 1: Perform native verification then perform the pairing on the outputs of the recursive
// verifier and check that the result agrees.
auto native_verifier = inner_composer.create_verifier(instance->verification_key);
InnerVerifier native_verifier(instance->verification_key);
auto native_result = native_verifier.verify_proof(inner_proof);
auto recursive_result = native_verifier.key->pcs_verification_key->pairing_check(pairing_points[0].get_value(),
pairing_points[1].get_value());
Expand All @@ -213,10 +215,9 @@ template <typename BuilderType> class GoblinRecursiveVerifierTest : public testi

// Check 3: Construct and verify a proof of the recursive verifier circuit
{
auto composer = get_outer_composer<OuterBuilder>();
auto instance = std::make_shared<OuterProverInstance>(outer_circuit);
OuterProver prover(instance);
auto verifier = composer.create_verifier(instance->verification_key);
OuterVerifier verifier(instance->verification_key);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ class RecursiveMergeVerifierTest : public testing::Test {

// Check 3: Construct and verify a (goblin) ultra honk proof of the Merge recursive verifier circuit
{
GoblinUltraComposer composer;
auto instance = std::make_shared<InnerProverInstance>(outer_circuit);
GoblinUltraProver prover(instance);
auto verifier = composer.create_verifier(instance->verification_key);
GoblinUltraVerifier verifier(instance->verification_key);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes
using Composer = ::bb::UltraComposer_<NativeFlavor>;
using Builder = typename RecursiveFlavor::CircuitBuilder;
using Prover = UltraProver_<NativeFlavor>;
using Verifier = UltraVerifier_<NativeFlavor>;
using ProverInstance = ::bb::ProverInstance_<NativeFlavor>;
using VerifierInstance = ::bb::VerifierInstance_<NativeFlavor>;
using RecursiveVerifierInstance = ::bb::stdlib::recursion::honk::RecursiveVerifierInstance_<RecursiveFlavor>;
Expand Down Expand Up @@ -203,10 +204,9 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes
// Check for a failure flag in the recursive verifier circuit

{
auto composer = Composer();
auto instance = std::make_shared<ProverInstance>(folding_circuit);
Prover prover(instance);
auto verifier = composer.create_verifier(instance->verification_key);
Verifier verifier(instance->verification_key);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);

Expand Down Expand Up @@ -293,10 +293,9 @@ template <typename RecursiveFlavor> class ProtoGalaxyRecursiveTests : public tes

// Construct and verify a proof of the recursive decider verifier circuit
{
auto composer = Composer();
auto instance = std::make_shared<ProverInstance>(decider_circuit);
Prover prover(instance);
auto verifier = composer.create_verifier(instance->verification_key);
Verifier verifier(instance->verification_key);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ template <typename BuilderType> class HonkRecursiveVerifierTest : public testing
using InnerProverInstance = ProverInstance_<InnerFlavor>;
using InnerComposer = UltraComposer;
using InnerProver = UltraProver;
using InnerVerifier = UltraVerifier;
using InnerBuilder = typename InnerComposer::CircuitBuilder;
using InnerCurve = bn254<InnerBuilder>;
using Commitment = InnerFlavor::Commitment;
Expand All @@ -39,6 +40,8 @@ template <typename BuilderType> class HonkRecursiveVerifierTest : public testing
std::conditional_t<std::same_as<BuilderType, GoblinUltraCircuitBuilder>, GoblinUltraFlavor, UltraFlavor>;
using OuterProver =
std::conditional_t<std::same_as<BuilderType, GoblinUltraCircuitBuilder>, GoblinUltraProver, UltraProver>;
using OuterVerifier =
std::conditional_t<std::same_as<BuilderType, GoblinUltraCircuitBuilder>, GoblinUltraVerifier, UltraVerifier>;
using OuterProverInstance = ProverInstance_<OuterFlavor>;

using VerificationKey = typename RecursiveVerifier::VerificationKey;
Expand Down Expand Up @@ -166,7 +169,6 @@ template <typename BuilderType> class HonkRecursiveVerifierTest : public testing
create_inner_circuit(inner_circuit);

// Generate a proof over the inner circuit
InnerComposer inner_composer;
auto instance = std::make_shared<InnerProverInstance>(inner_circuit);
InnerProver inner_prover(instance);
auto inner_proof = inner_prover.construct_proof();
Expand All @@ -182,7 +184,7 @@ template <typename BuilderType> class HonkRecursiveVerifierTest : public testing

// Check 1: Perform native verification then perform the pairing on the outputs of the recursive
// verifier and check that the result agrees.
auto native_verifier = inner_composer.create_verifier(instance->verification_key);
InnerVerifier native_verifier(instance->verification_key);
auto native_result = native_verifier.verify_proof(inner_proof);
auto recursive_result = native_verifier.key->pcs_verification_key->pairing_check(pairing_points[0].get_value(),
pairing_points[1].get_value());
Expand All @@ -198,10 +200,9 @@ template <typename BuilderType> class HonkRecursiveVerifierTest : public testing

// Check 3: Construct and verify a proof of the recursive verifier circuit
{
auto composer = get_outer_composer<OuterBuilder>();
auto instance = std::make_shared<OuterProverInstance>(outer_circuit);
OuterProver prover(instance);
auto verifier = composer.create_verifier(instance->verification_key);
OuterVerifier verifier(instance->verification_key);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ TEST_F(DataBusComposerTests, CallDataRead)
builder.calldata_read_counts[read_index]++;
}

auto composer = GoblinUltraComposer();

// Construct and verify Honk proof
auto instance = std::make_shared<ProverInstance_<GoblinUltraFlavor>>(builder);
// For debugging, use "instance_inspector::print_databus_info(instance)"
GoblinUltraProver prover(instance);
auto verifier = composer.create_verifier(instance->verification_key);
GoblinUltraVerifier verifier(instance->verification_key);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);
EXPECT_TRUE(verified);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ class GoblinUltraHonkComposerTests : public ::testing::Test {
* @brief Construct and a verify a Honk proof
*
*/
bool construct_and_verify_honk_proof(auto& composer, auto& builder)
bool construct_and_verify_honk_proof([[maybe_unused]] auto& composer, auto& builder)
{
auto instance = std::make_shared<ProverInstance_<GoblinUltraFlavor>>(builder);
GoblinUltraProver prover(instance);
auto verifier = composer.create_verifier(instance->verification_key);
GoblinUltraVerifier verifier(instance->verification_key);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,12 @@ TEST_F(GoblinUltraTranscriptTests, VerifierManifestConsistency)
generate_test_circuit(builder);

// Automatically generate a transcript manifest in the prover by constructing a proof
auto composer = GoblinUltraComposer();
auto instance = std::make_shared<ProverInstance>(builder);
GoblinUltraProver prover(instance);
auto proof = prover.construct_proof();

// Automatically generate a transcript manifest in the verifier by verifying a proof
auto verifier = composer.create_verifier(instance->verification_key);
GoblinUltraVerifier verifier(instance->verification_key);
verifier.verify_proof(proof);

// Check consistency between the manifests generated by the prover and verifier
Expand Down Expand Up @@ -218,15 +217,14 @@ TEST_F(GoblinUltraTranscriptTests, ChallengeGenerationTest)
TEST_F(GoblinUltraTranscriptTests, StructureTest)
{
// Construct a simple circuit of size n = 8 (i.e. the minimum circuit size)
auto builder = typename Flavor::CircuitBuilder();
Flavor::CircuitBuilder builder;
generate_test_circuit(builder);

// Automatically generate a transcript manifest by constructing a proof
auto composer = GoblinUltraComposer();
auto instance = std::make_shared<ProverInstance>(builder);
GoblinUltraProver prover(instance);
auto proof = prover.construct_proof();
auto verifier = composer.create_verifier(instance->verification_key);
GoblinUltraVerifier verifier(instance->verification_key);
EXPECT_TRUE(verifier.verify_proof(proof));

// try deserializing and serializing with no changes and check proof is still valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@

namespace bb {

template <IsUltraFlavor Flavor>
UltraVerifier_<Flavor> UltraComposer_<Flavor>::create_verifier(const std::shared_ptr<VerificationKey>& verification_key,
const std::shared_ptr<Transcript>& transcript)
{
return UltraVerifier_<Flavor>(transcript, verification_key);
}

template <IsUltraFlavor Flavor>
DeciderProver_<Flavor> UltraComposer_<Flavor>::create_decider_prover(const std::shared_ptr<ProverInstance>& accumulator,
const std::shared_ptr<Transcript>& transcript)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ template <IsUltraFlavor Flavor_> class UltraComposer_ {
using ProverInstances = ProverInstances_<Flavor>;
using VerifierInstances = VerifierInstances_<Flavor>;

UltraVerifier_<Flavor> create_verifier(
const std::shared_ptr<VerificationKey>&,
const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>());

DeciderProver_<Flavor> create_decider_prover(
const std::shared_ptr<ProverInstance>&,
const std::shared_ptr<Transcript>& transcript = std::make_shared<Transcript>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ std::vector<uint32_t> add_variables(auto& circuit_builder, std::vector<bb::fr> v
return res;
}

void prove_and_verify(auto& circuit_builder, auto& composer, bool expected_result)
void prove_and_verify(auto& circuit_builder, [[maybe_unused]] auto& composer, bool expected_result)
{
auto instance = std::make_shared<ProverInstance>(circuit_builder);
UltraProver prover(instance);
auto verifier = composer.create_verifier(instance->verification_key);
UltraVerifier verifier(instance->verification_key);
auto proof = prover.construct_proof();
bool verified = verifier.verify_proof(proof);
EXPECT_EQ(verified, expected_result);
Expand Down Expand Up @@ -198,10 +198,9 @@ TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators)
expected_scalar >>= table_bits;
}
}
auto composer = UltraComposer();
auto instance = std::make_shared<ProverInstance>(circuit_builder);
UltraProver prover(instance);
auto verifier = composer.create_verifier(instance->verification_key);
UltraVerifier verifier(instance->verification_key);
auto proof = prover.construct_proof();

bool result = verifier.verify_proof(proof);
Expand Down Expand Up @@ -886,4 +885,4 @@ TEST_F(UltraHonkComposerTests, range_constraint_small_variable)

auto composer = UltraComposer();
prove_and_verify(circuit_builder, composer, /*expected_result=*/true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,12 @@ TEST_F(UltraTranscriptTests, VerifierManifestConsistency)
generate_test_circuit(builder);

// Automatically generate a transcript manifest in the prover by constructing a proof
auto composer = UltraComposer();
auto instance = std::make_shared<ProverInstance>(builder);
UltraProver prover(instance);
auto proof = prover.construct_proof();

// Automatically generate a transcript manifest in the verifier by verifying a proof
auto verifier = composer.create_verifier(instance->verification_key);
UltraVerifier verifier(instance->verification_key);
verifier.verify_proof(proof);

// Check consistency between the manifests generated by the prover and verifier
Expand Down Expand Up @@ -208,11 +207,10 @@ TEST_F(UltraTranscriptTests, StructureTest)
generate_test_circuit(builder);

// Automatically generate a transcript manifest by constructing a proof
auto composer = UltraComposer();
auto instance = std::make_shared<ProverInstance>(builder);
UltraProver prover(instance);
auto proof = prover.construct_proof();
auto verifier = composer.create_verifier(instance->verification_key);
UltraVerifier verifier(instance->verification_key);
EXPECT_TRUE(verifier.verify_proof(proof));

// try deserializing and serializing with no changes and check proof is still valid
Expand Down

0 comments on commit 4ad0574

Please sign in to comment.