Skip to content

Commit

Permalink
more naming
Browse files Browse the repository at this point in the history
  • Loading branch information
maramihali committed Nov 17, 2023
1 parent e9079f3 commit 348f561
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
4 changes: 1 addition & 3 deletions barretenberg/cpp/src/barretenberg/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,7 @@ template <typename Tuple, std::size_t Index = 0> static constexpr size_t compute
}

/**
* @brief Recursive utility function to find max TOTAL_RELATION_LENGTH among tuples of Relations.
* @details The "total length" of a relation is 1 + the degree of the relation, where any challenges used in the
* relation are regarded as variables.
* @brief Recursive utility function to find the number of subrelations.
*
*/
template <typename Tuple, std::size_t Index = 0> static constexpr size_t compute_number_of_subrelations()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ template <class Fr, size_t domain_end, size_t domain_start = 0> class Univariate
Univariate(Univariate&& other) noexcept = default;
Univariate& operator=(const Univariate& other) = default;
Univariate& operator=(Univariate&& other) noexcept = default;
// Construct constant Univariate from scalar which represents the value all the point in the domain should evalute
// Construct constant Univariate from scalar which represents the value that all the points in the domain evaluate
// to
explicit Univariate(Fr value)
: evaluations{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ template <class ProverInstances_> class ProtoGalaxyProver_ {
using RowEvaluations = typename Flavor::AllValues;
using ProverPolynomials = typename Flavor::ProverPolynomials;
using Relations = typename Flavor::Relations;
using AlphaType = ProverInstances::AlphaType;
using AlphaType = typename ProverInstances::AlphaType;

using BaseUnivariate = Univariate<FF, ProverInstances::NUM>;
// The length of ExtendedUnivariate is the largest length (==degree + 1) of a univariate polynomial obtained by
Expand Down Expand Up @@ -345,8 +345,6 @@ template <class ProverInstances_> class ProtoGalaxyProver_ {
* univariate (i.e., sum them against an appropriate univariate Lagrange basis) and then extended as needed during
* the constuction of the combiner.
*/

// THIS SHOULD BE CALLED ACCUMULATED
static void fold_relation_parameters(ProverInstances& instances)
{
// array of parameters to be computed
Expand All @@ -355,7 +353,6 @@ template <class ProverInstances_> class ProtoGalaxyProver_ {
for (auto& folded_parameter : folded_parameters) {
Univariate<FF, ProverInstances::NUM> tmp(0);
size_t instance_idx = 0;
// it's not wrong i'm just dumb
for (auto& instance : instances) {
tmp.value_at(instance_idx) = instance->relation_parameters.to_fold[param_idx];
instance_idx++;
Expand All @@ -369,8 +366,10 @@ template <class ProverInstances_> class ProtoGalaxyProver_ {
* @brief Create folded univariate for the relation batching parameter (alpha).
*
*/

// THIS SHOULD BE CALLED ACCUMULATED
// TODO(https://github.com/AztecProtocol/barretenberg/issues/772): At the moment we have a single α per Instance, we
// fold them and then we use the unique folded_α for each folded subrelation that is batched in the combiner. This
// is obviously insecure. We need to generate α_i for each subrelation_i, fold them and then use folded_α_i when
// batching the i-th folded subrelation in the combiner.
static void fold_alpha(ProverInstances& instances)
{
Univariate<FF, ProverInstances::NUM> accumulated_alpha;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ VerifierFoldingResult<typename VerifierInstances::Flavor> ProtoGalaxyVerifier_<
auto perturbator_at_challenge = perturbator.evaluate(perturbator_challenge);

// Thed degree of K(X) is dk - k - 1 = k(d - 1) - 1. Hence we need k(d - 1) evaluations to represent it.
std::array<FF, (Flavor::MAX_TOTAL_RELATION_LENGTH - 2) * (VerifierInstances::NUM - 1)> combiner_quotient_evals = {};
for (size_t idx = 0; idx < (Flavor::MAX_TOTAL_RELATION_LENGTH - 2) * (VerifierInstances::NUM - 1); idx++) {
std::array<FF, VerifierInstances::BATCHED_EXTENDED_LENGTH - VerifierInstances::NUM> combiner_quotient_evals = {};
for (size_t idx = 0; idx < VerifierInstances::BATCHED_EXTENDED_LENGTH - VerifierInstances::NUM; idx++) {
combiner_quotient_evals[idx] = transcript.template receive_from_prover<FF>(
"combiner_quotient_" + std::to_string(idx + VerifierInstances::NUM));
}
Univariate<FF, (Flavor::MAX_TOTAL_RELATION_LENGTH - 1) * (VerifierInstances::NUM - 1) + 1, VerifierInstances::NUM>
combiner_quotient(combiner_quotient_evals);
Univariate<FF, VerifierInstances::BATCHED_EXTENDED_LENGTH, VerifierInstances::NUM> combiner_quotient(
combiner_quotient_evals);
auto combiner_challenge = transcript.get_challenge("combiner_quotient_challenge");
auto combiner_quotient_at_challenge = combiner_quotient.evaluate(combiner_challenge);

Expand Down
3 changes: 2 additions & 1 deletion barretenberg/cpp/src/barretenberg/relations/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ template <typename Flavor> class RelationUtils {
template <typename... T>
static constexpr void add_tuples(std::tuple<T...>& tuple_1, const std::tuple<T...>& tuple_2)
{
auto add_tuples_helper = [&]<std::size_t... I>(std::index_sequence<I...>) {
auto add_tuples_helper = [&]<std::size_t... I>(std::index_sequence<I...>)
{
((std::get<I>(tuple_1) += std::get<I>(tuple_2)), ...);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ template <typename Flavor_, size_t NUM_> struct VerifierInstances_ {

public:
static constexpr size_t NUM = NUM_;
static constexpr size_t BATCHED_EXTENDED_LENGTH = (Flavor::MAX_TOTAL_RELATION_LENGTH - 1 + NUM - 1) * (NUM - 1) + 1;
ArrayType _data;
std::shared_ptr<Instance> const& operator[](size_t idx) const { return _data[idx]; }
typename ArrayType::iterator begin() { return _data.begin(); };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ template <class Flavor> class ProverInstance_ {
// non-zero for Instances constructed from circuits, this concept doesn't exist for accumulated
// instances
size_t pub_inputs_offset = 0;
// I really wanna rename this relation_batching_challenge
FF alpha;
proof_system::RelationParameters<FF> relation_parameters;
std::vector<uint32_t> recursive_proof_public_input_indices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ template <class Flavor> class VerifierInstance_ {
size_t pub_inputs_offset;
size_t public_input_size;
size_t instance_size;
// Is this fine?
RelationParameters<FF> relation_parameters;
FF alpha;
FoldingParameters folding_parameters;
Expand Down

0 comments on commit 348f561

Please sign in to comment.