Skip to content

Commit

Permalink
folding proving key polys instead of prover polys
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasxia01 committed Mar 25, 2024
1 parent 12e2844 commit 8575640
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns
next_accumulator->gate_challenges = instances.next_gate_challenges;

// Initialize prover polynomials
ProverPolynomials acc_prover_polynomials;
for (auto& polynomial : acc_prover_polynomials.get_all()) {
ProvingKey acc_proving_key_polys;
for (auto& polynomial : acc_proving_key_polys.get_all()) {
polynomial = typename Flavor::Polynomial(instances[0]->proving_key->circuit_size);
}

// Fold the prover polynomials
// Fold the prover key polynomials
for (size_t inst_idx = 0; inst_idx < ProverInstances::NUM; inst_idx++) {
auto accumulator_polys = acc_prover_polynomials.get_all();
auto input_polys = instances[inst_idx]->prover_polynomials.get_all();
run_loop_in_parallel(Flavor::NUM_ALL_ENTITIES, [&](size_t start_idx, size_t end_idx) {
auto accumulator_polys = acc_proving_key_polys.get_all();
auto input_polys = instances[inst_idx]->proving_key->get_all();
run_loop_in_parallel(Flavor::NUM_FOLDED_ENTITIES, [&](size_t start_idx, size_t end_idx) {
for (size_t poly_idx = start_idx; poly_idx < end_idx; poly_idx++) {
auto& acc_poly = accumulator_polys[poly_idx];
auto& inst_poly = input_polys[poly_idx];
Expand All @@ -86,7 +86,10 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns
}
});
}
next_accumulator->prover_polynomials = std::move(acc_prover_polynomials);
for (auto [next_acc_poly, acc_poly] :
zip_view(next_accumulator->proving_key->get_all(), acc_proving_key_polys.get_all())) {
next_acc_poly = std::move(acc_poly);
}

// Fold public data ϕ from all instances to produce ϕ* and add it to the transcript. As part of the folding
// verification, the verifier will produce ϕ* as well and check it against what was sent by the prover.
Expand Down Expand Up @@ -124,6 +127,7 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns
combined_relation_parameters.lookup_grand_product_delta.evaluate(challenge),
};
next_accumulator->relation_parameters = folded_relation_parameters;
next_accumulator->prover_polynomials = ProverPolynomials(next_accumulator->proving_key);
return next_accumulator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ template <class ProverInstances_> class ProtoGalaxyProver_ {
using Instance = typename ProverInstances::Instance;
using Utils = bb::RelationUtils<Flavor>;
using RowEvaluations = typename Flavor::AllValues;
using ProvingKey = typename Flavor::ProvingKey;
using ProverPolynomials = typename Flavor::ProverPolynomials;
using Relations = typename Flavor::Relations;
using RelationSeparator = typename Flavor::RelationSeparator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class GoblinUltraFlavor {
static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 30;
// The total number of witness entities not including shifts.
static constexpr size_t NUM_WITNESS_ENTITIES = 14;
// Total number of folded polynomials, which is just all polynomials except the shifts
static constexpr size_t NUM_FOLDED_ENTITIES = NUM_PRECOMPUTED_ENTITIES + NUM_WITNESS_ENTITIES;

using GrandProductRelations = std::tuple<bb::UltraPermutationRelation<FF>, bb::LookupRelation<FF>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class UltraFlavor {
static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 25;
// The total number of witness entities not including shifts.
static constexpr size_t NUM_WITNESS_ENTITIES = 7;
// Total number of folded polynomials, which is just all polynomials except the shifts
static constexpr size_t NUM_FOLDED_ENTITIES = NUM_PRECOMPUTED_ENTITIES + NUM_WITNESS_ENTITIES;

using GrandProductRelations = std::tuple<bb::UltraPermutationRelation<FF>, bb::LookupRelation<FF>>;
// define the tuple of Relations that comprise the Sumcheck relation
Expand Down

0 comments on commit 8575640

Please sign in to comment.