Skip to content

draft: aztec-nr review#21213

Closed
LeilaWang wants to merge 1 commit intonextfrom
lw/aztec_nr_review
Closed

draft: aztec-nr review#21213
LeilaWang wants to merge 1 commit intonextfrom
lw/aztec_nr_review

Conversation

@LeilaWang
Copy link
Copy Markdown
Contributor

Please read contributing guidelines and remove this line.

For audit-related pull requests, please use the audit PR template.

Copy link
Copy Markdown
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the comments! Replied to most of them, for some I'll be opening PRs soon, for others only ~1 week from now as we want to not cause a lot of API breakage right now, but we'll definitely get to them before March is over.

I do have some follow-up questions in some of these.

Thanks again!

// If it's used for hashing with sha256 (as suggested in DAppPayload.to_be_bytes()), it could save quite a bit
// of gates.
// But the code doesn't seem to be used anywhere. Hashing of the payload uses serialize() and poseidon instead.
// Do we want to keep this?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove in the next pass, thanks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #22243

@@ -1,2 +1,3 @@
// TODO: Can be deleted. Not used anywhere.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will also remove, thanks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #22244.

@@ -1108,6 +1116,9 @@ impl PrivateContext {
args_hash: Field,
is_static_call: bool,
) -> ReturnsHash {
// Q: It can be misleading to make a static call when the caller specifically requests a non-static call
// (`is_static_call == false`). Although this is not allowed and will cause the kernel to fail.
// But rather than altering the user's intent, throw an error from the simulator might be better?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, there's a planned refactor to call interfaces. In practice this ends up not happening as users don't construct these calls manually, but we should still fix the plumbing here.

@@ -46,6 +46,8 @@ pub fn fields_from_bytes<let N: u32>(bytes: BoundedVec<u8, N>) -> BoundedVec<Fie
let p = std::field::modulus_be_bytes();

// Since input length is a multiple of 32, we can simply process all chunks fully
// TODO: Should be `for i in 0..N / 32 { if i < bytes.len() / 32 { ... } }` instead.
// This hasn't caused any problem because it's only used in an unconstrained fn at the moment.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This function is due a small rework, as the name doesn't clearly explain what it is it does (it's not 'conversion'), we'll make it unconstrained as part of that.

for i in 0..N {
if idx == 32 {
randomness = random().to_be_bytes();
idx = 1; // Skip the first byte as it's biased (not uniformly distributed over 0-255).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We got rid of this entire file as this function was bad, replaced for the new poseidon masking mechanism

@@ -50,6 +50,8 @@ impl NoteHash for UintNote {

// Then compute the completion note hash. In a real partial note this step would be performed in public.
partial_note.compute_complete_note_hash(self.value)

// Q: The partial note and the complete note probably shouldn't use the same domain separator?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the followup work to be done in #21189 - we need new domseps, and we need to change how the final note hash is computed (so that it guarantees separation by storage slot).

Partial note hash construction is about to get reworked, which is why this looks wrong now.

@@ -225,6 +227,7 @@ impl PartialUintNote {
// contract that emitted the nullifier) as it checks the value directly against the nullifier tree and all the
// nullifiers in the tree are siloed by the protocol.
let siloed_validity_commitment = compute_siloed_nullifier(context.this_address(), validity_commitment);
// Q: Why not use context.assert_nullifier_exists()?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear, that function may not have been nicely exposed at the time. Agreed that this is better, thanks. Possibly done this way because the author was porting the public case, and had settled nullifiers in mind.

// and that all side effects emitted in the child call have counters within the range
// [start_side_effect_counter, end_side_effect_counter].
// Therefore, we only need to ensure that the next side effect from the current call starts after the
// end side effect from the child call.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #22245.

@nventuro
Copy link
Copy Markdown
Contributor

nventuro commented Apr 1, 2026

Thanks! I left comments about where the different issues you highlighted are resolved, the remaining minor bits were done in #22251. We can now close this.

@nventuro nventuro closed this Apr 1, 2026
@nventuro nventuro deleted the lw/aztec_nr_review branch April 1, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants