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

Misleading error "missing compute_note_hash_and_nullifier" if note length is incorrect in the method signature #3012

Closed
spalladino opened this issue Oct 24, 2023 · 0 comments · Fixed by #3097
Assignees
Labels
T-bug Type: Bug. Something is broken. T-feedback Type: recording user feedback

Comments

@spalladino
Copy link
Collaborator

If SmallerNote is modified and has more entries than BiggerNote, then the preimage length needs to be changed. This is, afaik, undocumented, a bit bizarre, and leads to "Error: Mandatory implementation of "compute_note_hash_and_nullifier" missing" while it isn’t, in fact, missing:

unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, preimage: [Field; BIGGER_NOTE_LEN]) -> [Field; 4] {
        let note_header = NoteHeader::new(contract_address, nonce, storage_slot);

        if(storage_slot == 1) {
						// BiggerNote has BIGGER_NOTE_LEN elements
            note_utils::compute_note_hash_and_nullifier(BiggerNoteMethods, note_header, preimage)
        }
        else {
						// If this note "grows", 'preimage: [Field, BIGGER_NOTE_LEN]' isn't correct anymore
            note_utils::compute_note_hash_and_nullifier(SmallerNoteMethods, note_header, preimage)
        }
}

Reported by @0xShaito from Wonderland

@spalladino spalladino added T-bug Type: Bug. Something is broken. T-feedback Type: recording user feedback labels Oct 24, 2023
@rahul-kothari rahul-kothari added this to A3 Oct 25, 2023
@github-project-automation github-project-automation bot moved this to Todo in A3 Oct 25, 2023
rahul-kothari pushed a commit that referenced this issue Oct 30, 2023
Closes #3012 

# 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](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: Bug. Something is broken. T-feedback Type: recording user feedback
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants