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 folding of challenges #2935

Merged
merged 39 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a1c95c5
Uniformize relations in prep for refactor.
codygunton Oct 19, 2023
bee3ca2
Move translator relations to subfolder
codygunton Oct 19, 2023
6e77bce
Stalled experiment
codygunton Oct 20, 2023
98aec2a
Add tmp proxy to sumcheck prover prove
codygunton Oct 20, 2023
d3bde61
Change compute_combiner interface
codygunton Oct 20, 2023
b6df92e
Quick and dirty. IOU test
codygunton Oct 21, 2023
12b25b0
WORKTODO tweaks
codygunton Oct 21, 2023
ffaf07b
Fix?
codygunton Oct 21, 2023
ddeaba3
Move ParameterView gettinger
codygunton Oct 21, 2023
bd8e812
Compute full degrees where needed
codygunton Oct 23, 2023
ee83443
Compile with full degrees; IOU tests
codygunton Oct 24, 2023
f087936
Update two tests.
codygunton Oct 24, 2023
7092593
Update final test.
codygunton Oct 24, 2023
093255f
Rename MAX_RELATION_LENGTH
codygunton Oct 24, 2023
83de942
Stop detecting submodules!
codygunton Oct 24, 2023
dc77501
Rename FULL to TOTAL
codygunton Oct 24, 2023
0dac01d
RANDOM to BATCHED
codygunton Oct 24, 2023
dacacf9
Cleanup Pass
codygunton Oct 24, 2023
2bbac89
More smaller cleanup
codygunton Oct 24, 2023
4c207ee
Use instance interface.
codygunton Oct 24, 2023
03e31e7
Merge remote-tracking branch 'origin/master' into cg/pg-fold-challenges
codygunton Oct 24, 2023
f3caefa
Add comments
codygunton Oct 24, 2023
a5c985c
Test parameters_to_univariates
codygunton Oct 24, 2023
567346d
Merge remote-tracking branch 'origin/master' into cg/pg-fold-challenges
codygunton Oct 25, 2023
24c8c75
Merge remote-tracking branch 'origin/master' into cg/pg-fold-challenges
codygunton Oct 25, 2023
3fe5d56
Merge remote-tracking branch 'origin/master' into cg/pg-fold-challenges
codygunton Oct 25, 2023
c0a6114
Partial response to review.
codygunton Oct 26, 2023
cd644d0
More response
codygunton Oct 26, 2023
248d4e0
Double dereferencing improvement.
codygunton Oct 26, 2023
5e9c3b5
Clean up `fold_parameters`
codygunton Oct 26, 2023
1ffdb98
Last bit of cleanup.
codygunton Oct 26, 2023
22a6ee3
fix comments
maramihali Oct 27, 2023
a327957
Merge branch 'master' into cg/pg-fold-challenges
maramihali Oct 27, 2023
d0deb59
another comment fix
maramihali Oct 27, 2023
869b830
Fix bad naming.
codygunton Oct 27, 2023
7f33f9f
Merge remote-tracking branch 'origin/master' into cg/pg-fold-challenges
codygunton Oct 27, 2023
b9bd1b4
Add a comment.
codygunton Oct 27, 2023
e4097c3
Remove bad ref to sumcheck
codygunton Oct 27, 2023
02f1913
Merge remote-tracking branch 'origin/master' into cg/pg-fold-challenges
codygunton Oct 27, 2023
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
3 changes: 2 additions & 1 deletion barretenberg/barretenberg.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
"-g"
],
"cmake.useCMakePresets": "auto",
"editor.inlayHints.enabled": "offUnlessPressed"
"editor.inlayHints.enabled": "offUnlessPressed",
"git.detectSubmodules": false
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp"
#include "barretenberg/proof_system/relations/lookup_relation.hpp"
#include "barretenberg/proof_system/relations/permutation_relation.hpp"
#include "barretenberg/proof_system/relations/relation_parameters.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this include necessary here, i see it's also in other bench files that actually use relation parameters

Copy link
Contributor Author

@codygunton codygunton Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file does use them on Line 26.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad

#include "barretenberg/proof_system/relations/ultra_arithmetic_relation.hpp"
#include <benchmark/benchmark.h>

Expand Down
13 changes: 7 additions & 6 deletions barretenberg/cpp/src/barretenberg/honk/flavor/ecc_vm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "barretenberg/proof_system/relations/ecc_vm/ecc_set_relation.hpp"
#include "barretenberg/proof_system/relations/ecc_vm/ecc_transcript_relation.hpp"
#include "barretenberg/proof_system/relations/ecc_vm/ecc_wnaf_relation.hpp"
#include "barretenberg/proof_system/relations/relation_parameters.hpp"
#include "barretenberg/proof_system/relations/relation_types.hpp"
#include <array>
#include <concepts>
Expand Down Expand Up @@ -65,15 +66,15 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
sumcheck::ECCVMLookupRelation<FF>>;

using LookupRelation = sumcheck::ECCVMLookupRelation<FF>;
static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length<Relations>();
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = get_max_partial_relation_length<Relations>();

// MAX_RANDOM_RELATION_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` random
// polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation length = 3
static constexpr size_t MAX_RANDOM_RELATION_LENGTH = MAX_RELATION_LENGTH + 1;
// BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please explain what partial means here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, to be matching with the line above i'd use BATCHED_PARTIAL_RELATION_LENGTH

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's the "partial length of the batched relation" we're computing here, not the "batching of the partial relation length", so I think what I wrote is more meaningful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid duplicating the same comments in every flavor file, I'll write descriptions of "total" versus "partial" in the comments that define the functions. That should be good enough, right? I think anybody who's curious would look there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that makes sense, also did not realise the nuance until now, self note to take ordering into consideration in a name

// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size<Relations>::value;

// Instantiate the BarycentricData needed to extend each Relation Univariate
// static_assert(instantiate_barycentric_utils<FF, MAX_RANDOM_RELATION_LENGTH>());

// define the containers for storing the contributions from each relation in Sumcheck
using SumcheckTupleOfTuplesOfUnivariates = decltype(create_sumcheck_tuple_of_tuples_of_univariates<Relations>());
Expand Down Expand Up @@ -721,7 +722,7 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
/**
* @brief A container for univariates produced during the hot loop in sumcheck.
*/
using ExtendedEdges = ProverUnivariates<MAX_RELATION_LENGTH>;
using ExtendedEdges = ProverUnivariates<MAX_PARTIAL_RELATION_LENGTH>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i find the usage of partial in the context of sumcheck a bit strange because in that case the partial degree is actually the total degree :-?


/**
* @brief A container for the prover polynomials handles; only stores spans.
Expand Down
25 changes: 14 additions & 11 deletions barretenberg/cpp/src/barretenberg/honk/flavor/goblin_translator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "barretenberg/proof_system/arithmetization/arithmetization.hpp"
#include "barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp"
#include "barretenberg/proof_system/flavor/flavor.hpp"
#include "barretenberg/proof_system/relations/decomposition_relation.hpp"
#include "barretenberg/proof_system/relations/extra_relations.hpp"
#include "barretenberg/proof_system/relations/gen_perm_sort_relation.hpp"
#include "barretenberg/proof_system/relations/non_native_field_relation.hpp"
#include "barretenberg/proof_system/relations/permutation_relation.hpp"
#include "barretenberg/proof_system/relations/translator_vm/translator_decomposition_relation.hpp"
#include "barretenberg/proof_system/relations/translator_vm/translator_extra_relations.hpp"
#include "barretenberg/proof_system/relations/translator_vm/translator_gen_perm_sort_relation.hpp"
#include "barretenberg/proof_system/relations/translator_vm/translator_non_native_field_relation.hpp"
#include "barretenberg/proof_system/relations/translator_vm/translator_permutation_relation.hpp"
#include <array>
#include <concepts>
#include <span>
Expand Down Expand Up @@ -316,12 +316,15 @@ template <size_t mini_circuit_size> class GoblinTranslator_ {
GoblinTranslatorDecompositionRelation<FF>,
GoblinTranslatorNonNativeFieldRelation<FF>>;

static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length<Relations>();
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = get_max_partial_relation_length<Relations>();
static constexpr size_t MAX_TOTAL_RELATION_LENGTH = get_max_total_relation_length<Relations>();

// MAX_RANDOM_RELATION_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` random
// polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation length = 3
static constexpr size_t MAX_RANDOM_RELATION_LENGTH = MAX_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size<Relations>::value;
// BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;

// define the containers for storing the contributions from each relation in Sumcheck
using SumcheckTupleOfTuplesOfUnivariates = decltype(create_sumcheck_tuple_of_tuples_of_univariates<Relations>());
Expand Down Expand Up @@ -1503,7 +1506,7 @@ template <size_t mini_circuit_size> class GoblinTranslator_ {
/**
* @brief A container for univariates produced during the hot loop in sumcheck.
*/
using ExtendedEdges = ProverUnivariates<MAX_RELATION_LENGTH>;
using ExtendedEdges = ProverUnivariates<MAX_PARTIAL_RELATION_LENGTH>;

/**
* @brief A container for commitment labels.
Expand Down
15 changes: 9 additions & 6 deletions barretenberg/cpp/src/barretenberg/honk/flavor/goblin_ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ class GoblinUltra {
proof_system::AuxiliaryRelation<FF>,
proof_system::EccOpQueueRelation<FF>>;

static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length<Relations>();
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = get_max_partial_relation_length<Relations>();
static constexpr size_t MAX_TOTAL_RELATION_LENGTH = get_max_total_relation_length<Relations>();

// MAX_RANDOM_RELATION_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` random
// polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation length = 3
static constexpr size_t MAX_RANDOM_RELATION_LENGTH = MAX_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size<Relations>::value;
// BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;

template <size_t NUM_INSTANCES>
using ProtogalaxyTupleOfTuplesOfUnivariates =
Expand Down Expand Up @@ -330,7 +333,7 @@ class GoblinUltra {
/**
* @brief A container for univariates produced during the hot loop in sumcheck.
*/
using ExtendedEdges = ProverUnivariates<MAX_RELATION_LENGTH>;
using ExtendedEdges = ProverUnivariates<MAX_PARTIAL_RELATION_LENGTH>;

/**
* @brief A field element for each entity of the flavor. These entities represent the prover polynomials evaluated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ template <typename BuilderType> class GoblinUltraRecursive_ {
proof_system::AuxiliaryRelation<FF>,
proof_system::EccOpQueueRelation<FF>>;

static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length<Relations>();
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = get_max_partial_relation_length<Relations>();

// MAX_RANDOM_RELATION_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` random
// polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation length = 3
static constexpr size_t MAX_RANDOM_RELATION_LENGTH = MAX_RELATION_LENGTH + 1;
// BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size<Relations>::value;

// define the container for storing the univariate contribution from each relation in Sumcheck
Expand Down
22 changes: 13 additions & 9 deletions barretenberg/cpp/src/barretenberg/honk/flavor/ultra.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#pragma once
#include "barretenberg/ecc/curves/bn254/g1.hpp"
#include "barretenberg/honk/pcs/kzg/kzg.hpp"
#include "barretenberg/polynomials/barycentric.hpp"
#include "barretenberg/polynomials/univariate.hpp"

#include "barretenberg/honk/transcript/transcript.hpp"
#include "barretenberg/polynomials/barycentric.hpp"
#include "barretenberg/polynomials/evaluation_domain.hpp"
#include "barretenberg/polynomials/polynomial.hpp"
#include "barretenberg/polynomials/univariate.hpp"
#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp"
#include "barretenberg/proof_system/flavor/flavor.hpp"
#include "barretenberg/proof_system/relations/auxiliary_relation.hpp"
Expand Down Expand Up @@ -53,12 +52,17 @@ class Ultra {
proof_system::EllipticRelation<FF>,
proof_system::AuxiliaryRelation<FF>>;

static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length<Relations>();
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = get_max_partial_relation_length<Relations>();
static constexpr size_t MAX_TOTAL_RELATION_LENGTH = get_max_total_relation_length<Relations>();
static_assert(MAX_PARTIAL_RELATION_LENGTH == 6);
static_assert(MAX_TOTAL_RELATION_LENGTH == 12);

// MAX_RANDOM_RELATION_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` random
// polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation length = 3
static constexpr size_t MAX_RANDOM_RELATION_LENGTH = MAX_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size<Relations>::value;
// BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;

template <size_t NUM_INSTANCES>
using ProtogalaxyTupleOfTuplesOfUnivariates =
Expand Down Expand Up @@ -327,7 +331,7 @@ class Ultra {
/**
* @brief A container for univariates produced during the hot loop in sumcheck.
*/
using ExtendedEdges = ProverUnivariates<MAX_RELATION_LENGTH>;
using ExtendedEdges = ProverUnivariates<MAX_PARTIAL_RELATION_LENGTH>;

/**
* @brief A container for commitment labels.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ template <typename BuilderType> class UltraRecursive_ {
proof_system::EllipticRelation<FF>,
proof_system::AuxiliaryRelation<FF>>;

static constexpr size_t MAX_RELATION_LENGTH = get_max_relation_length<Relations>();
static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = get_max_partial_relation_length<Relations>();

// MAX_RANDOM_RELATION_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` random
// polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation length = 3
static constexpr size_t MAX_RANDOM_RELATION_LENGTH = MAX_RELATION_LENGTH + 1;
// BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta`
// random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation
// length = 3
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size<Relations>::value;

// define the container for storing the univariate contribution from each relation in Sumcheck
Expand Down
29 changes: 27 additions & 2 deletions barretenberg/cpp/src/barretenberg/honk/instance/instances.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
namespace proof_system::honk {

template <typename Flavor_, size_t NUM_> struct ProverInstances_ {
public:
using Flavor = Flavor_;
using FF = typename Flavor::FF;
static constexpr size_t NUM = NUM_;
using Instance = ProverInstance_<Flavor>;

using ArrayType = std::array<std::shared_ptr<Instance>, NUM_>;
// The extended length here is the length of a composition of polynomials.
static constexpr size_t EXTENDED_LENGTH = (Flavor::MAX_TOTAL_RELATION_LENGTH - 1) * (NUM - 1) + 1;
using RelationParameters = proof_system::RelationParameters<Univariate<FF, EXTENDED_LENGTH>>;

public:
static constexpr size_t NUM = NUM_;
ArrayType _data;
RelationParameters relation_parameters;

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(); };
Expand All @@ -24,6 +30,25 @@ template <typename Flavor_, size_t NUM_> struct ProverInstances_ {
}
};

/**
* @brief Create folded (univariate) relation parameters.
* @details For a given relation parameter type, extract that parameter from each instance, place the values in a
* univariate (i.e., sum them against an appropriate Lagrange basis) and then extended as needed during the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* univariate (i.e., sum them against an appropriate Lagrange basis) and then extended as needed during the
* univariate (i.e., sum them against an appropriate univariate Lagrange basis) and then extended as needed during the

* constuction of the combiner.
*/
void parameters_to_univariates()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would have had this in the protogalaxy prover, called fold_relation_parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair, I can move it.

{
auto params_to_fold = relation_parameters.to_fold;
for (size_t param_idx = 0; param_idx < params_to_fold.size(); param_idx++) {
auto& univariate_param = *params_to_fold[param_idx];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

folded_param maybe as this is the final result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think folding is kind of a stupid name tbh and univariate is more descriptive here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm yeah, just suggested it to be in consistency with everything else that we fold

Univariate<FF, NUM> tmp(0);
for (size_t instance_idx = 0; instance_idx < NUM; instance_idx++) {
tmp.value_at(instance_idx) = *((*_data[instance_idx]).relation_parameters.to_fold[param_idx]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how should I feel about double dereferencing?😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for raising this yes what I did here was no good and I thought I'd left a TODO note to help me catch it. Will rework.

}
univariate_param = tmp.template extend_to<EXTENDED_LENGTH>();
}
}

/**
* @brief For a prover polynomial label and a fixed row index, construct a uninvariate from the corresponding value
* from each instance.
Expand Down
46 changes: 46 additions & 0 deletions barretenberg/cpp/src/barretenberg/honk/instance/instances.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

#include "instances.hpp"
#include "barretenberg/ecc/curves/bn254/bn254.hpp"
#include "barretenberg/honk/proof_system/grand_product_library.hpp"
#include "barretenberg/polynomials/polynomial.hpp"
#include "barretenberg/srs/factories/file_crs_factory.hpp"
#include <gtest/gtest.h>

namespace proof_system::honk::instance_tests {

template <class Flavor> class InstancesTests : public testing::Test {
using FF = typename Flavor::FF;
using Builder = typename Flavor::CircuitBuilder;

public:
static void test_parameters_to_univariates()
{
using Instances = ProverInstances_<Flavor, 2>;
using Instance = typename Instances::Instance;

Builder builder1;
auto instance1 = std::make_shared<Instance>(builder1);
instance1->relation_parameters.eta = 1;

Builder builder2;
builder2.add_variable(3);
auto instance2 = std::make_shared<Instance>(builder2);
instance2->relation_parameters.eta = 3;

Instances instances{ { instance1, instance2 } };
instances.parameters_to_univariates();

Univariate<FF, 12> expected_eta{ { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23 } };
EXPECT_EQ(instances.relation_parameters.eta, expected_eta);
};
};

using FlavorTypes = testing::Types<flavor::Ultra>;
TYPED_TEST_SUITE(InstancesTests, FlavorTypes);

TYPED_TEST(InstancesTests, ParametersToUnivariates)
{
TestFixture::test_parameters_to_univariates();
}

} // namespace proof_system::honk::instance_tests
Loading
Loading