Skip to content

Commit 418a397

Browse files
committed
Merge with next
2 parents 84d3e40 + ae4bc46 commit 418a397

File tree

211 files changed

+4736
-3072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+4736
-3072
lines changed

barretenberg/cpp/pil/vm2/context.pil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ namespace execution;
128128

129129
// The initial next_context_id = 2, in row = 1
130130
#[INCR_NEXT_CONTEXT_ID]
131-
NOT_LAST_EXEC * (next_context_id' - (next_context_id + sel_enter_call)) = 0;
131+
NOT_LAST_EXEC * (next_context_id' - (next_context_id + sel_enter_call + enqueued_call_start')) = 0;
132132

133133
// nested_exit_call = 1 ==> context_id' = parent_id
134134
// sel_enter_call = 1 ==> context_id' = next_context_id
@@ -235,12 +235,12 @@ namespace execution;
235235
#[PROPAGATE_RD_SIZE]
236236
NOT_LAST_EXEC * DEFAULT_CTX_ROW * (last_child_returndata_size' - last_child_returndata_size) = 0;
237237

238-
// sel_exit_call = 1 ==> last_child_id' = context_id; <-- sel_exit_call includes error case
238+
// nested_exit_call = 1 ==> last_child_id' = context_id; <-- sel_exit_call includes error case
239239
// sel_enter_call = 1 ==> last_child_id' = 0;
240240
// enqueued_call_start = 1 ==> last_child_id = 0; <-- Current row is 0
241241
// otherwise = 0 ==> last_child_id' = last_child_id;
242242
#[EXIT_CALL_LAST_CHILD_ID]
243-
NOT_LAST_EXEC * sel_exit_call * (last_child_id' - context_id) = 0;
243+
NOT_LAST_EXEC * nested_exit_call * (last_child_id' - context_id) = 0;
244244
#[ENTER_CALL_LAST_CHILD_ID]
245245
NOT_LAST_EXEC * sel_enter_call * last_child_id' = 0;
246246
#[LAST_CHILD_ID_IS_ZERO]

barretenberg/cpp/pil/vm2/opcodes/internal_call.pil

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ namespace execution;
1919
// When we encounter this case, the internal call information in the next row is constrained to change (incremented, unwound, etc)
2020
pol NEW_NEXT_CALL_ID = (sel_execute_internal_call + sel_execute_internal_return) * (1 - sel_error) + sel_exit_call;
2121

22-
pol PROPAGATE_CALL_ID = 1 - RESET_NEXT_CALL_ID - NEW_NEXT_CALL_ID;
22+
// This is an XOR
23+
pol RESET_OR_NEW_NEXT_CALL_ID = (RESET_NEXT_CALL_ID + NEW_NEXT_CALL_ID) - (RESET_NEXT_CALL_ID * NEW_NEXT_CALL_ID);
24+
pol PROPAGATE_CALL_ID = 1 - RESET_OR_NEW_NEXT_CALL_ID;
2325

2426
// =============================
2527
// === Internal Call Pointer ===
@@ -57,9 +59,8 @@ namespace execution;
5759
#[NEXT_CALL_ID_STARTS_TWO]
5860
RESET_NEXT_CALL_ID * (next_internal_call_id' - 2) = 0;
5961
// If we encounter a sel_execute_internal_call, we increment the next next_internal_call_id, unless we are changing context
60-
pol CONTEXT_CHANGE = (RESET_NEXT_CALL_ID + sel_exit_call) - (RESET_NEXT_CALL_ID * sel_exit_call) ;
6162
#[INCR_NEXT_INT_CALL_ID]
62-
NOT_LAST_EXEC * (1 - CONTEXT_CHANGE) * (next_internal_call_id' - (next_internal_call_id + sel_execute_internal_call)) = 0;
63+
NOT_LAST_EXEC * (1 - RESET_OR_NEW_NEXT_CALL_ID) * (next_internal_call_id' - (next_internal_call_id + sel_execute_internal_call)) = 0;
6364

6465
// =============================
6566
// === Error Handling ====

barretenberg/cpp/scripts/test_civc_standalone_vks_havent_changed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cd ..
1111
# - Generate a hash for versioning: sha256sum bb-civc-inputs.tar.gz
1212
# - Upload the compressed results: aws s3 cp bb-civc-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-civc-inputs-[hash(0:8)].tar.gz
1313
# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0
14-
pinned_short_hash="f22d116f"
14+
pinned_short_hash="e5081516"
1515
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-${pinned_short_hash}.tar.gz"
1616

1717
function compress_and_upload {

barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ ClientIVC::ClientIVC(size_t num_circuits, TraceSettings trace_settings)
2828
size_t commitment_key_size =
2929
std::max(trace_settings.dyadic_size(), 1UL << TranslatorFlavor::CONST_TRANSLATOR_LOG_N);
3030
info("BN254 commitment key size: ", commitment_key_size);
31-
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1420): pass commitment keys by value
3231
bn254_commitment_key = CommitmentKey<curve::BN254>(commitment_key_size);
3332
}
3433

@@ -458,7 +457,6 @@ void ClientIVC::accumulate(ClientCircuit& circuit, const std::shared_ptr<MegaVer
458457
// If the current circuit overflows past the current size of the commitment key, reinitialize accordingly.
459458
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1319)
460459
if (proving_key->dyadic_size() > bn254_commitment_key.dyadic_size) {
461-
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1420): pass commitment keys by value
462460
bn254_commitment_key = CommitmentKey<curve::BN254>(proving_key->dyadic_size());
463461
goblin.commitment_key = bn254_commitment_key;
464462
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111
#include "barretenberg/common/op_count.hpp"
1212
#include "barretenberg/common/throw_or_abort.hpp"
1313
#include "barretenberg/dsl/acir_format/civc_recursion_constraints.hpp"
14+
#include "barretenberg/dsl/acir_format/ecdsa_constraints.hpp"
1415
#include "barretenberg/dsl/acir_format/honk_recursion_constraint.hpp"
1516
#include "barretenberg/dsl/acir_format/pg_recursion_constraint.hpp"
1617
#include "barretenberg/dsl/acir_format/proof_surgeon.hpp"
1718
#include "barretenberg/flavor/flavor.hpp"
1819
#include "barretenberg/honk/proving_key_inspector.hpp"
1920
#include "barretenberg/stdlib/eccvm_verifier/verifier_commitment_key.hpp"
2021
#include "barretenberg/stdlib/primitives/curves/grumpkin.hpp"
22+
#include "barretenberg/stdlib/primitives/curves/secp256k1.hpp"
23+
#include "barretenberg/stdlib/primitives/curves/secp256r1.hpp"
2124
#include "barretenberg/stdlib/primitives/field/field_conversion.hpp"
2225
#include "barretenberg/stdlib/primitives/pairing_points.hpp"
2326
#include "barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp"
@@ -185,15 +188,15 @@ void build_constraints(Builder& builder, AcirProgram& program, const ProgramMeta
185188
// Add ECDSA k1 constraints
186189
for (size_t i = 0; i < constraint_system.ecdsa_k1_constraints.size(); ++i) {
187190
const auto& constraint = constraint_system.ecdsa_k1_constraints.at(i);
188-
create_ecdsa_k1_verify_constraints(builder, constraint, has_valid_witness_assignments);
191+
create_ecdsa_verify_constraints<stdlib::secp256k1<Builder>>(builder, constraint, has_valid_witness_assignments);
189192
gate_counter.track_diff(constraint_system.gates_per_opcode,
190193
constraint_system.original_opcode_indices.ecdsa_k1_constraints.at(i));
191194
}
192195

193196
// Add ECDSA r1 constraints
194197
for (size_t i = 0; i < constraint_system.ecdsa_r1_constraints.size(); ++i) {
195198
const auto& constraint = constraint_system.ecdsa_r1_constraints.at(i);
196-
create_ecdsa_r1_verify_constraints(builder, constraint, has_valid_witness_assignments);
199+
create_ecdsa_verify_constraints<stdlib::secp256r1<Builder>>(builder, constraint, has_valid_witness_assignments);
197200
gate_counter.track_diff(constraint_system.gates_per_opcode,
198201
constraint_system.original_opcode_indices.ecdsa_r1_constraints.at(i));
199202
}

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
#include "blake3_constraint.hpp"
2020
#include "block_constraint.hpp"
2121
#include "ec_operations.hpp"
22-
#include "ecdsa_secp256k1.hpp"
23-
#include "ecdsa_secp256r1.hpp"
22+
#include "ecdsa_constraints.hpp"
2423
#include "honk_recursion_constraint.hpp"
2524
#include "keccak_constraint.hpp"
2625
#include "logic_constraint.hpp"
@@ -89,8 +88,8 @@ struct AcirFormat {
8988
std::vector<RangeConstraint> range_constraints;
9089
std::vector<AES128Constraint> aes128_constraints;
9190
std::vector<Sha256Compression> sha256_compression;
92-
std::vector<EcdsaSecp256k1Constraint> ecdsa_k1_constraints;
93-
std::vector<EcdsaSecp256r1Constraint> ecdsa_r1_constraints;
91+
std::vector<EcdsaConstraint> ecdsa_k1_constraints;
92+
std::vector<EcdsaConstraint> ecdsa_r1_constraints;
9493
std::vector<Blake2sConstraint> blake2s_constraints;
9594
std::vector<Blake3Constraint> blake3_constraints;
9695
std::vector<Keccakf1600> keccak_permutations;

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "barretenberg/op_queue/ecc_op_queue.hpp"
99

1010
#include "barretenberg/serialize/test_helper.hpp"
11-
#include "ecdsa_secp256k1.hpp"
1211

1312
using namespace bb;
1413
using namespace bb::crypto;

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "barretenberg/common/container.hpp"
1818
#include "barretenberg/common/map.hpp"
1919
#include "barretenberg/common/throw_or_abort.hpp"
20+
#include "barretenberg/dsl/acir_format/ecdsa_constraints.hpp"
2021
#include "barretenberg/dsl/acir_format/recursion_constraint.hpp"
2122
#include "barretenberg/honk/execution_trace/gate_data.hpp"
2223
#include "barretenberg/numeric/uint256/uint256.hpp"
@@ -651,7 +652,7 @@ void handle_blackbox_func_call(Acir::Opcode::BlackBoxFuncCall const& arg, AcirFo
651652
}
652653
af.original_opcode_indices.blake3_constraints.push_back(opcode_index);
653654
} else if constexpr (std::is_same_v<T, Acir::BlackBoxFuncCall::EcdsaSecp256k1>) {
654-
af.ecdsa_k1_constraints.push_back(EcdsaSecp256k1Constraint{
655+
af.ecdsa_k1_constraints.push_back(EcdsaConstraint{
655656
.hashed_message =
656657
transform::map(*arg.hashed_message, [](auto& e) { return get_witness_from_function_input(e); }),
657658
.signature =
@@ -665,16 +666,16 @@ void handle_blackbox_func_call(Acir::Opcode::BlackBoxFuncCall const& arg, AcirFo
665666
af.constrained_witness.insert(af.ecdsa_k1_constraints.back().result);
666667
af.original_opcode_indices.ecdsa_k1_constraints.push_back(opcode_index);
667668
} else if constexpr (std::is_same_v<T, Acir::BlackBoxFuncCall::EcdsaSecp256r1>) {
668-
af.ecdsa_r1_constraints.push_back(EcdsaSecp256r1Constraint{
669+
af.ecdsa_r1_constraints.push_back(EcdsaConstraint{
669670
.hashed_message =
670671
transform::map(*arg.hashed_message, [](auto& e) { return get_witness_from_function_input(e); }),
672+
.signature =
673+
transform::map(*arg.signature, [](auto& e) { return get_witness_from_function_input(e); }),
671674
.pub_x_indices =
672675
transform::map(*arg.public_key_x, [](auto& e) { return get_witness_from_function_input(e); }),
673676
.pub_y_indices =
674677
transform::map(*arg.public_key_y, [](auto& e) { return get_witness_from_function_input(e); }),
675678
.result = arg.output.value,
676-
.signature =
677-
transform::map(*arg.signature, [](auto& e) { return get_witness_from_function_input(e); }),
678679
});
679680
af.constrained_witness.insert(af.ecdsa_r1_constraints.back().result);
680681
af.original_opcode_indices.ecdsa_r1_constraints.push_back(opcode_index);

barretenberg/cpp/src/barretenberg/dsl/acir_format/avm2_recursion_constraint.cpp

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ namespace {
4646
*/
4747
void create_dummy_vkey_and_proof(Builder& builder,
4848
[[maybe_unused]] size_t proof_size,
49-
size_t public_inputs_size,
5049
const std::vector<field_ct>& key_fields,
5150
const std::vector<field_ct>& proof_fields)
5251
{
@@ -70,27 +69,7 @@ void create_dummy_vkey_and_proof(Builder& builder,
7069
offset++;
7170
};
7271

73-
// Relevant source for proof layout: AvmFlavor::Transcript::serialize_full_transcript()
74-
// TODO(#13390): Revive this assertion (and remove the >= 0 one) once we freeze the number of colums in AVM.
75-
// assert((proof_size - Flavor::NUM_WITNESS_ENTITIES * Flavor::NUM_FRS_COM -
76-
// (Flavor::NUM_ALL_ENTITIES + 1) * Flavor::NUM_FRS_FR - Flavor::NUM_FRS_COM) %
77-
// (Flavor::NUM_FRS_COM + Flavor::NUM_FRS_FR * (Flavor::BATCHED_RELATION_PARTIAL_LENGTH + 1)) ==
78-
// 0);
79-
80-
// Derivation of circuit size based on the proof
81-
// TODO#13390): Revive the following code once we freeze the number of colums in AVM.
82-
// const auto log_circuit_size =
83-
// (proof_size - Flavor::NUM_WITNESS_ENTITIES * Flavor::NUM_FRS_COM -
84-
// (Flavor::NUM_ALL_ENTITIES + 1) * Flavor::NUM_FRS_FR - Flavor::NUM_FRS_COM) /
85-
// (Flavor::NUM_FRS_COM + Flavor::NUM_FRS_FR * (Flavor::BATCHED_RELATION_PARTIAL_LENGTH + 1));
86-
const auto log_circuit_size = numeric::get_msb(avm2::CIRCUIT_SUBGROUP_SIZE);
87-
88-
// First key field is log circuit size
89-
builder.set_variable(key_fields[0].witness_index, log_circuit_size);
90-
// Second key field is number of public inputs
91-
builder.set_variable(key_fields[1].witness_index, public_inputs_size);
92-
93-
size_t offset = 2;
72+
size_t offset = 0;
9473
for (size_t i = 0; i < Flavor::NUM_PRECOMPUTED_ENTITIES; ++i) {
9574
set_dummy_commitment(key_fields, offset);
9675
}
@@ -106,7 +85,7 @@ void create_dummy_vkey_and_proof(Builder& builder,
10685
}
10786

10887
// now the univariates
109-
for (size_t i = 0; i < CONST_PROOF_SIZE_LOG_N * Flavor::BATCHED_RELATION_PARTIAL_LENGTH; i++) {
88+
for (size_t i = 0; i < avm2::MAX_AVM_TRACE_LOG_SIZE * Flavor::BATCHED_RELATION_PARTIAL_LENGTH; i++) {
11089
set_dummy_evaluation_in_proof_fields(offset);
11190
}
11291

@@ -116,12 +95,12 @@ void create_dummy_vkey_and_proof(Builder& builder,
11695
}
11796

11897
// now the gemini fold commitments which are CONST_PROOF_SIZE_LOG_N - 1
119-
for (size_t i = 1; i < CONST_PROOF_SIZE_LOG_N; i++) {
98+
for (size_t i = 1; i < avm2::MAX_AVM_TRACE_LOG_SIZE; i++) {
12099
set_dummy_commitment(proof_fields, offset);
121100
}
122101

123102
// the gemini fold evaluations which are CONST_PROOF_SIZE_LOG_N
124-
for (size_t i = 0; i < CONST_PROOF_SIZE_LOG_N; i++) {
103+
for (size_t i = 0; i < avm2::MAX_AVM_TRACE_LOG_SIZE; i++) {
125104
set_dummy_evaluation_in_proof_fields(offset);
126105
}
127106

@@ -160,7 +139,7 @@ HonkRecursionConstraintOutput<Builder> create_avm2_recursion_constraints_goblin(
160139

161140
// Populate the key fields and proof fields with dummy values to prevent issues (e.g. points must be on curve).
162141
if (!has_valid_witness_assignments) {
163-
create_dummy_vkey_and_proof(builder, input.proof.size(), input.public_inputs.size(), key_fields, proof_fields);
142+
create_dummy_vkey_and_proof(builder, input.proof.size(), key_fields, proof_fields);
164143
}
165144

166145
// Execute the Goblin AVM2 recursive verifier

barretenberg/cpp/src/barretenberg/dsl/acir_format/avm2_recursion_constraint.test.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "barretenberg/dsl/acir_format/acir_format_mocks.hpp"
66
#include "barretenberg/dsl/acir_format/avm2_recursion_constraint.hpp"
77
#include "barretenberg/dsl/acir_format/proof_surgeon.hpp"
8+
#include "barretenberg/dsl/acir_format/utils.hpp"
89
#include "barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp"
910
#include "barretenberg/ultra_honk/decider_keys.hpp"
1011
#include "barretenberg/ultra_honk/ultra_prover.hpp"
@@ -80,23 +81,10 @@ class AcirAvm2RecursionConstraint : public ::testing::Test {
8081
const std::vector<fr> proof_witnesses = inner_circuit_data.proof;
8182
const std::vector<fr> public_inputs_witnesses = inner_circuit_data.public_inputs_flat;
8283

83-
// Helper to append some values to the witness vector and return their corresponding indices
84-
auto add_to_witness_and_track_indices =
85-
[&witness](const std::vector<bb::fr>& input) -> std::vector<uint32_t> {
86-
std::vector<uint32_t> indices;
87-
indices.reserve(input.size());
88-
auto witness_idx = static_cast<uint32_t>(witness.size());
89-
for (const auto& value : input) {
90-
witness.push_back(value);
91-
indices.push_back(witness_idx++);
92-
}
93-
return indices;
94-
};
95-
9684
RecursionConstraint avm_recursion_constraint{
97-
.key = add_to_witness_and_track_indices(key_witnesses),
98-
.proof = add_to_witness_and_track_indices(proof_witnesses),
99-
.public_inputs = add_to_witness_and_track_indices(public_inputs_witnesses),
85+
.key = add_to_witness_and_track_indices<bb::fr>(witness, key_witnesses),
86+
.proof = add_to_witness_and_track_indices<bb::fr>(witness, proof_witnesses),
87+
.public_inputs = add_to_witness_and_track_indices<bb::fr>(witness, public_inputs_witnesses),
10088
.key_hash = 0, // not used
10189
.proof_type = AVM,
10290
};

0 commit comments

Comments
 (0)