Skip to content

Commit 5c5ebcb

Browse files
author
notnotraju
committed
improve ECCVM subrelation enum names for accuracy and clarity
Rename 16 subrelation enum constants across MSM and transcript relations to be more descriptive and accurately reflect the constraint semantics. Key MSM renames: - ROUND_TRANSITION_NO_OP -> ROUND_TRANSITION_NEEDS_DOUBLE_OR_SKEW - NO_OP_ACC_X/Y -> IDLE_ROW_PRESERVES_ACC_X/Y - SELECTOR_EXCLUSIVITY -> PHASE_SELECTOR_MUTUAL_EXCLUSIVITY - DOUBLE_THEN_ADD -> DOUBLE_IMPLIES_NEXT_IS_ADD - SKEW_PROPAGATION -> SKEW_PERSISTS_UNTIL_MSM_TRANSITION Key transcript renames: - MSM_COUNT_RESET -> MSM_COUNT_ZERO_WHEN_NOT_MUL - MSM_COUNT_UPDATE -> MSM_COUNT_INCREMENT_ACROSS_ROWS
1 parent e5ee2db commit 5c5ebcb

4 files changed

Lines changed: 53 additions & 48 deletions

File tree

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation.hpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,24 @@ template <typename FF_> class ECCVMMSMRelationImpl {
6969
INACTIVE_SLICE_2 = 14,
7070
INACTIVE_SLICE_3 = 15,
7171
INACTIVE_SLICE_4 = 16,
72-
// Selector mutual exclusivity: at most one of q_add, q_double, q_skew active
73-
SELECTOR_EXCLUSIVITY = 17,
74-
// Round transition: round_delta is boolean (when not at MSM transition)
75-
ROUND_TRANSITION_BOOL = 18,
76-
// Round transition -> skew: if round transition and skew_shift, then round == 31
77-
ROUND_TRANSITION_SKEW = 19,
78-
// Round transition -> double or skew: exactly one must be active
79-
ROUND_TRANSITION_DOUBLE_OR_SKEW = 20,
80-
// Round transition: if neither double nor skew shift, round_delta must be 0
81-
ROUND_TRANSITION_NO_OP = 21,
82-
// Double implies next row is add
83-
DOUBLE_THEN_ADD = 22,
84-
// Count reset on round change
85-
COUNT_ZERO_ON_ROUND_CHANGE = 23,
86-
// Count update within same round
87-
COUNT_UPDATE = 24,
88-
// Count shift must be zero at round boundary or MSM transition
89-
COUNT_SHIFT_ZERO = 25,
72+
// Phase selector mutual exclusivity: at most one of q_add, q_double, q_skew active
73+
PHASE_SELECTOR_MUTUAL_EXCLUSIVITY = 17,
74+
// Round transition forces round_delta == 1
75+
ROUND_TRANSITION_FORCES_DELTA_ONE = 18,
76+
// Round transition with skew implies round == 31
77+
ROUND_TRANSITION_SKEW_IMPLIES_ROUND_31 = 19,
78+
// Round transition requires exactly one of double or skew on next row
79+
ROUND_TRANSITION_EXACTLY_ONE_DOUBLE_OR_SKEW = 20,
80+
// Round transition needs double or skew (cannot have neither)
81+
ROUND_TRANSITION_NEEDS_DOUBLE_OR_SKEW = 21,
82+
// Double implies next row is an add row
83+
DOUBLE_IMPLIES_NEXT_IS_ADD = 22,
84+
// Count shift must be zero when round changes
85+
COUNT_SHIFT_ZERO_ON_ROUND_CHANGE = 23,
86+
// Count increments within the same round by number of active adds
87+
COUNT_INCREMENT_WITHIN_ROUND = 24,
88+
// Count must be zero at round boundary or MSM transition
89+
COUNT_ZERO_AT_ROUND_BOUNDARY_OR_TRANSITION = 25,
9090
// MSM transition implies round = 0
9191
MSM_TRANSITION_ROUND_ZERO = 26,
9292
// MSM transition: pc = pc_shift + msm_size
@@ -101,12 +101,12 @@ template <typename FF_> class ECCVMMSMRelationImpl {
101101
ADD_CROSS_ROW_CONTINUITY = 31,
102102
// add1 = q_add + q_skew
103103
ADD1_DECOMPOSITION = 32,
104-
// q_skew propagation: if not at MSM transition, q_skew implies q_skew_shift
105-
SKEW_PROPAGATION = 33,
104+
// q_skew persists until MSM transition: q_skew && !msm_transition_shift => q_skew_shift
105+
SKEW_PERSISTS_UNTIL_MSM_TRANSITION = 33,
106106
// q_skew implies round == 32
107-
SKEW_ROUND_CHECK = 34,
108-
// If round_delta == 0, then q_double_shift == 0
109-
NO_ROUND_CHANGE_NO_DOUBLE = 35,
107+
SKEW_IMPLIES_ROUND_32 = 34,
108+
// Doubling requires a round change (round_delta must be 1 if q_double_shift)
109+
DOUBLE_REQUIRES_ROUND_CHANGE = 35,
110110
// Additional addition slope constraints (split to prevent cancellation)
111111
ADD_SLOPE_2 = 36,
112112
ADD_SLOPE_3 = 37,
@@ -119,9 +119,9 @@ template <typename FF_> class ECCVMMSMRelationImpl {
119119
SKEW_SLOPE_2 = 42,
120120
SKEW_SLOPE_3 = 43,
121121
SKEW_SLOPE_4 = 44,
122-
// No-op row: accumulator preservation when no selector is active
123-
NO_OP_ACC_X = 45,
124-
NO_OP_ACC_Y = 46,
122+
// Idle row: accumulator preserved when no phase selector is active
123+
IDLE_ROW_PRESERVES_ACC_X = 45,
124+
IDLE_ROW_PRESERVES_ACC_Y = 46,
125125
NUM_SUBRELATIONS,
126126
};
127127

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_msm_relation_impl.hpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ void ECCVMMSMRelationImpl<FF>::accumulate(ContainerOverSubrelations& accumulator
482482
// SELECTORS ARE MUTUALLY EXCLUSIVE
483483
// at most one of q_skew, q_double, q_add can be nonzero.
484484
// note that as we can expect our table to be zero padded, we _do not_ insist that q_add + q_double + q_skew == 1.
485-
std::get<SELECTOR_EXCLUSIVITY>(accumulator) +=
485+
std::get<PHASE_SELECTOR_MUTUAL_EXCLUSIVITY>(accumulator) +=
486486
(q_add * q_double + q_add * q_skew + q_double * q_skew) * scaling_factor;
487487

488488
// ACCUMULATOR PRESERVATION ON NO-OP ROWS
@@ -501,8 +501,10 @@ void ECCVMMSMRelationImpl<FF>::accumulate(ContainerOverSubrelations& accumulator
501501
// starts a fresh MSM whose accumulator is initialized via first_add, not by continuity.
502502
auto no_op_selector =
503503
(-q_add + 1) * (-q_double + 1) * (-q_skew + 1) * (-msm_transition + 1) * (-lagrange_first + 1); // degree 5
504-
std::get<NO_OP_ACC_X>(accumulator) += no_op_selector * (acc_x_shift - acc_x) * scaling_factor; // degree 6
505-
std::get<NO_OP_ACC_Y>(accumulator) += no_op_selector * (acc_y_shift - acc_y) * scaling_factor; // degree 6
504+
std::get<IDLE_ROW_PRESERVES_ACC_X>(accumulator) +=
505+
no_op_selector * (acc_x_shift - acc_x) * scaling_factor; // degree 6
506+
std::get<IDLE_ROW_PRESERVES_ACC_Y>(accumulator) +=
507+
no_op_selector * (acc_y_shift - acc_y) * scaling_factor; // degree 6
506508

507509
// Validate that if q_add = 1 or q_skew = 1, add1 also is 1
508510
// NOTE(#2222): could just get rid of add1 as a column, as it is a linear combination.
@@ -522,7 +524,7 @@ void ECCVMMSMRelationImpl<FF>::accumulate(ContainerOverSubrelations& accumulator
522524
// in particular, `round_transition` is boolean. (`round_delta` is not boolean precisely one step before an MSM
523525
// transition, but that does not concern us here.)
524526
const auto round_transition = round_delta * (-msm_transition_shift + 1);
525-
std::get<ROUND_TRANSITION_BOOL>(accumulator) += round_transition * (round_delta - 1) * scaling_factor;
527+
std::get<ROUND_TRANSITION_FORCES_DELTA_ONE>(accumulator) += round_transition * (round_delta - 1) * scaling_factor;
526528

527529
// If `round_transition == 1`, then `round_delta == 1` and `msm_transition_shift == 0`. Therefore, we wish to
528530
// constrain next row in the VM to either be a double (if `round != 31`) or skew (if `round == 31`). In either case,
@@ -537,21 +539,22 @@ void ECCVMMSMRelationImpl<FF>::accumulate(ContainerOverSubrelations& accumulator
537539
// similarly, if q_double_shift == 1, then round_transition == 0,
538540
// the fact that a round_transition occurs at the first time skew_shift == 1 follows from the fact that skew == 1
539541
// implies round == 32 and the above three relations, together with the _definition_ of round_transition.
540-
std::get<ROUND_TRANSITION_SKEW>(accumulator) += round_transition * q_skew_shift * (round - 31) * scaling_factor;
541-
std::get<ROUND_TRANSITION_DOUBLE_OR_SKEW>(accumulator) +=
542+
std::get<ROUND_TRANSITION_SKEW_IMPLIES_ROUND_31>(accumulator) +=
543+
round_transition * q_skew_shift * (round - 31) * scaling_factor;
544+
std::get<ROUND_TRANSITION_EXACTLY_ONE_DOUBLE_OR_SKEW>(accumulator) +=
542545
round_transition * (q_skew_shift + q_double_shift - 1) * scaling_factor;
543-
std::get<NO_ROUND_CHANGE_NO_DOUBLE>(accumulator) += (-round_delta + 1) * q_double_shift * scaling_factor;
546+
std::get<DOUBLE_REQUIRES_ROUND_CHANGE>(accumulator) += (-round_delta + 1) * q_double_shift * scaling_factor;
544547
// if the next is neither double nor skew, and we are not at an msm_transition, then round_delta = 0 and the next
545548
// "row" of our VM is processing the same wNAF digit place.
546-
std::get<ROUND_TRANSITION_NO_OP>(accumulator) +=
549+
std::get<ROUND_TRANSITION_NEEDS_DOUBLE_OR_SKEW>(accumulator) +=
547550
round_transition * (-q_double_shift + 1) * (-q_skew_shift + 1) * scaling_factor;
548551

549552
// CONSTRAINING Q_DOUBLE AND Q_SKEW
550553
// NOTE: we have already constrained q_add, q_skew, and q_double to be mutually exclusive.
551554

552555
// if double, next add = 1. As q_double, q_add, and q_skew are mutually exclusive, this suffices to force
553556
// q_double_shift == q_skew_shift == 0.
554-
std::get<DOUBLE_THEN_ADD>(accumulator) += q_double * (-q_add_shift + 1) * scaling_factor;
557+
std::get<DOUBLE_IMPLIES_NEXT_IS_ADD>(accumulator) += q_double * (-q_add_shift + 1) * scaling_factor;
555558
// if the current row has q_skew == 1 and the next row is _not_ an MSM transition, then q_skew_shift = 1.
556559
// this forces q_skew to precisely correspond to the rows where `round == 32`. Indeed, note that the first q_skew
557560
// bit is set correctly:
@@ -561,28 +564,29 @@ void ECCVMMSMRelationImpl<FF>::accumulate(ContainerOverSubrelations& accumulator
561564
// == 1.)
562565
// this means that the first row with `round == 32` has q_skew == 1. then all subsequent q_skew entries must be 1,
563566
// _until_ we start our new MSM.
564-
std::get<SKEW_PROPAGATION>(accumulator) +=
567+
std::get<SKEW_PERSISTS_UNTIL_MSM_TRANSITION>(accumulator) +=
565568
(-msm_transition_shift + 1) * q_skew * (-q_skew_shift + 1) * scaling_factor;
566569
// if q_skew == 1, then round == 32. This is almost certainly redundant but psychologically useful to "constrain
567570
// both ends".
568-
std::get<SKEW_ROUND_CHECK>(accumulator) += q_skew * (-round + 32) * scaling_factor;
571+
std::get<SKEW_IMPLIES_ROUND_32>(accumulator) += q_skew * (-round + 32) * scaling_factor;
569572

570573
// UPDATING THE COUNT
571574

572575
// if we are changing the `round` (i.e., starting to process a new wNAF digit or at an msm transition), the
573576
// count_shift must be 0.
574-
std::get<COUNT_ZERO_ON_ROUND_CHANGE>(accumulator) += round_delta * count_shift * scaling_factor;
577+
std::get<COUNT_SHIFT_ZERO_ON_ROUND_CHANGE>(accumulator) += round_delta * count_shift * scaling_factor;
575578
// if msm_transition_shift = 0 and round_delta = 0, then the next "row" of the VM is processing the same wNAF digit.
576579
// this means that the count must increase: count_shift = count + add1 + add2 + add3 + add4
577-
std::get<COUNT_UPDATE>(accumulator) += (-msm_transition_shift + 1) * (-round_delta + 1) *
578-
(count_shift - count - add1 - add2 - add3 - add4) * scaling_factor;
580+
std::get<COUNT_INCREMENT_WITHIN_ROUND>(accumulator) += (-msm_transition_shift + 1) * (-round_delta + 1) *
581+
(count_shift - count - add1 - add2 - add3 - add4) *
582+
scaling_factor;
579583

580584
// at least one of the following must be true:
581585
// the next step is an MSM transition;
582586
// the next count is zero (meaning we are starting the processing of a new wNAF digit)
583587
// the next step is processing the same wNAF digit (i.e., round_delta == 0)
584588
// (note that at the start of a new MSM, the count is also zero, so the above are not mutually exclusive.)
585-
std::get<COUNT_SHIFT_ZERO>(accumulator) +=
589+
std::get<COUNT_ZERO_AT_ROUND_BOUNDARY_OR_TRANSITION>(accumulator) +=
586590
is_not_first_row * (-msm_transition_shift + 1) * round_delta * count_shift * scaling_factor;
587591

588592
// if msm_transition = 1, then round = 0.

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ template <typename FF_> class ECCVMTranscriptRelationImpl {
4949
MSM_COUNT_ZERO_AT_TRANSITION = 4,
5050
// MSM transition: msm_transition = q_mul * (1 - q_mul_shift) * (1 - msm_count_zero_at_transition)
5151
MSM_TRANSITION = 5,
52-
// MSM count reset: msm_count = 0 when not at a mul op
53-
MSM_COUNT_RESET = 6,
54-
// MSM count update: msm_count increments correctly during mul ops
55-
MSM_COUNT_UPDATE = 7,
52+
// MSM count zero when not at a mul op
53+
MSM_COUNT_ZERO_WHEN_NOT_MUL = 6,
54+
// MSM count increments correctly across mul rows
55+
MSM_COUNT_INCREMENT_ACROSS_ROWS = 7,
5656
// Opcode exclusion: q_mul and q_add are mutually exclusive with other opcodes
5757
OPCODE_EXCLUSION = 8,
5858
// Equality check x-coordinate

barretenberg/cpp/src/barretenberg/relations/ecc_vm/ecc_transcript_relation_impl.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,17 @@ void ECCVMTranscriptRelationImpl<FF>::accumulate(ContainerOverSubrelations& accu
195195
* @note this in particular "resets" the msm_count when we are done with an msm.
196196
*/
197197

198-
std::get<MSM_COUNT_RESET>(accumulator) += ((-q_mul + 1) * msm_count) * scaling_factor; // degree 2
198+
std::get<MSM_COUNT_ZERO_WHEN_NOT_MUL>(accumulator) += ((-q_mul + 1) * msm_count) * scaling_factor; // degree 2
199199

200200
/**
201201
* @brief Validate `msm_count` updates correctly for mul operations.
202202
* msm_count updates by (!z1_zero + !z2_zero) if current op is a mul instruction with the point _not_ the
203203
* point-at-infinity and msm is not terminating at next row.
204204
*/
205205
auto msm_count_delta = msm_count_shift - msm_count;
206-
std::get<MSM_COUNT_UPDATE>(accumulator) += is_not_first_row * (-msm_transition + 1) *
207-
(msm_count_delta - q_mul * num_muls_in_row) * scaling_factor; // degree 5
206+
std::get<MSM_COUNT_INCREMENT_ACROSS_ROWS>(accumulator) += is_not_first_row * (-msm_transition + 1) *
207+
(msm_count_delta - q_mul * num_muls_in_row) *
208+
scaling_factor; // degree 5
208209

209210
/**
210211
* @brief Opcode exclusion tests. We have the following assertions:

0 commit comments

Comments
 (0)