Skip to content

Commit

Permalink
feat!: updated note hash and nullifier macro (#3777)
Browse files Browse the repository at this point in the history
Fixes #3669
  • Loading branch information
benesjan authored and sirasistant committed Jan 4, 2024
1 parent d144743 commit 20f1652
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions aztec_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,15 @@ fn check_for_storage_definition(module: &SortedModule) -> bool {
module.types.iter().any(|r#struct| r#struct.name.0.contents == "Storage")
}

// Check if "compute_note_hash_and_nullifier(Field,Field,Field,[Field; N]) -> [Field; 4]" is defined
// Check if "compute_note_hash_and_nullifier(AztecAddress,Field,Field,[Field; N]) -> [Field; 4]" is defined
fn check_for_compute_note_hash_and_nullifier_definition(module: &SortedModule) -> bool {
module.functions.iter().any(|func| {
func.def.name.0.contents == "compute_note_hash_and_nullifier"
&& func.def.parameters.len() == 4
&& func.def.parameters[0].typ.typ == UnresolvedTypeData::FieldElement
&& match &func.def.parameters[0].typ.typ {
UnresolvedTypeData::Named(path, _) => path.segments.last().unwrap().0.contents == "AztecAddress",
_ => false,
}
&& func.def.parameters[1].typ.typ == UnresolvedTypeData::FieldElement
&& func.def.parameters[2].typ.typ == UnresolvedTypeData::FieldElement
// checks if the 4th parameter is an array and the Box<UnresolvedType> in
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_fmt/tests/expected/contract.nr
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract Benchmarking {
}

unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
preimage: [Field; VALUE_NOTE_LEN]
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_fmt/tests/input/contract.nr
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ contract Benchmarking {
emit_unencrypted_log(&mut context, storage.balances.at(owner).read());
}

unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, preimage: [Field; VALUE_NOTE_LEN]) -> [Field; 4] {
unconstrained fn compute_note_hash_and_nullifier(contract_address: AztecAddress, nonce: Field, storage_slot: Field, preimage: [Field; VALUE_NOTE_LEN]) -> [Field; 4] {
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, preimage)
}
Expand Down

0 comments on commit 20f1652

Please sign in to comment.