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: recursive folding and decider verifier for Protogalaxy #4156

Merged
merged 121 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
6313f15
wip wip wip
maramihali Oct 23, 2023
40cedd0
styuff
maramihali Oct 24, 2023
c7cc936
how do I do this?
maramihali Oct 24, 2023
59c69f2
pain
maramihali Oct 25, 2023
aed27df
pain
maramihali Oct 25, 2023
265f248
wip that works
maramihali Nov 6, 2023
44da63f
Merge branch 'master' into mm/pg-plumbing
maramihali Nov 6, 2023
7ffc364
cleanup
maramihali Nov 6, 2023
62df97a
Merge branch 'master' into mm/combiner-quotient
maramihali Nov 6, 2023
9d1b5c6
comment test
maramihali Nov 6, 2023
42ac7e2
comment test
maramihali 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
maramihali Nov 8, 2023
86963a5
pr review additions
maramihali Nov 9, 2023
a816c4b
Merge branch 'master' into mm/combiner-quotient
maramihali Nov 9, 2023
91ca591
fix formatting
maramihali Nov 9, 2023
abb6ed2
add missing issue
maramihali Nov 9, 2023
81f7d89
Merge branch 'mm/combiner-quotient' into mm/pg-fold-alpha
maramihali Nov 10, 2023
73068a6
wip that doesn't work
maramihali Nov 10, 2023
a86a9b4
wip
maramihali Nov 10, 2023
a51d686
subrelation number
maramihali Nov 11, 2023
df7a62c
add stuff
maramihali Nov 13, 2023
1ff05b6
confusion
maramihali Nov 16, 2023
1ed19f2
pain
maramihali Nov 16, 2023
dea27c1
compiles
maramihali Nov 16, 2023
05bf621
Merge branch 'master' into mm/pg-fold-alpha
maramihali Nov 17, 2023
073db88
works
maramihali Nov 17, 2023
e9079f3
Merge branch 'master' into mm/pg-fold-alpha
maramihali Nov 17, 2023
348f561
more naming
maramihali Nov 17, 2023
c380cea
fix sumcheck test that was failing
maramihali Nov 18, 2023
068ea31
Merge branch 'master' into mm/pg-fold-alpha
maramihali Nov 18, 2023
cbec5d6
Merge remote-tracking branch 'origin/mm/pg-fold-alpha' into HEAD
maramihali Nov 20, 2023
9d16416
stuff
maramihali Nov 20, 2023
0472c10
confusion
maramihali Nov 20, 2023
2ae95d2
stuff with pointer view
maramihali Nov 21, 2023
a2da6d4
Merge branch 'master' into mm/pg-poc
maramihali Nov 21, 2023
c0d39d8
hm
maramihali Nov 22, 2023
740d1c8
getting there
maramihali Nov 24, 2023
985c006
hmm
maramihali Nov 28, 2023
a19ae07
works
maramihali Nov 28, 2023
fdb9b6c
Merge branch 'master' into mm/pg-poc
maramihali Nov 28, 2023
4581a0c
confused
maramihali Nov 29, 2023
aa0acca
works
maramihali Nov 29, 2023
a13ee93
create witness commitments structure
maramihali Nov 29, 2023
5634ed1
add missing comments
maramihali Nov 29, 2023
ae55902
more missing docs
maramihali Nov 29, 2023
d1f7246
Merge branch 'master' into mm/witness-entities-refactor
maramihali Nov 29, 2023
4fa6c3d
refactor based on discussion
maramihali Nov 30, 2023
d43677d
Merge branch 'master' into mm/witness-entities-refactor
maramihali Nov 30, 2023
4adac47
WORKS
maramihali Nov 30, 2023
c2e78b5
cleaning up
maramihali Dec 1, 2023
5c29867
more refactoring
maramihali Dec 1, 2023
c5c7c61
cleanup
maramihali Dec 4, 2023
ff37810
Merge branch 'master' into mm/pg-poc
maramihali Dec 4, 2023
9796186
fix merge bug and cleanup
maramihali Dec 4, 2023
649fdeb
Merge branch 'master' into mm/pg-poc
maramihali Dec 4, 2023
1d24643
fix formatting
maramihali Dec 4, 2023
a720c80
add todo
maramihali Dec 4, 2023
e6e5db3
print statements
maramihali Dec 4, 2023
ee926f8
fix bug?
maramihali Dec 4, 2023
89bf847
remove prints
maramihali Dec 4, 2023
828ab91
Merge branch 'master' into mm/pg-poc
maramihali Dec 5, 2023
ac8b77c
remove unnecessary stuff
maramihali Dec 6, 2023
4cc7742
stuff
maramihali Dec 6, 2023
3e96712
pow poly works
maramihali Dec 11, 2023
4c62760
Merge branch 'master' into mm/pg-decider
maramihali Dec 11, 2023
c8909d0
wip that works
maramihali Dec 11, 2023
35c20e7
Merge branch 'master' into mm/pg-decider
maramihali Dec 12, 2023
98a7b6c
wip wip
maramihali Dec 12, 2023
9b49bab
doesn't work :(
maramihali Dec 13, 2023
81845c9
shit
maramihali Dec 14, 2023
4bce6e8
everything but beta
maramihali Dec 15, 2023
1cfabf9
this works
maramihali Dec 18, 2023
79408ed
cleaned up relation parameters
maramihali Dec 18, 2023
ba7ecf5
Merge branch 'master' into mm/pg-decider
maramihali Dec 18, 2023
a1d44a7
more stuff working
maramihali Dec 20, 2023
bcfd79a
batching challenges
maramihali Dec 21, 2023
fdd9311
fix formatting
maramihali Dec 21, 2023
afd16d5
fix wasm
maramihali Dec 21, 2023
de77d6e
more cleanup
maramihali Dec 21, 2023
dd0505e
Merge branch 'master' into mm/pg-decider
maramihali Dec 21, 2023
c7dec72
pow
maramihali Dec 21, 2023
413a801
remove resolved issues
maramihali Dec 21, 2023
8debe53
Merge branch 'master' into mm/pg-decider
maramihali Dec 21, 2023
c765771
replace honk-tests CI with ultra-honk-tests CI
maramihali Dec 21, 2023
62baf45
--no-edit
maramihali Dec 21, 2023
a8812f6
cleanup
maramihali Dec 21, 2023
5b2f955
stuff that doesn't work
maramihali Dec 21, 2023
8cb1d9e
fix idx overflow
maramihali Dec 22, 2023
4900dae
Merge branch 'master' into mm/pg-decider
maramihali Jan 8, 2024
be3a223
debug
maramihali Jan 8, 2024
deb239e
remove computation of power polynomial at values on the verifier side
maramihali Jan 8, 2024
ecf84ce
update tests and comments
maramihali Jan 8, 2024
5cc73f1
Merge branch 'master' into mm/pg-decider
maramihali Jan 8, 2024
aa51a31
Merge branch 'mm/pg-decider' into mm/pg-verifier-circuit
maramihali Jan 9, 2024
ecdf4d3
recursive decider verifier and folding wip
maramihali Jan 10, 2024
4c4d664
Merge branch 'master' into mm/pg-decider
maramihali Jan 10, 2024
65c6aeb
resolve review comments
maramihali Jan 10, 2024
4f7d79b
fix formatting
maramihali Jan 10, 2024
a63ffa2
Merge branch 'mm/pg-decider' into mm/pg-verifier-circuit
maramihali Jan 11, 2024
9ac85f1
doesn't work
maramihali Jan 11, 2024
c5fdb82
compiles
maramihali Jan 11, 2024
d0f760d
add tests
maramihali Jan 12, 2024
edda2b9
not working
maramihali Jan 16, 2024
571c060
Merge branch 'master' into mm/pg-verifier-circuit
maramihali Jan 16, 2024
08942a3
first working thingy
maramihali Jan 17, 2024
01ca9f6
Merge branch 'master' into mm/pg-verifier-circuit
maramihali Jan 17, 2024
52d31b9
cleanups
maramihali Jan 18, 2024
167ad39
stuff that works
maramihali Jan 19, 2024
2a772e0
fix formatting
maramihali Jan 19, 2024
06089f7
more stuff
maramihali Jan 19, 2024
a86f207
Merge branch 'master' into mm/pg-verifier-circuit
maramihali Jan 19, 2024
661b2d0
Merge branch 'master' into mm/pg-verifier-circuit
maramihali Jan 19, 2024
cb801bc
Merge branch 'master' into mm/pg-verifier-circuit
maramihali Jan 22, 2024
da3f158
pr review changes
maramihali Jan 23, 2024
600712e
Merge branch 'master' into mm/pg-verifier-circuit
maramihali Jan 23, 2024
4455659
passing recursive folding test
maramihali Jan 23, 2024
ce8cb53
Merge branch 'master' into mm/pg-verifier-circuit
maramihali Jan 23, 2024
cce5edc
Merge branch 'master' into mm/pg-verifier-circuit
maramihali Jan 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void fold_one(State& state) noexcept
std::shared_ptr<Instance> instance_1 = construct_instance();
std::shared_ptr<Instance> instance_2 = construct_instance();

auto folding_prover = composer.create_folding_prover({ instance_1, instance_2 }, composer.commitment_key);
maramihali marked this conversation as resolved.
Show resolved Hide resolved
auto folding_prover = composer.create_folding_prover({ instance_1, instance_2 });

for (auto _ : state) {
auto proof = folding_prover.fold_instances();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ template <class Params_> struct alignas(32) field {
*this = field(value);
}

constexpr explicit operator bool() const
{
field out = from_montgomery_form();
ASSERT(out.data[0] == 0 || out.data[0] == 1);
return static_cast<bool>(out.data[0]);
}

constexpr explicit operator uint32_t() const
{
field out = from_montgomery_form();
Expand Down
67 changes: 18 additions & 49 deletions barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class GoblinUltra {

// GoblinUltra needs to expose more public classes than most flavors due to GoblinUltraRecursive reuse, but these
// are internal:
private:
public:
// WireEntities for basic witness entities
template <typename DataType> class WireEntities {
public:
Expand Down Expand Up @@ -418,42 +418,8 @@ class GoblinUltra {
template <typename Commitment, typename VerificationKey>
class VerifierCommitments_ : public AllEntities<Commitment> {
public:
VerifierCommitments_(const std::shared_ptr<VerificationKey>& verification_key)
{
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;
}

VerifierCommitments_(const std::shared_ptr<VerificationKey>& verification_key,
const WitnessCommitments& witness_commitments)
const std::optional<WitnessEntities<Commitment>>& witness_commitments = std::nullopt)
{
this->q_m = verification_key->q_m;
this->q_l = verification_key->q_l;
Expand Down Expand Up @@ -486,19 +452,22 @@ class GoblinUltra {
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;
if (witness_commitments.has_value()) {
auto commitments = witness_commitments.value();
this->w_l = commitments.w_l;
this->w_r = commitments.w_r;
this->w_o = commitments.w_o;
this->sorted_accum = commitments.sorted_accum;
this->w_4 = commitments.w_4;
this->z_perm = commitments.z_perm;
this->z_lookup = commitments.z_lookup;
this->ecc_op_wire_1 = commitments.ecc_op_wire_1;
this->ecc_op_wire_2 = commitments.ecc_op_wire_2;
this->ecc_op_wire_3 = commitments.ecc_op_wire_3;
this->calldata = commitments.calldata;
this->calldata = commitments.calldata_read_counts;
this->lookup_inverses = commitments.lookup_inverses;
}
}
};
// Specialize for GoblinUltra (general case used in GoblinUltraRecursive).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ template <typename BuilderType> class GoblinUltraRecursive_ {
using Relations = GoblinUltra::Relations_<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>();

// 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;
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 challenge for each
// subrelation. This is because using powers of alpha would increase the degree of Protogalaxy polynomial $G$ (the
Expand Down Expand Up @@ -104,6 +106,12 @@ template <typename BuilderType> class GoblinUltraRecursive_ {
*/
class VerificationKey : public VerificationKey_<GoblinUltra::PrecomputedEntities<Commitment>> {
public:
VerificationKey(const size_t circuit_size, const size_t num_public_inputs)
{
this->circuit_size = circuit_size;
this->log_circuit_size = numeric::get_msb(circuit_size);
this->num_public_inputs = num_public_inputs;
ledwards2225 marked this conversation as resolved.
Show resolved Hide resolved
};
/**
* @brief Construct a new Verification Key with stdlib types from a provided native verification
* key
Expand All @@ -112,9 +120,10 @@ template <typename BuilderType> class GoblinUltraRecursive_ {
* @param native_key Native verification key from which to extract the precomputed commitments
*/
VerificationKey(CircuitBuilder* builder, const std::shared_ptr<NativeVerificationKey>& native_key)
: VerificationKey_<GoblinUltra::PrecomputedEntities<Commitment>>(native_key->circuit_size,
native_key->num_public_inputs)
{
this->circuit_size = native_key->circuit_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->num_public_inputs = native_key->num_public_inputs;
this->q_m = Commitment::from_witness(builder, native_key->q_m);
this->q_l = Commitment::from_witness(builder, native_key->q_l);
this->q_r = Commitment::from_witness(builder, native_key->q_r);
Expand Down Expand Up @@ -148,6 +157,11 @@ template <typename BuilderType> class GoblinUltraRecursive_ {
};
};

/**
* @brief A container for the witness commitments.
*/
using WitnessCommitments = GoblinUltra::WitnessEntities<Commitment>;

using CommitmentLabels = GoblinUltra::CommitmentLabels;
// Reuse the VerifierCommitments from GoblinUltra
using VerifierCommitments = GoblinUltra::VerifierCommitments_<Commitment, VerificationKey>;
Expand Down
48 changes: 11 additions & 37 deletions barretenberg/cpp/src/barretenberg/flavor/ultra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,37 +412,8 @@ class Ultra {
*/
class VerifierCommitments : public AllEntities<Commitment> {
public:
VerifierCommitments(const std::shared_ptr<VerificationKey>& verification_key)
{
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;
}

VerifierCommitments(const std::shared_ptr<VerificationKey>& verification_key,
const WitnessCommitments& witness_commitments)
const std::optional<WitnessCommitments>& witness_commitments = std::nullopt)
{
q_m = verification_key->q_m;
q_c = verification_key->q_c;
Expand Down Expand Up @@ -470,13 +441,16 @@ class Ultra {
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;
if (witness_commitments.has_value()) {
auto commitments = witness_commitments.value();
this->w_l = commitments.w_l;
this->w_r = commitments.w_r;
this->w_o = commitments.w_o;
this->sorted_accum = commitments.sorted_accum;
this->w_4 = commitments.w_4;
this->z_perm = commitments.z_perm;
this->z_lookup = commitments.z_lookup;
}
}
};

Expand Down
96 changes: 68 additions & 28 deletions barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ template <typename BuilderType> class UltraRecursive_ {
bb::AuxiliaryRelation<FF>>;

static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_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);

// 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<Relations>::value;

// For instances of this flavour, used in folding, we need a unique sumcheck batching challenges for each
Expand Down Expand Up @@ -161,6 +165,12 @@ template <typename BuilderType> class UltraRecursive_ {
RefVector<DataType> get_wires() { return { w_l, w_r, w_o, w_4 }; };
};

public:
/**
* @brief A container for the witness commitments.
*/
using WitnessCommitments = WitnessEntities<Commitment>;

/**
* @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during
* sumcheck) in this Honk variant along with particular subsets of interest
Expand Down Expand Up @@ -229,6 +239,17 @@ template <typename BuilderType> class UltraRecursive_ {

};
};
RefVector<DataType> get_precomputed()
{
return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort,
q_elliptic, q_aux, q_lookup, sigma_1, sigma_2, sigma_3, sigma_4, id_1,
id_2, id_3, id_4, table_1, table_2, table_3, table_4, lagrange_first,
lagrange_last

};
}

RefVector<DataType> get_witness() { return { w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; };
RefVector<DataType> get_to_be_shifted()
{
return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup };
Expand All @@ -251,15 +272,23 @@ template <typename BuilderType> class UltraRecursive_ {
*/
class VerificationKey : public VerificationKey_<PrecomputedEntities<Commitment>> {
public:
VerificationKey(const size_t circuit_size, const size_t num_public_inputs)
{
this->circuit_size = circuit_size;
this->log_circuit_size = numeric::get_msb(circuit_size);
this->num_public_inputs = num_public_inputs;
};
/**
* @brief Construct a new Verification Key with stdlib types from a provided native verification key
*
* @param builder
* @param native_key Native verification key from which to extract the precomputed commitments
*/
VerificationKey(CircuitBuilder* builder, const std::shared_ptr<NativeVerificationKey>& native_key)
: VerificationKey_<PrecomputedEntities<Commitment>>(native_key->circuit_size, native_key->num_public_inputs)
{
this->circuit_size = native_key->circuit_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->num_public_inputs = native_key->num_public_inputs;
this->q_m = Commitment::from_witness(builder, native_key->q_m);
this->q_l = Commitment::from_witness(builder, native_key->q_l);
this->q_r = Commitment::from_witness(builder, native_key->q_r);
Expand Down Expand Up @@ -317,38 +346,38 @@ template <typename BuilderType> class UltraRecursive_ {
this->z_lookup = "Z_LOOKUP";
this->sorted_accum = "SORTED_ACCUM";

// The ones beginning with "__" are only used for debugging
this->q_c = "__Q_C";
this->q_l = "__Q_L";
this->q_r = "__Q_R";
this->q_o = "__Q_O";
this->q_4 = "__Q_4";
this->q_m = "__Q_M";
this->q_arith = "__Q_ARITH";
this->q_sort = "__Q_SORT";
this->q_elliptic = "__Q_ELLIPTIC";
this->q_aux = "__Q_AUX";
this->q_lookup = "__Q_LOOKUP";
this->sigma_1 = "__SIGMA_1";
this->sigma_2 = "__SIGMA_2";
this->sigma_3 = "__SIGMA_3";
this->sigma_4 = "__SIGMA_4";
this->id_1 = "__ID_1";
this->id_2 = "__ID_2";
this->id_3 = "__ID_3";
this->id_4 = "__ID_4";
this->table_1 = "__TABLE_1";
this->table_2 = "__TABLE_2";
this->table_3 = "__TABLE_3";
this->table_4 = "__TABLE_4";
this->lagrange_first = "__LAGRANGE_FIRST";
this->lagrange_last = "__LAGRANGE_LAST";
this->q_c = "Q_C";
this->q_l = "Q_L";
this->q_r = "Q_R";
this->q_o = "Q_O";
this->q_4 = "Q_4";
this->q_m = "Q_M";
this->q_arith = "Q_ARITH";
this->q_sort = "Q_SORT";
this->q_elliptic = "Q_ELLIPTIC";
this->q_aux = "Q_AUX";
this->q_lookup = "Q_LOOKUP";
this->sigma_1 = "SIGMA_1";
this->sigma_2 = "SIGMA_2";
this->sigma_3 = "SIGMA_3";
this->sigma_4 = "SIGMA_4";
this->id_1 = "ID_1";
this->id_2 = "ID_2";
this->id_3 = "ID_3";
this->id_4 = "ID_4";
this->table_1 = "TABLE_1";
this->table_2 = "TABLE_2";
this->table_3 = "TABLE_3";
this->table_4 = "TABLE_4";
this->lagrange_first = "LAGRANGE_FIRST";
this->lagrange_last = "LAGRANGE_LAST";
};
};

class VerifierCommitments : public AllEntities<Commitment> {
public:
VerifierCommitments(const std::shared_ptr<VerificationKey>& verification_key)
VerifierCommitments(const std::shared_ptr<VerificationKey>& verification_key,
maramihali marked this conversation as resolved.
Show resolved Hide resolved
maramihali marked this conversation as resolved.
Show resolved Hide resolved
const std::optional<WitnessCommitments>& witness_commitments = std::nullopt)
{
this->q_m = verification_key->q_m;
this->q_l = verification_key->q_l;
Expand All @@ -375,6 +404,17 @@ template <typename BuilderType> class UltraRecursive_ {
this->table_4 = verification_key->table_4;
this->lagrange_first = verification_key->lagrange_first;
this->lagrange_last = verification_key->lagrange_last;

if (witness_commitments.has_value()) {
auto commitments = witness_commitments.value();
this->w_l = commitments.w_l;
this->w_r = commitments.w_r;
this->w_o = commitments.w_o;
this->sorted_accum = commitments.sorted_accum;
this->w_4 = commitments.w_4;
this->z_perm = commitments.z_perm;
this->z_lookup = commitments.z_lookup;
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,10 @@ std::shared_ptr<typename ProverInstances::Instance> ProtoGalaxyProver_<ProverIns
return next_accumulator;
}

// TODO(#https://github.com/AztecProtocol/barretenberg/issues/689): finalise implementation this function
template <class ProverInstances>
FoldingResult<typename ProverInstances::Flavor> ProtoGalaxyProver_<ProverInstances>::fold_instances()
{
prepare_for_folding();

// TODO(#https://github.com/AztecProtocol/barretenberg/issues/740): Handle the case where we are folding for the
// first time and accumulator is 0
FF delta = transcript->get_challenge("delta");

auto accumulator = get_accumulator();
Expand Down
Loading