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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread docs/docs-developers/docs/resources/migration_notes.md Outdated
Comment thread noir-projects/aztec-nr/aztec/src/note/utils.nr
Comment thread noir-projects/aztec-nr/aztec/src/note/utils.nr
Comment thread noir-projects/noir-protocol-circuits/crates/types/src/constants.nr
@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
Copy Markdown
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!

Comment thread docs/docs-developers/docs/resources/migration_notes.md
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 mentioned this pull request Mar 6, 2026
@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
github-merge-queue Bot pushed a commit that referenced this pull request Mar 9, 2026
BEGIN_COMMIT_OVERRIDE
feat: add note hash and nullifier helper functions with domain
separation (#21189)
feat(cli): auto-recompiling when aztec test is run (#20729)
docs: small delayedpubmut update (#21229)
test: restore pubmut tests (#21228)
END_COMMIT_OVERRIDE
AztecBot added a commit that referenced this pull request Mar 18, 2026
nventuro added a commit that referenced this pull request Mar 19, 2026
…1134, #21072, #21186, #21189, #21229, #21228, #21234, #21639) (#21745)

## Summary

Combined backport of 12 PRs to v4-next, cherry-picked in chronological
merge order:

1. #20512 — docs: add delayedpublicmutable apiref, fix misc docs
2. #20379 — feat: custom message handlers in Aztec.nr
3. #20831 — feat!: make unused msg disco fns private
4. #21024 — feat: add compile-time size check for events and error code
links
5. #21134 — chore: add warning on invalid recipients
6. #21072 — feat: add aztecaddress::is_valid
7. #21186 — chore: use returns `true` for boolean fns
8. #21189 — feat: add note hash and nullifier helper functions with
domain separation
9. #21229 — docs: small delayedpubmut update
10. #21228 — test: restore pubmut tests
11. #21234 — fix: claim contract & improve nullif docs
12. #21639 — feat!: split compute note hash and nullifier to reduce
hashing

Each PR is a separate commit (raw cherry-pick with conflicts left in),
followed by a single final commit that resolves all conflicts — making
it easy to review the conflict resolution independently.

## Conflict resolution (last commit)

- `delayed_public_mutable.nr` / `public_immutable.nr` — merged doc
comments from both sides
- `aztec.nr` macros — integrated custom message handler + split compute
functions
- `discovery/mod.nr` / `process_message.nr` — merged offchain inbox sync
+ custom handler dispatch + split compute
- `constants.nr` / `constants_tests.nr` — added new domain separators
- `Nargo.toml` — added custom_message_contract
- `netlify.toml` — merged error code redirects
- `auth_contract` — kept v4-next delay value
- `note_metadata.nr` — doc comment reformat
- `migration_notes.md` — merged migration notes from both sides
- Deleted `traits.nr` (v4-next uses `traits/` directory)


ClaudeBox log: https://claudebox.work/s/3145d1bd30977c20?run=1

---------

Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
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