Skip to content

Commit

Permalink
Good through creation of prover.
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed Apr 18, 2023
1 parent 08b6c34 commit 06ce1dc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ std::shared_ptr<StandardHonkComposerHelper::ProvingKey> StandardHonkComposerHelp
compute_standard_honk_sigma_permutations<Flavor>(circuit_constructor, proving_key.get());
compute_standard_honk_id_polynomials<Flavor>(proving_key.get());

compute_first_and_last_lagrange_polynomials(proving_key.get());
compute_first_and_last_lagrange_polynomials<Flavor>(proving_key.get());

return proving_key;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ std::shared_ptr<UltraHonkComposerHelper::Flavor::ProvingKey> UltraHonkComposerHe

compute_honk_generalized_sigma_permutations<Flavor>(circuit_constructor, circuit_proving_key.get());

compute_first_and_last_lagrange_polynomials(circuit_proving_key.get());
compute_first_and_last_lagrange_polynomials<Flavor>(circuit_proving_key.get());

const size_t subgroup_size = circuit_proving_key->circuit_size;

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/barretenberg/honk/proof_system/verifier.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
// proving_key->polynomial_store.put("sigma_3_lagrange", std::move(sigma_3_lagrange_base));

// compute_standard_honk_id_polynomials<honk::flavor::Standard>(proving_key);
// compute_first_and_last_lagrange_polynomials(proving_key);
// compute_first_and_last_lagrange_polynomials<honk::flavor::Standard>(proving_key);

// proving_key->polynomial_store.put("w_1_lagrange", std::move(w_l));
// proving_key->polynomial_store.put("w_2_lagrange", std::move(w_r));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ std::shared_ptr<typename Flavor::ProvingKey> initialize_proving_key(
}

/**
* @brief Construct lagrange selector polynomials from ciruit selector information and put into polynomial cache
* @brief Construct selector polynomials from ciruit selector information and put into polynomial cache
*
* @tparam CircuitConstructor The class holding the circuit
* @param circuit_constructor The object holding the circuit
* @param key Pointer to the proving key
*/
template <typename Flavor> // TODO(Cody): Always Lagrange
template <typename Flavor>
void construct_selector_polynomials(const typename Flavor::CircuitConstructor& circuit_constructor,
typename Flavor::ProvingKey* proving_key)
{
Expand Down
34 changes: 16 additions & 18 deletions cpp/src/barretenberg/proof_system/composer/permutation_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,17 @@ PermutationMapping<Flavor::num_wires> compute_permutation_mapping(
*/
template <typename Flavor>
void compute_honk_style_permutation_lagrange_polynomials_from_mapping(
std::string label,
std::vector<typename Flavor::PolynomialView> permutation_polynomials, // sigma or ID poly
std::array<std::vector<permutation_subgroup_element>, Flavor::num_wires>& permutation_mappings,
typename Flavor::ProvingKey* proving_key)
{
const size_t num_gates = proving_key->circuit_size;

std::array<barretenberg::polynomial, Flavor::num_wires> permutation_poly; // sigma or ID poly

size_t wire_index = 0;
for (auto& current_permutation_poly : proving_key->get_sigma_polynomials()) {
// permutation_poly[wire_index] = barretenberg::polynomial(num_gates);
// auto& current_permutation_poly = permutation_poly[wire_index];

auto new_poly = barretenberg::polynomial(num_gates); // WORKTODO
for (auto& current_permutation_poly : permutation_polynomials) {
auto new_poly = typename Flavor::Polynomial(num_gates); // TODO(Cody): Cleanly allocate in pk?
current_permutation_poly = new_poly;

ITERATE_OVER_DOMAIN_START(proving_key->evaluation_domain);
const auto& current_mapping = permutation_mappings[wire_index][i];
if (current_mapping.is_public_input) {
Expand All @@ -270,7 +266,7 @@ void compute_honk_style_permutation_lagrange_polynomials_from_mapping(
}
ITERATE_OVER_DOMAIN_END;
}
static_cast<void>(label);
// static_cast<void>(label);
// MERGECONFLICT
// // Save to polynomial cache
// for (size_t j = 0; j < Flavor::num_wires; j++) {
Expand Down Expand Up @@ -422,10 +418,10 @@ template <typename Flavor>
void compute_standard_honk_id_polynomials(auto proving_key) // TODO(Cody): proving_key* and shared_ptr<proving_key>
{
// Fill id polynomials with default values
// WORKTODO: Allocate polynomial space in proving key constructor.
// TODO(Cody): Allocate polynomial space in proving key constructor.
size_t coset_idx = 0;
for (auto& id_poly : proving_key->get_id_polynomials()) {
barretenberg::polynomial new_poly(proving_key->circuit_size);
typename Flavor::Polynomial new_poly(proving_key->circuit_size);
for (size_t i = 0; i < proving_key->circuit_size; ++i) {
new_poly[i] = coset_idx * proving_key->circuit_size + i;
}
Expand Down Expand Up @@ -454,7 +450,8 @@ void compute_standard_honk_sigma_permutations(const typename Flavor::CircuitCons
// Compute the permutation table specifying which element becomes which
auto mapping = compute_permutation_mapping<Flavor, /*generalized=*/false>(circuit_constructor, proving_key);
// Compute Honk-style sigma polynomial from the permutation table
compute_honk_style_permutation_lagrange_polynomials_from_mapping<Flavor>("sigma", mapping.sigmas, proving_key);
compute_honk_style_permutation_lagrange_polynomials_from_mapping<Flavor>(
proving_key->get_sigma_polynomials(), mapping.sigmas, proving_key);
}

/**
Expand Down Expand Up @@ -482,12 +479,11 @@ void compute_standard_plonk_sigma_permutations(const typename Flavor::CircuitCon
*
* @param key Proving key where we will save the polynomials
*/
inline void compute_first_and_last_lagrange_polynomials(
auto proving_key) // TODO(Cody) proving_key* and share_ptr<proving_key>
template <typename Flavor> inline void compute_first_and_last_lagrange_polynomials(auto proving_key)
{
const size_t n = proving_key->circuit_size;
barretenberg::polynomial lagrange_polynomial_0(n); // WORKTODO
barretenberg::polynomial lagrange_polynomial_n_min_1(n);
typename Flavor::Polynomial lagrange_polynomial_0(n);
typename Flavor::Polynomial lagrange_polynomial_n_min_1(n);
lagrange_polynomial_0[0] = 1;
proving_key->lagrange_first = lagrange_polynomial_0;

Expand Down Expand Up @@ -534,8 +530,10 @@ void compute_honk_generalized_sigma_permutations(const typename Flavor::CircuitC
auto mapping = compute_permutation_mapping<Flavor, true>(circuit_constructor, proving_key);

// Compute Honk-style sigma and ID polynomials from the corresponding mappings
compute_honk_style_permutation_lagrange_polynomials_from_mapping<Flavor>("sigma", mapping.sigmas, proving_key);
compute_honk_style_permutation_lagrange_polynomials_from_mapping<Flavor>("id", mapping.ids, proving_key);
compute_honk_style_permutation_lagrange_polynomials_from_mapping<Flavor>(
proving_key->get_sigma_polynomials(), mapping.sigmas, proving_key);
compute_honk_style_permutation_lagrange_polynomials_from_mapping<Flavor>(
proving_key->get_id_polynomials(), mapping.ids, proving_key);
}

} // namespace proof_system
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ TEST_F(PermutationHelperTests, ComputeHonkStyleSigmaLagrangePolynomialsFromMappi
{
auto mapping = compute_permutation_mapping<Flavor, /*generalized=*/false>(circuit_constructor, proving_key.get());
compute_honk_style_permutation_lagrange_polynomials_from_mapping<Flavor>(
"label", mapping.sigmas, proving_key.get());
proving_key->get_sigma_polynomials(), mapping.sigmas, proving_key.get());
}

TEST_F(PermutationHelperTests, ComputeStandardAuxPolynomials)
{
compute_standard_honk_id_polynomials<Flavor>(proving_key);
compute_standard_honk_sigma_permutations<Flavor>(circuit_constructor, proving_key.get());
compute_first_and_last_lagrange_polynomials(proving_key);
compute_first_and_last_lagrange_polynomials<Flavor>(proving_key);
}

} // namespace proof_system::test_composer_lib
2 changes: 2 additions & 0 deletions cpp/src/barretenberg/proof_system/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Standard {
static constexpr size_t num_wires = CircuitConstructor::num_wires;
static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 18;
static constexpr size_t NUM_ALL_ENTITIES = 13;
static constexpr size_t minimum_circuit_size = 3; // TODO(Cody): what is this?/s

// TODO(Cody): Made this public derivation so that I could populate selector
// polys from circuit constructor.
Expand Down Expand Up @@ -199,6 +200,7 @@ class Ultra {
static constexpr size_t num_wires = CircuitConstructor::num_wires;
static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 18;
static constexpr size_t NUM_ALL_ENTITIES = 13;
static constexpr size_t minimum_circuit_size = 3; // TODO(Cody): what is this?

// TODO(Cody): Made this public derivation so that I could populate selector
// polys from circuit constructor.
Expand Down

0 comments on commit 06ce1dc

Please # to comment.