@@ -103,31 +103,50 @@ template <typename FF_> class ECCVMLookupRelationImpl {
103103 }
104104 return Accumulator (1 );
105105 }
106-
106+ /* *
107+ * @brief Returns the fingerprint of `(precompute_pc, compressed_slice, (2 * compressed_slice - 15)[P])`, where [P]
108+ * is the point corresponding to `precompute_pc` and `compressed_slice`∈{0, ..., 15}.
109+ */
107110 template <typename Accumulator, size_t write_index, typename AllEntities, typename Parameters>
108111 static Accumulator compute_write_term (const AllEntities& in, const Parameters& params)
109112 {
110113 using View = typename Accumulator::View;
111114
112115 static_assert (write_index < WRITE_TERMS);
113-
114- // what are we looking up?
115- // we want to map:
116- // 1: point pc
117- // 2: point slice
118- // 3: point x
119- // 4: point y
120- // for each point in our point table, we want to map `slice` to (x, -y) AND `slice + 8` to (x, y)
116+ // write_index == 0 means our wNAF digit is positive (i.e., ∈{1, 3..., 15}).
117+ // write_index == 1 means our wNAF digit is negative (i.e., ∈{-15, -13..., -1})
121118
122119 // round starts at 0 and increments to 7
123120 // point starts at 15[P] and decrements to [P]
124121 // a slice value of 0 maps to -15[P]
125- // 1 -> -13[P]
126- // 7 -> -[P]
127- // 8 -> P
128- // 15 -> 15[P]
129- // negative points map pc, round, x, -y
130- // positive points map pc, 15 - (round * 2), x, y
122+
123+ // we have computed `(15 - 2 * round)[P] =: (precompute_tx, precompute_ty)`.
124+ // `round`∈{0, 1..., 7}
125+ // if write_index == 0, we want to write (pc, 15 - 2 * round, precompute_tx, precompute_ty)
126+ // if write_index == 1, we want to write (pc, round, precompute_tx, -precompute_ty)
127+ // to sum up, both:
128+ // (pc, round, precompute_tx, -precompute_ty) _and_
129+ // (pc, 15 - 2 * round, precompute_tx, precompute_ty)
130+ // will be written to the lookup table.
131+ //
132+ // therefore, if `pc` corresponds to the elliptic curve point [P], we will write:
133+ // | pc | 0 | -15[P].x | -15[P].y |
134+ // | pc | 1 | -13[P].x | -13[P].y |
135+ // | pc | 2 | -11[P].x | -11[P].y |
136+ // | pc | 3 | -9[P].x | -9[P].y |
137+ // | pc | 4 | -7[P].x | -7[P].y |
138+ // | pc | 5 | -5[P].x | -5[P].y |
139+ // | pc | 6 | -3[P].x | -3[P].y |
140+ // | pc | 7 | -1[P].x | -1[P].y |
141+ // | pc | 8 | [P].x | [P].y |
142+ // | pc | 9 | 3[P].x | 3[P].y |
143+ // | pc | 10 | 5[P].x | 5[P].y |
144+ // | pc | 11 | 7[P].x | 7[P].y |
145+ // | pc | 12 | 9[P].x | 9[P].y |
146+ // | pc | 13 | 11[P].x | 11[P].y |
147+ // | pc | 14 | 13[P].x | 13[P].y |
148+ // | pc | 15 | 15[P].x | 15[P].y |
149+
131150 const auto & precompute_pc = View (in.precompute_pc );
132151 const auto & tx = View (in.precompute_tx );
133152 const auto & ty = View (in.precompute_ty );
@@ -137,31 +156,6 @@ template <typename FF_> class ECCVMLookupRelationImpl {
137156 const auto & beta_sqr = params.beta_sqr ;
138157 const auto & beta_cube = params.beta_cube ;
139158
140- // slice value : (wnaf value) : lookup term
141- // 0 : -15 : 0
142- // 1 : -13 : 1
143- // 7 : -1 : 7
144- // 8 : 1 : 0
145- // 9 : 3 : 1
146- // 15 : 15 : 7
147-
148- // slice value : negative term : positive term
149- // 0 : 0 : 7
150- // 1 : 1 : 6
151- // 2 : 2 : 5
152- // 3 : 3 : 4
153- // 7 : 7 : 0
154-
155- // | 0 | 15[P].x | 15[P].y | 0, -15[P].x, -15[P].y | 15, 15[P].x, 15[P].y |
156- // | 1 | 13[P].x | 13[P].y | 1, -13[P].x, -13[P].y | 14, 13[P].x, 13[P].y
157- // | 2 | 11[P].x | 11[P].y
158- // | 3 | 9[P].x | 9[P].y
159- // | 4 | 7[P].x | 7[P].y
160- // | 5 | 5[P].x | 5[P].y
161- // | 6 | 3[P].x | 3[P].y
162- // | 7 | 1[P].x | 1[P].y | 7, -[P].x, -[P].y | 8 , [P].x, [P].y |
163-
164- // todo optimize this?
165159 if constexpr (write_index == 0 ) {
166160 const auto positive_slice_value = -(precompute_round) + 15 ;
167161 const auto positive_term =
@@ -180,8 +174,8 @@ template <typename FF_> class ECCVMLookupRelationImpl {
180174 {
181175 using View = typename Accumulator::View;
182176
183- // read term:
184- // pc, slice, x, y
177+ // read term: (pc, compressed_slice, (2 * compressed_slice - 15)[P])
178+ // (the latter term is of course represented via an x and y coordinate.)
185179 static_assert (read_index < READ_TERMS);
186180 const auto & gamma = params.gamma ;
187181 const auto & beta = params.beta ;
@@ -202,12 +196,12 @@ template <typename FF_> class ECCVMLookupRelationImpl {
202196 const auto & msm_y3 = View (in.msm_y3 );
203197 const auto & msm_y4 = View (in.msm_y4 );
204198
205- // how do we get pc value
199+ // Recall that `pc` stands for point-counter. We recall how to compute the current pc.
200+ //
206201 // row pc = value of pc after msm
207- // row count = num processed points in round
208- // size_of_msm = msm_size
209- // value of pc at start of msm = msm_pc - msm_size_of_msm
210- // value of current pc = msm_pc - msm_size_of_msm + msm_count + (0,1,2,3)
202+ // msm_count = number of (128-bit) multiplications processed so far in current MSM round (NOT INCLUDING current
203+ // row) current_pc = msm_pc - msm_count next_pc = current_pc - {0, 1, 2, 3}, depending on how many adds are
204+ // performed in the current row.
211205 const auto current_pc = msm_pc - msm_count;
212206
213207 if constexpr (read_index == 0 ) {
@@ -254,4 +248,4 @@ template <typename FF_> class ECCVMLookupRelationImpl {
254248
255249template <typename FF> using ECCVMLookupRelation = Relation<ECCVMLookupRelationImpl<FF>>;
256250
257- } // namespace bb
251+ } // namespace bb
0 commit comments