Skip to content

Commit

Permalink
1329 - add unit test for ordering and inner native private kernel
Browse files Browse the repository at this point in the history
circuit on 0-th nullifier being non-zero
  • Loading branch information
jeanmon committed Sep 28, 2023
1 parent 4c7e2a0 commit ec31d12
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -745,4 +745,20 @@ TEST_F(native_private_kernel_inner_tests, native_logs_are_hashed_as_expected)
ASSERT_EQ(public_inputs.end.unencrypted_logs_hash, expected_unencrypted_logs_hash);
}

TEST_F(native_private_kernel_inner_tests, 0th_nullifier_zero_fails)
{
auto private_inputs = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args());

// Change the 0th nullifier to be zero.
private_inputs.previous_kernel.public_inputs.end.new_nullifiers[0] = 0;

// Invoke the native private kernel circuit
DummyBuilder builder = DummyBuilder("private_kernel_tests__0th_nullifier_zero_fails");
native_private_kernel_circuit_inner(builder, private_inputs);

// Assertion checks
EXPECT_TRUE(builder.failed());
EXPECT_EQ(builder.get_first_failure().code, CircuitErrorCode::PRIVATE_KERNEL__0TH_NULLLIFIER_IS_ZERO);
}

} // namespace aztec3::circuits::kernel::private_kernel
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,21 @@ TEST_F(native_private_kernel_ordering_tests, native_empty_nullified_commitment_m
ASSERT_TRUE(array_length(public_inputs.end.new_nullifiers) == 1);
}

TEST_F(native_private_kernel_ordering_tests, 0th_nullifier_zero_fails)
{
auto private_inputs_inner = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args());

std::array<fr, MAX_NEW_NULLIFIERS_PER_TX> new_nullifiers{};
auto& previous_kernel = private_inputs_inner.previous_kernel;
previous_kernel.public_inputs.end.new_nullifiers = new_nullifiers;
PrivateKernelInputsOrdering<NT> private_inputs{ .previous_kernel = previous_kernel };

DummyBuilder builder = DummyBuilder("native_private_kernel_ordering_tests__0th_nullifier_zero_fails");
auto public_inputs = native_private_kernel_circuit_ordering(builder, private_inputs);

ASSERT_TRUE(builder.failed());
auto failure = builder.get_first_failure();
ASSERT_EQ(failure.code, CircuitErrorCode::PRIVATE_KERNEL__0TH_NULLLIFIER_IS_ZERO);
}

} // namespace aztec3::circuits::kernel::private_kernel

0 comments on commit ec31d12

Please sign in to comment.