Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Oct 18, 2024
1 parent dea191e commit bc6018f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 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
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

0 comments on commit bc6018f

Please sign in to comment.