Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed May 10, 2024
1 parent 218fde6 commit 28084d6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
41 changes: 2 additions & 39 deletions yarn-project/circuits.js/src/structs/complete_address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -107,21 +84,7 @@ export class CompleteAddress {
instance: Parameters<typeof computePartialAddress>[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.*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type ContractArtifact,
type ContractBase,
type DebugLogger,
type Fr,
Fr,
type PXE,
type Wallet,
createDebugLogger,
Expand Down Expand Up @@ -81,10 +81,8 @@ export class DeployTest {
}

async registerRandomAccount(): Promise<AztecAddress> {
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;
}
}

Expand Down

0 comments on commit 28084d6

Please sign in to comment.