From 28084d6a3cac70c06306170cfbe224311b48fc29 Mon Sep 17 00:00:00 2001 From: benesjan Date: Thu, 9 May 2024 15:36:10 +0000 Subject: [PATCH] cleanup --- .../key_registry_contract/src/main.nr | 5 +-- .../src/structs/complete_address.ts | 41 +------------------ .../src/e2e_deploy_contract/deploy_test.ts | 8 ++-- 3 files changed, 6 insertions(+), 48 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/key_registry_contract/src/main.nr b/noir-projects/noir-contracts/contracts/key_registry_contract/src/main.nr index 91105a51e29..9c07a53865e 100644 --- a/noir-projects/noir-contracts/contracts/key_registry_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/key_registry_contract/src/main.nr @@ -60,10 +60,7 @@ contract KeyRegistry { outgoing_public_key, tagging_public_key ); - let computed_address = AztecAddress::compute( - public_keys_hash, - partial_address - ); + let computed_address = AztecAddress::compute(public_keys_hash, partial_address); assert(computed_address.eq(address), "Computed address does not match supplied address"); diff --git a/yarn-project/circuits.js/src/structs/complete_address.ts b/yarn-project/circuits.js/src/structs/complete_address.ts index 595bfdba76f..7af0629a150 100644 --- a/yarn-project/circuits.js/src/structs/complete_address.ts +++ b/yarn-project/circuits.js/src/structs/complete_address.ts @@ -58,30 +58,7 @@ export class CompleteAddress { } static random(): CompleteAddress { - // TODO: the following should be cleaned up - const secretKey = Fr.random(); - const partialAddress = Fr.random(); - const address = computeContractAddressFromPartial({ secretKey, partialAddress }); - const { - masterNullifierPublicKey, - masterIncomingViewingPublicKey, - masterOutgoingViewingPublicKey, - masterTaggingPublicKey, - } = deriveKeys(secretKey); - return new CompleteAddress( - address, - masterNullifierPublicKey, - masterIncomingViewingPublicKey, - masterOutgoingViewingPublicKey, - masterTaggingPublicKey, - partialAddress, - ); - } - - static fromRandomSecretKey() { - const secretKey = Fr.random(); - const partialAddress = Fr.random(); - return { secretKey, completeAddress: CompleteAddress.fromSecretKeyAndPartialAddress(secretKey, partialAddress) }; + return this.fromSecretKeyAndPartialAddress(Fr.random(), Fr.random()); } static fromSecretKeyAndPartialAddress(secretKey: Fr, partialAddress: Fr): CompleteAddress { @@ -107,21 +84,7 @@ export class CompleteAddress { instance: Parameters[0], ): CompleteAddress { const partialAddress = computePartialAddress(instance); - const address = computeContractAddressFromPartial({ secretKey, partialAddress }); - const { - masterNullifierPublicKey, - masterIncomingViewingPublicKey, - masterOutgoingViewingPublicKey, - masterTaggingPublicKey, - } = deriveKeys(secretKey); - return new CompleteAddress( - address, - masterNullifierPublicKey, - masterIncomingViewingPublicKey, - masterOutgoingViewingPublicKey, - masterTaggingPublicKey, - partialAddress, - ); + return CompleteAddress.fromSecretKeyAndPartialAddress(secretKey, partialAddress); } /** Throws if the address is not correctly derived from the public key and partial address.*/ diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts index 05b31422828..eb490ad5aa1 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/deploy_test.ts @@ -7,7 +7,7 @@ import { type ContractArtifact, type ContractBase, type DebugLogger, - type Fr, + Fr, type PXE, type Wallet, createDebugLogger, @@ -81,10 +81,8 @@ export class DeployTest { } async registerRandomAccount(): Promise { - const pxe = this.pxe; - const { completeAddress: owner, secretKey } = CompleteAddress.fromRandomSecretKey(); - await pxe.registerAccount(secretKey, owner.partialAddress); - return owner.address; + const completeAddress = await this.pxe.registerAccount(Fr.random(), Fr.random()); + return completeAddress.address; } }