Type alias ComputeNoteHashAndNullifier
pub type ComputeNoteHashAndNullifier<Env> = unconstrained fn[Env](BoundedVec<Field, 8>, AztecAddress, Field, Field, AztecAddress, Field, Field) -> Option<NoteHashAndNullifier>;
pub type ComputeNoteHashAndNullifier<Env> = unconstrained fn[Env](BoundedVec<Field, 8>, AztecAddress, Field, Field, AztecAddress, Field, Field) -> Option<NoteHashAndNullifier>;
A contract's way of computing note hashes and nullifiers.
Each contract in the network is free to compute their note's hash and nullifiers as they see fit - the hash function itself and the nullifier derivation are not enshrined or standardized. Some aztec-nr functions however do need to know the details of this computation (e.g. when finding new notes), which is what this type represents.
This function takes a note's packed content, storage slot, note type ID, address of the emitting contract, randomness and note nonce, and attempts to compute its inner note hash (not siloed by address nor uniqued by nonce) and inner nullifier (not siloed by address).
Transient Notes
This function is meant to always be used on settled notes, i.e. those that have been inserted into the trees and for which the nonce is known. It is never invoked in the context of a transient note, as those are not involved in message processing.
Automatic Implementation
The
[#aztec]macro automatically creates a correct implementation of this function for each contract by inspecting all note types in use and the storage layout. This injected function is a#[contract_library_function]called_compute_note_hash_and_nullifier, and it looks something like this: