Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ecc_msm_relation.hpp
Go to the documentation of this file.
1
// === AUDIT STATUS ===
2
// internal: { status: Complete, auditors: [Raju], commit: 2a49eb6 }
3
// external_1: { status: not started, auditors: [], commit: }
4
// external_2: { status: not started, auditors: [], commit: }
5
// =====================
6
7
#pragma once
8
#include "
barretenberg/relations/relation_types.hpp
"
9
10
namespace
bb
{
11
43
template
<
typename
FF_>
class
ECCVMMSMRelationImpl
{
44
public
:
45
using
FF
= FF_;
46
47
// Named subrelation indices — matches SUBRELATION_PARTIAL_LENGTHS ordering.
48
// Grouped by logical function within the Strauss MSM algorithm.
49
enum
SubrelationIndex
:
size_t
{
50
// Addition round: accumulator update and slope constraints
51
ADD_ACC_X
= 0,
52
ADD_ACC_Y
= 1,
53
ADD_SLOPE_1
= 2,
54
ADD_SLOPE_2
= 3,
55
ADD_SLOPE_3
= 4,
56
ADD_SLOPE_4
= 5,
57
// Doubling round: accumulator update and slope constraint
58
DOUBLE_ACC_X
= 6,
59
DOUBLE_ACC_Y
= 7,
60
DOUBLE_SLOPE_1
= 8,
61
DOUBLE_SLOPE_2
= 9,
62
DOUBLE_SLOPE_3
= 10,
63
DOUBLE_SLOPE_4
= 11,
64
// Skew round: accumulator update and slope constraint
65
SKEW_ACC_X
= 12,
66
SKEW_ACC_Y
= 13,
67
SKEW_SLOPE_1
= 14,
68
SKEW_SLOPE_2
= 15,
69
SKEW_SLOPE_3
= 16,
70
SKEW_SLOPE_4
= 17,
71
// Collision checks: x-coordinate non-equality for point additions
72
COLLISION_CHECK_1
= 18,
73
COLLISION_CHECK_2
= 19,
74
COLLISION_CHECK_3
= 20,
75
COLLISION_CHECK_4
= 21,
76
// Inactive slice zeroing: force slice_i = 0 when add_i = 0
77
INACTIVE_SLICE_1
= 22,
78
INACTIVE_SLICE_2
= 23,
79
INACTIVE_SLICE_3
= 24,
80
INACTIVE_SLICE_4
= 25,
81
// Phase selector mutual exclusivity: at most one of q_add, q_double, q_skew active
82
PHASE_SELECTOR_MUTUAL_EXCLUSIVITY
= 26,
83
// Round transition forces round_delta == 1
84
ROUND_TRANSITION_FORCES_DELTA_ONE
= 27,
85
// Round transition with skew implies round == 31
86
ROUND_TRANSITION_SKEW_IMPLIES_ROUND_31
= 28,
87
// Round transition requires exactly one of double or skew on next row
88
ROUND_TRANSITION_EXACTLY_ONE_DOUBLE_OR_SKEW
= 29,
89
// Round transition needs double or skew (cannot have neither)
90
ROUND_TRANSITION_NEEDS_DOUBLE_OR_SKEW
= 30,
91
// Double implies next row is an add row
92
DOUBLE_IMPLIES_NEXT_IS_ADD
= 31,
93
// Count shift must be zero when round changes
94
COUNT_SHIFT_ZERO_ON_ROUND_CHANGE
= 32,
95
// Count increments within the same round by number of active adds
96
COUNT_INCREMENT_WITHIN_ROUND
= 33,
97
// Count must be zero at round boundary or MSM transition
98
COUNT_ZERO_AT_ROUND_BOUNDARY_OR_TRANSITION
= 34,
99
// MSM transition implies round = 0
100
MSM_TRANSITION_ROUND_ZERO
= 35,
101
// MSM transition: pc = pc_shift + msm_size
102
MSM_TRANSITION_PC
= 36,
103
// Addition continuity: add2 requires add1
104
ADD_CONTINUITY_2
= 37,
105
// Addition continuity: add3 requires add2
106
ADD_CONTINUITY_3
= 38,
107
// Addition continuity: add4 requires add3
108
ADD_CONTINUITY_4
= 39,
109
// Cross-row continuity: if add spans two rows, add4 must be 1
110
ADD_CROSS_ROW_CONTINUITY
= 40,
111
// add1 = q_add + q_skew
112
ADD1_DECOMPOSITION
= 41,
113
// q_skew persists until MSM transition: q_skew && !msm_transition_shift => q_skew_shift
114
SKEW_PERSISTS_UNTIL_MSM_TRANSITION
= 42,
115
// q_skew implies round == 32
116
SKEW_IMPLIES_ROUND_32
= 43,
117
// Doubling requires a round change (round_delta must be 1 if q_double_shift)
118
DOUBLE_REQUIRES_ROUND_CHANGE
= 44,
119
// Idle row: accumulator preserved when no phase selector is active
120
IDLE_ROW_PRESERVES_ACC_X
= 45,
121
IDLE_ROW_PRESERVES_ACC_Y
= 46,
122
NUM_SUBRELATIONS
,
123
};
124
125
static
constexpr
std::array<size_t, 47>
SUBRELATION_PARTIAL_LENGTHS
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
126
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
127
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 };
128
static_assert
(
NUM_SUBRELATIONS
==
SUBRELATION_PARTIAL_LENGTHS
.size());
129
130
template
<
typename
ContainerOverSubrelations,
typename
AllEntities,
typename
Parameters>
131
static
void
accumulate
(ContainerOverSubrelations& accumulator,
132
const
AllEntities& in,
133
const
Parameters&
/* unused */
,
134
const
FF
& scaling_factor);
135
};
136
137
template
<
typename
FF>
using
ECCVMMSMRelation
=
Relation<ECCVMMSMRelationImpl<FF>
>;
138
139
}
// namespace bb
bb::ECCVMMSMRelationImpl
MSM relations that evaluate the Strauss multiscalar multiplication algorithm.
Definition
ecc_msm_relation.hpp:43
bb::ECCVMMSMRelationImpl::accumulate
static void accumulate(ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters &, const FF &scaling_factor)
MSM relations that evaluate the Strauss multiscalar multiplication algorithm.
Definition
ecc_msm_relation_impl.hpp:48
bb::ECCVMMSMRelationImpl::SUBRELATION_PARTIAL_LENGTHS
static constexpr std::array< size_t, 47 > SUBRELATION_PARTIAL_LENGTHS
Definition
ecc_msm_relation.hpp:125
bb::ECCVMMSMRelationImpl::FF
FF_ FF
Definition
ecc_msm_relation.hpp:45
bb::ECCVMMSMRelationImpl::SubrelationIndex
SubrelationIndex
Definition
ecc_msm_relation.hpp:49
bb::ECCVMMSMRelationImpl::DOUBLE_SLOPE_4
@ DOUBLE_SLOPE_4
Definition
ecc_msm_relation.hpp:63
bb::ECCVMMSMRelationImpl::ADD_CONTINUITY_3
@ ADD_CONTINUITY_3
Definition
ecc_msm_relation.hpp:106
bb::ECCVMMSMRelationImpl::COUNT_INCREMENT_WITHIN_ROUND
@ COUNT_INCREMENT_WITHIN_ROUND
Definition
ecc_msm_relation.hpp:96
bb::ECCVMMSMRelationImpl::COUNT_SHIFT_ZERO_ON_ROUND_CHANGE
@ COUNT_SHIFT_ZERO_ON_ROUND_CHANGE
Definition
ecc_msm_relation.hpp:94
bb::ECCVMMSMRelationImpl::COLLISION_CHECK_4
@ COLLISION_CHECK_4
Definition
ecc_msm_relation.hpp:75
bb::ECCVMMSMRelationImpl::DOUBLE_SLOPE_2
@ DOUBLE_SLOPE_2
Definition
ecc_msm_relation.hpp:61
bb::ECCVMMSMRelationImpl::SKEW_ACC_Y
@ SKEW_ACC_Y
Definition
ecc_msm_relation.hpp:66
bb::ECCVMMSMRelationImpl::IDLE_ROW_PRESERVES_ACC_Y
@ IDLE_ROW_PRESERVES_ACC_Y
Definition
ecc_msm_relation.hpp:121
bb::ECCVMMSMRelationImpl::ROUND_TRANSITION_SKEW_IMPLIES_ROUND_31
@ ROUND_TRANSITION_SKEW_IMPLIES_ROUND_31
Definition
ecc_msm_relation.hpp:86
bb::ECCVMMSMRelationImpl::NUM_SUBRELATIONS
@ NUM_SUBRELATIONS
Definition
ecc_msm_relation.hpp:122
bb::ECCVMMSMRelationImpl::ADD_SLOPE_1
@ ADD_SLOPE_1
Definition
ecc_msm_relation.hpp:53
bb::ECCVMMSMRelationImpl::ADD_ACC_X
@ ADD_ACC_X
Definition
ecc_msm_relation.hpp:51
bb::ECCVMMSMRelationImpl::COLLISION_CHECK_1
@ COLLISION_CHECK_1
Definition
ecc_msm_relation.hpp:72
bb::ECCVMMSMRelationImpl::INACTIVE_SLICE_3
@ INACTIVE_SLICE_3
Definition
ecc_msm_relation.hpp:79
bb::ECCVMMSMRelationImpl::ROUND_TRANSITION_NEEDS_DOUBLE_OR_SKEW
@ ROUND_TRANSITION_NEEDS_DOUBLE_OR_SKEW
Definition
ecc_msm_relation.hpp:90
bb::ECCVMMSMRelationImpl::INACTIVE_SLICE_4
@ INACTIVE_SLICE_4
Definition
ecc_msm_relation.hpp:80
bb::ECCVMMSMRelationImpl::SKEW_IMPLIES_ROUND_32
@ SKEW_IMPLIES_ROUND_32
Definition
ecc_msm_relation.hpp:116
bb::ECCVMMSMRelationImpl::ADD_CONTINUITY_2
@ ADD_CONTINUITY_2
Definition
ecc_msm_relation.hpp:104
bb::ECCVMMSMRelationImpl::DOUBLE_REQUIRES_ROUND_CHANGE
@ DOUBLE_REQUIRES_ROUND_CHANGE
Definition
ecc_msm_relation.hpp:118
bb::ECCVMMSMRelationImpl::SKEW_SLOPE_2
@ SKEW_SLOPE_2
Definition
ecc_msm_relation.hpp:68
bb::ECCVMMSMRelationImpl::INACTIVE_SLICE_1
@ INACTIVE_SLICE_1
Definition
ecc_msm_relation.hpp:77
bb::ECCVMMSMRelationImpl::ADD_CONTINUITY_4
@ ADD_CONTINUITY_4
Definition
ecc_msm_relation.hpp:108
bb::ECCVMMSMRelationImpl::INACTIVE_SLICE_2
@ INACTIVE_SLICE_2
Definition
ecc_msm_relation.hpp:78
bb::ECCVMMSMRelationImpl::ADD1_DECOMPOSITION
@ ADD1_DECOMPOSITION
Definition
ecc_msm_relation.hpp:112
bb::ECCVMMSMRelationImpl::IDLE_ROW_PRESERVES_ACC_X
@ IDLE_ROW_PRESERVES_ACC_X
Definition
ecc_msm_relation.hpp:120
bb::ECCVMMSMRelationImpl::DOUBLE_ACC_X
@ DOUBLE_ACC_X
Definition
ecc_msm_relation.hpp:58
bb::ECCVMMSMRelationImpl::COLLISION_CHECK_2
@ COLLISION_CHECK_2
Definition
ecc_msm_relation.hpp:73
bb::ECCVMMSMRelationImpl::SKEW_SLOPE_3
@ SKEW_SLOPE_3
Definition
ecc_msm_relation.hpp:69
bb::ECCVMMSMRelationImpl::COLLISION_CHECK_3
@ COLLISION_CHECK_3
Definition
ecc_msm_relation.hpp:74
bb::ECCVMMSMRelationImpl::ADD_SLOPE_4
@ ADD_SLOPE_4
Definition
ecc_msm_relation.hpp:56
bb::ECCVMMSMRelationImpl::ADD_CROSS_ROW_CONTINUITY
@ ADD_CROSS_ROW_CONTINUITY
Definition
ecc_msm_relation.hpp:110
bb::ECCVMMSMRelationImpl::ADD_SLOPE_3
@ ADD_SLOPE_3
Definition
ecc_msm_relation.hpp:55
bb::ECCVMMSMRelationImpl::DOUBLE_SLOPE_1
@ DOUBLE_SLOPE_1
Definition
ecc_msm_relation.hpp:60
bb::ECCVMMSMRelationImpl::SKEW_PERSISTS_UNTIL_MSM_TRANSITION
@ SKEW_PERSISTS_UNTIL_MSM_TRANSITION
Definition
ecc_msm_relation.hpp:114
bb::ECCVMMSMRelationImpl::DOUBLE_SLOPE_3
@ DOUBLE_SLOPE_3
Definition
ecc_msm_relation.hpp:62
bb::ECCVMMSMRelationImpl::SKEW_SLOPE_4
@ SKEW_SLOPE_4
Definition
ecc_msm_relation.hpp:70
bb::ECCVMMSMRelationImpl::DOUBLE_ACC_Y
@ DOUBLE_ACC_Y
Definition
ecc_msm_relation.hpp:59
bb::ECCVMMSMRelationImpl::ROUND_TRANSITION_EXACTLY_ONE_DOUBLE_OR_SKEW
@ ROUND_TRANSITION_EXACTLY_ONE_DOUBLE_OR_SKEW
Definition
ecc_msm_relation.hpp:88
bb::ECCVMMSMRelationImpl::ADD_SLOPE_2
@ ADD_SLOPE_2
Definition
ecc_msm_relation.hpp:54
bb::ECCVMMSMRelationImpl::ADD_ACC_Y
@ ADD_ACC_Y
Definition
ecc_msm_relation.hpp:52
bb::ECCVMMSMRelationImpl::DOUBLE_IMPLIES_NEXT_IS_ADD
@ DOUBLE_IMPLIES_NEXT_IS_ADD
Definition
ecc_msm_relation.hpp:92
bb::ECCVMMSMRelationImpl::COUNT_ZERO_AT_ROUND_BOUNDARY_OR_TRANSITION
@ COUNT_ZERO_AT_ROUND_BOUNDARY_OR_TRANSITION
Definition
ecc_msm_relation.hpp:98
bb::ECCVMMSMRelationImpl::MSM_TRANSITION_ROUND_ZERO
@ MSM_TRANSITION_ROUND_ZERO
Definition
ecc_msm_relation.hpp:100
bb::ECCVMMSMRelationImpl::MSM_TRANSITION_PC
@ MSM_TRANSITION_PC
Definition
ecc_msm_relation.hpp:102
bb::ECCVMMSMRelationImpl::SKEW_SLOPE_1
@ SKEW_SLOPE_1
Definition
ecc_msm_relation.hpp:67
bb::ECCVMMSMRelationImpl::SKEW_ACC_X
@ SKEW_ACC_X
Definition
ecc_msm_relation.hpp:65
bb::ECCVMMSMRelationImpl::PHASE_SELECTOR_MUTUAL_EXCLUSIVITY
@ PHASE_SELECTOR_MUTUAL_EXCLUSIVITY
Definition
ecc_msm_relation.hpp:82
bb::ECCVMMSMRelationImpl::ROUND_TRANSITION_FORCES_DELTA_ONE
@ ROUND_TRANSITION_FORCES_DELTA_ONE
Definition
ecc_msm_relation.hpp:84
bb::Relation
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
Definition
relation_types.hpp:96
bb
Entry point for Barretenberg command-line interface.
Definition
api.hpp:5
relation_types.hpp
bb::field< bb::Bn254FrParams >
src
barretenberg
relations
ecc_vm
ecc_msm_relation.hpp
Generated by
1.9.8