Skip to content

Commit

Permalink
chore(avm): some cleaning in avm prover (#9311)
Browse files Browse the repository at this point in the history
The AvmProver constructor body can be replaced by calling the
constructor for prover_polynomials.
Furthermore, in execute_log_derivative_inverse_round() some temporary
prover_polynomials are superfluous.
  • Loading branch information
jeanmon authored Oct 21, 2024
1 parent f759d55 commit 523aa23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 31 deletions.
19 changes: 4 additions & 15 deletions barretenberg/cpp/src/barretenberg/vm/avm/generated/prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,9 @@ using FF = Flavor::FF;
*/
AvmProver::AvmProver(std::shared_ptr<Flavor::ProvingKey> input_key, std::shared_ptr<PCSCommitmentKey> commitment_key)
: key(std::move(input_key))
, prover_polynomials(*key)
, commitment_key(std::move(commitment_key))
{
for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), key->get_all())) {
ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == bb::flavor_get_label(*key, key_poly));
prover_poly = key_poly.share();
}
for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_shifted(), key->get_to_be_shifted())) {
ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) ==
bb::flavor_get_label(*key, key_poly) + "_shift");
prover_poly = key_poly.shifted();
}
}
{}

/**
* @brief Add circuit size, public input size, and public inputs to transcript
Expand Down Expand Up @@ -69,11 +60,9 @@ void AvmProver::execute_wire_commitments_round()

void AvmProver::execute_log_derivative_inverse_round()
{
auto [beta, gamm] = transcript->template get_challenges<FF>("beta", "gamma");
auto [beta, gamma] = transcript->template get_challenges<FF>("beta", "gamma");
relation_parameters.beta = beta;
relation_parameters.gamma = gamm;

auto prover_polynomials = ProverPolynomials(*key);
relation_parameters.gamma = gamma;
std::vector<std::function<void()>> tasks;

bb::constexpr_for<0, std::tuple_size_v<Flavor::LookupRelations>, 1>([&]<size_t relation_idx>() {
Expand Down
20 changes: 4 additions & 16 deletions bb-pilcom/bb-pil-backend/templates/prover.cpp.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,9 @@ using FF = Flavor::FF;
{{name}}Prover::{{name}}Prover(std::shared_ptr<Flavor::ProvingKey> input_key,
std::shared_ptr<PCSCommitmentKey> commitment_key)
: key(std::move(input_key))
, prover_polynomials(*key)
, commitment_key(std::move(commitment_key))
{
for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), key->get_all())) {
ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) ==
bb::flavor_get_label(*key, key_poly));
prover_poly = key_poly.share();
}
for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_shifted(), key->get_to_be_shifted())) {
ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) ==
bb::flavor_get_label(*key, key_poly) + "_shift");
prover_poly = key_poly.shifted();
}
}
{}

/**
* @brief Add circuit size, public input size, and public inputs to transcript
Expand Down Expand Up @@ -70,11 +60,9 @@ void {{name}}Prover::execute_wire_commitments_round()

void {{name}}Prover::execute_log_derivative_inverse_round()
{
auto [beta, gamm] = transcript->template get_challenges<FF>("beta", "gamma");
auto [beta, gamma] = transcript->template get_challenges<FF>("beta", "gamma");
relation_parameters.beta = beta;
relation_parameters.gamma = gamm;

auto prover_polynomials = ProverPolynomials(*key);
relation_parameters.gamma = gamma;
std::vector<std::function<void()>> tasks;

bb::constexpr_for<0, std::tuple_size_v<Flavor::LookupRelations>, 1>([&]<size_t relation_idx>() {
Expand Down

0 comments on commit 523aa23

Please sign in to comment.