Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
eccvm_row_tracker.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
8
12namespace bb {
13
21
22 uint32_t cached_num_muls = 0;
24 uint32_t num_transcript_rows = 0;
26 uint32_t num_msm_rows = 0;
27
28 public:
29 [[nodiscard]] uint32_t get_number_of_muls() const { return cached_num_muls + cached_active_msm_count; }
30
38 static uint32_t num_eccvm_msm_rows(const size_t msm_size)
39 {
40 const size_t rows_per_wnaf_digit =
41 (msm_size / eccvm::ADDITIONS_PER_ROW) +
42 ((msm_size % eccvm::ADDITIONS_PER_ROW != 0)
43 ? 1
44 : 0); // the Straus algorithm proceeds by incrementing through the digit-slots and doing
45 // computations *across* the MSMs. Each digit-slot therefore contributes the *ceiling* of
46 // `msm_size`/`ADDITIONS_PER_ROW`.
47 const size_t num_rows_for_all_rounds =
48 (eccvm::NUM_WNAF_DIGITS_PER_SCALAR + 1) * rows_per_wnaf_digit; // + 1 round for skew
49 const size_t num_double_rounds = eccvm::NUM_WNAF_DIGITS_PER_SCALAR - 1;
50 const size_t num_rows_for_msm = num_rows_for_all_rounds + num_double_rounds;
51
52 return static_cast<uint32_t>(num_rows_for_msm);
53 }
54
60 size_t get_num_msm_rows() const
61 {
62 size_t msm_rows = num_msm_rows + 2;
65 }
66 return msm_rows;
67 }
68
74 size_t get_num_rows() const
75 {
76 // add 1 row to start and end of transcript and msm sections
77 const size_t transcript_rows = num_transcript_rows + 2;
78 size_t msm_rows = num_msm_rows + 2;
79 // add 1 row to start of precompute table section
80 size_t precompute_rows = num_precompute_table_rows + 1;
84 }
85
86 return std::max(transcript_rows, std::max(msm_rows, precompute_rows));
87 }
88
97 {
99 if (op.op_code.mul) {
100 if (op.z1 != 0 && !op.base_point.is_point_at_infinity()) {
102 }
103 if (op.z2 != 0 && !op.base_point.is_point_at_infinity()) {
105 }
106 } else if (cached_active_msm_count != 0) {
111 }
112 }
113
120 static uint32_t get_precompute_table_row_count_for_single_msm(const size_t msm_count)
121 {
122 constexpr size_t num_precompute_rows_per_scalar =
123 eccvm::NUM_WNAF_DIGITS_PER_SCALAR / eccvm::WNAF_DIGITS_PER_ROW;
124 const size_t num_rows_for_precompute_table = msm_count * num_precompute_rows_per_scalar;
125 return static_cast<uint32_t>(num_rows_for_precompute_table);
126 }
127};
128
129} // namespace bb
Class for tracking the number of rows in the ECCVM circuit and the number of muls performed as the op...
size_t get_num_rows() const
Get the number of rows for the current ECCVM circuit.
size_t get_num_msm_rows() const
Get the number of rows in the 'msm' column section, for all msms in the circuit.
uint32_t get_number_of_muls() const
static uint32_t get_precompute_table_row_count_for_single_msm(const size_t msm_count)
Get the precompute table row count for single msm object.
static uint32_t num_eccvm_msm_rows(const size_t msm_size)
Get the number of rows in the 'msm' column section of the ECCVM associated with a single multiscalar ...
void update_cached_msms(const ECCVMOperation &op)
Update cached_active_msm_count or update other row counts and reset cached_active_msm_count.
Entry point for Barretenberg command-line interface.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
AffineElement base_point