Skip to content

Commit

Permalink
fix: update toy to new master
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Dec 18, 2023
1 parent d8b9a4f commit 78cf525
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
30 changes: 22 additions & 8 deletions barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ class ToyFlavor {
using Base = ProvingKey_<PrecomputedEntities<Polynomial>, WitnessEntities<Polynomial>>;
using Base::Base;

RefVector<DataType> get_to_be_shifted() { return { toy_x }; };

// The plookup wires that store plookup read data.
std::array<PolynomialHandle, 0> get_table_column_wires() { return {}; };
};

using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment>>;

using ProverPolynomials = AllEntities<PolynomialHandle>;

using FoldedPolynomials = AllEntities<std::vector<FF>>;

class AllValues : public AllEntities<FF> {
Expand All @@ -142,21 +142,35 @@ class ToyFlavor {
using Base::Base;
};

class AllPolynomials : public AllEntities<Polynomial> {
using RowPolynomials = AllEntities<FF>;

/**
* @brief A container for the prover polynomials handles.
*/
class ProverPolynomials : public AllEntities<Polynomial> {
public:
[[nodiscard]] size_t get_polynomial_size() const { return this->toy_q_tuple_set.size(); }
[[nodiscard]] AllValues get_row(const size_t row_idx) const
// Define all operations as default, except move construction/assignment
ProverPolynomials() = default;
ProverPolynomials& operator=(const ProverPolynomials&) = delete;
ProverPolynomials(const ProverPolynomials& o) = delete;
ProverPolynomials(ProverPolynomials&& o) noexcept = default;
ProverPolynomials& operator=(ProverPolynomials&& o) noexcept = default;
~ProverPolynomials() = default;
[[nodiscard]] size_t get_polynomial_size() const { return toy_first.size(); }
/**
* @brief Returns the evaluations of all prover polynomials at one point on the boolean hypercube, which
* represents one row in the execution trace.
*/
[[nodiscard]] AllValues get_row(size_t row_idx) const
{
AllValues result;
for (auto [result_field, polynomial] : zip_view(result.get_all(), get_all())) {
for (auto [result_field, polynomial] : zip_view(result.get_all(), this->get_all())) {
result_field = polynomial[row_idx];
}
return result;
}
};

using RowPolynomials = AllEntities<FF>;

class PartiallyEvaluatedMultivariates : public AllEntities<Polynomial> {
public:
PartiallyEvaluatedMultivariates() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ class ToyCircuitBuilder {

// TODO: template
using Polynomial = Flavor::Polynomial;
using AllPolynomials = Flavor::AllPolynomials;
using ProverPolynomials = Flavor::ProverPolynomials;

static constexpr size_t num_fixed_columns = 9;
static constexpr size_t num_polys = 8;
std::vector<Row> rows;

void set_trace(std::vector<Row>&& trace) { rows = std::move(trace); }

AllPolynomials compute_polynomials()
ProverPolynomials compute_polynomials()
{
const auto num_rows = get_circuit_subgroup_size();
AllPolynomials polys;
ProverPolynomials polys;

// Allocate mem for each column
for (auto& poly : polys.get_all()) {
Expand Down Expand Up @@ -88,7 +88,7 @@ class ToyCircuitBuilder {
.eccvm_set_permutation_delta = 0,
};

auto polys = compute_polynomials();
ProverPolynomials polys = compute_polynomials();
const size_t num_rows = polys.get_polynomial_size();

const auto evaluate_relation = [&]<typename Relation>(const std::string& relation_name) {
Expand Down
25 changes: 10 additions & 15 deletions barretenberg/cpp/src/barretenberg/vm/generated/Toy_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,16 @@ ToyProver::ToyProver(std::shared_ptr<Flavor::ProvingKey> input_key, std::shared_
, commitment_key(commitment_key)
{
// TODO: take every polynomial and assign it to the key!!
prover_polynomials.toy_first = key->toy_first;
prover_polynomials.toy_q_tuple_set = key->toy_q_tuple_set;
prover_polynomials.toy_set_1_column_1 = key->toy_set_1_column_1;
prover_polynomials.toy_set_1_column_2 = key->toy_set_1_column_2;
prover_polynomials.toy_set_2_column_1 = key->toy_set_2_column_1;
prover_polynomials.toy_set_2_column_2 = key->toy_set_2_column_2;
prover_polynomials.toy_x = key->toy_x;
prover_polynomials.two_column_perm = key->two_column_perm;

prover_polynomials.toy_x = key->toy_x;
prover_polynomials.toy_x_shift = key->toy_x.shifted();

// prover_polynomials.lookup_inverses = key->lookup_inverses;
// key->z_perm = Polynomial(key->circuit_size);
// prover_polynomials.z_perm = key->z_perm;
for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), key->get_all())) {
ASSERT(proof_system::flavor_get_label(prover_polynomials, prover_poly) ==
proof_system::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(proof_system::flavor_get_label(prover_polynomials, prover_poly) ==
proof_system::flavor_get_label(*key, key_poly) + "_shift");
prover_poly = key_poly.shifted();
}
}

/**
Expand Down

0 comments on commit 78cf525

Please sign in to comment.