Skip to content

refactor: fixing log related naming#16882

Merged
benesjan merged 1 commit into
nextfrom
09-09-refactor_fixing_log_related_naming
Sep 10, 2025
Merged

refactor: fixing log related naming#16882
benesjan merged 1 commit into
nextfrom
09-09-refactor_fixing_log_related_naming

Conversation

@benesjan

@benesjan benesjan commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Fixes #15012

The naming became strange with the introduction of the concept of a message that can be emitted either as a private log or as an offchain message - via an offchain effect (also used to be called out-of-band). Before we just used to have a private log.

Changes

  • Introduces "alias" for PRIVATE_LOG_CIPHERTEXT_LEN called MESSAGE_CIPHERTEXT_LEN in Aztec.nr
  • Renames PRIVATE_LOG_PLAINTEXT_SIZE_IN_{BYTES,FIELDS}MESSAGE_PLAINTEXT_SIZE_IN_{BYTES,FIELDS}

benesjan commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@benesjan benesjan force-pushed the 09-09-refactor_fixing_log_related_naming branch from f4d3736 to e3c1e34 Compare September 9, 2025 09:59
@benesjan benesjan marked this pull request as ready for review September 9, 2025 09:59
const std::unordered_map<CanonicalAddress, DerivedAddress> derived_addresses = {
{ CANONICAL_AUTH_REGISTRY_ADDRESS, AztecAddress("0x1c2474a77af3c756895867fa7622e5e9295121b35849e965f4614d51f00c62e2") },
{ CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, AztecAddress("0x001e627e78063a4944f1331b4c59544f8ad6d6d478f2fc79b025e8240b94b816") },
{ CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, AztecAddress("0x1f4284dea3e475d9d40283c7fe4c1aef5cdea59c012a8fa84c0c9ebe0752327e") },

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benesjan benesjan removed the request for review from LeilaWang September 9, 2025 10:03
@fcarreiro fcarreiro removed their request for review September 9, 2025 11:16
Comment thread noir-projects/noir-protocol-circuits/crates/types/src/constants.nr Outdated
Comment thread noir-projects/aztec-nr/aztec/src/messages/processing/log_retrieval_response.nr Outdated
@benesjan benesjan marked this pull request as draft September 9, 2025 13:20
@benesjan benesjan changed the base branch from next to graphite-base/16882 September 9, 2025 14:04
@benesjan benesjan changed the base branch from graphite-base/16882 to next September 9, 2025 14:04
@benesjan benesjan changed the base branch from next to graphite-base/16882 September 9, 2025 14:05
@benesjan benesjan changed the base branch from graphite-base/16882 to next September 9, 2025 14:05
@benesjan benesjan force-pushed the 09-09-refactor_fixing_log_related_naming branch from e3c1e34 to bd87602 Compare September 9, 2025 14:43
@@ -161,7 +160,7 @@ impl LogEncryption for AES128 {
fn encrypt_log<let PlaintextLen: u32>(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be renamed in a followup PR to MessageEncryption::encrypt.

Comment on lines +11 to +25
// TODO(#12750): The global variables below should not be here as they are AES128 specific.
// ciphertext_length (2) + 14 bytes pkcs#7 AES padding.
pub(crate) global HEADER_CIPHERTEXT_SIZE_IN_BYTES: u32 = 16;

pub global EPH_PK_X_SIZE_IN_FIELDS: u32 = 1;
pub global EPH_PK_SIGN_BYTE_SIZE_IN_BYTES: u32 = 1;

// (17 - 1) * 31 - 16 - 1 = 479
global MESSAGE_PLAINTEXT_SIZE_IN_BYTES: u32 = (MESSAGE_CIPHERTEXT_LEN - EPH_PK_X_SIZE_IN_FIELDS)
* 31
- HEADER_CIPHERTEXT_SIZE_IN_BYTES
- EPH_PK_SIGN_BYTE_SIZE_IN_BYTES;
// Each field of the original note log was serialized to 32 bytes. Below we convert the bytes back to fields.
// 479 / 32 = 15
pub global MESSAGE_PLAINTEXT_SIZE_IN_FIELDS: u32 = MESSAGE_PLAINTEXT_SIZE_IN_BYTES / 32;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values were moved in here from log_encryption.nr and renamed to reflect the message naming. This allowed me to hide the MESSAGE_PLAINTEXT_SIZE_IN_BYTES which I think is a good sign (meaning it was only used in this file and previously imported from log_encryption.nr).

Think this file being called encoding.nr makes this quite a natural place for these constants but if the reviewer have a better idea where to place these I am fine with reworking this.

The HEADER_CIPHERTEXT_SIZE_IN_BYTES being here is ugly but having that in log_encryption.nr was ugly as well so I think I didn't worsen it.

@benesjan benesjan marked this pull request as ready for review September 9, 2025 14:53
@benesjan benesjan requested a review from nventuro September 9, 2025 15:03

@nventuro nventuro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. Thank you.

/// - `PRIVATE_LOG_CIPHERTEXT_LEN`: Fixed length of encrypted logs (defined globally)
/// - `PRIVATE_LOG_PLAINTEXT_SIZE_IN_FIELDS`: Maximum size of decrypted plaintext (defined globally)
/// - `MESSAGE_CIPHERTEXT_LEN`: Fixed length of encrypted message (defined globally)
/// - `MESSAGE_PLAINTEXT_SIZE_IN_FIELDS`: Maximum size of decrypted plaintext (defined globally)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// - `MESSAGE_PLAINTEXT_SIZE_IN_FIELDS`: Maximum size of decrypted plaintext (defined globally)
/// - `MAX_MESSAGE_PLAINTEXT_LEN`: Maximum size of decrypted plaintext (defined globally)

This creates a nice simmetry with MESSAGE_PLAINTEXT_LEN no? Without looking at this explanation it's not obvious to me what the difference between MESSAGE_CIPHERTEXT_LEN and MESSAGE_PLAINTEXT_SIZE_IN_FIELDS is - I'd guess that it has to do with fields vs bytes, but that's not it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in e1f6ab9

There is a bit of an inconsistency in naming. For length denominated in fields we use "_LEN" and for length denominated in bytes we use "_SIZE_IN_BYTES". The change would explode the scope of the PR so decided to not do it here and plan on just learning to live with it.

@benesjan benesjan force-pushed the 09-09-refactor_fixing_log_related_naming branch from 4603717 to e1f6ab9 Compare September 10, 2025 18:14
@benesjan benesjan enabled auto-merge September 10, 2025 18:16
Fixes #15012

The naming became strange with the introduction of the concept of a message that can be emitted either as a private log or as an offchain message - via an offchain effect (also used to be called out-of-band). Before we just used to have a private log.

### Changes
- Introduces "alias" for  `PRIVATE_LOG_CIPHERTEXT_LEN` called `MESSAGE_CIPHERTEXT_LEN` in `Aztec.nr`
- Renames `PRIVATE_LOG_PLAINTEXT_SIZE_IN_{BYTES,FIELDS}` → `MESSAGE_PLAINTEXT_SIZE_IN_{BYTES,FIELDS}`
@AztecBot AztecBot force-pushed the 09-09-refactor_fixing_log_related_naming branch from e1f6ab9 to 05d892d Compare September 10, 2025 18:48
@benesjan benesjan added this pull request to the merge queue Sep 10, 2025
auto-merge was automatically disabled September 10, 2025 19:07

Pull Request is not mergeable

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 10, 2025
@benesjan benesjan added this pull request to the merge queue Sep 10, 2025
Merged via the queue into next with commit 46a54f1 Sep 10, 2025
15 checks passed
@benesjan benesjan deleted the 09-09-refactor_fixing_log_related_naming branch September 10, 2025 20:26
AztecBot pushed a commit that referenced this pull request Sep 23, 2025
Fixes #16885

As promised in [here](#16882 (comment)) in this PR I rename `LogEncryption` trait as `MessageEncryption` and I drop "_log" from it's method names. Didn't replace it with "_message" as it seemed unncessary. I also do some related minor renamings.
AztecBot pushed a commit that referenced this pull request Sep 23, 2025
Fixes #16885

As promised in [here](#16882 (comment)) in this PR I rename `LogEncryption` trait as `MessageEncryption` and I drop "_log" from it's method names. Didn't replace it with "_message" as it seemed unncessary. I also do some related minor renamings.
github-merge-queue Bot pushed a commit that referenced this pull request Sep 23, 2025
Fixes #16885

As promised in
[here](#16882 (comment))
in this PR I rename `LogEncryption` trait as `MessageEncryption` and I
drop "_log" from it's method names. Didn't replace it with "_message" as
it seemed unncessary. I also do some related minor renamings.
mralj pushed a commit that referenced this pull request Oct 13, 2025
Fixes #16885

As promised in [here](#16882 (comment)) in this PR I rename `LogEncryption` trait as `MessageEncryption` and I drop "_log" from it's method names. Didn't replace it with "_message" as it seemed unncessary. I also do some related minor renamings.
ludamad pushed a commit that referenced this pull request Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify message vs log terminology and standardize encryption naming

3 participants