Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boxes/blank/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract Blank {
// own logic once you start working with private storage.
// TODO: Remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; 0]
Expand Down
5 changes: 2 additions & 3 deletions boxes/token/src/contracts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,12 @@ contract Token {
// Note 1: Needs to be defined by every contract producing logs.
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; TOKEN_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
if (storage_slot == 5) {
note_utils::compute_note_hash_and_nullifier(TransparentNoteMethods, note_header, serialized_note)
} else {
Expand Down
7 changes: 5 additions & 2 deletions noir/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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More a question really, but do you know why it is typ.typ instead of just a single typ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first "typ" has UnresolvedType and the second one is UnresolvedTypeData. It looks like a bit of a messy naming.

This is more of a question for someone from noir team (maybe @kevaundray ?).

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 noir/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 noir/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
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,12 @@ contract Benchmarking {
}

unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; VALUE_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, serialized_note)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,12 @@ contract CardGame {
// Note 1: Needs to be defined by every contract producing logs.
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; VALUE_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, serialized_note)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ type = "contract"

[dependencies]
aztec = { path = "../../../../aztec-nr/aztec" }
protocol_types = { path = "../../../../noir-protocol-circuits/src/crates/types" }
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ contract Child {
state_vars::public_state::PublicState,
types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN},
};
use dep::protocol_types::address::AztecAddress;

struct Storage {
current_value: PublicState<Field, FIELD_SERIALIZED_LEN>,
Expand Down Expand Up @@ -109,7 +110,7 @@ contract Child {
}

// TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented
unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, serialized_note: [Field; 0]) -> pub [Field; 4] {
unconstrained fn compute_note_hash_and_nullifier(contract_address: AztecAddress, nonce: Field, storage_slot: Field, serialized_note: [Field; 0]) -> pub [Field; 4] {
[0, 0, 0, 0]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,12 @@ contract Counter {

// docs:start:nullifier
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; VALUE_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, serialized_note)
}
// docs:end:nullifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ contract DocsExample {

// TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; 0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,12 @@ contract EasyPrivateToken {
// Note 1: Needs to be defined by every contract producing logs.
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; VALUE_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, serialized_note)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ contract EasyPrivateVoting {
// docs:end:get_vote
// docs:start:compute_note_hash_and_nullifier
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; 0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,13 @@ contract EcdsaAccount {
// Note 1: Needs to be defined by every contract producing logs.
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; ECDSA_PUBLIC_KEY_NOTE_LEN]
) -> pub [Field; 4] {
assert(storage_slot == 1);
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(EcdsaPublicKeyNoteInterface, note_header, serialized_note)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,12 @@ contract Escrow {
}

unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; ADDRESS_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
assert(storage_slot == 1);
note_utils::compute_note_hash_and_nullifier(AddressNoteMethods, note_header, serialized_note)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,12 @@ contract InclusionProofs {
// Note 1: Needs to be defined by every contract producing logs.
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; VALUE_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, serialized_note)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ contract Lending {

// TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; 0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,12 @@ contract PendingCommitments {
// Note 1: Needs to be defined by every contract producing logs.
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; VALUE_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, serialized_note)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ type = "contract"

[dependencies]
aztec = { path = "../../../../aztec-nr/aztec" }
protocol_types = { path = "../../../../noir-protocol-circuits/src/crates/types" }
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ contract PriceFeed {
public_state::PublicState,
},
};
use dep::protocol_types::address::AztecAddress;
use crate::asset::{ASSET_SERIALIZED_LEN, Asset, AssetSerializationMethods};

// Storage structure, containing all storage, and specifying what slots they use.
Expand Down Expand Up @@ -54,7 +55,7 @@ contract PriceFeed {

// TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; 0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,13 @@ contract SchnorrAccount {
// Note 1: Needs to be defined by every contract producing logs.
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; PUBLIC_KEY_NOTE_LEN]
) -> pub [Field; 4] {
assert(storage_slot == 1);
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(PublicKeyNoteMethods, note_header, serialized_note)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ contract SlowTree {
}

unconstrained fn compute_note_hash_and_nullifier(
_contract_address: Field,
_contract_address: AztecAddress,
_nonce: Field,
_storage_slot: Field,
_serialized_note: [Field; 4]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,12 @@ contract StatefulTest {
}

unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; VALUE_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(ValueNoteMethods, note_header, serialized_note)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,13 @@ contract Test {
// Note 1: Needs to be defined by every contract producing logs.
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; FIELD_NOTE_LEN]
) -> pub [Field; 4] {
assert(storage_slot == 1);
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
note_utils::compute_note_hash_and_nullifier(FieldNoteMethods, note_header, serialized_note)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,12 @@ contract TokenBlacklist {
// Note 1: Needs to be defined by every contract producing logs.
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
preimage: [Field; TOKEN_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
if (storage_slot == 5) {
note_utils::compute_note_hash_and_nullifier(TransparentNoteMethods, note_header, preimage)
} else if (storage_slot == 7) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ contract TokenBridge {
// TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented
// docs:start:compute_note_hash_and_nullifier_placeholder
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; 0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,12 @@ contract Token {
// Note 1: Needs to be defined by every contract producing logs.
// Note 2: Having it in all the contracts gives us the ability to compute the note hash and nullifier differently for different kind of notes.
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; TOKEN_NOTE_LEN]
) -> pub [Field; 4] {
let _address = AztecAddress::from_field(contract_address); // TODO(benesjan) https://github.com/AztecProtocol/aztec-packages/issues/3669
let note_header = NoteHeader::new(_address, nonce, storage_slot);
let note_header = NoteHeader::new(contract_address, nonce, storage_slot);
if (storage_slot == 5) {
note_utils::compute_note_hash_and_nullifier(TransparentNoteMethods, note_header, serialized_note)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ contract Uniswap {

// TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented
unconstrained fn compute_note_hash_and_nullifier(
contract_address: Field,
contract_address: AztecAddress,
nonce: Field,
storage_slot: Field,
serialized_note: [Field; 0]
Expand Down