Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify variants of compute_note_hash_and_nullif #11638

Closed
Tracked by #9119
nventuro opened this issue Jan 30, 2025 · 0 comments · Fixed by #12171
Closed
Tracked by #9119

Simplify variants of compute_note_hash_and_nullif #11638

nventuro opened this issue Jan 30, 2025 · 0 comments · Fixed by #12171
Labels
C-aztec.nr Component: Aztec smart contract framework team-fairies Nico's team

Comments

@nventuro
Copy link
Contributor

nventuro commented Jan 30, 2025

Now that we are performing nonce discovery inside aztec-nr we have multiple places in which we need to invoke this function. Ideally we'd simply remove the top-level unconstrained compute_note_hash_and_nullif fn, have the macros inject a contract library method with the note::discovery::ComputeNoteHashAndNullifier signature and just use that everywhere. We could also delete the utility in notes/utils.nr since it just adds more calls back and forth, resulting in making it hard to follow what's going on.

This would also be a good opportunity to make sure we're not trusting the contract to perform correct siloing of note hashes and instead do it ourselves in PXE.

@nventuro nventuro added team-fairies Nico's team C-aztec.nr Component: Aztec smart contract framework labels Jan 30, 2025
nventuro added a commit that referenced this issue Feb 21, 2025
This removes the `addNote` function from PXE (`addNullifiedNote` had
been removed in #11822). With this change, PXE no longer needs to
understand how to compute note hashes and perform nonce discovery, which
means we can also get rid of all of that code, _plus_ we can delete the
mandatory `compute_note_hash_and_optionally_a_nullifier` contract
function, _plus_ all of the auxiliary code used to call those.

Instead, contracts that wish to deliver notes to their recipients via
offchain mechanisms (i.e. not the protocol logs) must create custom
unconstrained functions that know how to construct said notes and add
them to PXE. For cases such as `TransparentNote`, where all of the note
contents are public already, this is quite simple:
`aztec::discovery::process_private_log` can be leveraged to a great
degree by mimicking the log encoding aztec-nr uses - see the
TokenBlacklist and Test contracts for examples of this. More fine
grained control could be achieved by calling
`aztec::discovery::attempt_note_nonce_discovery` and then the
`deliver_note` oracle (which is essentially what `process_private_log`
does, sans the decoding).

The removal of `compute_note_hash_and_optionally_a_nullifier` freed us
from some legacy burdens in having to produce the 4 field array, dealing
with optional nullifier computation, etc., which in turn allowed for the
contract library method `_compute_note_hash_and_optionally_a_nullifier`
to be streamlined and converted into the new
`compute_note_hash_and_nullifier`, which matches
`aztec::discovery::ComputeNoteHashAndNullifier` and hence results in
much easier use of the discovery functions.

Tagging @critesjosh since `addNote` was quite a basic and old primitive.

Closes #11638.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-aztec.nr Component: Aztec smart contract framework team-fairies Nico's team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant