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 @@ -20,16 +20,15 @@ template <typename FF_> class EccOpQueueRelationImpl {

template <typename AllEntities> inline static bool skip([[maybe_unused]] const AllEntities& in)
{
// The prover can skip execution of this relation altogether since an honest input will lead to a zero
// contribution at every row, even when the selector lagrange_ecc_op is on
return true;

Choose a reason for hiding this comment

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

i have thought at some point that this is bizzare but didn't get the chance to investigate it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I think this was just faulty/rushed thinking that got reinforced by an erroneously passing test

// The prover can skip execution of this relation if the ecc op selector is identically zero
return in.lagrange_ecc_op.is_zero();
}

/**
* @brief Expression for the generalized permutation sort gate.
* @details The relation is defined as C(in(X)...) =
* \alpha_{base} *
* ( \Sum_{i=0}^3 \alpha^i * (w_i - w_{op,i}) * \chi_{ecc_op} +
* ( \Sum_{i=0}^3 \alpha^i * (w_i_shift - w_{op,i}) * \chi_{ecc_op} +
* \Sum_{i=0}^3 \alpha^{i+4} w_{op,i} * \bar{\chi}_{ecc_op} )
*
* where w_{op,i} are the ecc op gate wires, \chi_{ecc_op} is the indicator for the portion of the domain
Expand All @@ -38,6 +37,8 @@ template <typename FF_> class EccOpQueueRelationImpl {
* The first four sub-relations check that the values in the conventional wires are identical to the values in the
* ecc op wires over the portion of the execution trace representing ECC op queue gates. The next four check
* that the op wire polynomials are identically zero everywhere else.
* @note This relation utilizes the shifted wires so that the ecc op wires can store the data begining at index 0,
* unlike the wires which contain an initial zero row to facilitate the left-shift-by-1 needed by other relations.

Choose a reason for hiding this comment

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

isn't it right-shift-by-1?

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 guess it depends how your reference but the things we label *_shift are the left shift by 1 of *

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so * is the right shift by 1 of *_shift if you like...

*
* @param evals transformed to `evals + C(in(X)...)*scaling_factor`
* @param in an std::array containing the fully extended Univariate edges.
Expand All @@ -57,10 +58,10 @@ template <typename FF_> class EccOpQueueRelationImpl {
// 3). To do a degree-1 multiplication in the coefficient basis requires 3 Fp muls and 4 Fp adds (karatsuba
// multiplication). But a multiplication of a degree-3 Univariate only requires 3 Fp muls.
// We still cast to CoefficientAccumulator so that the degree is extended to degree-3 from degree-1
auto w_1 = Accumulator(CoefficientAccumulator(in.w_l));
auto w_2 = Accumulator(CoefficientAccumulator(in.w_r));
auto w_3 = Accumulator(CoefficientAccumulator(in.w_o));
auto w_4 = Accumulator(CoefficientAccumulator(in.w_4));
auto w_1_shift = Accumulator(CoefficientAccumulator(in.w_l_shift));
auto w_2_shift = Accumulator(CoefficientAccumulator(in.w_r_shift));
auto w_3_shift = Accumulator(CoefficientAccumulator(in.w_o_shift));
auto w_4_shift = Accumulator(CoefficientAccumulator(in.w_4_shift));
auto op_wire_1 = Accumulator(CoefficientAccumulator(in.ecc_op_wire_1));
auto op_wire_2 = Accumulator(CoefficientAccumulator(in.ecc_op_wire_2));
auto op_wire_3 = Accumulator(CoefficientAccumulator(in.ecc_op_wire_3));
Expand All @@ -72,22 +73,22 @@ template <typename FF_> class EccOpQueueRelationImpl {
auto complement_ecc_op_by_scaling = -lagrange_by_scaling + scaling_factor;

// Contribution (1)
auto tmp = op_wire_1 - w_1;
auto tmp = op_wire_1 - w_1_shift;
tmp *= lagrange_by_scaling;
std::get<0>(accumulators) += tmp;

// Contribution (2)
tmp = op_wire_2 - w_2;
tmp = op_wire_2 - w_2_shift;
tmp *= lagrange_by_scaling;
std::get<1>(accumulators) += tmp;

// Contribution (3)
tmp = op_wire_3 - w_3;
tmp = op_wire_3 - w_3_shift;
tmp *= lagrange_by_scaling;
std::get<2>(accumulators) += tmp;

// Contribution (4)
tmp = op_wire_4 - w_4;
tmp = op_wire_4 - w_4_shift;
tmp *= lagrange_by_scaling;
std::get<3>(accumulators) += tmp;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ void TraceToPolynomials<Flavor>::add_ecc_op_wires_to_proving_key(Builder& builde
requires IsMegaFlavor<Flavor>
{
auto& ecc_op_selector = proving_key.polynomials.lagrange_ecc_op;
const size_t op_wire_offset = Flavor::has_zero_row ? 1 : 0;
const size_t wire_idx_offset = Flavor::has_zero_row ? 1 : 0;

// Copy the ecc op data from the conventional wires into the op wires over the range of ecc op gates
// Copy the ecc op data from the conventional wires into the op wires over the range of ecc op gates. The data is
// stored in the ecc op wires starting from index 0, whereas the wires contain the data offset by a zero row.
const size_t num_ecc_ops = builder.blocks.ecc_op.size();
for (auto [ecc_op_wire, wire] :
zip_view(proving_key.polynomials.get_ecc_op_wires(), proving_key.polynomials.get_wires())) {
for (size_t i = 0; i < num_ecc_ops; ++i) {
size_t idx = i + op_wire_offset;
ecc_op_wire.at(idx) = wire[idx];
ecc_op_selector.at(idx) = 1; // construct selector as the indicator on the ecc op block
ecc_op_wire.at(i) = wire[i + wire_idx_offset];
ecc_op_selector.at(i) = 1; // construct selector as the indicator on the ecc op block
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,11 @@ void DeciderProvingKey_<Flavor>::allocate_ecc_op_polynomials(const Circuit& circ
PROFILE_THIS_NAME("allocate_ecc_op_polynomials");

// Allocate the ecc op wires and selector
const size_t op_wire_offset = circuit.blocks.ecc_op.trace_offset;
const size_t ecc_op_block_size = circuit.blocks.ecc_op.get_fixed_size(is_structured);
for (auto& wire : proving_key.polynomials.get_ecc_op_wires()) {
wire = Polynomial(ecc_op_block_size, proving_key.circuit_size, op_wire_offset);
wire = Polynomial(ecc_op_block_size, proving_key.circuit_size);
}
proving_key.polynomials.lagrange_ecc_op = Polynomial(ecc_op_block_size, proving_key.circuit_size, op_wire_offset);
proving_key.polynomials.lagrange_ecc_op = Polynomial(ecc_op_block_size, proving_key.circuit_size);
}

template <IsUltraFlavor Flavor>
Expand Down