aztec-nr - noir_aztec::macros::notes

Function custom_note

pub comptime fn custom_note(s: TypeDefinition) -> Quoted

Generates code for a custom note implementation that requires specialized note hash or nullifier computation.

Generated Code

  • NoteTypeProperties: Defines the structure and properties of note fields
  • NoteType trait implementation: Provides the note type ID

Requirements

The note struct must:

  • Implement the Packable trait
  • Not exceed MAX_NOTE_PACKED_LEN when packed

Registration

Registers the note in the global NOTES BoundedVec to enable note processing functionality.

Use Cases

Use this macro when implementing a note that needs custom:

  • Note hash computation logic
  • Nullifier computation logic

The macro omits generating default NoteHash trait implementation, allowing you to provide your own.

Example

#[custom_note]
struct CustomNote {
    value: Field,
    metadata: Field
}

impl NoteHash for CustomNote {
    // Custom note hash computation...
    fn compute_note_hash(...) -> Field { ... }

    // Custom nullifier computation...
    fn compute_nullifier(...) -> Field { ... }
    fn compute_nullifier_unconstrained(...) -> Field { ... }
}