Struct NoteMessage
pub struct NoteMessage<Note>
{ /* private fields */ }
Implementations
impl<Note> NoteMessage<Note>
pub fn new(new_note: NewNote<Note>, context: &mut PrivateContext) -> Self
pub fn deliver(self, delivery_mode: u8)
Delivers the note message to its owner, providing them access to the private note information.
The message is first encrypted to the owner's public key, ensuring no other actor can read it.
The delivery_mode must be one of crate::messages::message_delivery::MessageDeliveryEnum, and will inform
costs (both proving time and TX fees) as well as delivery guarantees. This value must be a compile-time
constant.
To deliver the message to a recipient that is not the note's owner, use NoteMessage::deliver_to instead.
Invalid Recipients
If the note's owner is an invalid address, then a random public key is selected and message delivery continues as normal. This prevents both 'king of the hill' attacks (where a sender would otherwise fail to deliver a note to an invalid recipient) and forced privacy leaks (where an invalid recipient results in a unique transaction fingerprint, e.g. one lacking the private logs that would correspond to message delivery).
pub fn deliver_to(self, recipient: AztecAddress, delivery_mode: u8)
Same as NoteMessage::deliver, except the message gets delivered to an arbitrary recipient instead of the
note owner.
Note that recipient getting the message does not let them use the note, it only means that thy will know
about it, including the transaction in which it was created, and prove it exists. They will also not be able to
know when or if the note is used (i.e. nullified), assuming the standard note nullifier function.
Use Cases
This feature enables many design patterns that diverge in how notes are traditionally handled. For example, an institutional contract may require to have some actor receive all notes created for compliance purposes. Or a low value application like a game might deliver all notes offchain to a centralized server that then serves them via the app, bypassing the need for contract sync and improving UX.
pub fn get_note(self) -> Note
Returns the note contained in the message.
pub fn get_new_note(self) -> NewNote<Note>
Returns the NewNote container in the message.
This is an advanced function, typically needed only when creating new kinds of state variables that need to create MaybeNoteMessage values.
A message with information about a note that was created in the current contract call. This message MUST be delivered to a recipient in order to not lose the private note information.
Use NoteMessage::deliver to select a delivery mechanism. The same message can be delivered to multiple recipients.