diff --git a/yarn-project/aztec-nr/aztec/src/address.nr b/yarn-project/aztec-nr/aztec/src/address.nr deleted file mode 100644 index 38a1ca0fe56..00000000000 --- a/yarn-project/aztec-nr/aztec/src/address.nr +++ /dev/null @@ -1,14 +0,0 @@ -use dep::protocol_types::{ - address::AztecAddress, - constants::GENERATOR_INDEX__CONTRACT_ADDRESS, - hash::pedersen_hash, -}; - -pub fn compute_address(pub_key_x: Field, pub_key_y: Field, partial_address: Field) -> AztecAddress { - AztecAddress::from_field( - pedersen_hash( - [pub_key_x, pub_key_y, partial_address], - GENERATOR_INDEX__CONTRACT_ADDRESS - ) - ) -} diff --git a/yarn-project/aztec-nr/aztec/src/lib.nr b/yarn-project/aztec-nr/aztec/src/lib.nr index 007ce181db5..2a3f9113224 100644 --- a/yarn-project/aztec-nr/aztec/src/lib.nr +++ b/yarn-project/aztec-nr/aztec/src/lib.nr @@ -1,5 +1,4 @@ mod abi; -mod address; mod context; mod hash; mod history; diff --git a/yarn-project/aztec-nr/aztec/src/oracle/get_public_key.nr b/yarn-project/aztec-nr/aztec/src/oracle/get_public_key.nr index 2dde51102dd..b22f8ae84de 100644 --- a/yarn-project/aztec-nr/aztec/src/oracle/get_public_key.nr +++ b/yarn-project/aztec-nr/aztec/src/oracle/get_public_key.nr @@ -1,5 +1,4 @@ use crate::types::point::Point; -use crate::address::compute_address; use dep::protocol_types::address::AztecAddress; #[oracle(getPublicKeyAndPartialAddress)] @@ -15,7 +14,7 @@ pub fn get_public_key(address: AztecAddress) -> Point { let pub_key_y = result[1]; let partial_address = result[2]; - let calculated_address = compute_address(pub_key_x, pub_key_y, partial_address); + let calculated_address = AztecAddress::compute(pub_key_x, pub_key_y, partial_address); assert(calculated_address.eq(address)); Point::new(pub_key_x, pub_key_y) diff --git a/yarn-project/noir-contracts/src/contracts/schnorr_single_key_account_contract/src/util.nr b/yarn-project/noir-contracts/src/contracts/schnorr_single_key_account_contract/src/util.nr index cf8db726439..3a097cbd5dc 100644 --- a/yarn-project/noir-contracts/src/contracts/schnorr_single_key_account_contract/src/util.nr +++ b/yarn-project/noir-contracts/src/contracts/schnorr_single_key_account_contract/src/util.nr @@ -1,15 +1,16 @@ use dep::protocol_types::address::AztecAddress; use dep::std::{schnorr::verify_signature}; -use dep::aztec::address::compute_address; use crate::auth_oracle::{AuthWitness}; pub fn recover_address(message_hash: Field, witness: AuthWitness) -> AztecAddress { let message_bytes = message_hash.to_be_bytes(32); - let verification = verify_signature(witness.owner.x, + let verification = verify_signature( + witness.owner.x, witness.owner.y, witness.signature, - message_bytes); + message_bytes + ); assert(verification == true); - compute_address(witness.owner.x, witness.owner.y, witness.partial_address) + AztecAddress::compute(witness.owner.x, witness.owner.y, witness.partial_address) } diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/address.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/address.nr index cc8142d7b6a..30d761df875 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/address.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/address.nr @@ -1,4 +1,8 @@ -use crate::utils; +use crate::{ + constants::GENERATOR_INDEX__CONTRACT_ADDRESS, + hash::pedersen_hash, + utils, +}; // Aztec address struct AztecAddress { @@ -24,6 +28,15 @@ impl AztecAddress { } } + pub fn compute(pub_key_x: Field, pub_key_y: Field, partial_address: Field) -> AztecAddress { + AztecAddress::from_field( + pedersen_hash( + [pub_key_x, pub_key_y, partial_address], + GENERATOR_INDEX__CONTRACT_ADDRESS + ) + ) + } + pub fn to_field(self) -> Field { self.inner }