Struct miden_objects::notes::Note
source · pub struct Note { /* private fields */ }Expand description
A note with all the data required for it to be consumed by executing it against the transaction kernel.
Notes consist of note metadata and details. Note metadata is always public, but details may be either public, encrypted, or private, depending on the note type. Note details consist of note assets, script, inputs, and a serial number, the three latter grouped into a recipient object.
Note details can be reduced to two unique identifiers: NoteId and Nullifier. The former is publicly associated with a note, while the latter is known only to entities which have access to full note details.
Fungible and non-fungible asset transfers are done by moving assets to the note’s assets. The note’s script determines the conditions required for the note consumption, i.e. the target account of a P2ID or conditions of a SWAP, and the effects of the note. The serial number has a double duty of preventing double spend, and providing unlikability to the consumer of a note. The note’s inputs allow for customization of its script.
To create a note, the kernel does not require all the information above, a user can create a note only with the commitment to the script, inputs, the serial number (i.e., the recipient), and the kernel only verifies the source account has the assets necessary for the note creation. See NoteRecipient for more details.
Implementations§
source§impl Note
impl Note
sourcepub fn new(
assets: NoteAssets,
metadata: NoteMetadata,
recipient: NoteRecipient
) -> Self
pub fn new( assets: NoteAssets, metadata: NoteMetadata, recipient: NoteRecipient ) -> Self
Returns a new Note created with the specified parameters.
sourcepub fn header(&self) -> &NoteHeader
pub fn header(&self) -> &NoteHeader
Returns the note’s header.
sourcepub fn id(&self) -> NoteId
pub fn id(&self) -> NoteId
Returns the note’s unique identifier.
This value is both an unique identifier and a commitment to the note.
sourcepub fn metadata(&self) -> &NoteMetadata
pub fn metadata(&self) -> &NoteMetadata
Returns the note’s metadata.
sourcepub fn assets(&self) -> &NoteAssets
pub fn assets(&self) -> &NoteAssets
Returns the note’s assets.
sourcepub fn serial_num(&self) -> Word
pub fn serial_num(&self) -> Word
Returns the note’s recipient serial_num, the secret required to consume the note.
sourcepub fn script(&self) -> &NoteScript
pub fn script(&self) -> &NoteScript
Returns the note’s recipient script which locks the assets of this note.
sourcepub fn inputs(&self) -> &NoteInputs
pub fn inputs(&self) -> &NoteInputs
Returns the note’s recipient inputs which customizes the script’s behavior.
sourcepub fn recipient(&self) -> &NoteRecipient
pub fn recipient(&self) -> &NoteRecipient
Returns the note’s recipient.
sourcepub fn nullifier(&self) -> Nullifier
pub fn nullifier(&self) -> Nullifier
Returns the note’s nullifier.
This is public data, used to prevent double spend.
sourcepub fn authentication_hash(&self) -> Digest
pub fn authentication_hash(&self) -> Digest
Returns the note’s authentication hash.
This value is used authenticate the note’s presence in the note tree, it is computed as:
hash(note_id, note_metadata)
Methods from Deref<Target = NoteDetails>§
sourcepub fn id(&self) -> NoteId
pub fn id(&self) -> NoteId
Returns the note’s unique identifier.
This value is both an unique identifier and a commitment to the note.
sourcepub fn assets(&self) -> &NoteAssets
pub fn assets(&self) -> &NoteAssets
Returns the note’s assets.
sourcepub fn serial_num(&self) -> Word
pub fn serial_num(&self) -> Word
Returns the note’s recipient serial_num, the secret required to consume the note.
sourcepub fn script(&self) -> &NoteScript
pub fn script(&self) -> &NoteScript
Returns the note’s recipient script which locks the assets of this note.
sourcepub fn inputs(&self) -> &NoteInputs
pub fn inputs(&self) -> &NoteInputs
Returns the note’s recipient inputs which customizes the script’s behavior.
sourcepub fn recipient(&self) -> &NoteRecipient
pub fn recipient(&self) -> &NoteRecipient
Returns the note’s recipient.
Trait Implementations§
source§impl Deserializable for Note
impl Deserializable for Note
source§fn read_from<R: ByteReader>(
source: &mut R
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R ) -> Result<Self, DeserializationError>
source, attempts to deserialize these bytes
into Self, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl From<&Note> for NoteDetails
impl From<&Note> for NoteDetails
source§impl From<&Note> for NoteHeader
impl From<&Note> for NoteHeader
source§impl From<Note> for NoteDetails
impl From<Note> for NoteDetails
source§impl From<Note> for NoteHeader
impl From<Note> for NoteHeader
source§impl PartialEq for Note
impl PartialEq for Note
source§impl Serializable for Note
impl Serializable for Note
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self into bytes and writes these bytes into the target.