Skip to content

Commit

Permalink
1329 - enforce that 0th nullifier is non-zero in private kernel circuit
Browse files Browse the repository at this point in the history
(inner and ordering)
  • Loading branch information
jeanmon committed Sep 28, 2023
1 parent 89e280a commit a5dcc0e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ void common_validate_read_requests(DummyBuilder& builder,
}
}

void common_validate_0th_nullifier(DummyBuilder& builder, CombinedAccumulatedData<NT> 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<NT> const& private_call,
KernelCircuitPublicInputs<NT>& public_inputs)
Expand Down
4 changes: 4 additions & 0 deletions circuits/cpp/src/aztec3/circuits/kernel/private/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand All @@ -32,6 +34,8 @@ void common_validate_read_requests(DummyBuilder& builder,
std::array<ReadRequestMembershipWitness<NT, PRIVATE_DATA_TREE_HEIGHT>,
MAX_READ_REQUESTS_PER_CALL> const& read_request_membership_witnesses);

void common_validate_0th_nullifier(DummyBuilder& builder, CombinedAccumulatedData<NT> const& end);

void common_update_end_values(DummyBuilder& builder,
PrivateCallData<NT> const& private_call,
KernelCircuitPublicInputs<NT>& public_inputs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void validate_inputs(DummyCircuitBuilder& builder, PrivateKernelInputsInner<NT>
"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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ KernelCircuitPublicInputsFinal<NT> 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)`

Expand Down
1 change: 1 addition & 0 deletions circuits/cpp/src/aztec3/utils/circuit_errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a5dcc0e

Please sign in to comment.