aztec-nr - noir_aztec::note::note_metadata

Struct NoteMetadata

pub struct NoteMetadata
{ /* private fields */ }

The metadata required to both prove a note's existence and destroy it, by computing the correct note hash for kernel read requests, as well as the correct nullifier to avoid double-spends.

This represents a note in any of the three valid stages (pending same phase, pending previous phase, or settled). In order to access the underlying fields callers must first find the appropriate stage (e.g. via is_settled()) and then convert this into the appropriate type (e.g. via to_settled()).

Implementations

impl NoteMetadata

pub fn from_raw_data(nonzero_note_hash_counter: bool, maybe_note_nonce: Field) -> Self

Constructs a NoteMetadata object from optional note hash counter and nonce. Both a zero note hash counter and a zero nonce are invalid, so those are used to signal non-existent values.

pub fn is_pending_same_phase(self) -> bool

Returns true if the note is pending and from the same phase, i.e. if it's been created in the current transaction during the current execution phase (either non-revertible or revertible).

pub fn is_pending_previous_phase(self) -> bool

Returns true if the note is pending and from the previous phase, i.e. if it's been created in the current transaction during an execution phase prior to the current one. Because private execution only has two phases with strict ordering, this implies that the note was created in the non-revertible phase, and that the current phase is the revertible phase.

pub fn is_settled(self) -> bool

Returns true if the note is settled, i.e. if it's been created in a prior transaction and is therefore already in the note hash tree.

pub fn to_pending_same_phase(self) -> PendingSamePhaseNoteMetadata

Asserts that the metadata is that of a pending note from the same phase and converts it accordingly.

pub fn to_pending_previous_phase(self) -> PendingPreviousPhaseNoteMetadata

Asserts that the metadata is that of a pending note from a previous phase and converts it accordingly.

pub fn to_settled(self) -> SettledNoteMetadata

Asserts that the metadata is that of a settled note and converts it accordingly.

Trait implementations

impl Deserialize for NoteMetadata

pub fn deserialize(serialized: [Field; 2]) -> Self

impl Eq for NoteMetadata

pub fn eq(_self: Self, _other: Self) -> bool

impl From<PendingPreviousPhaseNoteMetadata> for NoteMetadata

pub fn from(value: PendingPreviousPhaseNoteMetadata) -> Self

impl From<PendingSamePhaseNoteMetadata> for NoteMetadata

pub fn from(_value: PendingSamePhaseNoteMetadata) -> Self

impl From<SettledNoteMetadata> for NoteMetadata

pub fn from(value: SettledNoteMetadata) -> Self

impl Packable for NoteMetadata

pub fn pack(self) -> [Field; 2] pub fn unpack(packed: [Field; 2]) -> Self

impl Serialize for NoteMetadata

pub fn serialize(self) -> [Field; 2]