Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
constants.hpp
Go to the documentation of this file.
1#pragma once
2#include <cmath>
3#include <cstddef>
4#include <cstdint>
5
6namespace bb {
7
8// Arbitrarily large constant (> size of the BN254 srs) used to ensure that the evaluations on the hypercube of the
9// permutation argument polynomials (sigmas, ids) are unique, e.g. id[i][j] == id[m][n] iff (i == m && j == n)
10constexpr uint32_t PERMUTATION_ARGUMENT_VALUE_SEPARATOR = 1 << 28;
11
12// The fixed size of the Translator trace where each accumulation gate, corresponding to one UltraOp, will occupy two
13// rows.
14static constexpr uint32_t CONST_TRANSLATOR_MINI_CIRCUIT_LOG_SIZE = 13;
15
16// -1 as each op occupies two rows in Translator trace
17static constexpr uint32_t CONST_OP_QUEUE_LOG_SIZE = CONST_TRANSLATOR_MINI_CIRCUIT_LOG_SIZE - 1;
18
19// The log of the max circuit size assumed in order to achieve constant sized Honk proofs
20// TODO(https://github.com/AztecProtocol/barretenberg/issues/1046): Remove the need for const sized proofs
21static constexpr uint32_t CONST_PROOF_SIZE_LOG_N = 25;
22
23// The log of the max circuit size of circuits being folded. This size is assumed by the HN prover and verifier in order
24// to ensure a constant HN proof size and a HN recursive verifier circuit that is independent of the size of the
25// circuits being folded.
26static constexpr uint32_t CONST_FOLDING_LOG_N = 24;
27// Hiding kernel is a constant circuit that is being proven with MegaZKFlavor as a part Chonk
28static constexpr uint32_t HIDING_KERNEL_LOG_N = 16;
29// The size of the AVMRecursiveVerifier circuit arithmetized with Mega.
30static constexpr uint32_t MEGA_AVM_LOG_N = 21;
31
32static constexpr uint32_t CONST_ECCVM_LOG_N = 15;
33
34// IPA proof length: 4 * CONST_ECCVM_LOG_N (L and R commitments) + 2 (G_0) + 2 (a_0)
35// Note: Updating this requires updating noir protocol circuits (rollup-base-private,
36// rollup-base-public, rollup-block-merge, rollup-block-root, rollup-merge, rollup-root)
37static constexpr size_t IPA_PROOF_LENGTH = (4 * CONST_ECCVM_LOG_N) + 4;
38
39// The number of rows randomized to mask witness polynomials, hiding (1) witness commitments, (2) multilinear
40// evaluations of witness polynomials in Sumcheck, (3) evaluations of shifted witness polynomials in Sumcheck or
41// univariate evaluations required in ECCVM. The masking values are placed in the rows NUM_ZERO_ROWS .. TRACE_OFFSET +
42// NUM_ZERO_ROWS - 1 of the trace. (Recall that the first NUM_ZERO_ROWS are zeroed out.)
43static constexpr uint32_t NUM_MASKED_ROWS = 3;
44
45// The first NUM_MASKED_ROWS + 1 rows are disabled in Sumcheck (= TRACE_OFFSET = NUM_DISABLED_ROWS_IN_SUMCHECK). The
46// +1 accounts for shifts: the relation at row TRACE_OFFSET involves w_shift(TRACE_OFFSET) = w(TRACE_OFFSET + 1),
47// but the gate separator vanishes there, so the first row where relations are active is TRACE_OFFSET.
48static constexpr uint32_t NUM_DISABLED_ROWS_IN_SUMCHECK = NUM_MASKED_ROWS + 1;
49
50// For ZK Flavors: the number of the commitments required by Libra and SmallSubgroupIPA.
51static constexpr uint32_t NUM_LIBRA_COMMITMENTS = 3;
52
53// The SmallSubgroupIPA is a sub-protocol used in several Flavors, to prove claimed inner product, the Prover sends 4
54// extra evaluations
55static constexpr uint32_t NUM_SMALL_IPA_EVALUATIONS = 4;
56
57static constexpr uint32_t MERGE_PROOF_SIZE = 42; // used to ensure mock proofs are generated correctly
58
59// There are 5 distinguished wires in ECCVM that have to be opened as univariates to establish the connection between
60// ECCVM and Translator
61static constexpr uint32_t NUM_TRANSLATION_EVALUATIONS = 5;
62
63// The number of leading zero rows in the execution trace. Used to enable shifted polynomials.
64static constexpr size_t NUM_ZERO_ROWS = 1;
65
66// The maximum number of app circuits a single kernel can recursively verify in one accumulation group.
67static constexpr uint8_t MAX_APPS_PER_KERNEL = 3;
68
69static constexpr size_t CHONK_MAX_NUM_APPS = 36;
70static constexpr size_t compute_chonk_max_num_circuits()
71{
72 return CHONK_MAX_NUM_APPS + ((CHONK_MAX_NUM_APPS + MAX_APPS_PER_KERNEL - 1) / MAX_APPS_PER_KERNEL) +
73 /*trailing kernels*/ 3;
74}
75static constexpr size_t CHONK_MAX_NUM_CIRCUITS = compute_chonk_max_num_circuits();
76
77static constexpr size_t BATCH_MERGE_PROOF_SIZE =
78 /*num subtables*/ 1 +
79 /*shift sizes*/ CHONK_MAX_NUM_CIRCUITS +
80 /*commitments*/ (4 * (4 * (CHONK_MAX_NUM_CIRCUITS + /*zk tables, merged tables*/ 2) + /*degree check*/ 1)) +
81 /*evals*/ (4 * (CHONK_MAX_NUM_CIRCUITS + 2) + 1) +
82 /*shplonk and kzg*/ 8;
83} // namespace bb
Entry point for Barretenberg command-line interface.
Definition api.hpp:5
constexpr uint32_t PERMUTATION_ARGUMENT_VALUE_SEPARATOR
Definition constants.hpp:10