Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(noir-libs): TransparentNote rework #1412

Merged
merged 43 commits into from
Aug 7, 2023

Conversation

dbanks12
Copy link
Collaborator

@dbanks12 dbanks12 commented Aug 3, 2023

Closes #1194
Closes #1363

Will likely rename getCommitment alongside all instances of "commitment" as a part of this other issue: #1408

Checklist:

Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.

  • If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag.
  • I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code.
  • Every change is related to the PR description.
  • I have linked this pull request to relevant issues (if any exist).

@dbanks12 dbanks12 changed the base branch from master to db/1210-rework-nonces August 3, 2023 15:34
Base automatically changed from db/1210-rework-nonces to master August 3, 2023 17:34
@dbanks12 dbanks12 marked this pull request as ready for review August 4, 2023 02:30
@dbanks12 dbanks12 requested a review from Maddiaa0 August 4, 2023 02:30
Copy link
Member

@Maddiaa0 Maddiaa0 left a comment

Choose a reason for hiding this comment

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

Over all looks good to me, however ive not dug into the test failures.

One thing that caught my eye is that note_hash is being used in place of commitment in some places. As the rest of the codebase uses commitment it may be worth maintaining the terminology

// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1386): should use
// `compute_note_hash_for_read_or_nullify` once public functions inject nonce!
let siloed_note_hash = compute_siloed_note_hash(TransparentNoteMethods, self);
pedersen([self.secret, siloed_note_hash, self.leafIndex])[0]
Copy link
Member

Choose a reason for hiding this comment

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

in this construction will leaf index ever not be 0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. Realistically we should just get rid of this leafIndex. Once we have nonces all working for public, the commitments themselves will be unique and this won't be necessary. I'll just remove leafIndex here for now and will link the ticket to add nonces here.

note: &mut Note,
note_interface: NoteInterface<Note, N>,
) {
let mut inner_note_hash = 0;
Copy link
Member

Choose a reason for hiding this comment

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

This does not need to be initialised up here, it can just be assigned on line 46

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. I'll fix create_note too.

context: &mut Context,
storage_slot: Field,
note_interface: NoteInterface<Note, N>,
note: &mut Note,
Copy link
Member

Choose a reason for hiding this comment

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

I dont think note needs to be mutable here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The note ends up getting its header populated although the existing NonNativeToken contract does not actually use the updated note. But this mimics the ensure_note_exists function above it.

// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1386): rename to
// `assert_contains` and replace function above ^ once public kernel injects
// nonces to note hashes.
fn assert_contains_note_hash(self, context: &mut Context, note: &mut Note) {
Copy link
Member

Choose a reason for hiding this comment

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

assert_note_hash is maybe enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤔 maybe but I'm mimicking assert the above function assert_contains. Eventually we can replace assert_contains with this implementation. Right now assert_contains_note_hash only works for notes created in public.

@dbanks12
Copy link
Collaborator Author

dbanks12 commented Aug 4, 2023

Over all looks good to me, however ive not dug into the test failures.

One thing that caught my eye is that note_hash is being used in place of commitment in some places. As the rest of the codebase uses commitment it may be worth maintaining the terminology

We are planning to rename commitment to noteHash just about everywhere. So I have been using the term noteHash in all new instances in the meantime. It is already being used often in Noir, although I agree that it is very confusing that we are using both terms.

@dbanks12 dbanks12 force-pushed the db/1194-transparentnote-rework branch from a3e4bd3 to 44b67e1 Compare August 4, 2023 18:30
@dbanks12 dbanks12 requested a review from Maddiaa0 August 7, 2023 12:18
Copy link
Member

@Maddiaa0 Maddiaa0 left a comment

Choose a reason for hiding this comment

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

lgtm

@Maddiaa0 Maddiaa0 merged commit 22fb8fe into master Aug 7, 2023
@Maddiaa0 Maddiaa0 deleted the db/1194-transparentnote-rework branch August 7, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
2 participants