Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: protogalaxy perturbator! #2624

Merged
merged 20 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions barretenberg/cpp/src/barretenberg/honk/flavor/ecc_vm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,8 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
using FoldedPolynomials = AllEntities<std::vector<FF>, PolynomialHandle>;

/**
* @brief A field element for each entity of the flavor.
* @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated
* at one point.
*/
class AllValues : public AllEntities<FF, FF> {
public:
Expand All @@ -678,7 +679,7 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
*/
class AllPolynomials : public AllEntities<Polynomial, PolynomialHandle> {
public:
AllValues get_row(const size_t row_idx)
AllValues get_row(const size_t row_idx) const
{
AllValues result;
size_t column_idx = 0; // // TODO(https://github.com/AztecProtocol/barretenberg/issues/391) zip
Expand Down Expand Up @@ -720,10 +721,14 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
barretenberg::Univariate<FF, MAX_RELATION_LENGTH>>;

/**
* @brief A container for polynomials handles; only stores spans.
* @brief A container for the prover polynomials handles; only stores spans.
*/
class ProverPolynomials : public AllEntities<PolynomialHandle, PolynomialHandle> {
public:
/**
* @brief Returns the evaluations of all prover polynomials at one point on the boolean hypercube, which
* represents one row in the execution trace.
*/
AllValues get_row(const size_t row_idx)
{
AllValues result;
Expand Down
27 changes: 20 additions & 7 deletions barretenberg/cpp/src/barretenberg/honk/flavor/goblin_ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,6 @@ class GoblinUltra {
*/
using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment, CommitmentHandle>>;

/**
* @brief A container for polynomials handles; only stores spans.
*/
using ProverPolynomials = AllEntities<PolynomialHandle, PolynomialHandle>;

/**
* @brief A container for storing the partially evaluated multivariates produced by sumcheck.
*/
Expand All @@ -332,7 +327,8 @@ class GoblinUltra {
barretenberg::Univariate<FF, MAX_RELATION_LENGTH>>;

/**
* @brief A field element for each entity of the flavor.
* @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated
* at one point.
*/
class AllValues : public AllEntities<FF, FF> {
public:
Expand All @@ -341,6 +337,23 @@ class GoblinUltra {
AllValues(std::array<FF, NUM_ALL_ENTITIES> _data_in) { this->_data = _data_in; }
};

/**
* @brief A container for the prover polynomials handles; only stores spans.
*/
class ProverPolynomials : public AllEntities<PolynomialHandle, PolynomialHandle> {
public:
AllValues get_row(const size_t row_idx) const
{
AllValues result;
size_t column_idx = 0; // TODO(https://github.com/AztecProtocol/barretenberg/issues/391) zip
for (auto& column : this->_data) {
result[column_idx] = column[row_idx];
column_idx++;
}
return result;
}
};

/**
* @brief A container for commitment labels.
* @note It's debatable whether this should inherit from AllEntities. since most entries are not strictly needed. It
Expand Down Expand Up @@ -429,7 +442,7 @@ class GoblinUltra {

class FoldingParameters {
public:
FF gate_separation_challenge;
std::vector<FF> gate_separation_challenges;
FF target_sum;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ template <typename BuilderType> class GoblinUltraRecursive_ {
};

/**
* @brief A field element for each entity of the flavor.
* @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated
* at one point.
*/
class AllValues : public AllEntities<FF, FF> {
public:
Expand Down
7 changes: 4 additions & 3 deletions barretenberg/cpp/src/barretenberg/honk/flavor/ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ class Ultra {
using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment, CommitmentHandle>>;

/**
* @brief A field element for each entity of the flavor.
* @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated
* at one point.
*/
class AllValues : public AllEntities<FF, FF> {
public:
Expand All @@ -286,7 +287,7 @@ class Ultra {
*/
class ProverPolynomials : public AllEntities<PolynomialHandle, PolynomialHandle> {
public:
AllValues get_row(const size_t row_idx)
AllValues get_row(const size_t row_idx) const
{
AllValues result;
size_t column_idx = 0; // TODO(https://github.com/AztecProtocol/barretenberg/issues/391) zip
Expand Down Expand Up @@ -404,7 +405,7 @@ class Ultra {

class FoldingParameters {
public:
FF gate_separation_challenge;
std::vector<FF> gate_separation_challenges;
FF target_sum;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ template <typename BuilderType> class UltraRecursive_ {
};

/**
* @brief A field element for each entity of the flavor.
* @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated
* at one point.
*/
class AllValues : public AllEntities<FF, FF> {
public:
Expand Down
8 changes: 4 additions & 4 deletions barretenberg/cpp/src/barretenberg/honk/instance/instances.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ template <typename Flavor_, size_t NUM_> struct ProverInstances_ {
public:
static constexpr size_t NUM = NUM_;
ArrayType _data;
Instance const& operator[](size_t idx) const { return _data[idx]; }
std::shared_ptr<Instance> const& operator[](size_t idx) const { return _data[idx]; }
typename ArrayType::iterator begin() { return _data.begin(); };
typename ArrayType::iterator end() { return _data.end(); };
ProverInstances_(std::vector<std::shared_ptr<Instance>> data)
Expand All @@ -27,12 +27,12 @@ template <typename Flavor_, size_t NUM_> struct VerifierInstances_ {
using Flavor = Flavor_;
using VerificationKey = typename Flavor::VerificationKey;
using Instance = VerifierInstance_<Flavor>;
using ArrayType = std::array<Instance, NUM_>;
using ArrayType = std::array<std::shared_ptr<Instance>, NUM_>;

public:
static constexpr size_t NUM = NUM_;
ArrayType _data;
Instance const& operator[](size_t idx) const { return _data[idx]; }
std::shared_ptr<Instance> const& operator[](size_t idx) const { return _data[idx]; }
typename ArrayType::iterator begin() { return _data.begin(); };
typename ArrayType::iterator end() { return _data.end(); };
VerifierInstances_(std::vector<std::shared_ptr<VerificationKey>> vks)
Expand All @@ -41,7 +41,7 @@ template <typename Flavor_, size_t NUM_> struct VerifierInstances_ {
for (size_t idx = 0; idx < vks.size(); idx++) {
Instance inst;
inst.verification_key = std::move(vks[idx]);
_data[idx] = inst;
_data[idx] = std::make_unique<Instance>(inst);
}
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ template <class Flavor> class ProverInstance_ {
using Polynomial = typename Flavor::Polynomial;

public:
// offset due to placing zero wires at the start of execution trace

std::shared_ptr<ProvingKey> proving_key;
std::shared_ptr<VerificationKey> verification_key;
std::shared_ptr<CommitmentKey> commitment_key;
Expand All @@ -39,10 +37,14 @@ template <class Flavor> class ProverInstance_ {
// The number of public inputs has to be the same for all instances because they are
// folded element by element.
std::vector<FF> public_inputs;
// offset due to placing zero wires at the start of execution trace
// non-zero for Instances constructed from circuits, this concept doesn't exist for accumulated
// instances
size_t pub_inputs_offset = 0;
proof_system::RelationParameters<FF> relation_parameters;
maramihali marked this conversation as resolved.
Show resolved Hide resolved
std::vector<uint32_t> recursive_proof_public_input_indices;
FoldingParameters folding_params;
// non-empty for the accumulated instances
FoldingParameters folding_parameters;

ProverInstance_(Circuit& circuit)
{
Expand All @@ -55,7 +57,7 @@ template <class Flavor> class ProverInstance_ {
: verification_key(std::move(result.verification_key))
, prover_polynomials(result.folded_prover_polynomials)
, public_inputs(result.folded_public_inputs)
, folding_params(result.params){};
, folding_parameters(result.folding_parameters){};

~ProverInstance_() = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ template <class Flavor> class VerifierInstance_ {
std::vector<FF> public_inputs;
size_t pub_inputs_offset;
size_t public_input_size;
size_t circuit_size;
size_t instance_size;
RelationParameters<FF> relation_parameters;
FoldingParameters folding_params;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "barretenberg/proof_system/flavor/flavor.hpp"
#include "barretenberg/proof_system/relations/relation_parameters.hpp"
namespace proof_system::honk {
template <class Flavor> struct ProverFoldingResult {
public:
Expand Down Expand Up @@ -33,6 +34,6 @@ template <class Flavor> struct FoldingResult {
ProverPolynomials folded_prover_polynomials;
std::vector<FF> folded_public_inputs;
std::shared_ptr<VerificationKey> verification_key;
FoldingParameters params;
FoldingParameters folding_parameters;
};
} // namespace proof_system::honk
Loading