With the inclusion of encrypted event logs, we will need to get a hold of some bytes to emit.
Since we need different data to emit it in private and public we will need to have two functions. In private we need to include some randomness that is also used for the masked address, which is not needed in public.
We should also provide the event_type_id to make it straight forward.
to_be_bytes is essentially serialize to bytes of the event, and then we have
private_to_be_bytes which is also prepending the randomness
// Autogenerated by the #[aztec(event)] macro unless it is overridden by a custom implementation
fn serialize(self) -> [Field; N];
// Autogenerated by the #[aztec(event)] macro unless it is overridden by a custom implementation
fn deserialize(fields: [Field; N]) -> Self;
// Autogenerated by the #[aztec(event)] macro unless it is overridden by a custom implementation
fn get_event_type_id() -> Field;
// Autogenerated by the #[aztec(event)] macro unless it is overridden by a custom implementation
fn private_to_be_bytes(self, randomness: Field) -> [u8; M];
// Autogenerated by the #[aztec(event)] macro unless it is overridden by a custom implementation
fn to_be_bytes(self) -> [u8; P];
Logic should be very similar to what we have from the note in note_interface.rs
fn private_to_be_bytes(self: {1}, randomness: Field) -> [u8; {0}] {{
assert({0} == {2} * 32 + 64, \"Event byte length must be equal to (serialized_length * 32) + 64 bytes\");
let serialized_event = self.serialize();
let mut buffer: [u8; {0}] = [0; {0}];
let randomness_bytes = randomness.to_be_bytes(32);
let event_type_id_bytes = {1}::get_event_type_id().to_be_bytes(32);
for i in 0..32 {{
buffer[i] = randomness_bytes[i];
buffer[32 + i] = event_type_id_bytes[i];
}}
for i in 0..serialized_event.len() {{
let bytes = serialized_event[i].to_be_bytes(32);
for j in 0..32 {{
buffer[64 + i * 32 + j] = bytes[j];
}}
}}
buffer
}}
With the inclusion of encrypted event logs, we will need to get a hold of some bytes to emit.
Since we need different data to emit it in private and public we will need to have two functions. In private we need to include some
randomness
that is also used for the masked address, which is not needed in public.We should also provide the
event_type_id
to make it straight forward.to_be_bytes
is essentially serialize to bytes of the event, and then we haveprivate_to_be_bytes
which is also prepending therandomness
Logic should be very similar to what we have from the note in
note_interface.rs