Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
test_bench_shared.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
13
14namespace bb {
15
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
39 size_t num_app_circuits, auto& precomputed_vks, const bool large_first_app = true)
40{
41 PrivateFunctionExecutionMockCircuitProducer circuit_producer(num_app_circuits, large_first_app);
42 const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits;
43 TraceSettings trace_settings{ AZTEC_TRACE_STRUCTURE };
44 ClientIVC ivc{ NUM_CIRCUITS, trace_settings };
45
46 BB_ASSERT_EQ(precomputed_vks.size(), NUM_CIRCUITS, "There should be a precomputed VK for each circuit");
47
48 for (size_t circuit_idx = 0; circuit_idx < NUM_CIRCUITS; ++circuit_idx) {
49 MegaCircuitBuilder circuit;
50 {
51 PROFILE_THIS_NAME("construct_circuits");
52 circuit = circuit_producer.create_next_circuit(ivc);
53 }
54
55 ivc.accumulate(circuit, precomputed_vks[circuit_idx]);
56 }
57 return { ivc.prove(), ivc.get_vk() };
58}
59
61 const bool large_first_app = true)
62{
63 using CircuitProducer = PrivateFunctionExecutionMockCircuitProducer;
64 CircuitProducer circuit_producer(num_app_circuits, large_first_app);
65 const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits;
66 TraceSettings trace_settings{ AZTEC_TRACE_STRUCTURE };
67 ClientIVC ivc{ NUM_CIRCUITS, trace_settings };
68
70 for (size_t j = 0; j < NUM_CIRCUITS; ++j) {
71
72 auto circuit = circuit_producer.create_next_circuit(ivc);
73
74 // Hiding kernel does not use structured trace
75 if (j == NUM_CIRCUITS - 1) {
76 trace_settings = TraceSettings{};
77 }
78 auto vk = CircuitProducer::get_verification_key(circuit, trace_settings);
79 vkeys.push_back(vk);
80 ivc.accumulate(circuit, vk);
81 }
82
83 return vkeys;
84}
85
86} // namespace bb
#define BB_ASSERT_EQ(actual, expected,...)
Definition assert.hpp:59
The IVC scheme used by the aztec client for private function execution.
static bool verify(const Proof &proof, const VerificationKey &vk)
void info(Args... args)
Definition log.hpp:70
Entry point for Barretenberg command-line interface.
std::pair< ClientIVC::Proof, ClientIVC::VerificationKey > accumulate_and_prove_ivc_with_precomputed_vks(size_t num_app_circuits, auto &precomputed_vks, const bool large_first_app=true)
Perform a specified number of circuit accumulation rounds.
std::vector< std::shared_ptr< typename MegaFlavor::VerificationKey > > precompute_vks(const size_t num_app_circuits, const bool large_first_app=true)
bool verify_ivc(ClientIVC::Proof &proof, ClientIVC &ivc)
Verify an IVC proof.
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define PROFILE_THIS_NAME(name)
Definition op_count.hpp:16
A full proof for the IVC scheme containing a Mega proof showing correctness of the hiding circuit (wh...