Skip to content

Commit

Permalink
chore: remove stale zk constants and methods (#11715)
Browse files Browse the repository at this point in the history
We're using sumcheck with disabled rows that does not require all the
constants that I introduced a while ago with an implementation of a
different witness masking technique.
  • Loading branch information
iakovenkos authored Feb 5, 2025
1 parent 255b3d8 commit 7a2870f
Show file tree
Hide file tree
Showing 33 changed files with 13 additions and 485 deletions.
2 changes: 0 additions & 2 deletions barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class ECCVMFlavor {
static constexpr size_t NUM_SHIFTED_ENTITIES = 26;
// The number of entities in DerivedWitnessEntities that are not going to be shifted.
static constexpr size_t NUM_DERIVED_WITNESS_ENTITIES_NON_SHIFTED = 1;
// The total number of witnesses including shifts and derived entities.
static constexpr size_t NUM_ALL_WITNESS_ENTITIES = NUM_WITNESS_ENTITIES + NUM_SHIFTED_ENTITIES;
// A container to be fed to ShpleminiVerifier to avoid redundant scalar muls, the first number is the index of the
// first witness to be shifted.
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS =
Expand Down
16 changes: 4 additions & 12 deletions barretenberg/cpp/src/barretenberg/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,11 @@ auto get_unshifted_then_shifted(const auto& all_entities)
* @details The "partial length" of a relation is 1 + the degree of the relation, where any challenges used in the
* relation are as constants, not as variables..
*/
template <typename Tuple, bool ZK = false> constexpr size_t compute_max_partial_relation_length()
template <typename Tuple> constexpr size_t compute_max_partial_relation_length()
{
constexpr auto seq = std::make_index_sequence<std::tuple_size_v<Tuple>>();
return []<std::size_t... Is>(std::index_sequence<Is...>) {
if constexpr (ZK) {
return std::max({ std::tuple_element_t<Is, Tuple>::ZK_RELATION_LENGTH... });
} else {
return std::max({ std::tuple_element_t<Is, Tuple>::RELATION_LENGTH... });
}
return std::max({ std::tuple_element_t<Is, Tuple>::RELATION_LENGTH... });
}(seq);
}

Expand All @@ -259,15 +255,11 @@ template <typename Tuple, bool ZK = false> constexpr size_t compute_max_partial_
* @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.
*/
template <typename Tuple, bool ZK = false> constexpr size_t compute_max_total_relation_length()
template <typename Tuple> constexpr size_t compute_max_total_relation_length()
{
constexpr auto seq = std::make_index_sequence<std::tuple_size_v<Tuple>>();
return []<std::size_t... Is>(std::index_sequence<Is...>) {
if constexpr (ZK) {
return std::max({ std::tuple_element_t<Is, Tuple>::ZK_TOTAL_RELATION_LENGTH... });
} else {
return std::max({ std::tuple_element_t<Is, Tuple>::TOTAL_RELATION_LENGTH... });
}
return std::max({ std::tuple_element_t<Is, Tuple>::TOTAL_RELATION_LENGTH... });
}(seq);
}

Expand Down
15 changes: 0 additions & 15 deletions barretenberg/cpp/src/barretenberg/relations/auxiliary_relation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,6 @@ template <typename FF_> class AuxiliaryRelationImpl {
6, // RAM consistency sub-relation 2
6 // RAM consistency sub-relation 3
};
/**
* @brief For ZK-Flavors: The degrees of subrelations considered as polynomials only in witness polynomials,
* i.e. all selectors and public polynomials are treated as constants.
*
*/
static constexpr std::array<size_t, 6> SUBRELATION_WITNESS_DEGREES{
2, // auxiliary sub-relation;
2, // ROM consistency sub-relation 1: adjacent values match if adjacent indices match and next access is a read
// operation
2, // ROM consistency sub-relation 2: index is monotonously increasing
3, // RAM consistency sub-relation 1: adjacent values match if adjacent indices match and next access is a read
// operation
2, // RAM consistency sub-relation 2: index is monotonously increasing
2 // RAM consistency sub-relation 3: next gate access type is boolean
};

static constexpr std::array<size_t, 6> TOTAL_LENGTH_ADJUSTMENTS{
1, // auxiliary sub-relation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,6 @@ template <typename FF_> class DatabusLookupRelationImpl {
LOOKUP_SUBREL_LENGTH // log-derivative lookup argument subrelation (bus_idx 2)
};

static constexpr size_t INVERSE_SUBREL_WITNESS_DEGREE = 4; // witness degree of inverse correctness subrelation
static constexpr size_t LOOKUP_SUBREL_WITNESS_DEGREE = 4; // witness degree of log-deriv lookup subrelation

/**
* @brief For ZK-Flavors: Upper bound on the degrees of subrelations considered as polynomials only in witness
* polynomials, i.e. all selectors and public polynomials are treated as constants. The subrelation witness degree
* does not exceed the subrelation partial degree, which is given by LENGTH - 1 in this case.
*/
static constexpr std::array<size_t, NUM_BUS_COLUMNS * 2> SUBRELATION_WITNESS_DEGREES{
INVERSE_SUBREL_WITNESS_DEGREE, // inverse polynomial correctness subrelation (bus_idx 0)
LOOKUP_SUBREL_WITNESS_DEGREE, // log-derivative lookup argument subrelation (bus_idx 0)
INVERSE_SUBREL_WITNESS_DEGREE, // inverse polynomial correctness subrelation (bus_idx 1)
LOOKUP_SUBREL_WITNESS_DEGREE, // log-derivative lookup argument subrelation (bus_idx 1)
INVERSE_SUBREL_WITNESS_DEGREE, // inverse polynomial correctness subrelation (bus_idx 2)
LOOKUP_SUBREL_WITNESS_DEGREE // log-derivative lookup argument subrelation (bus_idx 2)
};

static constexpr bool INVERSE_SUBREL_LIN_INDEPENDENT = true; // to be satisfied independently at each row
static constexpr bool LOOKUP_SUBREL_LIN_INDEPENDENT = false; // to be satisfied as a sum across all rows

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ template <typename FF_> class DeltaRangeConstraintRelationImpl {
6, // range constrain sub-relation 3
6 // range constrain sub-relation 4
};
/**
* @brief For ZK-Flavors: The degrees of subrelations considered as polynomials only in witness polynomials,
* i.e. all selectors and public polynomials are treated as constants.
*
*/
static constexpr std::array<size_t, 4> SUBRELATION_WITNESS_DEGREES{
3, // range constrain sub-relation 1
3, // range constrain sub-relation 2
3, // range constrain sub-relation 3
3 // range constrain sub-relation 4
};

/**
* @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,6 @@ template <typename FF_> class EccOpQueueRelationImpl {
3, // op-queue-wire vanishes sub-relation 3
3 // op-queue-wire vanishes sub-relation 4
};
/**
* @brief For ZK-Flavors: The degrees of subrelations considered as polynomials only in witness polynomials,
* i.e. all selectors and public polynomials are treated as constants.
*
*/
static constexpr std::array<size_t, 8> SUBRELATION_WITNESS_DEGREES{
1, // wire - op-queue-wire consistency sub-relation 1
1, // wire - op-queue-wire consistency sub-relation 2
1, // wire - op-queue-wire consistency sub-relation 3
1, // wire - op-queue-wire consistency sub-relation 4
1, // op-queue-wire vanishes sub-relation 1
1, // op-queue-wire vanishes sub-relation 2
1, // op-queue-wire vanishes sub-relation 3
1 // op-queue-wire vanishes sub-relation 4
};

template <typename AllEntities> inline static bool skip([[maybe_unused]] const AllEntities& in)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ template <typename FF_> class ECCVMBoolsRelationImpl {
static constexpr std::array<size_t, 19> SUBRELATION_PARTIAL_LENGTHS{
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
};
/**
* @brief For ZK-Flavors: Upper bound on the degrees of subrelations considered as polynomials only in witness
polynomials,
* i.e. all selectors and public polynomials are treated as constants. The subrelation witness degree does not
* exceed the subrelation partial degree given by SUBRELATION_PARTIAL_LENGTH - 1.
*/
static constexpr std::array<size_t, 19> SUBRELATION_WITNESS_DEGREES{
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
};

// Max among {SUBRELATION_PARTIAL_LENGTH + SUBRELATION_WITNESS_DEGREE}
static constexpr size_t ZK_RELATION_LENGTH = 5;

template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
static void accumulate(ContainerOverSubrelations& accumulator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@ template <typename FF_> class ECCVMLookupRelationImpl {
LENGTH, // grand product construction sub-relation
LENGTH // left-shiftable polynomial sub-relation
};
/**
* @brief For ZK-Flavors: Upper bound on the degrees of subrelations considered as polynomials only in witness
polynomials,
* i.e. all selectors and public polynomials are treated as constants. The subrelation witness degree does not
* exceed the subrelation partial degree given by LENGTH - 1.
*/
static constexpr std::array<size_t, 2> SUBRELATION_WITNESS_DEGREES{
LENGTH - 1, // grand product construction sub-relation
LENGTH - 1 // left-shiftable polynomial sub-relation
};

// Max among {SUBRELATION_PARTIAL_LENGTH + SUBRELATION_WITNESS_DEGREE}
static constexpr size_t ZK_RELATION_LENGTH = 17;

static constexpr std::array<bool, 2> SUBRELATION_LINEARLY_INDEPENDENT = { true, false };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ template <typename FF_> class ECCVMMSMRelationImpl {
static constexpr std::array<size_t, 36> SUBRELATION_PARTIAL_LENGTHS{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 };
/**
* @brief Upper bound on the degrees of subrelations considered as polynomials only in witness polynomials,
* i.e. all selectors and public polynomials are treated as constants. The subrelation witness degree does not
* exceed the subrelation partial degree given by SUBRELATION_PARTIAL_LENGTH - 1.
*/
static constexpr std::array<size_t, 36> SUBRELATION_WITNESS_DEGREES{ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 };
// Max among {SUBRELATION_PARTIAL_LENGTH + SUBRELATION_WITNESS_DEGREE}
static constexpr size_t ZK_RELATION_LENGTH = 15;

template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
static void accumulate(ContainerOverSubrelations& accumulator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,8 @@ namespace bb {
template <typename FF_> class ECCVMPointTableRelationImpl {
public:
using FF = FF_;
static constexpr size_t ZK_RELATION_LENGTH = 11;

static constexpr std::array<size_t, 6> SUBRELATION_PARTIAL_LENGTHS{ 6, 6, 6, 6, 6, 6 };
/**
* @brief For ZK-Flavors: Upper bound on the degrees of subrelations considered as polynomials only in witness
polynomials,
* i.e. all selectors and public polynomials are treated as constants. The subrelation witness degree does not
* exceed the subrelation partial degree given by SUBRELATION_PARTIAL_LENGTH - 1.
*/
static constexpr std::array<size_t, 6> SUBRELATION_WITNESS_DEGREES{ 5, 5, 5, 5, 5, 5 };

template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
static void accumulate(ContainerOverSubrelations& accumulator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ template <typename FF_> class ECCVMSetRelationImpl {
22, // grand product construction sub-relation
3 // left-shiftable polynomial sub-relation
};
/**
* @brief For ZK-Flavors: Upper bound on the degrees of subrelations considered as polynomials only in witness
polynomials,
* i.e. all selectors and public polynomials are treated as constants. The subrelation witness degree does not
* exceed the subrelation partial degree given by SUBRELATION_PARTIAL_LENGTH - 1.
*/
static constexpr std::array<size_t, 2> SUBRELATION_WITNESS_DEGREES{
21, // grand product construction sub-relation
1 // left-shiftable polynomial sub-relation
};

// Max among {SUBRELATION_PARTIAL_LENGTH + SUBRELATION_WITNESS_DEGREE}
static constexpr size_t ZK_RELATION_LENGTH = 43;

template <typename Accumulator> static Accumulator convert_to_wnaf(const auto& s0, const auto& s1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,7 @@ template <typename FF_> class ECCVMTranscriptRelationImpl {
static constexpr std::array<size_t, 25> SUBRELATION_PARTIAL_LENGTHS{
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
};
/**
* @brief Upper bound on the degrees of subrelations considered as polynomials only in
witness polynomials,
* i.e. all selectors and public polynomials are treated as constants. The subrelation witness degree does
not
* exceed the subrelation partial degree given by SUBRELATION_PARTIAL_LENGTH - 1.
*/
static constexpr std::array<size_t, 25> SUBRELATION_WITNESS_DEGREES{
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
};
// Max among {SUBRELATION_PARTIAL_LENGTH + SUBRELATION_WITNESS_DEGREE}
static constexpr size_t ZK_RELATION_LENGTH = 15;

template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
static void accumulate(ContainerOverSubrelations& accumulator,
const AllEntities& in,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ template <typename FF_> class ECCVMWnafRelationImpl {
static constexpr std::array<size_t, 21> SUBRELATION_PARTIAL_LENGTHS{
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
};
/**
* @brief For ZK-Flavors: Upper bound on the degrees of subrelations considered as polynomials only in witness
polynomials,
* i.e. all selectors and public polynomials are treated as constants. The subrelation witness degree does not
* exceed the subrelation partial degree given by SUBRELATION_PARTIAL_LENGTH - 1.
*/
static constexpr std::array<size_t, 21> SUBRELATION_WITNESS_DEGREES{
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
};

// Max among {SUBRELATION_PARTIAL_LENGTH + SUBRELATION_WITNESS_DEGREE}
static constexpr size_t ZK_RELATION_LENGTH = 9;

template <typename ContainerOverSubrelations, typename AllEntities, typename Parameters>
static void accumulate(ContainerOverSubrelations& accumulator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ template <typename FF_> class EllipticRelationImpl {
6, // x-coordinate sub-relation
6, // y-coordinate sub-relation
};
/**
* @brief For ZK-Flavors: The degrees of subrelations considered as polynomials only in witness polynomials,
* i.e. all selectors and public polynomials are treated as constants.
*
*/
static constexpr std::array<size_t, 2> SUBRELATION_WITNESS_DEGREES{
3, // x-coordinate sub-relation
3, // y-coordinate sub-relation (because of point doubling)
};

/**
* @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ template <typename FF_> class LogDerivLookupRelationImpl {
LENGTH, // inverse construction sub-relation
LENGTH // log derivative lookup argument sub-relation
};
/**
* @brief For ZK-Flavors: The degrees of subrelations considered as polynomials only in witness polynomials,
* i.e. all selectors and public polynomials are treated as constants.
*
*/
static constexpr std::array<size_t, 2> SUBRELATION_WITNESS_DEGREES{
2, // inverse construction sub-relation
3, // log derivative lookup argument sub-relation
};

// Note: the required correction for the second sub-relation is technically +1 but the two corrections must agree
// due to the way the relation algebra is written so both are set to +2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ template <typename FF_> class UltraPermutationRelationImpl {
0 // left-shiftable polynomial sub-relation
};

/**
* @brief For ZK-Flavors: The degrees of subrelations considered as polynomials only in witness polynomials,
* i.e. all selectors and public polynomials are treated as constants.
*
*/
static constexpr std::array<size_t, 2> SUBRELATION_WITNESS_DEGREES{
5, // grand product construction sub-relation
1 // left-shiftable polynomial sub-relation
};

/**
* @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ template <typename FF_> class Poseidon2ExternalRelationImpl {
7, // external poseidon2 round sub-relation for third value
7, // external poseidon2 round sub-relation for fourth value
};
/**
* @brief For ZK-Flavors: The degrees of subrelations considered as polynomials only in witness polynomials,
* i.e. all selectors and public polynomials are treated as constants.
*
*/
static constexpr std::array<size_t, 4> SUBRELATION_WITNESS_DEGREES{
5, // external poseidon2 round sub-relation for first value
5, // external poseidon2 round sub-relation for second value
5, // external poseidon2 round sub-relation for third value
5, // external poseidon2 round sub-relation for fourth value
};

/**
* @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ template <typename FF_> class Poseidon2InternalRelationImpl {
7, // internal poseidon2 round sub-relation for third value
7, // internal poseidon2 round sub-relation for fourth value
};
/**
* @brief For ZK-Flavors: The degrees of subrelations considered as polynomials only in witness polynomials,
* i.e. all selectors and public polynomials are treated as constants.
*
*/
static constexpr std::array<size_t, 4> SUBRELATION_WITNESS_DEGREES{
5, // external poseidon2 round sub-relation for first value
5, // external poseidon2 round sub-relation for second value
5, // external poseidon2 round sub-relation for third value
5, // external poseidon2 round sub-relation for fourth value
};

/**
* @brief Returns true if the contribution from all subrelations for the provided inputs is identically zero
Expand Down
Loading

1 comment on commit 7a2870f

@AztecBot
Copy link
Collaborator

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 7a2870f Previous: 08fc279 Ratio
commit(t) 2902792846 ns/iter 2680544585 ns/iter 1.08

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ludamad @codygunton

Please sign in to comment.