Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ void plookup_auxiliary_kernel(::benchmark::State& state) noexcept
for (auto _ : state) {
// NOTE: this simply calls the following 3 functions it does NOT try to replicate ProverPlookupAuxiliaryWidget
// logic exactly
widget::containers::coefficient_array<barretenberg::fr> linear_terms;
FFTKernel::compute_linear_terms(polynomials, challenges, linear_terms, 0);
barretenberg::fr sum_of_linear_terms = FFTKernel::sum_linear_terms(polynomials, challenges, linear_terms, 0);
FFTKernel::compute_non_linear_terms(polynomials, challenges, sum_of_linear_terms, 0);
barretenberg::fr result{ 0 };
FFTKernel::accumulate_contribution(polynomials, challenges, result, 0);
}
}
BENCHMARK(plookup_auxiliary_kernel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ enum PolynomialIndex {
Q_FIXED_BASE,
Q_RANGE,
Q_SORT,
Q_LOGIC,
TABLE_1,
TABLE_2,
TABLE_3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#include "../widgets/random_widgets/random_widget.hpp"
#include "../widgets/transition_widgets/arithmetic_widget.hpp"
#include "../widgets/transition_widgets/elliptic_widget.hpp"
#include "../widgets/transition_widgets/fixed_base_widget.hpp"
#include "../widgets/transition_widgets/genperm_sort_widget.hpp"
#include "../widgets/transition_widgets/logic_widget.hpp"
#include "../widgets/transition_widgets/plookup_arithmetic_widget.hpp"
#include "../widgets/transition_widgets/plookup_auxiliary_widget.hpp"
#include "./prover_settings.hpp"
Expand Down Expand Up @@ -64,7 +62,6 @@ class ultra_verifier_settings : public ultra_settings {
typedef transcript::StandardTranscript Transcript;
typedef VerifierPlookupArithmeticWidget<fr, g1::affine_element, Transcript, ultra_settings> PlookupArithmeticWidget;
typedef VerifierGenPermSortWidget<fr, g1::affine_element, Transcript, ultra_settings> GenPermSortWidget;
typedef VerifierLogicWidget<fr, g1::affine_element, Transcript, ultra_settings> LogicWidget;
typedef VerifierPermutationWidget<fr, g1::affine_element, Transcript> PermutationWidget;
typedef VerifierPlookupWidget<fr, g1::affine_element, Transcript> PlookupWidget;
typedef VerifierEllipticWidget<fr, g1::affine_element, Transcript, ultra_settings> EllipticWidget;
Expand Down Expand Up @@ -120,7 +117,6 @@ class ultra_to_standard_verifier_settings : public ultra_verifier_settings {
typedef VerifierPlookupArithmeticWidget<fr, g1::affine_element, Transcript, ultra_to_standard_settings>
PlookupArithmeticWidget;
typedef VerifierGenPermSortWidget<fr, g1::affine_element, Transcript, ultra_to_standard_settings> GenPermSortWidget;
typedef VerifierLogicWidget<fr, g1::affine_element, Transcript, ultra_to_standard_settings> LogicWidget;
typedef VerifierPermutationWidget<fr, g1::affine_element, Transcript> PermutationWidget;
typedef VerifierPlookupWidget<fr, g1::affine_element, Transcript> PlookupWidget;
typedef VerifierEllipticWidget<fr, g1::affine_element, Transcript, ultra_to_standard_settings> EllipticWidget;
Expand All @@ -136,7 +132,6 @@ class ultra_with_keccak_verifier_settings : public ultra_verifier_settings {
typedef VerifierPlookupArithmeticWidget<fr, g1::affine_element, Transcript, ultra_with_keccak_settings>
PlookupArithmeticWidget;
typedef VerifierGenPermSortWidget<fr, g1::affine_element, Transcript, ultra_with_keccak_settings> GenPermSortWidget;
typedef VerifierLogicWidget<fr, g1::affine_element, Transcript, ultra_with_keccak_settings> LogicWidget;
typedef VerifierPermutationWidget<fr, g1::affine_element, Transcript> PermutationWidget;
typedef VerifierPlookupWidget<fr, g1::affine_element, Transcript> PlookupWidget;
typedef VerifierEllipticWidget<fr, g1::affine_element, Transcript, ultra_with_keccak_settings> EllipticWidget;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ template <class Field, class Getters, typename PolyContainer> class ArithmeticKe
private:
// A structure with various challenges, even though only alpha is used here.
typedef containers::challenge_array<Field, num_independent_relations> challenge_array;
// Type for the linear terms of the transition
typedef containers::coefficient_array<Field> coefficient_array;

public:
inline static std::set<PolynomialIndex> const& get_required_polynomial_ids()
Expand All @@ -51,10 +49,10 @@ template <class Field, class Getters, typename PolyContainer> class ArithmeticKe
* @param linear_terms Container for results of computation
* @param i Index at which the wire values are sampled.
*/
inline static void compute_linear_terms(PolyContainer& polynomials,
const challenge_array&,
coefficient_array& linear_terms,
const size_t i = 0)
inline static void accumulate_contribution(PolyContainer& polynomials,
const challenge_array& challenges,
Field& quotient,
const size_t i = 0)
{
const Field& w_1 =
Getters::template get_value<EvaluationType::NON_SHIFTED, PolynomialIndex::W_1>(polynomials, i);
Expand All @@ -63,34 +61,6 @@ template <class Field, class Getters, typename PolyContainer> class ArithmeticKe
const Field& w_3 =
Getters::template get_value<EvaluationType::NON_SHIFTED, PolynomialIndex::W_3>(polynomials, i);

linear_terms[0] = w_1 * w_2;
linear_terms[1] = w_1;
linear_terms[2] = w_2;
linear_terms[3] = w_3;
}

/**
* @brief Not being used in arithmetic_widget because there are none
*
*/
inline static void compute_non_linear_terms(PolyContainer&, const challenge_array&, Field&, const size_t = 0) {}

/**
* @brief Scale and sum the linear terms for the final equation.
*
* @details Multiplies the linear terms by selector values and scale the whole sum by alpha before returning
*
* @param polynomials Container with polynomials or their simulation
* @param challenges A structure with various challenges
* @param linear_terms Precomuputed linear terms to be scaled and summed
* @param i The index at which selector/witness values are sampled
* @return Field Scaled sum of values
*/
inline static Field sum_linear_terms(PolyContainer& polynomials,
const challenge_array& challenges,
coefficient_array& linear_terms,
const size_t i = 0)
{
const Field& alpha = challenges.alpha_powers[0];
const Field& q_1 =
Getters::template get_value<EvaluationType::NON_SHIFTED, PolynomialIndex::Q_1>(polynomials, i);
Expand All @@ -103,32 +73,13 @@ template <class Field, class Getters, typename PolyContainer> class ArithmeticKe
const Field& q_c =
Getters::template get_value<EvaluationType::NON_SHIFTED, PolynomialIndex::Q_C>(polynomials, i);

Field result = linear_terms[0] * q_m;
result += (linear_terms[1] * q_1);
result += (linear_terms[2] * q_2);
result += (linear_terms[3] * q_3);
Field result = (w_1 * w_2) * q_m;
result += w_1 * q_1;
result += w_2 * q_2;
result += w_3 * q_3;
result += q_c;
result *= alpha;
return result;
}

/**
* @brief Compute the scaled values of openings
*
* @param linear_terms The original computed linear terms of the product and wires
* @param scalars A map where we put the values
* @param challenges Challenges where we get the alpha
*/
inline static void update_kate_opening_scalars(coefficient_array& linear_terms,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This function (implemented in each widget) was part of the linearization trick and was no longer used at all.

std::map<std::string, Field>& scalars,
const challenge_array& challenges)
{
const Field& alpha = challenges.alpha_powers[0];
scalars["Q_M"] += linear_terms[0] * alpha;
scalars["Q_1"] += linear_terms[1] * alpha;
scalars["Q_2"] += linear_terms[2] * alpha;
scalars["Q_3"] += linear_terms[3] * alpha;
scalars["Q_C"] += alpha;
quotient += result;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ template <class Field, class Getters, typename PolyContainer> class EllipticKern

private:
typedef containers::challenge_array<Field, num_independent_relations> challenge_array;
typedef containers::coefficient_array<Field> coefficient_array;

public:
inline static std::set<PolynomialIndex> const& get_required_polynomial_ids()
Expand All @@ -93,10 +92,10 @@ template <class Field, class Getters, typename PolyContainer> class EllipticKern
* @param linear_terms Output array
* @param i Gate index
*/
inline static void compute_linear_terms(PolyContainer& polynomials,
const challenge_array& challenges,
coefficient_array& linear_terms,
const size_t i = 0)
inline static void accumulate_contribution(PolyContainer& polynomials,
const challenge_array& challenges,
Field& quotient,
const size_t i = 0)
{
const Field& x_1 =
Getters::template get_value<EvaluationType::NON_SHIFTED, PolynomialIndex::W_2>(polynomials, i);
Expand All @@ -106,6 +105,8 @@ template <class Field, class Getters, typename PolyContainer> class EllipticKern
const Field& y_2 = Getters::template get_value<EvaluationType::SHIFTED, PolynomialIndex::W_4>(polynomials, i);
const Field& x_3 = Getters::template get_value<EvaluationType::SHIFTED, PolynomialIndex::W_2>(polynomials, i);
const Field& y_3 = Getters::template get_value<EvaluationType::SHIFTED, PolynomialIndex::W_3>(polynomials, i);
const Field& q_elliptic =
Getters::template get_value<EvaluationType::NON_SHIFTED, PolynomialIndex::Q_ELLIPTIC>(polynomials, i);

// sign
const Field& q_sign =
Expand Down Expand Up @@ -139,41 +140,9 @@ template <class Field, class Getters, typename PolyContainer> class EllipticKern
(q_is_double * (x_identity_double - x_identity_add) + x_identity_add) * challenges.alpha_powers[0];
auto y_identity =
(q_is_double * (y_identity_double - y_identity_add) + y_identity_add) * challenges.alpha_powers[1];
linear_terms[0] = x_identity + y_identity;
}
Field identity = x_identity + y_identity;

/**
* @brief Return the linear term multiplied by elliptic curve addition selector value at gate
*
* @param polynomials Polynomial container or simulator
* @param linear_terms Array of linear terms
* @param i Gate index
* @return Field
*/
inline static Field sum_linear_terms(PolyContainer& polynomials,
const challenge_array&,
coefficient_array& linear_terms,
const size_t i = 0)
{
const Field& q_elliptic =
Getters::template get_value<EvaluationType::NON_SHIFTED, PolynomialIndex::Q_ELLIPTIC>(polynomials, i);

return linear_terms[0] * q_elliptic;
}

inline static void compute_non_linear_terms(PolyContainer&, const challenge_array&, Field&, const size_t = 0) {}

/**
* @brief Update opening scalars with the linear term from elliptic gate
*
* @param linear_terms Contains input scalar
* @param scalars Output map for updates
*/
inline static void update_kate_opening_scalars(coefficient_array& linear_terms,
std::map<std::string, Field>& scalars,
const challenge_array&)
{
scalars["Q_ELLIPTIC"] += linear_terms[0];
quotient += identity * q_elliptic;
}
};

Expand Down
Loading