Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: moving compute_address func to AztecAddress #3801

Merged
merged 1 commit into from
Jan 3, 2024
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
14 changes: 0 additions & 14 deletions yarn-project/aztec-nr/aztec/src/address.nr

This file was deleted.

1 change: 0 additions & 1 deletion yarn-project/aztec-nr/aztec/src/lib.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod abi;
mod address;
mod context;
mod hash;
mod history;
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/aztec-nr/aztec/src/oracle/get_public_key.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::types::point::Point;
use crate::address::compute_address;
use dep::protocol_types::address::AztecAddress;

#[oracle(getPublicKeyAndPartialAddress)]
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use crate::utils;
use crate::{
constants::GENERATOR_INDEX__CONTRACT_ADDRESS,
hash::pedersen_hash,
utils,
};

// Aztec address
struct AztecAddress {
Expand All @@ -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
}
Expand Down