Skip to content

Commit

Permalink
chore(avm): smaller prover
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarreiro committed Jul 5, 2024
1 parent 47d9268 commit 455e4ad
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,8 @@ class AvmFlavor {
class WitnessEntities : public WireEntities<DataType>, public DerivedWitnessEntities<DataType> {
public:
DEFINE_COMPOUND_GET_ALL(WireEntities<DataType>, DerivedWitnessEntities<DataType>)
auto get_wires() { return WireEntities<DataType>::get_all(); };
auto get_wires() { return WireEntities<DataType>::get_all(); }
auto get_derived() { return DerivedWitnessEntities<DataType>::get_all(); }
};

template <typename DataType>
Expand Down
118 changes: 6 additions & 112 deletions barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,120 +72,14 @@ void AvmProver::execute_log_derivative_inverse_round()
key->compute_logderivative_inverses(relation_parameters);

// Commit to all logderivative inverse polynomials
witness_commitments.perm_main_alu = commitment_key->commit(key->perm_main_alu);
witness_commitments.perm_main_bin = commitment_key->commit(key->perm_main_bin);
witness_commitments.perm_main_conv = commitment_key->commit(key->perm_main_conv);
witness_commitments.perm_main_pos2_perm = commitment_key->commit(key->perm_main_pos2_perm);
witness_commitments.perm_main_pedersen = commitment_key->commit(key->perm_main_pedersen);
witness_commitments.perm_main_mem_a = commitment_key->commit(key->perm_main_mem_a);
witness_commitments.perm_main_mem_b = commitment_key->commit(key->perm_main_mem_b);
witness_commitments.perm_main_mem_c = commitment_key->commit(key->perm_main_mem_c);
witness_commitments.perm_main_mem_d = commitment_key->commit(key->perm_main_mem_d);
witness_commitments.perm_main_mem_ind_addr_a = commitment_key->commit(key->perm_main_mem_ind_addr_a);
witness_commitments.perm_main_mem_ind_addr_b = commitment_key->commit(key->perm_main_mem_ind_addr_b);
witness_commitments.perm_main_mem_ind_addr_c = commitment_key->commit(key->perm_main_mem_ind_addr_c);
witness_commitments.perm_main_mem_ind_addr_d = commitment_key->commit(key->perm_main_mem_ind_addr_d);
witness_commitments.lookup_byte_lengths = commitment_key->commit(key->lookup_byte_lengths);
witness_commitments.lookup_byte_operations = commitment_key->commit(key->lookup_byte_operations);
witness_commitments.lookup_opcode_gas = commitment_key->commit(key->lookup_opcode_gas);
witness_commitments.range_check_l2_gas_hi = commitment_key->commit(key->range_check_l2_gas_hi);
witness_commitments.range_check_l2_gas_lo = commitment_key->commit(key->range_check_l2_gas_lo);
witness_commitments.range_check_da_gas_hi = commitment_key->commit(key->range_check_da_gas_hi);
witness_commitments.range_check_da_gas_lo = commitment_key->commit(key->range_check_da_gas_lo);
witness_commitments.kernel_output_lookup = commitment_key->commit(key->kernel_output_lookup);
witness_commitments.lookup_into_kernel = commitment_key->commit(key->lookup_into_kernel);
witness_commitments.incl_main_tag_err = commitment_key->commit(key->incl_main_tag_err);
witness_commitments.incl_mem_tag_err = commitment_key->commit(key->incl_mem_tag_err);
witness_commitments.lookup_mem_rng_chk_lo = commitment_key->commit(key->lookup_mem_rng_chk_lo);
witness_commitments.lookup_mem_rng_chk_mid = commitment_key->commit(key->lookup_mem_rng_chk_mid);
witness_commitments.lookup_mem_rng_chk_hi = commitment_key->commit(key->lookup_mem_rng_chk_hi);
witness_commitments.lookup_pow_2_0 = commitment_key->commit(key->lookup_pow_2_0);
witness_commitments.lookup_pow_2_1 = commitment_key->commit(key->lookup_pow_2_1);
witness_commitments.lookup_u8_0 = commitment_key->commit(key->lookup_u8_0);
witness_commitments.lookup_u8_1 = commitment_key->commit(key->lookup_u8_1);
witness_commitments.lookup_u16_0 = commitment_key->commit(key->lookup_u16_0);
witness_commitments.lookup_u16_1 = commitment_key->commit(key->lookup_u16_1);
witness_commitments.lookup_u16_2 = commitment_key->commit(key->lookup_u16_2);
witness_commitments.lookup_u16_3 = commitment_key->commit(key->lookup_u16_3);
witness_commitments.lookup_u16_4 = commitment_key->commit(key->lookup_u16_4);
witness_commitments.lookup_u16_5 = commitment_key->commit(key->lookup_u16_5);
witness_commitments.lookup_u16_6 = commitment_key->commit(key->lookup_u16_6);
witness_commitments.lookup_u16_7 = commitment_key->commit(key->lookup_u16_7);
witness_commitments.lookup_u16_8 = commitment_key->commit(key->lookup_u16_8);
witness_commitments.lookup_u16_9 = commitment_key->commit(key->lookup_u16_9);
witness_commitments.lookup_u16_10 = commitment_key->commit(key->lookup_u16_10);
witness_commitments.lookup_u16_11 = commitment_key->commit(key->lookup_u16_11);
witness_commitments.lookup_u16_12 = commitment_key->commit(key->lookup_u16_12);
witness_commitments.lookup_u16_13 = commitment_key->commit(key->lookup_u16_13);
witness_commitments.lookup_u16_14 = commitment_key->commit(key->lookup_u16_14);
witness_commitments.lookup_div_u16_0 = commitment_key->commit(key->lookup_div_u16_0);
witness_commitments.lookup_div_u16_1 = commitment_key->commit(key->lookup_div_u16_1);
witness_commitments.lookup_div_u16_2 = commitment_key->commit(key->lookup_div_u16_2);
witness_commitments.lookup_div_u16_3 = commitment_key->commit(key->lookup_div_u16_3);
witness_commitments.lookup_div_u16_4 = commitment_key->commit(key->lookup_div_u16_4);
witness_commitments.lookup_div_u16_5 = commitment_key->commit(key->lookup_div_u16_5);
witness_commitments.lookup_div_u16_6 = commitment_key->commit(key->lookup_div_u16_6);
witness_commitments.lookup_div_u16_7 = commitment_key->commit(key->lookup_div_u16_7);
for (auto [commitment, key_poly] : zip_view(witness_commitments.get_derived(), key->get_derived())) {
commitment = commitment_key->commit(key_poly);
}

// Send all commitments to the verifier
transcript->send_to_verifier(commitment_labels.perm_main_alu, witness_commitments.perm_main_alu);
transcript->send_to_verifier(commitment_labels.perm_main_bin, witness_commitments.perm_main_bin);
transcript->send_to_verifier(commitment_labels.perm_main_conv, witness_commitments.perm_main_conv);
transcript->send_to_verifier(commitment_labels.perm_main_pos2_perm, witness_commitments.perm_main_pos2_perm);
transcript->send_to_verifier(commitment_labels.perm_main_pedersen, witness_commitments.perm_main_pedersen);
transcript->send_to_verifier(commitment_labels.perm_main_mem_a, witness_commitments.perm_main_mem_a);
transcript->send_to_verifier(commitment_labels.perm_main_mem_b, witness_commitments.perm_main_mem_b);
transcript->send_to_verifier(commitment_labels.perm_main_mem_c, witness_commitments.perm_main_mem_c);
transcript->send_to_verifier(commitment_labels.perm_main_mem_d, witness_commitments.perm_main_mem_d);
transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_addr_a,
witness_commitments.perm_main_mem_ind_addr_a);
transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_addr_b,
witness_commitments.perm_main_mem_ind_addr_b);
transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_addr_c,
witness_commitments.perm_main_mem_ind_addr_c);
transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_addr_d,
witness_commitments.perm_main_mem_ind_addr_d);
transcript->send_to_verifier(commitment_labels.lookup_byte_lengths, witness_commitments.lookup_byte_lengths);
transcript->send_to_verifier(commitment_labels.lookup_byte_operations, witness_commitments.lookup_byte_operations);
transcript->send_to_verifier(commitment_labels.lookup_opcode_gas, witness_commitments.lookup_opcode_gas);
transcript->send_to_verifier(commitment_labels.range_check_l2_gas_hi, witness_commitments.range_check_l2_gas_hi);
transcript->send_to_verifier(commitment_labels.range_check_l2_gas_lo, witness_commitments.range_check_l2_gas_lo);
transcript->send_to_verifier(commitment_labels.range_check_da_gas_hi, witness_commitments.range_check_da_gas_hi);
transcript->send_to_verifier(commitment_labels.range_check_da_gas_lo, witness_commitments.range_check_da_gas_lo);
transcript->send_to_verifier(commitment_labels.kernel_output_lookup, witness_commitments.kernel_output_lookup);
transcript->send_to_verifier(commitment_labels.lookup_into_kernel, witness_commitments.lookup_into_kernel);
transcript->send_to_verifier(commitment_labels.incl_main_tag_err, witness_commitments.incl_main_tag_err);
transcript->send_to_verifier(commitment_labels.incl_mem_tag_err, witness_commitments.incl_mem_tag_err);
transcript->send_to_verifier(commitment_labels.lookup_mem_rng_chk_lo, witness_commitments.lookup_mem_rng_chk_lo);
transcript->send_to_verifier(commitment_labels.lookup_mem_rng_chk_mid, witness_commitments.lookup_mem_rng_chk_mid);
transcript->send_to_verifier(commitment_labels.lookup_mem_rng_chk_hi, witness_commitments.lookup_mem_rng_chk_hi);
transcript->send_to_verifier(commitment_labels.lookup_pow_2_0, witness_commitments.lookup_pow_2_0);
transcript->send_to_verifier(commitment_labels.lookup_pow_2_1, witness_commitments.lookup_pow_2_1);
transcript->send_to_verifier(commitment_labels.lookup_u8_0, witness_commitments.lookup_u8_0);
transcript->send_to_verifier(commitment_labels.lookup_u8_1, witness_commitments.lookup_u8_1);
transcript->send_to_verifier(commitment_labels.lookup_u16_0, witness_commitments.lookup_u16_0);
transcript->send_to_verifier(commitment_labels.lookup_u16_1, witness_commitments.lookup_u16_1);
transcript->send_to_verifier(commitment_labels.lookup_u16_2, witness_commitments.lookup_u16_2);
transcript->send_to_verifier(commitment_labels.lookup_u16_3, witness_commitments.lookup_u16_3);
transcript->send_to_verifier(commitment_labels.lookup_u16_4, witness_commitments.lookup_u16_4);
transcript->send_to_verifier(commitment_labels.lookup_u16_5, witness_commitments.lookup_u16_5);
transcript->send_to_verifier(commitment_labels.lookup_u16_6, witness_commitments.lookup_u16_6);
transcript->send_to_verifier(commitment_labels.lookup_u16_7, witness_commitments.lookup_u16_7);
transcript->send_to_verifier(commitment_labels.lookup_u16_8, witness_commitments.lookup_u16_8);
transcript->send_to_verifier(commitment_labels.lookup_u16_9, witness_commitments.lookup_u16_9);
transcript->send_to_verifier(commitment_labels.lookup_u16_10, witness_commitments.lookup_u16_10);
transcript->send_to_verifier(commitment_labels.lookup_u16_11, witness_commitments.lookup_u16_11);
transcript->send_to_verifier(commitment_labels.lookup_u16_12, witness_commitments.lookup_u16_12);
transcript->send_to_verifier(commitment_labels.lookup_u16_13, witness_commitments.lookup_u16_13);
transcript->send_to_verifier(commitment_labels.lookup_u16_14, witness_commitments.lookup_u16_14);
transcript->send_to_verifier(commitment_labels.lookup_div_u16_0, witness_commitments.lookup_div_u16_0);
transcript->send_to_verifier(commitment_labels.lookup_div_u16_1, witness_commitments.lookup_div_u16_1);
transcript->send_to_verifier(commitment_labels.lookup_div_u16_2, witness_commitments.lookup_div_u16_2);
transcript->send_to_verifier(commitment_labels.lookup_div_u16_3, witness_commitments.lookup_div_u16_3);
transcript->send_to_verifier(commitment_labels.lookup_div_u16_4, witness_commitments.lookup_div_u16_4);
transcript->send_to_verifier(commitment_labels.lookup_div_u16_5, witness_commitments.lookup_div_u16_5);
transcript->send_to_verifier(commitment_labels.lookup_div_u16_6, witness_commitments.lookup_div_u16_6);
transcript->send_to_verifier(commitment_labels.lookup_div_u16_7, witness_commitments.lookup_div_u16_7);
for (auto [label, commitment] : zip_view(commitment_labels.get_derived(), witness_commitments.get_derived())) {
transcript->send_to_verifier(label, commitment);
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion bb-pilcom/bb-pil-backend/templates/flavor.hpp.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class {{name}}Flavor {
class WitnessEntities: public WireEntities<DataType>, public DerivedWitnessEntities<DataType> {
public:
DEFINE_COMPOUND_GET_ALL(WireEntities<DataType>, DerivedWitnessEntities<DataType>)
auto get_wires() { return WireEntities<DataType>::get_all(); };
auto get_wires() { return WireEntities<DataType>::get_all(); }
auto get_derived() { return DerivedWitnessEntities<DataType>::get_all(); }
};

template <typename DataType>
Expand Down
12 changes: 6 additions & 6 deletions bb-pilcom/bb-pil-backend/templates/prover.cpp.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ void {{name}}Prover::execute_log_derivative_inverse_round()
key->compute_logderivative_inverses(relation_parameters);

// Commit to all logderivative inverse polynomials
{{#each lookups as |l|}}
witness_commitments.{{l}} = commitment_key->commit(key->{{l}});
{{/each}}
for (auto [commitment, key_poly] : zip_view(witness_commitments.get_derived(), key->get_derived())) {
commitment = commitment_key->commit(key_poly);
}

// Send all commitments to the verifier
{{#each lookups as |l|}}
transcript->send_to_verifier(commitment_labels.{{l}}, witness_commitments.{{l}});
{{/each}}
for (auto [label, commitment] : zip_view(commitment_labels.get_derived(), witness_commitments.get_derived())) {
transcript->send_to_verifier(label, commitment);
}
}

/**
Expand Down

0 comments on commit 455e4ad

Please sign in to comment.