aztec-nr - noir_aztec::event::event_message

Struct EventMessage

pub struct EventMessage<Event>
{ /* private fields */ }

A message with information about an event that was emitted in the current contract call. This message MUST be delivered to a recipient in order to not lose the private event information.

Use EventMessage::deliver_to to select a delivery mechanism.

Implementations

impl<Event> EventMessage<Event>

pub fn deliver_to(self, recipient: AztecAddress, delivery_mode: u8)
where Event: EventInterface, Event: Serialize

Delivers the event message to a recipient, providing them access to the private event information.

The same message can be delivered to multiple recipients, resulting in all of them learning about the event. Any recipient that receives the private event information will be able to prove its emission - events have no owner, and as such all recipients are treated equally.

The message is first encrypted to the recipient'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.

Invalid Recipients

If recipient 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 message 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).