Skip to content

Commit f6d0643

Browse files
authored
refactor: small internal event fn cleanup (#19151)
This just deletes a function that was unused and moves some docs around.
2 parents 12a2391 + 772b867 commit f6d0643

File tree

3 files changed

+18
-27
lines changed

3 files changed

+18
-27
lines changed

noir-projects/aztec-nr/aztec/src/messages/logs/event.nr

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,16 @@
11
use crate::{
22
event::event_interface::EventInterface,
33
messages::{
4-
encoding::{encode_message, MESSAGE_CIPHERTEXT_LEN, MESSAGE_EXPANDED_METADATA_LEN},
5-
encryption::{aes128::AES128, message_encryption::MessageEncryption},
4+
encoding::{encode_message, MESSAGE_EXPANDED_METADATA_LEN},
65
msg_type::PRIVATE_EVENT_MSG_TYPE_ID,
76
},
8-
oracle::random::random,
97
};
10-
use protocol_types::{address::AztecAddress, traits::{Serialize, ToField}};
8+
use protocol_types::traits::{Serialize, ToField};
119

1210
global PRIVATE_EVENT_RESERVED_FIELDS: u32 = 1;
1311
global PRIVATE_EVENT_RANDOMNESS_INDEX: u32 = 0;
1412

15-
/// Creates an encrypted private event message (i.e. one of type `PRIVATE_EVENT_MSG_TYPE_ID`) by encoding the contents
16-
/// of the event and then encrypting them for `recipient`.
17-
pub fn to_encrypted_private_event_message<Event>(
18-
event: Event,
19-
recipient: AztecAddress,
20-
) -> ([Field; MESSAGE_CIPHERTEXT_LEN], Field)
21-
where
22-
Event: EventInterface + Serialize,
23-
{
24-
// In private events, we automatically inject randomness to prevent event commitment preimage attacks and event
25-
// commitment collisions (the commitments are included in the nullifier tree and duplicate nullifiers are by
26-
// definition not allowed).
27-
// Safety: We use the randomness to preserve the privacy of the event recipient by preventing brute-forcing,
28-
// so a malicious sender could use non-random values to make the event less private. But they already know
29-
// the full event pre-image anyway, and so the recipient already trusts them to not disclose this information.
30-
// We can therefore assume that the sender will cooperate in the random value generation.
31-
let randomness = unsafe { random() };
32-
33-
let plaintext = private_event_to_message_plaintext(event, randomness);
34-
35-
(AES128::encrypt(plaintext, recipient), randomness)
36-
}
37-
13+
/// Creates the plaintext for a private event message (i.e. one of type [PRIVATE_EVENT_MSG_TYPE_ID]).
3814
pub fn private_event_to_message_plaintext<Event>(
3915
event: Event,
4016
randomness: Field,

noir-projects/aztec-nr/aztec/src/messages/logs/note.nr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ where
4040
prefix_with_tag(message_ciphertext, recipient)
4141
}
4242

43+
/// Creates the plaintext for a private note message (i.e. one of type [PRIVATE_NOTE_MSG_TYPE_ID]).
4344
pub fn private_note_to_message_plaintext<Note>(
4445
note: Note,
4546
owner: AztecAddress,
@@ -63,6 +64,7 @@ where
6364
encode_message(PRIVATE_NOTE_MSG_TYPE_ID, Note::get_id() as u64, msg_content)
6465
}
6566

67+
/// Creates the plaintext for a partial note private message (i.e. one of type [PARTIAL_NOTE_PRIVATE_MSG_TYPE_ID]).
6668
pub fn partial_note_private_content_to_message_plaintext<PartialNotePrivateContent>(
6769
partial_note_private_content: PartialNotePrivateContent,
6870
owner: AztecAddress,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/// A message containing the information about a private note, i.e. one that has been created fully privately with no
2+
/// public fields.
3+
///
4+
/// This message contains all information necessary in order to prove existence of the note.
15
pub global PRIVATE_NOTE_MSG_TYPE_ID: u64 = 0;
6+
7+
/// A message containing the private informatio of a partial note, i.e. one that has both private and public fields.
8+
///
9+
/// This message contains all information necessary in order to find the public note information once it is created, and
10+
/// then prove existence of the note.
211
pub global PARTIAL_NOTE_PRIVATE_MSG_TYPE_ID: u64 = 1;
12+
13+
/// A message containing the information about a private event, i.e. one that has been emitted privately.
14+
///
15+
/// This message contains all information necessary in order to prove existence of the event.
316
pub global PRIVATE_EVENT_MSG_TYPE_ID: u64 = 2;

0 commit comments

Comments
 (0)