-
Notifications
You must be signed in to change notification settings - Fork 607
feat!: remove addNote, compute_note_hash_... #12171
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
Changes from all commits
3b905c3
15ac04a
2b7583c
a853732
eee3434
4a32aaa
f2dcacf
dfdbe93
22ff683
d74c114
2aec304
4d9a065
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,31 +28,32 @@ pub struct NoteHashAndNullifier { | |
| /// address). | ||
| /// | ||
| /// This function must be user-provided as its implementation requires knowledge of how note type IDs are allocated in a | ||
| /// contract. A typical implementation would look like this: | ||
| /// contract. The `#[aztec]` macro automatically creates such a contract library method called | ||
| /// `_compute_note_hash_and_nullifier`, which looks something like this: | ||
| /// | ||
| /// ``` | ||
| /// |packed_note_content, contract_address, nonce, storage_slot, note_type_id| { | ||
| /// if note_type_id == MyNoteType::get_note_type_id() { | ||
| /// assert(packed_note_content.len() == MY_NOTE_TYPE_SERIALIZATION_LENGTH); | ||
| /// let hashes = dep::aztec::note::utils::compute_note_hash_and_optionally_a_nullifier( | ||
| /// MyNoteType::unpack_content, | ||
| /// note_header, | ||
| /// true, | ||
| /// packed_note_content.storage(), | ||
| /// ) | ||
| /// | ||
| /// Option::some(dep::aztec::oracle::management::NoteHashesAndNullifier { | ||
| /// note_hash: hashes[0], | ||
| /// inner_nullifier: hashes[3], | ||
| /// }) | ||
| /// let note = MyNoteType::unpack(aztec::utils::array::subarray(packed_note.storage(), 0)); | ||
| /// | ||
| /// let note_hash = note.compute_note_hash(storage_slot); | ||
| /// let inner_nullifier = note.compute_nullifier_without_context(storage_slot, contract_address, nonce); | ||
| /// | ||
| /// Option::some( | ||
| /// aztec::discovery::NoteHashAndNullifier { | ||
| /// note_hash, inner_nullifier | ||
| /// } | ||
| /// ) | ||
| /// } else if note_type_id == MyOtherNoteType::get_note_type_id() { | ||
| /// ... // Similar to above but calling MyOtherNoteType::unpack_content | ||
| /// } else { | ||
| /// Option::none() // Unknown note type ID | ||
| /// }; | ||
| /// } | ||
| /// ``` | ||
| type ComputeNoteHashAndNullifier<Env> = fn[Env](/* packed_note_content */BoundedVec<Field, MAX_NOTE_PACKED_LEN>, /* contract_address */ AztecAddress, /* nonce */ Field, /* storage_slot */ Field, /* note_type_id */ Field) -> Option<NoteHashAndNullifier>; | ||
| type ComputeNoteHashAndNullifier<Env> = unconstrained fn[Env](/* packed_note_content */BoundedVec<Field, MAX_NOTE_PACKED_LEN>, /* storage_slot */ Field, /* note_type_id */ Field, /* contract_address */ AztecAddress, /* nonce */ Field) -> Option<NoteHashAndNullifier>; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed this order to one that was more natural - the old one was related to the original order of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's "natural"?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is storage_slot before contract_address natural, ser? I do not respect this nature
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because you need the packed content and storage slot to compute the note hash. It later gets siloed by contract address, and later by nonce. If you just compute the inner note hash you never use contract address. Storage slot and note type id are emitted in that order in the logs and passed in that order in the functions - once we extend logs to have things that are not note logs we'll likely change this (since there'll be no storage slot), but this is highly internally consistent right now. |
||
|
|
||
| /// Performs the note discovery process, in which private and public logs are downloaded and inspected to find private | ||
| /// notes, partial notes, and their completion. This is the mechanism via which PXE learns of new notes. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.