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 @@ -114,7 +114,7 @@ constexpr std::tuple<size_t, size_t> HONK_RECURSION_CONSTANTS(
// ========================================

// Gate count for Chonk recursive verification (Ultra with RollupIO)
inline constexpr size_t CHONK_RECURSION_GATES = 1563538;
inline constexpr size_t CHONK_RECURSION_GATES = 1563553;

// ========================================
// Hypernova Recursion Constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@

namespace bb {

namespace detail {
template <typename> struct ref_array_extent;
template <typename T, std::size_t N> struct ref_array_extent<RefArray<T, N>> {
static constexpr std::size_t value = N;
};
} // namespace detail

class TranslatorFlavor {

public:
Expand Down Expand Up @@ -586,17 +593,23 @@ class TranslatorFlavor {

/**
* @brief All unshifted polynomials for PCS (excludes computable precomputed, includes concatenated).
* @details masking(1) + ordered_extra(1) + op(1) + ordered(5) + z_perm(1) + concat(5) = 14
* @details masking(1) + ordered_extra(1) + op(1) + op_queue_tbs(3) + ordered(5) + z_perm(1) + concat(5) = 17
*
* The op-queue to-be-shifted wires (x_lo_y_hi, x_hi_z_1, y_lo_z_2) appear here in addition to
* get_pcs_to_be_shifted because the decomposition relation reads them both unshifted (e.g. `x_lo`)
* and shift-by-1 (e.g. `y_hi`) at the same row. Without registering the unshifted opening, the
* unshifted MLE evaluations at the sumcheck point would be unconstrained.
*/
auto get_pcs_unshifted()
{
return concatenate(
MaskingEntities<DataType>::get_all(), // gemini_masking_poly
RefArray<DataType, 1>{ this->ordered_extra_range_constraints_numerator }, // non-computable precomputed
WireNonshiftedEntities<DataType>::get_all(), // op (from merge protocol)
OrderedRangeConstraints<DataType>::get_all(), // ordered_0..4
DerivedWitnessEntities<DataType>::get_all(), // z_perm
ConcatenatedPolynomials<DataType>::get_all()); // concat_0..4
OpQueueWiresToBeShiftedEntities<DataType>::get_all(), // x_lo_y_hi, x_hi_z_1, y_lo_z_2
OrderedRangeConstraints<DataType>::get_all(), // ordered_0..4
DerivedWitnessEntities<DataType>::get_all(), // z_perm
ConcatenatedPolynomials<DataType>::get_all()); // concat_0..4
}

/**
Expand Down Expand Up @@ -711,9 +724,11 @@ class TranslatorFlavor {
"Range constraint wires must fill exactly 4 concatenation groups");

// PCS batch sizes
static constexpr size_t NUM_UNSHIFTED_WITNESSES_WITHOUT_CONCATENATED = WireNonshiftedEntities<FF>::_members_size +
OrderedRangeConstraints<FF>::_members_size +
DerivedWitnessEntities<FF>::_members_size;
// Note: op-queue to-be-shifted wires (x_lo_y_hi, x_hi_z_1, y_lo_z_2) are registered in BOTH the
// unshifted and shifted PCS batches because the decomposition relation reads them in both forms.
static constexpr size_t NUM_UNSHIFTED_WITNESSES_WITHOUT_CONCATENATED =
WireNonshiftedEntities<FF>::_members_size + OpQueueWiresToBeShiftedEntities<FF>::_members_size +
OrderedRangeConstraints<FF>::_members_size + DerivedWitnessEntities<FF>::_members_size;
static constexpr size_t NUM_TO_BE_SHIFTED = OpQueueWiresToBeShiftedEntities<FF>::_members_size +
OrderedRangeConstraints<FF>::_members_size +
DerivedWitnessEntities<FF>::_members_size;
Expand All @@ -731,17 +746,20 @@ class TranslatorFlavor {

// A container to be fed to ShpleminiVerifier to avoid redundant scalar muls.
// Identifies commitments that appear in both the unshifted and shifted batches:
// Unshifted batch: masking(1) + ordered_extra(1) + op(1) + ordered(5) + z_perm(1) + concat(5) = 14
// Unshifted batch: masking(1) + ordered_extra(1) + op(1) + op_queue_tbs(3) + ordered(5) + z_perm(1) + concat(5)
// = 17
// Shifted batch: op_queue(3) + ordered(5) + z_perm(1) + concat(5) = 14
// Range 1: ordered(5) + z_perm(1) — stored indices 2..7 (unshifted) ↔ 16..21 (shifted)
// Range 2: concatenated(5) — stored indices 8..12 (unshifted) ↔ 22..26 (shifted)
// Range 1: op_queue_tbs(3) + ordered(5) + z_perm(1) = 9 (contiguous in both batches)
// stored indices 2..10 (unshifted) ↔ 16..24 (shifted)
// Range 2: concatenated(5) — stored indices 11..15 (unshifted) ↔ 25..29 (shifted)
// (Stored indices are 0-based after ZK offset; offset=2 accounts for Q_commitment + gemini_masking_poly)
static constexpr size_t NUM_OP_QUEUE_TO_BE_SHIFTED = OpQueueWiresToBeShiftedEntities<FF>::_members_size;
static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS =
RepeatedCommitmentsData(2,
2 + NUM_PCS_TO_BE_SHIFTED,
NUM_ORDERED_RANGE + 1,
2 + NUM_ORDERED_RANGE + 1,
2 + NUM_PCS_TO_BE_SHIFTED + NUM_ORDERED_RANGE + 1,
NUM_OP_QUEUE_TO_BE_SHIFTED + NUM_ORDERED_RANGE + 1,
2 + NUM_OP_QUEUE_TO_BE_SHIFTED + NUM_ORDERED_RANGE + 1,
2 + NUM_PCS_TO_BE_SHIFTED + NUM_OP_QUEUE_TO_BE_SHIFTED + NUM_ORDERED_RANGE + 1,
NUM_CONCATENATED_POLYS);

static constexpr size_t PROOF_LENGTH =
Expand Down Expand Up @@ -1249,4 +1267,17 @@ class TranslatorFlavor {
using VerifierCommitments = VerifierCommitments_<Commitment, VerificationKey>;
};

// Guard against drift between the runtime PCS entity lists and their compile-time counts;
// REPEATED_COMMITMENTS and PROOF_LENGTH depend on these counts and desync silently otherwise.
static_assert(detail::ref_array_extent<decltype(std::declval<TranslatorFlavor::AllEntities<TranslatorFlavor::FF>&>()
.get_pcs_unshifted())>::value ==
TranslatorFlavor::NUM_PCS_UNSHIFTED,
"get_pcs_unshifted() entity count must equal NUM_PCS_UNSHIFTED. If you added a witness entity, "
"update both the runtime list and NUM_UNSHIFTED_WITNESSES_WITHOUT_CONCATENATED.");
static_assert(detail::ref_array_extent<decltype(std::declval<TranslatorFlavor::AllEntities<TranslatorFlavor::FF>&>()
.get_pcs_to_be_shifted())>::value ==
TranslatorFlavor::NUM_PCS_TO_BE_SHIFTED,
"get_pcs_to_be_shifted() entity count must equal NUM_PCS_TO_BE_SHIFTED. If you added a to-be-shifted "
"entity, update both the runtime list and NUM_TO_BE_SHIFTED.");

} // namespace bb
Loading