Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
wnaf.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
9#include <cstdint>
10#include <iostream>
11
12// NOLINTBEGIN(readability-implicit-bool-conversion)
13namespace bb::wnaf {
14constexpr size_t SCALAR_BITS = 127;
15
16#define WNAF_SIZE(x) ((bb::wnaf::SCALAR_BITS + (x) - 1) / (x)) // NOLINT(cppcoreguidelines-macro-usage)
17
18constexpr size_t get_optimal_bucket_width(const size_t num_points)
19{
20 if (num_points >= 14617149) {
21 return 21;
22 }
23 if (num_points >= 1139094) {
24 return 18;
25 }
26 // if (num_points >= 100000)
27 if (num_points >= 155975) {
28 return 15;
29 }
30 if (num_points >= 144834)
31 // if (num_points >= 100000)
32 {
33 return 14;
34 }
35 if (num_points >= 25067) {
36 return 12;
37 }
38 if (num_points >= 13926) {
39 return 11;
40 }
41 if (num_points >= 7659) {
42 return 10;
43 }
44 if (num_points >= 2436) {
45 return 9;
46 }
47 if (num_points >= 376) {
48 return 7;
49 }
50 if (num_points >= 231) {
51 return 6;
52 }
53 if (num_points >= 97) {
54 return 5;
55 }
56 if (num_points >= 35) {
57 return 4;
58 }
59 if (num_points >= 10) {
60 return 3;
61 }
62 if (num_points >= 2) {
63 return 2;
64 }
65 return 1;
66}
67constexpr size_t get_num_buckets(const size_t num_points)
68{
69 const size_t bits_per_bucket = get_optimal_bucket_width(num_points / 2);
70 return 1UL << bits_per_bucket;
71}
72
73constexpr size_t get_num_rounds(const size_t num_points)
74{
75 const size_t bits_per_bucket = get_optimal_bucket_width(num_points / 2);
76 return WNAF_SIZE(bits_per_bucket + 1);
77}
78
79template <size_t bits, size_t bit_position> inline uint64_t get_wnaf_bits_const(const uint64_t* scalar) noexcept
80{
81 if constexpr (bits == 0) {
82 return 0ULL;
83 } else {
97 constexpr size_t lo_limb_idx = bit_position / 64;
98 constexpr size_t hi_limb_idx = (bit_position + bits - 1) / 64;
99 constexpr uint64_t lo_shift = bit_position & 63UL;
100 constexpr uint64_t bit_mask = (1UL << static_cast<uint64_t>(bits)) - 1UL;
101
102 uint64_t lo = (scalar[lo_limb_idx] >> lo_shift);
103 if constexpr (lo_limb_idx == hi_limb_idx) {
104 return lo & bit_mask;
105 } else {
106 constexpr uint64_t hi_shift = 64UL - (bit_position & 63UL);
107 uint64_t hi = ((scalar[hi_limb_idx] << (hi_shift)));
108 return (lo | hi) & bit_mask;
109 }
110 }
111}
112
113inline uint64_t get_wnaf_bits(const uint64_t* scalar, const uint64_t bits, const uint64_t bit_position) noexcept
114{
128 const auto lo_limb_idx = static_cast<size_t>(bit_position >> 6);
129 const auto hi_limb_idx = static_cast<size_t>((bit_position + bits - 1) >> 6);
130 const uint64_t lo_shift = bit_position & 63UL;
131 const uint64_t bit_mask = (1UL << static_cast<uint64_t>(bits)) - 1UL;
132
133 const uint64_t lo = (scalar[lo_limb_idx] >> lo_shift);
134 const uint64_t hi_shift = bit_position ? 64UL - (bit_position & 63UL) : 0;
135 const uint64_t hi = ((scalar[hi_limb_idx] << (hi_shift)));
136 const uint64_t hi_mask = bit_mask & (0ULL - (lo_limb_idx != hi_limb_idx));
137
138 return (lo & bit_mask) | (hi & hi_mask);
139}
140
142 const uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const uint64_t point_index, const size_t wnaf_bits) noexcept
143{
144 skew_map = ((scalar[0] & 1) == 0);
145 uint64_t previous = get_wnaf_bits(scalar, wnaf_bits, 0) + static_cast<uint64_t>(skew_map);
146 const size_t wnaf_entries = (SCALAR_BITS + wnaf_bits - 1) / wnaf_bits;
147
148 for (size_t round_i = 1; round_i < wnaf_entries - 1; ++round_i) {
149 uint64_t slice = get_wnaf_bits(scalar, wnaf_bits, round_i * wnaf_bits);
150 uint64_t predicate = ((slice & 1UL) == 0UL);
151 wnaf[(wnaf_entries - round_i)] =
152 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
153 (point_index);
154 previous = slice + predicate;
155 }
156 size_t final_bits = SCALAR_BITS - (wnaf_bits * (wnaf_entries - 1));
157 uint64_t slice = get_wnaf_bits(scalar, final_bits, (wnaf_entries - 1) * wnaf_bits);
158 uint64_t predicate = ((slice & 1UL) == 0UL);
159
160 wnaf[1] = ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
161 (point_index);
162 wnaf[0] = ((slice + predicate) >> 1UL) | (point_index);
163}
164
178inline void fixed_wnaf(const uint64_t* scalar,
179 uint64_t* wnaf,
180 bool& skew_map,
181 const uint64_t point_index,
182 const uint64_t num_points,
183 const size_t wnaf_bits) noexcept
184{
185 skew_map = ((scalar[0] & 1) == 0);
186 uint64_t previous = get_wnaf_bits(scalar, wnaf_bits, 0) + static_cast<uint64_t>(skew_map);
187 const size_t wnaf_entries = (SCALAR_BITS + wnaf_bits - 1) / wnaf_bits;
188
189 for (size_t round_i = 1; round_i < wnaf_entries - 1; ++round_i) {
190 uint64_t slice = get_wnaf_bits(scalar, wnaf_bits, round_i * wnaf_bits);
191 uint64_t predicate = ((slice & 1UL) == 0UL);
192 wnaf[(wnaf_entries - round_i) * num_points] =
193 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
194 (point_index);
195 previous = slice + predicate;
196 }
197 size_t final_bits = SCALAR_BITS - (wnaf_bits * (wnaf_entries - 1));
198 uint64_t slice = get_wnaf_bits(scalar, final_bits, (wnaf_entries - 1) * wnaf_bits);
199 uint64_t predicate = ((slice & 1UL) == 0UL);
200
201 wnaf[num_points] =
202 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
203 (point_index);
204 wnaf[0] = ((slice + predicate) >> 1UL) | (point_index);
205}
206
234inline uint64_t get_num_scalar_bits(const uint64_t* scalar)
235{
236 const uint64_t msb_1 = numeric::get_msb(scalar[1]);
237 const uint64_t msb_0 = numeric::get_msb(scalar[0]);
238
239 const uint64_t scalar_1_mask = (0ULL - (scalar[1] > 0));
240 const uint64_t scalar_0_mask = (0ULL - (scalar[0] > 0)) & ~scalar_1_mask;
241
242 const uint64_t msb = (scalar_1_mask & (msb_1 + 64)) | (scalar_0_mask & (msb_0));
243 return msb;
244}
245
274inline void fixed_wnaf_with_counts(const uint64_t* scalar,
275 uint64_t* wnaf,
276 bool& skew_map,
277 uint64_t* wnaf_round_counts,
278 const uint64_t point_index,
279 const uint64_t num_points,
280 const size_t wnaf_bits) noexcept
281{
282 const size_t max_wnaf_entries = (SCALAR_BITS + wnaf_bits - 1) / wnaf_bits;
283 if ((scalar[0] | scalar[1]) == 0ULL) {
284 skew_map = false;
285 for (size_t round_i = 0; round_i < max_wnaf_entries; ++round_i) {
286 wnaf[(round_i)*num_points] = 0xffffffffffffffffULL;
287 }
288 return;
289 }
290 const auto current_scalar_bits = static_cast<size_t>(get_num_scalar_bits(scalar) + 1);
291 skew_map = ((scalar[0] & 1) == 0);
292 uint64_t previous = get_wnaf_bits(scalar, wnaf_bits, 0) + static_cast<uint64_t>(skew_map);
293 const auto wnaf_entries = static_cast<size_t>((current_scalar_bits + wnaf_bits - 1) / wnaf_bits);
294
295 if (wnaf_entries == 1) {
296 wnaf[(max_wnaf_entries - 1) * num_points] = (previous >> 1UL) | (point_index);
297 ++wnaf_round_counts[max_wnaf_entries - 1];
298 for (size_t j = wnaf_entries; j < max_wnaf_entries; ++j) {
299 wnaf[(max_wnaf_entries - 1 - j) * num_points] = 0xffffffffffffffffULL;
300 }
301 return;
302 }
303
304 // If there are several windows
305 for (size_t round_i = 1; round_i < wnaf_entries - 1; ++round_i) {
306
307 // Get a bit slice
308 uint64_t slice = get_wnaf_bits(scalar, wnaf_bits, round_i * wnaf_bits);
309
310 // Get the predicate (last bit is zero)
311 uint64_t predicate = ((slice & 1UL) == 0UL);
312
313 // Update round count
314 ++wnaf_round_counts[max_wnaf_entries - round_i];
315
316 // Calculate entry value
317 // If the last bit of current slice is 1, we simply put the previous value with the point index
318 // If the last bit of the current slice is 0, we negate everything, so that we subtract from the WNAF form and
319 // make it 0
320 wnaf[(max_wnaf_entries - round_i) * num_points] =
321 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
322 (point_index);
323
324 // Update the previous value to the next windows
325 previous = slice + predicate;
326 }
327 // The final iteration for top bits
328 auto final_bits = static_cast<size_t>(current_scalar_bits - (wnaf_bits * (wnaf_entries - 1)));
329 uint64_t slice = get_wnaf_bits(scalar, final_bits, (wnaf_entries - 1) * wnaf_bits);
330 uint64_t predicate = ((slice & 1UL) == 0UL);
331
332 ++wnaf_round_counts[(max_wnaf_entries - wnaf_entries + 1)];
333 wnaf[((max_wnaf_entries - wnaf_entries + 1) * num_points)] =
334 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
335 (point_index);
336
337 // Saving top bits
338 ++wnaf_round_counts[max_wnaf_entries - wnaf_entries];
339 wnaf[(max_wnaf_entries - wnaf_entries) * num_points] = ((slice + predicate) >> 1UL) | (point_index);
340
341 // Fill all unused slots with -1
342 for (size_t j = wnaf_entries; j < max_wnaf_entries; ++j) {
343 wnaf[(max_wnaf_entries - 1 - j) * num_points] = 0xffffffffffffffffULL;
344 }
345}
346
347template <size_t num_points, size_t wnaf_bits, size_t round_i>
348inline void wnaf_round(uint64_t* scalar, uint64_t* wnaf, const uint64_t point_index, const uint64_t previous) noexcept
349{
350 constexpr size_t wnaf_entries = (SCALAR_BITS + wnaf_bits - 1) / wnaf_bits;
351 constexpr auto log2_num_points = static_cast<size_t>(numeric::get_msb(static_cast<uint32_t>(num_points)));
352
353 if constexpr (round_i < wnaf_entries - 1) {
354 uint64_t slice = get_wnaf_bits(scalar, wnaf_bits, round_i * wnaf_bits);
355 uint64_t predicate = ((slice & 1UL) == 0UL);
356 wnaf[(wnaf_entries - round_i) << log2_num_points] =
357 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
358 (point_index << 32UL);
359 wnaf_round<num_points, wnaf_bits, round_i + 1>(scalar, wnaf, point_index, slice + predicate);
360 } else {
361 constexpr size_t final_bits = SCALAR_BITS - (SCALAR_BITS / wnaf_bits) * wnaf_bits;
362 uint64_t slice = get_wnaf_bits(scalar, final_bits, (wnaf_entries - 1) * wnaf_bits);
363 // uint64_t slice = get_wnaf_bits_const<final_bits, (wnaf_entries - 1) * wnaf_bits>(scalar);
364 uint64_t predicate = ((slice & 1UL) == 0UL);
365 wnaf[num_points] =
366 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
367 (point_index << 32UL);
368 wnaf[0] = ((slice + predicate) >> 1UL) | (point_index << 32UL);
369 }
370}
371
372template <size_t scalar_bits, size_t num_points, size_t wnaf_bits, size_t round_i>
373inline void wnaf_round(uint64_t* scalar, uint64_t* wnaf, const uint64_t point_index, const uint64_t previous) noexcept
374{
375 constexpr size_t wnaf_entries = (scalar_bits + wnaf_bits - 1) / wnaf_bits;
376 constexpr auto log2_num_points = static_cast<uint64_t>(numeric::get_msb(static_cast<uint32_t>(num_points)));
377
378 if constexpr (round_i < wnaf_entries - 1) {
379 uint64_t slice = get_wnaf_bits_const<wnaf_bits, round_i * wnaf_bits>(scalar);
380 uint64_t predicate = ((slice & 1UL) == 0UL);
381 wnaf[(wnaf_entries - round_i) << log2_num_points] =
382 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
383 (point_index << 32UL);
384 wnaf_round<scalar_bits, num_points, wnaf_bits, round_i + 1>(scalar, wnaf, point_index, slice + predicate);
385 } else {
386 constexpr size_t final_bits = ((scalar_bits / wnaf_bits) * wnaf_bits == scalar_bits)
387 ? wnaf_bits
388 : scalar_bits - (scalar_bits / wnaf_bits) * wnaf_bits;
389 uint64_t slice = get_wnaf_bits_const<final_bits, (wnaf_entries - 1) * wnaf_bits>(scalar);
390 uint64_t predicate = ((slice & 1UL) == 0UL);
391 wnaf[num_points] =
392 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
393 (point_index << 32UL);
394 wnaf[0] = ((slice + predicate) >> 1UL) | (point_index << 32UL);
395 }
396}
397
398template <size_t wnaf_bits, size_t round_i>
399inline void wnaf_round_packed(const uint64_t* scalar,
400 uint64_t* wnaf,
401 const uint64_t point_index,
402 const uint64_t previous) noexcept
403{
404 constexpr size_t wnaf_entries = (SCALAR_BITS + wnaf_bits - 1) / wnaf_bits;
405
406 if constexpr (round_i < wnaf_entries - 1) {
407 uint64_t slice = get_wnaf_bits(scalar, wnaf_bits, round_i * wnaf_bits);
408 // uint64_t slice = get_wnaf_bits_const<wnaf_bits, round_i * wnaf_bits>(scalar);
409 uint64_t predicate = ((slice & 1UL) == 0UL);
410 wnaf[(wnaf_entries - round_i)] =
411 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
412 (point_index);
413 wnaf_round_packed<wnaf_bits, round_i + 1>(scalar, wnaf, point_index, slice + predicate);
414 } else {
415 constexpr size_t final_bits = SCALAR_BITS - (SCALAR_BITS / wnaf_bits) * wnaf_bits;
416 uint64_t slice = get_wnaf_bits(scalar, final_bits, (wnaf_entries - 1) * wnaf_bits);
417 // uint64_t slice = get_wnaf_bits_const<final_bits, (wnaf_entries - 1) * wnaf_bits>(scalar);
418 uint64_t predicate = ((slice & 1UL) == 0UL);
419 wnaf[1] =
420 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
421 (point_index);
422
423 wnaf[0] = ((slice + predicate) >> 1UL) | (point_index);
424 }
425}
426
427template <size_t num_points, size_t wnaf_bits>
428inline void fixed_wnaf(uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept
429{
430 skew_map = ((scalar[0] & 1) == 0);
431 uint64_t previous = get_wnaf_bits_const<wnaf_bits, 0>(scalar) + static_cast<uint64_t>(skew_map);
432 wnaf_round<num_points, wnaf_bits, 1UL>(scalar, wnaf, point_index, previous);
433}
434
435template <size_t num_bits, size_t num_points, size_t wnaf_bits>
436inline void fixed_wnaf(uint64_t* scalar, uint64_t* wnaf, bool& skew_map, const size_t point_index) noexcept
437{
438 skew_map = ((scalar[0] & 1) == 0);
439 uint64_t previous = get_wnaf_bits_const<wnaf_bits, 0>(scalar) + static_cast<uint64_t>(skew_map);
440 wnaf_round<num_bits, num_points, wnaf_bits, 1UL>(scalar, wnaf, point_index, previous);
441}
442
443template <size_t scalar_bits, size_t num_points, size_t wnaf_bits, size_t round_i>
444inline void wnaf_round_with_restricted_first_slice(uint64_t* scalar,
445 uint64_t* wnaf,
446 const uint64_t point_index,
447 const uint64_t previous) noexcept
448{
449 constexpr size_t wnaf_entries = (scalar_bits + wnaf_bits - 1) / wnaf_bits;
450 constexpr auto log2_num_points = static_cast<uint64_t>(numeric::get_msb(static_cast<uint32_t>(num_points)));
451 constexpr size_t bits_in_first_slice = scalar_bits % wnaf_bits;
452 if constexpr (round_i == 1) {
453 uint64_t slice = get_wnaf_bits_const<wnaf_bits, (round_i - 1) * wnaf_bits + bits_in_first_slice>(scalar);
454 uint64_t predicate = ((slice & 1UL) == 0UL);
455
456 wnaf[(wnaf_entries - round_i) << log2_num_points] =
457 ((((previous - (predicate << (bits_in_first_slice /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) |
458 (predicate << 31UL)) |
459 (point_index << 32UL);
460 if (round_i == 1) {
461 std::cerr << "writing value " << std::hex << wnaf[(wnaf_entries - round_i) << log2_num_points] << std::dec
462 << " at index " << ((wnaf_entries - round_i) << log2_num_points) << std::endl;
463 }
464 wnaf_round_with_restricted_first_slice<scalar_bits, num_points, wnaf_bits, round_i + 1>(
465 scalar, wnaf, point_index, slice + predicate);
466
467 } else if constexpr (round_i < wnaf_entries - 1) {
468 uint64_t slice = get_wnaf_bits_const<wnaf_bits, (round_i - 1) * wnaf_bits + bits_in_first_slice>(scalar);
469 uint64_t predicate = ((slice & 1UL) == 0UL);
470 wnaf[(wnaf_entries - round_i) << log2_num_points] =
471 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
472 (point_index << 32UL);
473 wnaf_round_with_restricted_first_slice<scalar_bits, num_points, wnaf_bits, round_i + 1>(
474 scalar, wnaf, point_index, slice + predicate);
475 } else {
476 uint64_t slice = get_wnaf_bits_const<wnaf_bits, (wnaf_entries - 1) * wnaf_bits>(scalar);
477 uint64_t predicate = ((slice & 1UL) == 0UL);
478 wnaf[num_points] =
479 ((((previous - (predicate << (wnaf_bits /*+ 1*/))) ^ (0UL - predicate)) >> 1UL) | (predicate << 31UL)) |
480 (point_index << 32UL);
481 wnaf[0] = ((slice + predicate) >> 1UL) | (point_index << 32UL);
482 }
483}
484
485template <size_t num_bits, size_t num_points, size_t wnaf_bits>
486inline void fixed_wnaf_with_restricted_first_slice(uint64_t* scalar,
487 uint64_t* wnaf,
488 bool& skew_map,
489 const size_t point_index) noexcept
490{
491 constexpr size_t bits_in_first_slice = num_bits % wnaf_bits;
492 std::cerr << "bits in first slice = " << bits_in_first_slice << std::endl;
493 skew_map = ((scalar[0] & 1) == 0);
494 uint64_t previous = get_wnaf_bits_const<bits_in_first_slice, 0>(scalar) + static_cast<uint64_t>(skew_map);
495 std::cerr << "previous = " << previous << std::endl;
496 wnaf_round_with_restricted_first_slice<num_bits, num_points, wnaf_bits, 1UL>(scalar, wnaf, point_index, previous);
497}
498
499// template <size_t wnaf_bits>
500// inline void fixed_wnaf_packed(const uint64_t* scalar,
501// uint64_t* wnaf,
502// bool& skew_map,
503// const uint64_t point_index) noexcept
504// {
505// skew_map = ((scalar[0] & 1) == 0);
506// uint64_t previous = get_wnaf_bits_const<wnaf_bits, 0>(scalar) + (uint64_t)skew_map;
507// wnaf_round_packed<wnaf_bits, 1UL>(scalar, wnaf, point_index, previous);
508// }
509
510// template <size_t wnaf_bits>
511// inline constexpr std::array<uint32_t, WNAF_SIZE(wnaf_bits)> fixed_wnaf(const uint64_t *scalar) const noexcept
512// {
513// bool skew_map = ((scalar[0] * 1) == 0);
514// uint64_t previous = get_wnaf_bits_const<wnaf_bits, 0>(scalar) + (uint64_t)skew_map;
515// std::array<uint32_t, WNAF_SIZE(wnaf_bits)> result;
516// }
517} // namespace bb::wnaf
518
519// NOLINTEND(readability-implicit-bool-conversion)
constexpr T get_msb(const T in)
Definition get_msb.hpp:47
constexpr size_t get_num_buckets(const size_t num_points)
Definition wnaf.hpp:67
void wnaf_round_packed(const uint64_t *scalar, uint64_t *wnaf, const uint64_t point_index, const uint64_t previous) noexcept
Definition wnaf.hpp:399
uint64_t get_num_scalar_bits(const uint64_t *scalar)
Definition wnaf.hpp:234
void fixed_wnaf(const uint64_t *scalar, uint64_t *wnaf, bool &skew_map, const uint64_t point_index, const uint64_t num_points, const size_t wnaf_bits) noexcept
Performs fixed-window non-adjacent form (WNAF) computation for scalar multiplication.
Definition wnaf.hpp:178
constexpr size_t SCALAR_BITS
Definition wnaf.hpp:14
void fixed_wnaf_with_restricted_first_slice(uint64_t *scalar, uint64_t *wnaf, bool &skew_map, const size_t point_index) noexcept
Definition wnaf.hpp:486
uint64_t get_wnaf_bits_const(const uint64_t *scalar) noexcept
Definition wnaf.hpp:79
void wnaf_round(uint64_t *scalar, uint64_t *wnaf, const uint64_t point_index, const uint64_t previous) noexcept
Definition wnaf.hpp:348
constexpr size_t get_optimal_bucket_width(const size_t num_points)
Definition wnaf.hpp:18
void fixed_wnaf_packed(const uint64_t *scalar, uint64_t *wnaf, bool &skew_map, const uint64_t point_index, const size_t wnaf_bits) noexcept
Definition wnaf.hpp:141
void fixed_wnaf_with_counts(const uint64_t *scalar, uint64_t *wnaf, bool &skew_map, uint64_t *wnaf_round_counts, const uint64_t point_index, const uint64_t num_points, const size_t wnaf_bits) noexcept
Definition wnaf.hpp:274
void wnaf_round_with_restricted_first_slice(uint64_t *scalar, uint64_t *wnaf, const uint64_t point_index, const uint64_t previous) noexcept
Definition wnaf.hpp:444
uint64_t get_wnaf_bits(const uint64_t *scalar, const uint64_t bits, const uint64_t bit_position) noexcept
Definition wnaf.hpp:113
constexpr size_t get_num_rounds(const size_t num_points)
Definition wnaf.hpp:73
C slice(C const &container, size_t start)
Definition container.hpp:9
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define WNAF_SIZE(x)
Definition wnaf.hpp:16