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
Reported by @0xShaito from Wonderland