25class MockDatabusProducer {
30 using BusDataArray = std::vector<FF>;
32 static constexpr size_t BUS_ARRAY_SIZE = 3;
33 BusDataArray app_return_data;
34 BusDataArray kernel_return_data;
36 FF dummy_return_val = 1;
38 BusDataArray generate_random_bus_array()
41 for (
size_t i = 0; i < BUS_ARRAY_SIZE; ++i) {
42 result.emplace_back(dummy_return_val);
44 dummy_return_val += 1;
52 void populate_app_databus(ClientCircuit& circuit)
54 app_return_data = generate_random_bus_array();
55 for (
auto& val : app_return_data) {
56 circuit.add_public_return_data(circuit.add_variable(val));
64 void populate_kernel_databus(ClientCircuit& circuit)
67 for (
auto& val : kernel_return_data) {
68 circuit.add_public_calldata(circuit.add_variable(val));
71 for (
auto& val : app_return_data) {
72 circuit.add_public_secondary_calldata(circuit.add_variable(val));
74 app_return_data.clear();
77 kernel_return_data = generate_random_bus_array();
78 for (
auto& val : kernel_return_data) {
79 circuit.add_public_return_data(circuit.add_variable(val));
87 void tamper_with_app_return_data() { app_return_data.emplace_back(17); }
97 size_t num_public_inputs = 0;
101 size_t log2_num_gates = 0;
112class PrivateFunctionExecutionMockCircuitProducer {
117 size_t circuit_counter = 0;
118 std::vector<bool> is_kernel_flags;
120 MockDatabusProducer mock_databus;
121 bool large_first_app =
true;
122 constexpr static size_t NUM_TRAILING_KERNELS = 3;
125 size_t total_num_circuits = 0;
127 PrivateFunctionExecutionMockCircuitProducer(
size_t num_app_circuits,
bool large_first_app =
true)
128 : large_first_app(large_first_app)
129 , total_num_circuits(num_app_circuits * 2 +
130 NUM_TRAILING_KERNELS)
133 is_kernel_flags.resize(total_num_circuits,
true);
134 for (
size_t i = 0; i < num_app_circuits; ++i) {
135 is_kernel_flags[2 * i] =
false;
143 static std::shared_ptr<VerificationKey> get_verification_key(ClientCircuit& builder_in)
163 ClientCircuit create_next_circuit(
Chonk& ivc,
164 size_t log2_num_gates = 0,
165 size_t num_public_inputs = 0,
166 bool check_circuit_sizes =
false)
168 const bool is_kernel = is_kernel_flags[circuit_counter++];
169 const bool use_large_circuit = large_first_app && (circuit_counter == 1);
175 if (log2_num_gates != 0) {
178 for (
size_t i = 0; i < num_public_inputs; ++i) {
179 circuit.add_public_variable(
typename Flavor::FF(13634816 + i));
186 if (!is_trailing_kernel) {
189 mock_databus.populate_kernel_databus(circuit);
192 mock_databus.populate_app_databus(circuit);
202 if (check_circuit_sizes) {
204 size_t log2_dyadic_size =
numeric::get_msb(prover_instance->get_metadata().dyadic_size);
205 if (log2_num_gates != 0) {
211 "Log number of gates in a kernel with fixed number of arithmetic gates has exceeded bound.");
212 vinfo(
"Log number of gates in a kernel with fixed number of arithmetic gates is: ",
216 size_t LOG2_OFFSET = 2;
218 log2_num_gates + LOG2_OFFSET,
219 "Log number of arithemtic gates produced is different from the one requested.");
224 if (is_trailing_kernel) {
228 "Trailing kernel circuit size has exceeded expected bound (should be <= 2^16).");
229 vinfo(
"Log number of gates in a trailing kernel circuit is: ", log2_dyadic_size);
233 "There has been a change in the number of gates of a mock kernel circuit.");
237 use_large_circuit ? 19UL : 17UL,
238 "There has been a change in the of gates generated for a mock app circuit.");
256 create_next_circuit(ivc, settings.log2_num_gates, settings.num_public_inputs, check_circuit_size);
257 return { circuit, get_verification_key(circuit) };
260 void construct_and_accumulate_next_circuit(
Chonk& ivc,
TestSettings settings = {},
bool check_circuit_sizes =
false)
262 auto [circuit,
vk] = create_next_circuit_and_vk(ivc, settings, check_circuit_sizes);
269 void tamper_with_databus() { mock_databus.tamper_with_app_return_data(); }
#define BB_ASSERT_EQ(actual, expected,...)
#define BB_ASSERT_LTE(left, right,...)
The IVC scheme used by the aztec client for private function execution.
void complete_kernel_circuit_logic(ClientCircuit &circuit)
Append logic to complete a kernel circuit.
size_t num_circuits_accumulated
size_t get_num_circuits() const
void accumulate(ClientCircuit &circuit, const std::shared_ptr< MegaVerificationKey > &precomputed_vk) override
Perform prover work for accumulation (e.g. HN folding, merge proving)
MegaCircuitBuilder ClientCircuit
The verification key is responsible for storing the commitments to the precomputed (non-witnessk) pol...
typename Curve::ScalarField FF
std::shared_ptr< OpQueue > op_queue
static void construct_mock_app_circuit(MegaBuilder &builder, bool large=false)
Populate a builder with some arbitrary but nontrivial constraints.
static void construct_mock_folding_kernel(MegaBuilder &builder)
Construct a mock kernel circuit.
std::shared_ptr< ECCOpQueue > op_queue
static void construct_arithmetic_circuit(Builder &builder, const size_t target_log2_dyadic_size=4, bool include_public_inputs=true)
Populate a builder with a specified number of arithmetic gates; includes a PI.
static void add_default(Builder &builder)
Add default public inputs when they are not present.
UltraKeccakFlavor::VerificationKey VerificationKey
constexpr T get_msb(const T in)
Entry point for Barretenberg command-line interface.
::testing::Types< BN254Settings, GrumpkinSettings > TestSettings
VerifierCommitmentKey< Curve > vk
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept