diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index ea3ee298746c..92b066d05ea7 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -128,17 +128,35 @@ void common_validate_arrays(DummyBuilder& builder, PrivateCircuitPublicInputs const& end) +{ + // Each of the following arrays is expected to be zero-padded. + validate_array(builder, end.read_requests, "Accumulated data - Read Requests"); + validate_array(builder, end.new_commitments, "Accumulated data - New commitments"); + validate_array(builder, end.new_nullifiers, "Accumulated data - New nullifiers"); + validate_array(builder, end.nullified_commitments, "Accumulated data - Nullified commitments"); + validate_array(builder, end.private_call_stack, "Accumulated data - Private call stack"); + validate_array(builder, end.public_call_stack, "Accumulated data - Public call stack"); + validate_array(builder, end.new_l2_to_l1_msgs, "Accumulated data - New L2 to L1 messages"); +} + void common_validate_0th_nullifier(DummyBuilder& builder, CombinedAccumulatedData const& end) { builder.do_assert(end.new_nullifiers[0] != 0, @@ -146,6 +164,12 @@ void common_validate_0th_nullifier(DummyBuilder& builder, CombinedAccumulatedDat CircuitErrorCode::PRIVATE_KERNEL__0TH_NULLLIFIER_IS_ZERO); } +void common_validate_end_values(DummyBuilder& builder, CombinedAccumulatedData const& end) +{ + common_validate_end_arrays(builder, end); + common_validate_0th_nullifier(builder, end); +} + void common_update_end_values(DummyBuilder& builder, PrivateCallData const& private_call, KernelCircuitPublicInputs& public_inputs) diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp index 97f3de0843ce..755ff4ce5a04 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp @@ -37,6 +37,8 @@ void common_validate_read_requests(DummyBuilder& builder, MAX_READ_REQUESTS_PER_CALL> const& read_request_membership_witnesses); void common_validate_arrays(DummyBuilder& builder, PrivateCircuitPublicInputs const& app_public_inputs); +void common_validate_end_arrays(DummyBuilder& builder, CombinedAccumulatedData const& end); +void common_validate_end_values(DummyBuilder& builder, CombinedAccumulatedData const& end); void common_validate_0th_nullifier(DummyBuilder& builder, CombinedAccumulatedData const& end); void common_update_end_values(DummyBuilder& builder, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp index aac28a78a1c1..62e84102dab9 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp @@ -91,8 +91,6 @@ void validate_inputs(DummyCircuitBuilder& builder, PrivateKernelInputsInner builder.do_assert(start_private_call_stack_length != 0, "Cannot execute private kernel circuit with an empty private call stack", CircuitErrorCode::PRIVATE_KERNEL__PRIVATE_CALL_STACK_EMPTY); - - common_validate_0th_nullifier(builder, private_inputs.previous_kernel.public_inputs.end); } KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyCircuitBuilder& builder, @@ -101,6 +99,8 @@ KernelCircuitPublicInputs native_private_kernel_circuit_inner(DummyCircuitBu // We'll be pushing data to this during execution of this circuit. KernelCircuitPublicInputs public_inputs{}; + common_validate_end_values(builder, private_inputs.previous_kernel.public_inputs.end); + // Do this before any functions can modify the inputs. initialise_end_values(private_inputs.previous_kernel, public_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp index 91d8a9e3381b..4d4900822900 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp @@ -154,6 +154,8 @@ KernelCircuitPublicInputsFinal native_private_kernel_circuit_ordering( // We'll be pushing data to this during execution of this circuit. KernelCircuitPublicInputsFinal public_inputs{}; + common_validate_end_values(builder, private_inputs.previous_kernel.public_inputs.end); + // Do this before any functions can modify the inputs. initialise_end_values(private_inputs.previous_kernel, public_inputs);