19class MockDatabusProducer {
24 using BusDataArray = std::vector<FF>;
26 static constexpr size_t BUS_ARRAY_SIZE = 3;
27 BusDataArray app_return_data;
28 BusDataArray kernel_return_data;
30 FF dummy_return_val = 1;
32 BusDataArray generate_random_bus_array()
35 for (
size_t i = 0; i < BUS_ARRAY_SIZE; ++i) {
36 result.emplace_back(dummy_return_val);
38 dummy_return_val += 1;
46 void populate_app_databus(ClientCircuit& circuit)
48 app_return_data = generate_random_bus_array();
49 for (
auto& val : app_return_data) {
50 circuit.add_public_return_data(circuit.add_variable(val));
58 void populate_kernel_databus(ClientCircuit& circuit)
61 for (
auto& val : kernel_return_data) {
62 circuit.add_public_calldata(circuit.add_variable(val));
65 for (
auto& val : app_return_data) {
66 circuit.add_public_secondary_calldata(circuit.add_variable(val));
68 app_return_data.clear();
71 kernel_return_data = generate_random_bus_array();
72 for (
auto& val : kernel_return_data) {
73 circuit.add_public_return_data(circuit.add_variable(val));
81 void tamper_with_app_return_data() { app_return_data.emplace_back(17); }
91 size_t num_public_inputs = 0;
95 size_t log2_num_gates = 0;
106class PrivateFunctionExecutionMockCircuitProducer {
111 size_t circuit_counter = 0;
112 std::vector<bool> is_kernel_flags;
114 MockDatabusProducer mock_databus;
115 bool large_first_app =
true;
116 constexpr static size_t NUM_TRAILING_KERNELS = 3;
119 size_t total_num_circuits = 0;
121 PrivateFunctionExecutionMockCircuitProducer(
size_t num_app_circuits,
bool large_first_app =
true)
122 : large_first_app(large_first_app)
123 , total_num_circuits(num_app_circuits * 2 +
124 NUM_TRAILING_KERNELS)
127 is_kernel_flags.resize(total_num_circuits,
true);
128 for (
size_t i = 0; i < num_app_circuits; ++i) {
129 is_kernel_flags[2 * i] =
false;
137 static std::shared_ptr<VerificationKey> get_verification_key(ClientCircuit& builder_in)
157 ClientCircuit create_next_circuit(
Chonk& ivc,
158 size_t log2_num_gates = 0,
159 size_t num_public_inputs = 0,
160 bool check_circuit_sizes =
false)
162 const bool is_kernel = is_kernel_flags[circuit_counter++];
163 const bool use_large_circuit = large_first_app && (circuit_counter == 1);
169 if (log2_num_gates != 0) {
172 for (
size_t i = 0; i < num_public_inputs; ++i) {
173 circuit.add_public_variable(
typename Flavor::FF(13634816 + i));
180 if (!is_trailing_kernel) {
183 mock_databus.populate_kernel_databus(circuit);
186 mock_databus.populate_app_databus(circuit);
196 if (check_circuit_sizes) {
198 size_t log2_dyadic_size =
numeric::get_msb(prover_instance->get_metadata().dyadic_size);
199 if (log2_num_gates != 0) {
205 "Log number of gates in a kernel with fixed number of arithmetic gates has exceeded bound.");
206 vinfo(
"Log number of gates in a kernel with fixed number of arithmetic gates is: ",
210 size_t LOG2_OFFSET = 2;
212 log2_num_gates + LOG2_OFFSET,
213 "Log number of arithemtic gates produced is different from the one requested.");
218 if (is_trailing_kernel) {
222 "Trailing kernel circuit size has exceeded expected bound (should be <= 2^16).");
223 vinfo(
"Log number of gates in a trailing kernel circuit is: ", log2_dyadic_size);
227 "There has been a change in the number of gates of a mock kernel circuit.");
231 use_large_circuit ? 19UL : 17UL,
232 "There has been a change in the of gates generated for a mock app circuit.");
250 create_next_circuit(ivc, settings.log2_num_gates, settings.num_public_inputs, check_circuit_size);
251 return { circuit, get_verification_key(circuit) };
254 void construct_and_accumulate_next_circuit(
Chonk& ivc,
TestSettings settings = {},
bool check_circuit_sizes =
false)
256 auto [circuit,
vk] = create_next_circuit_and_vk(ivc, settings, check_circuit_sizes);
263 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
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
NativeVerificationKey_< PrecomputedEntities< Commitment >, Codec, HashFunction, CommitmentKey > VerificationKey
The verification key is responsible for storing the commitments to the precomputed (non-witness) poly...
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.
Base Native verification key class.
static void add_default(Builder &builder)
Add default public inputs when they are not present.
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