Skip to content

Commit 07cac06

Browse files
committed
remove redundant verify methods
1 parent 674d53a commit 07cac06

File tree

8 files changed

+24
-69
lines changed

8 files changed

+24
-69
lines changed

barretenberg/cpp/src/barretenberg/api/api_client_ivc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ bool ClientIVCAPI::prove_and_verify(const std::filesystem::path& input_path)
154154
std::shared_ptr<ClientIVC> ivc = steps.accumulate();
155155
// Construct the hiding kernel as the final step of the IVC
156156

157-
const bool verified = ivc->prove_and_verify();
157+
auto proof = ivc->prove();
158+
const bool verified = ClientIVC::verify(proof, ivc->get_vk());
158159
return verified;
159160
}
160161

barretenberg/cpp/src/barretenberg/bbapi/bbapi_client_ivc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ClientIvcProve::Response ClientIvcProve::execute(BBApiRequest& request) &&
8181
// We verify this proof. Another bb call to verify has some overhead of loading VK/proof/SRS,
8282
// and it is mysterious if this transaction fails later in the lifecycle.
8383
info("ClientIvcProve - verifying the generated proof as a sanity check");
84-
if (!request.ivc_in_progress->verify(proof)) {
84+
if (!request.ivc_in_progress->verify(proof, request.ivc_in_progress->get_vk())) {
8585
throw_or_abort("Failed to verify the generated proof!");
8686
}
8787

barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -601,17 +601,6 @@ bool ClientIVC::verify(const Proof& proof, const VerificationKey& vk)
601601
return goblin_verified && mega_verified;
602602
}
603603

604-
/**
605-
* @brief Verify a full proof of the IVC
606-
*
607-
* @param proof
608-
* @return bool
609-
*/
610-
bool ClientIVC::verify(const Proof& proof) const
611-
{
612-
return verify(proof, get_vk());
613-
}
614-
615604
/**
616605
* @brief Internal method for constructing a decider proof
617606
*
@@ -626,30 +615,6 @@ HonkProof ClientIVC::construct_decider_proof(const std::shared_ptr<Transcript>&
626615
return decider_prover.export_proof();
627616
}
628617

629-
/**
630-
* @brief Construct and verify a proof for the IVC
631-
* @note Use of this method only makes sense when the prover and verifier are the same entity, e.g. in
632-
* development/testing.
633-
*
634-
*/
635-
bool ClientIVC::prove_and_verify()
636-
{
637-
auto start = std::chrono::steady_clock::now();
638-
const auto proof = prove();
639-
auto end = std::chrono::steady_clock::now();
640-
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
641-
vinfo("time to call ClientIVC::prove: ", diff.count(), " ms.");
642-
643-
start = end;
644-
const bool verified = verify(proof);
645-
end = std::chrono::steady_clock::now();
646-
647-
diff = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
648-
vinfo("time to verify ClientIVC proof: ", diff.count(), " ms.");
649-
650-
return verified;
651-
}
652-
653618
// Proof methods
654619
size_t ClientIVC::Proof::size() const
655620
{

barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,6 @@ class ClientIVC {
273273

274274
static bool verify(const Proof& proof, const VerificationKey& vk);
275275

276-
bool verify(const Proof& proof) const;
277-
278-
bool prove_and_verify();
279-
280276
HonkProof construct_decider_proof(const std::shared_ptr<Transcript>& transcript);
281277

282278
VerificationKey get_vk() const;

barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ TEST_F(ClientIVCTests, BadProofFailure)
108108
for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) {
109109
circuit_producer.construct_and_accumulate_next_circuit(ivc, settings);
110110
}
111-
EXPECT_TRUE(ivc.prove_and_verify());
111+
auto proof = ivc.prove();
112+
EXPECT_TRUE(ClientIVC::verify(proof, ivc.get_vk()));
112113
}
113114

114115
// The IVC throws an exception if the FIRST fold proof is tampered with
@@ -135,7 +136,8 @@ TEST_F(ClientIVCTests, BadProofFailure)
135136
num_public_inputs); // tamper with first proof
136137
}
137138
}
138-
EXPECT_FALSE(ivc.prove_and_verify());
139+
auto proof = ivc.prove();
140+
EXPECT_FALSE(ClientIVC::verify(proof, ivc.get_vk()));
139141
}
140142

141143
// The IVC fails if the SECOND fold proof is tampered with
@@ -156,7 +158,8 @@ TEST_F(ClientIVCTests, BadProofFailure)
156158
circuit.num_public_inputs()); // tamper with second proof
157159
}
158160
}
159-
EXPECT_FALSE(ivc.prove_and_verify());
161+
auto proof = ivc.prove();
162+
EXPECT_FALSE(ClientIVC::verify(proof, ivc.get_vk()));
160163
}
161164

162165
EXPECT_TRUE(true);
@@ -309,7 +312,8 @@ TEST_F(ClientIVCTests, StructuredTraceOverflow)
309312
log2_num_gates += 1;
310313
}
311314

312-
EXPECT_TRUE(ivc.prove_and_verify());
315+
auto proof = ivc.prove();
316+
EXPECT_TRUE(ClientIVC::verify(proof, ivc.get_vk()));
313317
};
314318

315319
/**
@@ -345,7 +349,8 @@ TEST_F(ClientIVCTests, DynamicTraceOverflow)
345349
}
346350

347351
EXPECT_EQ(check_accumulator_target_sum_manual(ivc.prover_accumulator), true);
348-
EXPECT_TRUE(ivc.prove_and_verify());
352+
auto proof = ivc.prove();
353+
EXPECT_TRUE(ClientIVC::verify(proof, ivc.get_vk()));
349354
}
350355
}
351356

@@ -417,5 +422,6 @@ TEST_F(ClientIVCTests, DatabusFailure)
417422
ivc.accumulate(circuit, vk);
418423
}
419424

420-
EXPECT_FALSE(ivc.prove_and_verify());
425+
auto proof = ivc.prove();
426+
EXPECT_FALSE(ClientIVC::verify(proof, ivc.get_vk()));
421427
};

barretenberg/cpp/src/barretenberg/client_ivc/test_bench_shared.hpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,6 @@
1313

1414
namespace bb {
1515

16-
/**
17-
* @brief Verify an IVC proof
18-
*
19-
*/
20-
bool verify_ivc(ClientIVC::Proof& proof, ClientIVC& ivc)
21-
{
22-
bool verified = ivc.verify(proof);
23-
24-
// This is a benchmark, not a test, so just print success or failure to the log
25-
if (verified) {
26-
info("IVC successfully verified!");
27-
} else {
28-
info("IVC failed to verify.");
29-
}
30-
return verified;
31-
}
32-
3316
/**
3417
* @brief Perform a specified number of circuit accumulation rounds
3518
*

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_integration.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ TEST_F(AcirIntegrationTest, DISABLED_ClientIVCMsgpackInputs)
511511
std::shared_ptr<ClientIVC> ivc = steps.accumulate();
512512
ClientIVC::Proof proof = ivc->prove();
513513

514-
EXPECT_TRUE(ivc->verify(proof));
514+
EXPECT_TRUE(ivc->verify(proof, ivc->get_vk()));
515515
}
516516

517517
/**

barretenberg/cpp/src/barretenberg/dsl/acir_format/pg_recursion_constraint.test.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ TEST_F(IvcRecursionConstraintTest, AccumulateSingleApp)
313313
// add the trailing kernels
314314
construct_and_accumulate_trailing_kernels(ivc, trace_settings);
315315

316-
EXPECT_TRUE(ivc->prove_and_verify());
316+
auto proof = ivc->prove();
317+
EXPECT_TRUE(ClientIVC::verify(proof, ivc->get_vk()));
317318
}
318319

319320
/**
@@ -343,7 +344,8 @@ TEST_F(IvcRecursionConstraintTest, AccumulateTwoApps)
343344
// Accumulate the trailing kernels
344345
construct_and_accumulate_trailing_kernels(ivc, trace_settings);
345346

346-
EXPECT_TRUE(ivc->prove_and_verify());
347+
auto proof = ivc->prove();
348+
EXPECT_TRUE(ClientIVC::verify(proof, ivc->get_vk()));
347349
}
348350

349351
// Test generation of "init" kernel VK via dummy IVC data
@@ -584,7 +586,8 @@ TEST_F(IvcRecursionConstraintTest, RecursiveVerifierAppCircuitTest)
584586

585587
construct_and_accumulate_trailing_kernels(ivc, trace_settings);
586588

587-
EXPECT_TRUE(ivc->prove_and_verify());
589+
auto proof = ivc->prove();
590+
EXPECT_TRUE(ClientIVC::verify(proof, ivc->get_vk()));
588591
}
589592

590593
/**
@@ -607,5 +610,6 @@ TEST_F(IvcRecursionConstraintTest, BadRecursiveVerifierAppCircuitTest)
607610
construct_and_accumulate_trailing_kernels(ivc, trace_settings);
608611

609612
// We expect the CIVC proof to fail due to the app with a failed UH recursive verification
610-
EXPECT_FALSE(ivc->prove_and_verify());
613+
auto proof = ivc->prove();
614+
EXPECT_FALSE(ClientIVC::verify(proof, ivc->get_vk()));
611615
}

0 commit comments

Comments
 (0)