diff --git a/noir-projects/aztec-nr/aztec/src/initializer.nr b/noir-projects/aztec-nr/aztec/src/initializer.nr index 415def6d69f..2eb92d6b31c 100644 --- a/noir-projects/aztec-nr/aztec/src/initializer.nr +++ b/noir-projects/aztec-nr/aztec/src/initializer.nr @@ -37,11 +37,11 @@ fn compute_unsiloed_contract_initialization_nullifier(address: AztecAddress) -> address.to_field() } +// Used in macros by `create_assert_correct_initializer_args` func. pub fn assert_initialization_matches_address_preimage_public(context: PublicContext) { let address = context.this_address(); - let deployer = unsafe { get_contract_instance_deployer_avm(address).unwrap() }; - let initialization_hash = - unsafe { get_contract_instance_initialization_hash_avm(address).unwrap() }; + let deployer = get_contract_instance_deployer_avm(address).unwrap(); + let initialization_hash = get_contract_instance_initialization_hash_avm(address).unwrap(); let expected_init = compute_initialization_hash(context.selector(), context.get_args_hash()); assert(initialization_hash == expected_init, "Initialization hash does not match"); assert( @@ -50,6 +50,7 @@ pub fn assert_initialization_matches_address_preimage_public(context: PublicCont ); } +// Used in macros by `create_assert_correct_initializer_args` func. pub fn assert_initialization_matches_address_preimage_private(context: PrivateContext) { let address = context.this_address(); let instance = get_contract_instance(address); diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr index 586f1292a60..763856a6e2c 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr @@ -18,10 +18,8 @@ unconstrained fn get_contract_instance_internal( // NOTE: this is for use in private only pub fn get_contract_instance(address: AztecAddress) -> ContractInstance { - let instance = unsafe { - //@safety The instance is verified against the contract address below. - ContractInstance::deserialize(get_contract_instance_internal(address)) - }; + let instance = + unsafe { ContractInstance::deserialize(get_contract_instance_internal(address)) }; // The to_address function combines all values in the instance object to produce an address, so by checking that we // get the expected address we validate the entire struct. assert_eq(instance.to_address(), address); @@ -60,30 +58,33 @@ pub unconstrained fn get_contract_instance_initialization_hash_internal_avm( get_contract_instance_initialization_hash_oracle_avm(address) } -pub unconstrained fn get_contract_instance_deployer_avm( - address: AztecAddress, -) -> Option { - let (member, exists) = get_contract_instance_deployer_internal_avm(address); +pub fn get_contract_instance_deployer_avm(address: AztecAddress) -> Option { + let (member, exists) = unsafe { + //@safety AVM opcodes are constrained by the AVM itself + get_contract_instance_deployer_internal_avm(address) + }; if exists { Option::some(AztecAddress::from_field(member)) } else { Option::none() } } -pub unconstrained fn get_contract_instance_class_id_avm( - address: AztecAddress, -) -> Option { - let (member, exists) = get_contract_instance_class_id_internal_avm(address); +pub fn get_contract_instance_class_id_avm(address: AztecAddress) -> Option { + let (member, exists) = unsafe { + //@safety AVM opcodes are constrained by the AVM itself + get_contract_instance_class_id_internal_avm(address) + }; if exists { Option::some(ContractClassId::from_field(member)) } else { Option::none() } } -pub unconstrained fn get_contract_instance_initialization_hash_avm( - address: AztecAddress, -) -> Option { - let (member, exists) = get_contract_instance_initialization_hash_internal_avm(address); +pub fn get_contract_instance_initialization_hash_avm(address: AztecAddress) -> Option { + let (member, exists) = unsafe { + //@safety AVM opcodes are constrained by the AVM itself + get_contract_instance_initialization_hash_internal_avm(address) + }; if exists { Option::some(member) } else {