diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index 27e1f2ffddb9..adf1d70353a5 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -114,6 +114,13 @@ void common_validate_read_requests(DummyBuilder& builder, } } +void common_validate_0th_nullifier(DummyBuilder& builder, CombinedAccumulatedData const& end) +{ + builder.do_assert(end.new_nullifiers[0] != 0, + "The 0th nullifier in the accumulated nullifier array is zero", + CircuitErrorCode::PRIVATE_KERNEL__0TH_NULLLIFIER_IS_ZERO); +} + 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 52e26279d7b5..32f231262cce 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp @@ -2,6 +2,7 @@ #include "init.hpp" +#include "aztec3/circuits/abis/combined_accumulated_data.hpp" #include "aztec3/circuits/abis/contract_deployment_data.hpp" #include "aztec3/circuits/abis/function_data.hpp" #include "aztec3/circuits/abis/kernel_circuit_public_inputs.hpp" @@ -13,6 +14,7 @@ namespace aztec3::circuits::kernel::private_kernel { +using aztec3::circuits::abis::CombinedAccumulatedData; using aztec3::circuits::abis::ContractDeploymentData; using aztec3::circuits::abis::FunctionData; using aztec3::circuits::abis::KernelCircuitPublicInputs; @@ -32,6 +34,8 @@ void common_validate_read_requests(DummyBuilder& builder, std::array, MAX_READ_REQUESTS_PER_CALL> const& read_request_membership_witnesses); +void common_validate_0th_nullifier(DummyBuilder& builder, CombinedAccumulatedData const& 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/native_private_kernel_circuit_inner.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.cpp index fa8337b6656f..db7662394fc9 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 @@ -112,7 +112,7 @@ void validate_inputs(DummyCircuitBuilder& builder, PrivateKernelInputsInner "Cannot execute private kernel circuit with an empty private call stack", CircuitErrorCode::PRIVATE_KERNEL__PRIVATE_CALL_STACK_EMPTY); - // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1329): validate that 0th nullifier is nonzero + common_validate_0th_nullifier(builder, private_inputs.previous_kernel.public_inputs.end); } // NOTE: THIS IS A VERY UNFINISHED WORK IN PROGRESS. 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 c1fd7362e455..3e1f39183bbc 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 @@ -161,7 +161,8 @@ KernelCircuitPublicInputsFinal native_private_kernel_circuit_ordering( // Do this before any functions can modify the inputs. initialise_end_values(private_inputs.previous_kernel, public_inputs); - // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1329): validate that 0th nullifier is nonzero + common_validate_0th_nullifier(builder, private_inputs.previous_kernel.public_inputs.end); + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1486): validate that `len(new_nullifiers) == // len(nullified_commitments)` diff --git a/circuits/cpp/src/aztec3/utils/circuit_errors.hpp b/circuits/cpp/src/aztec3/utils/circuit_errors.hpp index ecb297c03213..f3a46976397c 100644 --- a/circuits/cpp/src/aztec3/utils/circuit_errors.hpp +++ b/circuits/cpp/src/aztec3/utils/circuit_errors.hpp @@ -34,6 +34,7 @@ enum CircuitErrorCode : uint16_t { PRIVATE_KERNEL__UNRESOLVED_NON_TRANSIENT_READ_REQUEST = 2021, PRIVATE_KERNEL__IS_INTERNAL_BUT_NOT_SELF_CALL = 2022, PRIVATE_KERNEL__TRANSIENT_NEW_NULLIFIER_NO_MATCH = 2023, + PRIVATE_KERNEL__0TH_NULLLIFIER_IS_ZERO = 2024, // Public kernel related errors PUBLIC_KERNEL_CIRCUIT_FAILED = 3000,