feat: add note hash and nullifier helper functions with domain separation#21189
Merged
nventuro merged 9 commits intomerge-train/fairiesfrom Mar 6, 2026
Conversation
…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>
Contributor
Co-authored-by: Jan Beneš <janbenes1234@gmail.com>
…ard-note-hash-and-nullifier-encodings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
SingleUseClaimby 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.