Skip to content

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

@spalladino

Description

@spalladino

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

Metadata

Metadata

Assignees

Labels

T-bugType: Bug. Something is broken.T-feedbackType: recording user feedback

Type

No type
No fields configured for issues without a type.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions