Skip to content

feat: add note hash and nullifier helper functions with domain separation#21189

Merged
nventuro merged 9 commits intomerge-train/fairiesfrom
nico/f-180-come-up-with-standard-note-hash-and-nullifier-encodings
Mar 6, 2026
Merged

feat: add note hash and nullifier helper functions with domain separation#21189
nventuro merged 9 commits intomerge-train/fairiesfrom
nico/f-180-come-up-with-standard-note-hash-and-nullifier-encodings

Conversation

@nventuro
Copy link
Contributor

@nventuro nventuro commented Mar 5, 2026

This is the first part of my review of domain separator usage and hashing. I created two standard functions for computing note hashes and note nullifiers in aztecnr, and added some comments to the separators themselves. In a future PR we'll move them to aztec-nr (not now as it'd be api breakage).

I also fixed SingleUseClaim by having it use a new dedicated domain separator, as should've always been the case given that it is not a note nullifier - it is its own thing.

I added comments to the protocol contracts explaining why the lack of separators there is ok, and found an issue in our Orderbook contract in which we miss domain separation, which is wrong - left a todo.

Finally, there's also a todo to fix how partial notes compute both of their note hashes, as they dont' follow the current domain separation. Given we're about to rework them I chose not to mess with it at this time.

…tion

Add `compute_note_hash` and `compute_note_nullifier` helpers in `note/utils.nr`
that enforce fixed positions for `storage_slot` and `note_hash_for_nullification`
respectively, preventing collisions across different note implementations.

Also set `DOM_SEP__SINGLE_USE_CLAIM_NULLIFIER = 1465998995` and add its
corresponding test in `constants_tests.nr`. Update all note nullifier
computations across the codebase to use `compute_note_nullifier`, and improve
related documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nventuro nventuro requested a review from LeilaWang as a code owner March 5, 2026 22:02
@benesjan benesjan marked this pull request as draft March 6, 2026 07:08
@benesjan
Copy link
Contributor

benesjan commented Mar 6, 2026

@nventuro Did this fix (+ fixed fmt in 3741abc).

Pretty cool that now the compiler captured the issue in the Claim contract.

Copy link
Contributor

@benesjan benesjan left a comment

Choose a reason for hiding this comment

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

Lovely cleanup

@benesjan benesjan marked this pull request as ready for review March 6, 2026 07:30
@AztecBot AztecBot requested a review from a team March 6, 2026 07:43
Copy link
Contributor

@nchamo nchamo left a comment

Choose a reason for hiding this comment

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

Great work!

nventuro and others added 3 commits March 6, 2026 18:10
Co-authored-by: Jan Beneš <janbenes1234@gmail.com>
@nventuro nventuro enabled auto-merge (squash) March 6, 2026 21:12
@nventuro nventuro merged commit b361b7b into merge-train/fairies Mar 6, 2026
10 checks passed
@nventuro nventuro deleted the nico/f-180-come-up-with-standard-note-hash-and-nullifier-encodings branch March 6, 2026 23:29
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.

3 participants