Skip to content

Commit 68e4b6f

Browse files
authored
chore: use PublicComponentKeys (#13686)
Replaces `contains_ipa_claim` and `ipa_claim_public_input_indices` with `ipa_claim_public_input_key` (a `PublicComponentKey`). This reduces the rollup flavor UH VK size in fields from 139 to 129. Note: Huge diff is due to regeneration of some Prover.toml files in `noir-protocol-circuits/crates`
1 parent f54c8a1 commit 68e4b6f

29 files changed

Lines changed: 2403 additions & 2532 deletions

File tree

barretenberg/acir_tests/internal_test_programs/double_verify_honk_proof/src/main.nr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// This circuit aggregates two Honk proof from `assert_statement`.
22
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 456;
33
global HONK_IDENTIFIER: u32 = 1;
4+
global HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS: u32 = 128;
45
fn main(
5-
verification_key: [Field; 128],
6+
verification_key: [Field; HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS],
67
// This is the proof without public inputs attached.
78
// This means: the size of this does not change with the number of public inputs.
89
proof: [Field; SIZE_OF_PROOF_IF_LOGN_IS_28],

barretenberg/acir_tests/internal_test_programs/verify_honk_proof/src/main.nr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// This circuit aggregates a single Honk proof from `assert_statement`.
22
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 456;
33
global HONK_IDENTIFIER: u32 = 1;
4+
global HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS: u32 = 128;
45
fn main(
5-
verification_key: [Field; 128],
6+
verification_key: [Field; HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS],
67
// This is the proof without public inputs attached.
78
// This means: the size of this does not change with the number of public inputs.
89
proof: [Field; SIZE_OF_PROOF_IF_LOGN_IS_28],

barretenberg/acir_tests/internal_test_programs/verify_rollup_honk_proof/src/main.nr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// This circuit aggregates a single Honk proof from `assert_statement`.
22
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 466 + 69;
33
global ROLLUP_HONK_IDENTIFIER: u32 = 5;
4+
global ROLLUP_HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS: u32 = 129;
45
fn main(
5-
verification_key: [Field; 139],
6+
verification_key: [Field; ROLLUP_HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS],
67
// This is the proof without public inputs attached.
78
// This means: the size of this does not change with the number of public inputs.
89
proof: [Field; SIZE_OF_PROOF_IF_LOGN_IS_28],

barretenberg/cpp/src/barretenberg/commitment_schemes/claim.hpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@ template <typename Curve> class OpeningClaim {
7474
commitment.set_public();
7575

7676
Builder* ctx = commitment.get_context();
77-
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1325): Eventually the builder/PK/VK will store
78-
// public input key which should be set here and ipa_claim_public_input_indices should go away.
79-
uint32_t pub_idx = start_idx;
80-
for (uint32_t& idx : ctx->ipa_claim_public_input_indices) {
81-
idx = pub_idx++;
82-
}
83-
ctx->contains_ipa_claim = true;
77+
ctx->ipa_claim_public_input_key.start_idx = start_idx;
8478

8579
return start_idx;
8680
}

barretenberg/cpp/src/barretenberg/dsl/acir_format/honk_recursion_constraint.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,10 @@ void create_dummy_vkey_and_proof(typename Flavor::CircuitBuilder& builder,
7070
}
7171

7272
if constexpr (HasIPAAccumulator<Flavor>) {
73-
// Key field is the whether the proof contains an aggregation object.
74-
builder.assert_equal(builder.add_variable(1), key_fields[offset++].witness_index);
7573
// We are making the assumption that the IPA claim is behind the inner public inputs and pairing point object
76-
for (size_t i = 0; i < bb::IPA_CLAIM_SIZE; i++) {
77-
builder.assert_equal(builder.add_variable(num_inner_public_inputs + PAIRING_POINT_ACCUMULATOR_SIZE + i),
78-
key_fields[offset].witness_index);
79-
offset++;
80-
}
74+
builder.assert_equal(builder.add_variable(num_inner_public_inputs + PAIRING_POINT_ACCUMULATOR_SIZE),
75+
key_fields[offset].witness_index);
76+
offset++;
8177
}
8278

8379
for (size_t i = 0; i < Flavor::NUM_PRECOMPUTED_ENTITIES; ++i) {

barretenberg/cpp/src/barretenberg/plonk_honk_shared/types/aggregation_object_type.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,5 @@ using PairingPointAccumulatorIndices = std::array<uint32_t, PAIRING_POINT_ACCUMU
1414
// of the nested aggregation object.
1515
using PairingPointAccumulatorPubInputIndices = std::array<uint32_t, PAIRING_POINT_ACCUMULATOR_SIZE>;
1616

17-
static constexpr uint32_t IPA_CLAIM_SIZE = 10;
18-
using IPAClaimIndices = std::array<uint32_t, IPA_CLAIM_SIZE>;
19-
using IPAClaimPubInputIndices = std::array<uint32_t, IPA_CLAIM_SIZE>;
20-
} // namespace bb
17+
static constexpr uint32_t IPA_CLAIM_SIZE = 10; // Size public inputs representaiton of a Grumpkin opening claim
18+
} // namespace bb

barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ UltraRecursiveVerifier_<Flavor>::Output UltraRecursiveVerifier_<Flavor>::verify_
8080

8181
// Parse out the aggregation object using the key->pairing_point_accumulator_public_input_indices
8282
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1325): Eventually vk stores public input key directly.
83-
const PublicComponentKey pairing_point_public_input_key{ key->pairing_point_accumulator_public_input_indices[0],
84-
true };
83+
const PublicComponentKey pairing_point_public_input_key{ key->pairing_point_accumulator_public_input_indices[0] };
8584
AggregationObject nested_agg_obj =
8685
PublicAggState::reconstruct(verification_key->public_inputs, pairing_point_public_input_key);
8786
// TODO(https://github.com/AztecProtocol/barretenberg/issues/995): generate this challenge properly.
@@ -136,15 +135,10 @@ UltraRecursiveVerifier_<Flavor>::Output UltraRecursiveVerifier_<Flavor>::verify_
136135
output.agg_obj = std::move(agg_obj);
137136

138137
// Extract the IPA claim from the public inputs
139-
// Parse out the nested IPA claim using key->ipa_claim_public_input_indices and run the native IPA verifier.
140138
if constexpr (HasIPAAccumulator<Flavor>) {
141139
using PublicIpaClaim = PublicInputComponent<OpeningClaim<grumpkin<Builder>>>;
142-
143-
if (verification_key->verification_key->contains_ipa_claim) {
144-
PublicComponentKey ipa_claim_key{ verification_key->verification_key->ipa_claim_public_input_indices[0],
145-
true };
146-
output.ipa_claim = PublicIpaClaim::reconstruct(verification_key->public_inputs, ipa_claim_key);
147-
}
140+
output.ipa_claim = PublicIpaClaim::reconstruct(verification_key->public_inputs,
141+
verification_key->verification_key->ipa_claim_public_input_key);
148142
}
149143

150144
return output;

barretenberg/cpp/src/barretenberg/stdlib/primitives/public_input_component/public_input_component.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,14 @@ class PublicInputComponent {
4646
{
4747
Key key;
4848
key.start_idx = component.set_public();
49-
key.exists_flag = true;
5049
return key;
5150
}
5251

5352
// Reconstruct the component from the public inputs and the key indicating its location
5453
static ComponentType reconstruct(const std::vector<Fr>& public_inputs, const Key& key)
5554
{
5655
// Ensure that the key has been set
57-
if (!key.exists_flag) {
56+
if (!key.is_set()) {
5857
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1284): determine when/whether a check of this
5958
// form is needed: info("WARNING: Trying to construct a PublicInputComponent from an invalid key!");
6059
// ASSERT(false);

barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/circuit_builder_base.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ template <typename FF_> class CircuitBuilderBase {
4343
PairingPointAccumulatorPubInputIndices pairing_point_accumulator_public_input_indices;
4444
bool contains_pairing_point_accumulator = false;
4545

46-
// Public input indices which contain the output IPA opening claim
47-
IPAClaimPubInputIndices ipa_claim_public_input_indices;
48-
bool contains_ipa_claim = false;
46+
// Index of the IPA opening claim in the public inputs
47+
PublicComponentKey ipa_claim_public_input_key;
4948

5049
// We know from the CLI arguments during proving whether a circuit should use a prover which produces
5150
// proofs that are friendly to verify in a circuit themselves. A verifier does not need a full circuit

barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/public_component_key.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ namespace bb {
66

77
// The data needed to reconstruct a public input component from its limbs stored in the public inputs
88
struct PublicComponentKey {
9-
uint32_t start_idx = 0; // start index within public inputs array
10-
bool exists_flag = false; // flag indicating exitence of component in the PI
9+
constexpr static uint32_t DEFAULT_IDX = std::numeric_limits<uint32_t>::max();
10+
uint32_t start_idx = DEFAULT_IDX; // start index within public inputs array
1111

1212
bool operator==(const PublicComponentKey&) const = default;
1313

14-
MSGPACK_FIELDS(start_idx, exists_flag);
14+
bool is_set() const { return start_idx != DEFAULT_IDX; }
15+
16+
MSGPACK_FIELDS(start_idx);
1517
};
1618
} // namespace bb

0 commit comments

Comments
 (0)