Skip to content

Commit 66cf61d

Browse files
Define constants for sizes of special public inputs
1 parent 62aa28e commit 66cf61d

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

barretenberg/cpp/src/barretenberg/honk/types/public_inputs_type.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,29 @@ static constexpr std::size_t GRUMPKIN_OPENING_CLAIM_SIZE = 2 * FR_PUBLIC_INPUTS_
3838
// Invalid public input size, used in OpeningClaim<Curve> when Curve is not Grumpkin
3939
static constexpr std::size_t INVALID_PUBLIC_INPUTS_SIZE = 0;
4040

41+
// Number of wires in the Mega execution trace, they must be re-defined to avoid circular dependencies
42+
static constexpr std::size_t MEGA_EXECUTION_TRACE_NUM_WIRES = 4;
43+
44+
// Number of bb::fr elements used to represent the public inputs of an INIT/INNER/RESET/TAIL kernel
45+
static constexpr std::size_t KERNEL_PUBLIC_INPUTS_SIZE =
46+
/*pairing_inputs*/ PAIRING_POINTS_SIZE +
47+
/*kernel_return_data*/ GOBLIN_GROUP_PUBLIC_INPUTS_SIZE +
48+
/*app_return_data*/ GOBLIN_GROUP_PUBLIC_INPUTS_SIZE +
49+
/*table_commitments*/ MEGA_EXECUTION_TRACE_NUM_WIRES * GOBLIN_GROUP_PUBLIC_INPUTS_SIZE;
50+
51+
// Number of bb::fr elements used to represent the default public inputs, i.e., the pairing points
52+
static constexpr std::size_t DEFAULT_PUBLIC_INPUTS_SIZE = PAIRING_POINTS_SIZE;
53+
54+
// Number of bb::fr elements used to represent the public inputs of an App circuit
55+
static constexpr std::size_t APP_PUBLIC_INPUTS_SIZE = PAIRING_POINTS_SIZE;
56+
57+
// Number of bb::fr elements used to represent the public inputs of the HIDING kernel
58+
static constexpr std::size_t HIDING_KERNEL_PUBLIC_INPUTS_SIZE =
59+
/*pairing_inputs*/ PAIRING_POINTS_SIZE +
60+
/*table_commitments*/ MEGA_EXECUTION_TRACE_NUM_WIRES * GOBLIN_GROUP_PUBLIC_INPUTS_SIZE;
61+
62+
// Number of bb::fr elements used to represent the public inputs of a ROLLUP circuit
63+
static constexpr std::size_t ROLLUP_PUBLIC_INPUTS_SIZE =
64+
/*pairing_inputs*/ PAIRING_POINTS_SIZE + /*ipa_claim*/ GRUMPKIN_OPENING_CLAIM_SIZE;
65+
4166
} // namespace bb

barretenberg/cpp/src/barretenberg/special_public_inputs/special_public_inputs.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DefaultIO {
2121
using FF = curve::BN254::ScalarField;
2222
using PublicPairingPoints = PublicInputComponent<PairingPoints>;
2323

24-
static constexpr size_t PUBLIC_INPUTS_SIZE = PairingPoints::PUBLIC_INPUTS_SIZE;
24+
static constexpr size_t PUBLIC_INPUTS_SIZE = DEFAULT_PUBLIC_INPUTS_SIZE;
2525

2626
PairingPoints pairing_inputs;
2727

@@ -44,18 +44,14 @@ class DefaultIO {
4444
*/
4545
class HidingKernelIO {
4646
public:
47-
// Number of columns that jointly constitute the op_queue, should be the same as the number of wires in the
48-
// MegaCircuitBuilder
49-
static constexpr size_t NUM_WIRES = 4;
50-
5147
using FF = curve::BN254::ScalarField;
5248
using G1 = curve::BN254::AffineElement;
53-
using TableCommitments = std::array<G1, NUM_WIRES>;
49+
using TableCommitments = std::array<G1, MegaCircuitBuilder::NUM_WIRES>;
5450

5551
using PublicPairingPoints = PublicInputComponent<PairingPoints>;
5652
using PublicPoint = PublicInputComponent<G1>;
5753

58-
static constexpr size_t PUBLIC_INPUTS_SIZE = PairingPoints::PUBLIC_INPUTS_SIZE + NUM_WIRES * G1::PUBLIC_INPUTS_SIZE;
54+
static constexpr size_t PUBLIC_INPUTS_SIZE = HIDING_KERNEL_PUBLIC_INPUTS_SIZE;
5955

6056
PairingPoints pairing_inputs;
6157
TableCommitments ecc_op_tables;
@@ -90,7 +86,7 @@ class RollupIO {
9086
using PublicPairingPoints = PublicInputComponent<PairingPoints>;
9187
using PublicIpaClaim = PublicInputComponent<IpaClaim>;
9288

93-
static constexpr size_t PUBLIC_INPUTS_SIZE = PairingPoints::PUBLIC_INPUTS_SIZE + IpaClaim::PUBLIC_INPUTS_SIZE;
89+
static constexpr size_t PUBLIC_INPUTS_SIZE = ROLLUP_PUBLIC_INPUTS_SIZE;
9490

9591
PairingPoints pairing_inputs;
9692
IpaClaim ipa_claim;

barretenberg/cpp/src/barretenberg/stdlib/special_public_inputs/special_public_inputs.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ class KernelIO {
4646
// FF pg_acc_hash;
4747

4848
// Total size of the kernel IO public inputs
49-
static constexpr size_t PUBLIC_INPUTS_SIZE = PairingInputs::PUBLIC_INPUTS_SIZE + G1::PUBLIC_INPUTS_SIZE +
50-
G1::PUBLIC_INPUTS_SIZE + Builder::NUM_WIRES * G1::PUBLIC_INPUTS_SIZE;
49+
static constexpr size_t PUBLIC_INPUTS_SIZE = KERNEL_PUBLIC_INPUTS_SIZE;
5150

5251
/**
5352
* @brief Reconstructs the IO components from a public inputs array.
@@ -126,7 +125,7 @@ template <typename Builder> class DefaultIO {
126125
PairingInputs pairing_inputs;
127126

128127
// Total size of the IO public inputs
129-
static constexpr size_t PUBLIC_INPUTS_SIZE = PairingInputs::PUBLIC_INPUTS_SIZE;
128+
static constexpr size_t PUBLIC_INPUTS_SIZE = DEFAULT_PUBLIC_INPUTS_SIZE;
130129

131130
/**
132131
* @brief Reconstructs the IO components from a public inputs array.
@@ -184,8 +183,7 @@ template <class Builder_> class HidingKernelIO {
184183
TableCommitments ecc_op_tables; // commitments to merged tables obtained from final Merge verification
185184

186185
// Total size of the IO public inputs
187-
static constexpr size_t PUBLIC_INPUTS_SIZE =
188-
PairingInputs::PUBLIC_INPUTS_SIZE + Builder::NUM_WIRES * G1::PUBLIC_INPUTS_SIZE;
186+
static constexpr size_t PUBLIC_INPUTS_SIZE = HIDING_KERNEL_PUBLIC_INPUTS_SIZE;
189187

190188
/**
191189
* @brief Reconstructs the IO components from a public inputs array.
@@ -282,7 +280,7 @@ class RollupIO {
282280
IpaClaim ipa_claim;
283281

284282
// Total size of the IO public inputs
285-
static constexpr size_t PUBLIC_INPUTS_SIZE = PairingInputs::PUBLIC_INPUTS_SIZE + IpaClaim::PUBLIC_INPUTS_SIZE;
283+
static constexpr size_t PUBLIC_INPUTS_SIZE = ROLLUP_PUBLIC_INPUTS_SIZE;
286284

287285
/**
288286
* @brief Reconstructs the IO components from a public inputs array.

0 commit comments

Comments
 (0)