Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
6313f15
wip wip wip
Oct 23, 2023
40cedd0
styuff
Oct 24, 2023
c7cc936
how do I do this?
Oct 24, 2023
59c69f2
pain
Oct 25, 2023
aed27df
pain
Oct 25, 2023
265f248
wip that works
Nov 6, 2023
44da63f
Merge branch 'master' into mm/pg-plumbing
Nov 6, 2023
7ffc364
cleanup
Nov 6, 2023
62df97a
Merge branch 'master' into mm/combiner-quotient
Nov 6, 2023
9d1b5c6
comment test
Nov 6, 2023
42ac7e2
comment test
Nov 6, 2023
75221fb
Merge remote-tracking branch 'origin/master' into mm/combiner-quotient
codygunton Nov 6, 2023
bc63909
Add weirder test
codygunton Nov 8, 2023
7d3e01b
Use clearer type names
codygunton Nov 8, 2023
2287a76
wip
Nov 8, 2023
86963a5
pr review additions
Nov 9, 2023
a816c4b
Merge branch 'master' into mm/combiner-quotient
Nov 9, 2023
91ca591
fix formatting
Nov 9, 2023
abb6ed2
add missing issue
Nov 9, 2023
81f7d89
Merge branch 'mm/combiner-quotient' into mm/pg-fold-alpha
Nov 10, 2023
73068a6
wip that doesn't work
Nov 10, 2023
a86a9b4
wip
Nov 10, 2023
a51d686
subrelation number
Nov 11, 2023
df7a62c
add stuff
Nov 13, 2023
1ff05b6
confusion
Nov 16, 2023
1ed19f2
pain
Nov 16, 2023
dea27c1
compiles
Nov 16, 2023
05bf621
Merge branch 'master' into mm/pg-fold-alpha
Nov 17, 2023
073db88
works
Nov 17, 2023
e9079f3
Merge branch 'master' into mm/pg-fold-alpha
Nov 17, 2023
348f561
more naming
Nov 17, 2023
c380cea
fix sumcheck test that was failing
Nov 18, 2023
068ea31
Merge branch 'master' into mm/pg-fold-alpha
Nov 18, 2023
cbec5d6
Merge remote-tracking branch 'origin/mm/pg-fold-alpha' into HEAD
Nov 20, 2023
9d16416
stuff
Nov 20, 2023
0472c10
confusion
Nov 20, 2023
2ae95d2
stuff with pointer view
Nov 21, 2023
a2da6d4
Merge branch 'master' into mm/pg-poc
Nov 21, 2023
c0d39d8
hm
Nov 22, 2023
740d1c8
getting there
Nov 24, 2023
985c006
hmm
Nov 28, 2023
a19ae07
works
Nov 28, 2023
fdb9b6c
Merge branch 'master' into mm/pg-poc
Nov 28, 2023
4581a0c
confused
Nov 29, 2023
aa0acca
works
Nov 29, 2023
a13ee93
create witness commitments structure
Nov 29, 2023
5634ed1
add missing comments
Nov 29, 2023
ae55902
more missing docs
Nov 29, 2023
d1f7246
Merge branch 'master' into mm/witness-entities-refactor
Nov 29, 2023
4fa6c3d
refactor based on discussion
Nov 30, 2023
d43677d
Merge branch 'master' into mm/witness-entities-refactor
Nov 30, 2023
4adac47
WORKS
Nov 30, 2023
c2e78b5
cleaning up
Dec 1, 2023
5c29867
more refactoring
Dec 1, 2023
c5c7c61
cleanup
Dec 4, 2023
ff37810
Merge branch 'master' into mm/pg-poc
Dec 4, 2023
9796186
fix merge bug and cleanup
Dec 4, 2023
649fdeb
Merge branch 'master' into mm/pg-poc
Dec 4, 2023
1d24643
fix formatting
Dec 4, 2023
a720c80
add todo
Dec 4, 2023
e6e5db3
print statements
Dec 4, 2023
ee926f8
fix bug?
Dec 4, 2023
89bf847
remove prints
Dec 4, 2023
828ab91
Merge branch 'master' into mm/pg-poc
Dec 5, 2023
ac8b77c
remove unnecessary stuff
Dec 6, 2023
4cc7742
stuff
Dec 6, 2023
3e96712
pow poly works
Dec 11, 2023
4c62760
Merge branch 'master' into mm/pg-decider
Dec 11, 2023
c8909d0
wip that works
Dec 11, 2023
35c20e7
Merge branch 'master' into mm/pg-decider
Dec 12, 2023
98a7b6c
wip wip
Dec 12, 2023
9b49bab
doesn't work :(
Dec 13, 2023
81845c9
shit
Dec 14, 2023
4bce6e8
everything but beta
Dec 15, 2023
1cfabf9
this works
Dec 18, 2023
79408ed
cleaned up relation parameters
Dec 18, 2023
ba7ecf5
Merge branch 'master' into mm/pg-decider
Dec 18, 2023
a1d44a7
more stuff working
Dec 20, 2023
bcfd79a
batching challenges
Dec 21, 2023
fdd9311
fix formatting
Dec 21, 2023
afd16d5
fix wasm
Dec 21, 2023
de77d6e
more cleanup
Dec 21, 2023
dd0505e
Merge branch 'master' into mm/pg-decider
Dec 21, 2023
c7dec72
pow
Dec 21, 2023
413a801
remove resolved issues
Dec 21, 2023
8debe53
Merge branch 'master' into mm/pg-decider
Dec 21, 2023
c765771
replace honk-tests CI with ultra-honk-tests CI
Dec 21, 2023
62baf45
--no-edit
Dec 21, 2023
a8812f6
cleanup
Dec 21, 2023
8cb1d9e
fix idx overflow
Dec 22, 2023
4900dae
Merge branch 'master' into mm/pg-decider
Jan 8, 2024
be3a223
debug
Jan 8, 2024
deb239e
remove computation of power polynomial at values on the verifier side
Jan 8, 2024
ecf84ce
update tests and comments
Jan 8, 2024
5cc73f1
Merge branch 'master' into mm/pg-decider
Jan 8, 2024
4c4d664
Merge branch 'master' into mm/pg-decider
Jan 10, 2024
65c6aeb
resolve review comments
Jan 10, 2024
4f7d79b
fix formatting
Jan 10, 2024
7ae0880
Merge remote-tracking branch 'origin/master' into mm/pg-decider
codygunton Jan 11, 2024
066f35c
Merge branch 'master' into mm/pg-decider
Jan 11, 2024
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
12 changes: 0 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,6 @@ jobs:
command: |
barretenberg/cpp/scripts/ci/upload_benchmarks_to_s3.sh

barretenberg-honk-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Test"
command: cond_spot_run_test barretenberg-x86_64-linux-clang-assert 32 ./scripts/run_tests 1 honk_tests

barretenberg-proof-system-tests:
docker:
- image: aztecprotocol/alpine-build-image
Expand Down Expand Up @@ -1135,7 +1124,6 @@ workflows:
- barretenberg-x86_64-linux-clang
<<: *defaults
- barretenberg-proof-system-tests: *bb_test
- barretenberg-honk-tests: *bb_test
- barretenberg-dsl-tests: *bb_test
- barretenberg-tests: *bb_test
- barretenberg-stdlib-tests: *bb_test
Expand Down
3 changes: 1 addition & 2 deletions barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@
"acvm_backend.wasm",
"barretenberg",
"wasi",
"env",
"honk_tests"
Copy link
Author

Choose a reason for hiding this comment

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

we don't have honk_tests anymore?

"env"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
* simplify the codebase.
*/

#include "barretenberg/ecc/curves/bn254/bn254.hpp"
Copy link
Author

Choose a reason for hiding this comment

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

discovered a couple of places that could do with less include statements

#include "barretenberg/ecc/curves/bn254/pairing.hpp"
#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp"
#include "barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp"
#include "barretenberg/numeric/bitop/pow.hpp"
#include "barretenberg/polynomials/polynomial.hpp"
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/src/barretenberg/common/thread_utils.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once
#include "thread.hpp"

namespace barretenberg::thread_utils {
Expand Down
9 changes: 6 additions & 3 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_prover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "barretenberg/common/ref_array.hpp"
#include "barretenberg/honk/proof_system/logderivative_library.hpp"
#include "barretenberg/honk/proof_system/permutation_library.hpp"
#include "barretenberg/honk/proof_system/power_polynomial.hpp"
#include "barretenberg/polynomials/polynomial.hpp"
#include "barretenberg/proof_system/library/grand_product_library.hpp"
#include "barretenberg/relations/lookup_relation.hpp"
Expand Down Expand Up @@ -111,8 +110,12 @@ template <ECCVMFlavor Flavor> void ECCVMProver_<Flavor>::execute_relation_check_
using Sumcheck = sumcheck::SumcheckProver<Flavor>;

auto sumcheck = Sumcheck(key->circuit_size, transcript);
FF alpha = transcript->get_challenge("alpha");
sumcheck_output = sumcheck.prove(prover_polynomials, relation_parameters, alpha);
FF alpha = transcript->get_challenge("Sumcheck:alpha");
std::vector<FF> gate_challenges(numeric::get_msb(key->circuit_size));
for (size_t idx = 0; idx < gate_challenges.size(); idx++) {
gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx));
}
sumcheck_output = sumcheck.prove(prover_polynomials, relation_parameters, alpha, gate_challenges);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,13 @@ template <typename Flavor> class ECCVMTranscriptTests : public ::testing::Test {
round++;
manifest_expected.add_entry(round, "LOOKUP_INVERSES", size_G);
manifest_expected.add_entry(round, "Z_PERM", size_G);
manifest_expected.add_challenge(round, "alpha");
manifest_expected.add_challenge(round, "Sumcheck:alpha");

round++;
manifest_expected.add_challenge(round, "Sumcheck:zeta");
for (size_t i = 0; i < log_n; i++) {
round++;
std::string label = "Sumcheck:gate_challenge_" + std::to_string(i);
manifest_expected.add_challenge(round, label);
}

for (size_t i = 0; i < log_n; ++i) {
round++;
Expand Down
13 changes: 9 additions & 4 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "./eccvm_verifier.hpp"
#include "barretenberg/commitment_schemes/gemini/gemini.hpp"
#include "barretenberg/commitment_schemes/shplonk/shplonk.hpp"
#include "barretenberg/honk/proof_system/power_polynomial.hpp"
#include "barretenberg/numeric/bitop/get_msb.hpp"
#include "barretenberg/transcript/transcript.hpp"

Expand Down Expand Up @@ -158,10 +157,16 @@ template <typename Flavor> bool ECCVMVerifier_<Flavor>::verify_proof(const plonk
commitments.z_perm = receive_commitment(commitment_labels.z_perm);

// Execute Sumcheck Verifier
auto sumcheck = SumcheckVerifier<Flavor>(circuit_size);
FF alpha = transcript->get_challenge("alpha");
const size_t log_circuit_size = numeric::get_msb(circuit_size);
auto sumcheck = SumcheckVerifier<Flavor>(log_circuit_size, transcript);
FF alpha = transcript->get_challenge("Sumcheck:alpha");
std::vector<FF> gate_challenges(numeric::get_msb(key->circuit_size));
for (size_t idx = 0; idx < gate_challenges.size(); idx++) {
gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx));
}

auto [multivariate_challenge, purported_evaluations, sumcheck_verified] =
sumcheck.verify(relation_parameters, alpha, transcript);
sumcheck.verify(relation_parameters, alpha, gate_challenges);

// If Sumcheck did not verify, return false
if (sumcheck_verified.has_value() && !sumcheck_verified.value()) {
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
using CommitmentHandle = typename G1::affine_element;
using CommitmentKey = pcs::CommitmentKey<Curve>;
using VerifierCommitmentKey = pcs::VerifierCommitmentKey<Curve>;
using RelationSeparator = FF;

static constexpr size_t NUM_WIRES = 74;

Expand Down
4 changes: 4 additions & 0 deletions barretenberg/cpp/src/barretenberg/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ concept IsRecursiveFlavor = IsAnyOf<T, honk::flavor::UltraRecursive_<UltraCircui

template <typename T> concept IsGrumpkinFlavor = IsAnyOf<T, honk::flavor::ECCVM>;

template <typename T> concept IsFoldingFlavor = IsAnyOf<T, honk::flavor::Ultra, honk::flavor::GoblinUltra,honk::flavor::UltraRecursive_<UltraCircuitBuilder>,
honk::flavor::UltraRecursive_<GoblinUltraCircuitBuilder>,
honk::flavor::GoblinUltraRecursive>;

template <typename T> concept UltraFlavor = IsAnyOf<T, honk::flavor::Ultra, honk::flavor::GoblinUltra>;

template <typename T> concept ECCVMFlavor = IsAnyOf<T, honk::flavor::ECCVM>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include "barretenberg/relations/generated/AvmMini/mem_trace.hpp"
#include "barretenberg/transcript/transcript.hpp"

namespace proof_system::honk {
namespace flavor {
namespace proof_system::honk::flavor {

class AvmMiniFlavor {
public:
Expand All @@ -34,6 +33,7 @@ class AvmMiniFlavor {
using CommitmentHandle = G1::affine_element;
using CommitmentKey = pcs::CommitmentKey<Curve>;
using VerifierCommitmentKey = pcs::VerifierCommitmentKey<Curve>;
using RelationSeparator = FF;

static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2;
static constexpr size_t NUM_WITNESS_ENTITIES = 38;
Expand Down Expand Up @@ -636,5 +636,4 @@ class AvmMiniFlavor {
};
};

} // namespace flavor
} // namespace proof_system::honk
} // namespace proof_system::honk::flavor
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ToyFlavor {
using CommitmentHandle = G1::affine_element;
using CommitmentKey = pcs::CommitmentKey<Curve>;
using VerifierCommitmentKey = pcs::VerifierCommitmentKey<Curve>;
using RelationSeparator = FF;

static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 1;
static constexpr size_t NUM_WITNESS_ENTITIES = 16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class GoblinTranslator {
using BF = Curve::BaseField;
using Polynomial = barretenberg::Polynomial<FF>;
using PolynomialHandle = std::span<FF>;
using RelationSeparator = FF;

// The size of the circuit which is filled with non-zero values for most polynomials. Most relations (everything
// except for Permutation and GenPermSort) can be evaluated just on the first chunk
Expand Down
62 changes: 55 additions & 7 deletions barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class GoblinUltra {

static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
static constexpr size_t MAX_TOTAL_RELATION_LENGTH = compute_max_total_relation_length<Relations>();
static constexpr size_t NUMBER_OF_SUBRELATIONS = compute_number_of_subrelations<Relations>();

// 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
Expand All @@ -77,6 +76,12 @@ class GoblinUltra {
static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size_v<Relations>;

// For instances of this flavour, used in folding, we need a unique sumcheck batching challenges for each
// subrelation. This
// is because using powers of alpha would increase the degree of Protogalaxy polynomial $G$ (the combiner) to much.
static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
using RelationSeparator = std::array<FF, NUM_SUBRELATIONS - 1>;

template <size_t NUM_INSTANCES>
using ProtogalaxyTupleOfTuplesOfUnivariates =
decltype(create_protogalaxy_tuple_of_tuples_of_univariates<Relations, NUM_INSTANCES>());
Expand All @@ -85,7 +90,6 @@ class GoblinUltra {

// Whether or not the first row of the execution trace is reserved for 0s to enable shifts
static constexpr bool has_zero_row = true;

/**
* @brief A base class labelling precomputed entities and (ordered) subsets of interest.
* @details Used to build the proving key and verification key.
Expand Down Expand Up @@ -448,14 +452,58 @@ class GoblinUltra {
this->lagrange_ecc_op = verification_key->lagrange_ecc_op;
this->databus_id = verification_key->databus_id;
}

VerifierCommitments_(const std::shared_ptr<VerificationKey>& verification_key,
const WitnessCommitments& witness_commitments)
{
this->q_m = verification_key->q_m;
this->q_l = verification_key->q_l;
this->q_r = verification_key->q_r;
this->q_o = verification_key->q_o;
this->q_4 = verification_key->q_4;
this->q_c = verification_key->q_c;
this->q_arith = verification_key->q_arith;
this->q_sort = verification_key->q_sort;
this->q_elliptic = verification_key->q_elliptic;
this->q_aux = verification_key->q_aux;
this->q_lookup = verification_key->q_lookup;
this->q_busread = verification_key->q_busread;
this->q_poseidon2_external = verification_key->q_poseidon2_external;
this->q_poseidon2_internal = verification_key->q_poseidon2_internal;
this->sigma_1 = verification_key->sigma_1;
this->sigma_2 = verification_key->sigma_2;
this->sigma_3 = verification_key->sigma_3;
this->sigma_4 = verification_key->sigma_4;
this->id_1 = verification_key->id_1;
this->id_2 = verification_key->id_2;
this->id_3 = verification_key->id_3;
this->id_4 = verification_key->id_4;
this->table_1 = verification_key->table_1;
this->table_2 = verification_key->table_2;
this->table_3 = verification_key->table_3;
this->table_4 = verification_key->table_4;
this->lagrange_first = verification_key->lagrange_first;
this->lagrange_last = verification_key->lagrange_last;
this->lagrange_ecc_op = verification_key->lagrange_ecc_op;
this->databus_id = verification_key->databus_id;

this->w_l = witness_commitments.w_l;
this->w_r = witness_commitments.w_r;
this->w_o = witness_commitments.w_o;
this->sorted_accum = witness_commitments.sorted_accum;
this->w_4 = witness_commitments.w_4;
this->z_perm = witness_commitments.z_perm;
this->z_lookup = witness_commitments.z_lookup;
this->ecc_op_wire_1 = witness_commitments.ecc_op_wire_1;
this->ecc_op_wire_2 = witness_commitments.ecc_op_wire_2;
this->ecc_op_wire_3 = witness_commitments.ecc_op_wire_3;
this->calldata = witness_commitments.calldata;
this->calldata = witness_commitments.calldata_read_counts;
this->lookup_inverses = witness_commitments.lookup_inverses;
}
};
// Specialize for GoblinUltra (general case used in GoblinUltraRecursive).
using VerifierCommitments = VerifierCommitments_<Commitment, VerificationKey>;
class FoldingParameters {
Copy link
Author

Choose a reason for hiding this comment

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

established the Folding Parameters shouldn't really be something defined in the flavor because they are the same regardless of what flavor we use

public:
std::vector<FF> gate_challenges;
FF target_sum;
};

/**
* @brief Derived class that defines proof structure for GoblinUltra proofs, as well as supporting functions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class GoblinUltraRecursive {
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size<Relations>::value;

// For instances of this flavour, used in folding, we need a unique sumcheck batching challenge for each
// subrelation. This is because using powers of alpha would increase the degree of Protogalaxy polynomial $G$ (the
// combiner) to much.
static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
using RelationSeparator = std::array<FF, NUM_SUBRELATIONS - 1>;

// define the container for storing the univariate contribution from each relation in Sumcheck
using SumcheckTupleOfTuplesOfUnivariates = decltype(create_sumcheck_tuple_of_tuples_of_univariates<Relations>());
using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values<Relations>());
Expand Down
57 changes: 50 additions & 7 deletions barretenberg/cpp/src/barretenberg/flavor/ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ class Ultra {
proof_system::AuxiliaryRelation<FF>>;

static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length<Relations>();
static constexpr size_t MAX_TOTAL_RELATION_LENGTH = compute_max_total_relation_length<Relations>();
static_assert(MAX_PARTIAL_RELATION_LENGTH == 6);
static constexpr size_t MAX_TOTAL_RELATION_LENGTH = compute_max_total_relation_length<Relations>();
static_assert(MAX_TOTAL_RELATION_LENGTH == 12);
static constexpr size_t NUMBER_OF_SUBRELATIONS = compute_number_of_subrelations<Relations>();
static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
// For instances of this flavour, used in folding, we need a unique sumcheck batching challenge for each
// subrelation. This is because using powers of alpha would increase the degree of Protogalaxy polynomial $G$ (the
// combiner) too much.
using RelationSeparator = std::array<FF, NUM_SUBRELATIONS - 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
Expand All @@ -75,6 +79,8 @@ class Ultra {
// Whether or not the first row of the execution trace is reserved for 0s to enable shifts
static constexpr bool has_zero_row = true;

static constexpr bool is_decider = true;

private:
/**
* @brief A base class labelling precomputed entities and (ordered) subsets of interest.
Expand Down Expand Up @@ -400,6 +406,11 @@ class Ultra {
};
};

/**
* @brief A container encapsulating all the commitments that the verifier receives (to precomputed polynomials and
* witness polynomials).
*
*/
class VerifierCommitments : public AllEntities<Commitment> {
public:
VerifierCommitments(const std::shared_ptr<VerificationKey>& verification_key)
Expand Down Expand Up @@ -430,12 +441,44 @@ class Ultra {
lagrange_first = verification_key->lagrange_first;
lagrange_last = verification_key->lagrange_last;
}
};

class FoldingParameters {
public:
std::vector<FF> gate_challenges;
FF target_sum;
VerifierCommitments(const std::shared_ptr<VerificationKey>& verification_key,
const WitnessCommitments& witness_commitments)
{
q_m = verification_key->q_m;
q_c = verification_key->q_c;
q_l = verification_key->q_l;
q_r = verification_key->q_r;
q_o = verification_key->q_o;
q_4 = verification_key->q_4;
q_arith = verification_key->q_arith;
q_sort = verification_key->q_sort;
q_elliptic = verification_key->q_elliptic;
q_aux = verification_key->q_aux;
q_lookup = verification_key->q_lookup;
sigma_1 = verification_key->sigma_1;
sigma_2 = verification_key->sigma_2;
sigma_3 = verification_key->sigma_3;
sigma_4 = verification_key->sigma_4;
id_1 = verification_key->id_1;
id_2 = verification_key->id_2;
id_3 = verification_key->id_3;
id_4 = verification_key->id_4;
table_1 = verification_key->table_1;
table_2 = verification_key->table_2;
table_3 = verification_key->table_3;
table_4 = verification_key->table_4;
lagrange_first = verification_key->lagrange_first;
lagrange_last = verification_key->lagrange_last;

w_l = witness_commitments.w_l;
w_r = witness_commitments.w_r;
w_o = witness_commitments.w_o;
sorted_accum = witness_commitments.sorted_accum;
w_4 = witness_commitments.w_4;
z_perm = witness_commitments.z_perm;
z_lookup = witness_commitments.z_lookup;
}
};

/**
Expand Down
6 changes: 6 additions & 0 deletions barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ template <typename BuilderType> class UltraRecursive_ {
static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1;
static constexpr size_t NUM_RELATIONS = std::tuple_size<Relations>::value;

// For instances of this flavour, used in folding, we need a unique sumcheck batching challenges for each
// subrelation to avoid increasing the degree of Protogalaxy polynomial $G$ (the
// combiner) too much.
static constexpr size_t NUM_SUBRELATIONS = compute_number_of_subrelations<Relations>();
using RelationSeparator = std::array<FF, NUM_SUBRELATIONS - 1>;

// define the container for storing the univariate contribution from each relation in Sumcheck
using SumcheckTupleOfTuplesOfUnivariates = decltype(create_sumcheck_tuple_of_tuples_of_univariates<Relations>());
using TupleOfArraysOfValues = decltype(create_tuple_of_arrays_of_values<Relations>());
Expand Down
Loading