Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Oct 19, 2024
1 parent dea191e commit 62b4c08
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/contract/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Contract extends ContractBase {
*/
public static deploy(wallet: Wallet, artifact: ContractArtifact, args: any[], constructorName?: string) {
const postDeployCtor = (address: AztecAddress, wallet: Wallet) => Contract.at(address, artifact, wallet);
return new DeployMethod(PublicKeys.empty(), wallet, artifact, postDeployCtor, args, constructorName);
return new DeployMethod(PublicKeys.default(), wallet, artifact, postDeployCtor, args, constructorName);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/deployment/contract_deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ContractDeployer {
public deploy(...args: any[]) {
const postDeployCtor = (address: AztecAddress, wallet: Wallet) => Contract.at(address, this.artifact, wallet);
return new DeployMethod(
this.publicKeys ?? PublicKeys.empty(),
this.publicKeys ?? PublicKeys.default(),
this.wallet,
this.artifact,
postDeployCtor,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/cmds/start_pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export async function addPXE(
address,
deployer: AztecAddress.ZERO,
contractClassId: getContractClassFromArtifact(artifact!).id,
publicKeys: PublicKeys.empty(),
publicKeys: PublicKeys.default(),
};
userLog(`Registering ${name} at ${address.toString()}`);
await pxe.registerContract({ artifact, instance });
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/builder/src/contract-interface-gen/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function generateDeploy(input: ContractArtifact) {
* Creates a tx to deploy a new instance of this contract.
*/
public static deploy(wallet: Wallet, ${args}) {
return new DeployMethod<${contractName}>(PublicKeys.empty(), wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(1));
return new DeployMethod<${contractName}>(PublicKeys.default(), wallet, ${artifactName}, ${contractName}.at, Array.from(arguments).slice(1));
}
/**
Expand All @@ -102,7 +102,7 @@ function generateDeploy(input: ContractArtifact) {
...args: Parameters<${contractName}['methods'][M]>
) {
return new DeployMethod<${contractName}>(
opts.publicKeys ?? PublicKeys.empty(),
opts.publicKeys ?? PublicKeys.default(),
opts.wallet,
${artifactName},
${contractName}.at,
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/circuits.js/src/contract/contract_instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class SerializableContractInstance {
deployer: AztecAddress.zero(),
contractClassId: Fr.zero(),
initializationHash: Fr.zero(),
publicKeys: PublicKeys.empty(),
publicKeys: PublicKeys.default(),
});
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ export function getContractInstanceFromDeployParams(
args,
)
: computeInitializationHash(constructorArtifact, args);
const publicKeys = opts.publicKeys ?? PublicKeys.empty();
const publicKeys = opts.publicKeys ?? PublicKeys.default();

const instance: ContractInstance = {
contractClassId,
Expand Down
8 changes: 7 additions & 1 deletion yarn-project/circuits.js/src/types/public_keys.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
import { Fr, Point } from '@aztec/foundation/fields';
import { Fq, Fr, Point } from '@aztec/foundation/fields';
import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';

import { GeneratorIndex } from '../constants.gen.js';
import { type PublicKey } from './public_key.js';
import { derivePublicKeyFromSecretKey } from '../keys/derivation.js';

export class PublicKeys {
public constructor(
Expand Down Expand Up @@ -45,6 +46,11 @@ export class PublicKeys {
return new PublicKeys(Point.ZERO, Point.ZERO, Point.ZERO, Point.ZERO);
}

static default(): PublicKeys {
// We use this because empty will produce a point not on the curve. We may want to replace this with some sort of hash to curve func.
return new PublicKeys(derivePublicKeyFromSecretKey(new Fq(1)), derivePublicKeyFromSecretKey(new Fq(2)), derivePublicKeyFromSecretKey(new Fq(3)), derivePublicKeyFromSecretKey(new Fq(4)));
}

static random(): PublicKeys {
return new PublicKeys(Point.random(), Point.random(), Point.random(), Point.random());
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/cli-wallet/src/cmds/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function deploy(
);
}

const deployer = new ContractDeployer(contractArtifact, wallet, publicKeys ?? PublicKeys.empty(), initializer);
const deployer = new ContractDeployer(contractArtifact, wallet, publicKeys ?? PublicKeys.default(), initializer);

let args = [];
if (rawArgs.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/cli/src/cmds/pxe/add_contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function addContract(
salt,
initializationHash,
contractClassId: getContractClassFromArtifact(artifact).id,
publicKeys: publicKeys ?? PublicKeys.empty(),
publicKeys: publicKeys ?? PublicKeys.default(),
address,
deployer: deployer ?? AztecAddress.ZERO,
};
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/txe/src/txe_service/txe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class TXEService {
skipArgsDecoding: true,
salt: Fr.ONE,
// TODO: Modify this to allow for passing public keys.
publicKeys: PublicKeys.empty(),
publicKeys: PublicKeys.default(),
constructorArtifact: initializerStr ? initializerStr : undefined,
deployer: AztecAddress.ZERO,
});
Expand Down

0 comments on commit 62b4c08

Please sign in to comment.