Type alias ComputeNoteHash
pub type ComputeNoteHash = unconstrained fn(BoundedVec<Field, 8>, AztecAddress, Field, Field, AztecAddress, Field) -> Option<Field>;
pub type ComputeNoteHash = unconstrained fn(BoundedVec<Field, 8>, AztecAddress, Field, Field, AztecAddress, Field) -> Option<Field>;
A contract's way of computing note hashes.
Each contract in the network is free to compute their note's hash as they see fit - the hash function itself is 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 and randomness, and attempts to compute its inner note hash (not siloed by address nor uniqued by nonce).
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_method]called_compute_note_hash, and it looks something like this: