@aztec/accounts 0.82.2 → 0.82.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/artifacts/EcdsaKAccount.json +479 -475
  2. package/artifacts/EcdsaRAccount.json +783 -779
  3. package/artifacts/SchnorrAccount.json +597 -593
  4. package/artifacts/SchnorrSingleKeyAccount.json +174 -174
  5. package/dest/ecdsa/ecdsa_r/account_contract.d.ts +21 -0
  6. package/dest/ecdsa/ecdsa_r/account_contract.d.ts.map +1 -0
  7. package/dest/ecdsa/ecdsa_r/account_contract.js +41 -0
  8. package/dest/ecdsa/ecdsa_r/index.d.ts +43 -0
  9. package/dest/ecdsa/ecdsa_r/index.d.ts.map +1 -0
  10. package/dest/ecdsa/ecdsa_r/index.js +44 -0
  11. package/dest/ecdsa/ecdsa_r/lazy.d.ts +47 -0
  12. package/dest/ecdsa/ecdsa_r/lazy.d.ts.map +1 -0
  13. package/dest/ecdsa/ecdsa_r/lazy.js +52 -0
  14. package/dest/ecdsa/index.d.ts +1 -0
  15. package/dest/ecdsa/index.d.ts.map +1 -1
  16. package/dest/ecdsa/index.js +1 -0
  17. package/dest/ecdsa/lazy.d.ts +1 -0
  18. package/dest/ecdsa/lazy.d.ts.map +1 -1
  19. package/dest/ecdsa/lazy.js +1 -0
  20. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +0 -1
  21. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
  22. package/dest/ecdsa/ssh_ecdsa_r/index.js +1 -5
  23. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +0 -4
  24. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -1
  25. package/dest/ecdsa/ssh_ecdsa_r/lazy.js +1 -15
  26. package/dest/testing/index.d.ts +7 -1
  27. package/dest/testing/index.d.ts.map +1 -1
  28. package/dest/testing/index.js +9 -5
  29. package/package.json +6 -6
  30. package/src/ecdsa/ecdsa_r/account_contract.ts +42 -0
  31. package/src/ecdsa/ecdsa_r/index.ts +63 -0
  32. package/src/ecdsa/ecdsa_r/lazy.ts +71 -0
  33. package/src/ecdsa/index.ts +1 -0
  34. package/src/ecdsa/lazy.ts +1 -0
  35. package/src/ecdsa/ssh_ecdsa_r/index.ts +1 -7
  36. package/src/ecdsa/ssh_ecdsa_r/lazy.ts +1 -18
  37. package/src/testing/index.ts +16 -11
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
4
+ import { CompleteAddress } from '@aztec/stdlib/contract';
5
+ import { DefaultAccountContract } from '../../defaults/account_contract.js';
6
+ /**
7
+ * Account contract that authenticates transactions using ECDSA signatures
8
+ * verified against a secp256r1 public key stored in an immutable encrypted note.
9
+ * This abstract version does not provide a way to retrieve the artifact, as it
10
+ * can be implemented with or without lazy loading.
11
+ */
12
+ export declare abstract class EcdsaRBaseAccountContract extends DefaultAccountContract {
13
+ private signingPrivateKey;
14
+ constructor(signingPrivateKey: Buffer);
15
+ getDeploymentFunctionAndArgs(): Promise<{
16
+ constructorName: string;
17
+ constructorArgs: Buffer[];
18
+ }>;
19
+ getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider;
20
+ }
21
+ //# sourceMappingURL=account_contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_r/account_contract.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E;;;;;GAKG;AACH,8BAAsB,yBAA0B,SAAQ,sBAAsB;IAChE,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,MAAM;IAIvC,4BAA4B;;;;IAQlC,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB;CAGvE"}
@@ -0,0 +1,41 @@
1
+ import { Ecdsa } from '@aztec/foundation/crypto';
2
+ import { AuthWitness } from '@aztec/stdlib/auth-witness';
3
+ import { DefaultAccountContract } from '../../defaults/account_contract.js';
4
+ /**
5
+ * Account contract that authenticates transactions using ECDSA signatures
6
+ * verified against a secp256r1 public key stored in an immutable encrypted note.
7
+ * This abstract version does not provide a way to retrieve the artifact, as it
8
+ * can be implemented with or without lazy loading.
9
+ */ export class EcdsaRBaseAccountContract extends DefaultAccountContract {
10
+ signingPrivateKey;
11
+ constructor(signingPrivateKey){
12
+ super(), this.signingPrivateKey = signingPrivateKey;
13
+ }
14
+ async getDeploymentFunctionAndArgs() {
15
+ const signingPublicKey = await new Ecdsa('secp256r1').computePublicKey(this.signingPrivateKey);
16
+ return {
17
+ constructorName: 'constructor',
18
+ constructorArgs: [
19
+ signingPublicKey.subarray(0, 32),
20
+ signingPublicKey.subarray(32, 64)
21
+ ]
22
+ };
23
+ }
24
+ getAuthWitnessProvider(_address) {
25
+ return new EcdsaRAuthWitnessProvider(this.signingPrivateKey);
26
+ }
27
+ }
28
+ /** Creates auth witnesses using ECDSA signatures. */ class EcdsaRAuthWitnessProvider {
29
+ signingPrivateKey;
30
+ constructor(signingPrivateKey){
31
+ this.signingPrivateKey = signingPrivateKey;
32
+ }
33
+ async createAuthWit(messageHash) {
34
+ const ecdsa = new Ecdsa('secp256r1');
35
+ const signature = await ecdsa.constructSignature(messageHash.toBuffer(), this.signingPrivateKey);
36
+ return Promise.resolve(new AuthWitness(messageHash, [
37
+ ...signature.r,
38
+ ...signature.s
39
+ ]));
40
+ }
41
+ }
@@ -0,0 +1,43 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ /**
4
+ * The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
5
+ * Consider using this account type when working with integrations with Ethereum wallets.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import { AccountManager, type Salt } from '@aztec/aztec.js/account';
10
+ import { type AccountWallet } from '@aztec/aztec.js/wallet';
11
+ import { Fr } from '@aztec/foundation/fields';
12
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
13
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
15
+ import { EcdsaRBaseAccountContract } from './account_contract.js';
16
+ export declare const EcdsaRAccountContractArtifact: ContractArtifact;
17
+ /**
18
+ * Account contract that authenticates transactions using ECDSA signatures
19
+ * verified against a secp256k1 public key stored in an immutable encrypted note.
20
+ * Eagerly loads the contract artifact
21
+ */
22
+ export declare class EcdsaRAccountContract extends EcdsaRBaseAccountContract {
23
+ constructor(signingPrivateKey: Buffer);
24
+ getContractArtifact(): Promise<ContractArtifact>;
25
+ }
26
+ /**
27
+ * Creates an Account that relies on an ECDSA signing key for authentication.
28
+ * @param pxe - An PXE server instance.
29
+ * @param secretKey - Secret key used to derive all the keystore keys.
30
+ * @param signingPrivateKey - Secp256k1 key used for signing transactions.
31
+ * @param salt - Deployment salt.
32
+ * @returns An account manager initialized with the account contract and its deployment params
33
+ */
34
+ export declare function getEcdsaRAccount(pxe: PXE, secretKey: Fr, signingPrivateKey: Buffer, salt?: Salt): Promise<AccountManager>;
35
+ /**
36
+ * Gets a wallet for an already registered account using ECDSA signatures.
37
+ * @param pxe - An PXE server instance.
38
+ * @param address - Address for the account.
39
+ * @param signingPrivateKey - ECDSA key used for signing transactions.
40
+ * @returns A wallet for this account that can be used to interact with a contract instance.
41
+ */
42
+ export declare function getEcdsaRWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: Buffer): Promise<AccountWallet>;
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_r/index.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAI3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,eAAO,MAAM,6BAA6B,EAAE,gBAE3C,CAAC;AAEF;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,yBAAyB;gBACtD,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AACD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,MAAM,EACzB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAElH"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
3
+ * Consider using this account type when working with integrations with Ethereum wallets.
4
+ *
5
+ * @packageDocumentation
6
+ */ import { AccountManager } from '@aztec/aztec.js/account';
7
+ import { getWallet } from '@aztec/aztec.js/wallet';
8
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
9
+ import EcdsaRAccountContractJson from '../../../artifacts/EcdsaRAccount.json' assert {
10
+ type: 'json'
11
+ };
12
+ import { EcdsaRBaseAccountContract } from './account_contract.js';
13
+ export const EcdsaRAccountContractArtifact = loadContractArtifact(EcdsaRAccountContractJson);
14
+ /**
15
+ * Account contract that authenticates transactions using ECDSA signatures
16
+ * verified against a secp256k1 public key stored in an immutable encrypted note.
17
+ * Eagerly loads the contract artifact
18
+ */ export class EcdsaRAccountContract extends EcdsaRBaseAccountContract {
19
+ constructor(signingPrivateKey){
20
+ super(signingPrivateKey);
21
+ }
22
+ getContractArtifact() {
23
+ return Promise.resolve(EcdsaRAccountContractArtifact);
24
+ }
25
+ }
26
+ /**
27
+ * Creates an Account that relies on an ECDSA signing key for authentication.
28
+ * @param pxe - An PXE server instance.
29
+ * @param secretKey - Secret key used to derive all the keystore keys.
30
+ * @param signingPrivateKey - Secp256k1 key used for signing transactions.
31
+ * @param salt - Deployment salt.
32
+ * @returns An account manager initialized with the account contract and its deployment params
33
+ */ export function getEcdsaRAccount(pxe, secretKey, signingPrivateKey, salt) {
34
+ return AccountManager.create(pxe, secretKey, new EcdsaRAccountContract(signingPrivateKey), salt);
35
+ }
36
+ /**
37
+ * Gets a wallet for an already registered account using ECDSA signatures.
38
+ * @param pxe - An PXE server instance.
39
+ * @param address - Address for the account.
40
+ * @param signingPrivateKey - ECDSA key used for signing transactions.
41
+ * @returns A wallet for this account that can be used to interact with a contract instance.
42
+ */ export function getEcdsaRWallet(pxe, address, signingPrivateKey) {
43
+ return getWallet(pxe, address, new EcdsaRAccountContract(signingPrivateKey));
44
+ }
@@ -0,0 +1,47 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ /**
4
+ * The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
5
+ * Consider using this account type when working with integrations with Ethereum wallets.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import { AccountManager, type Salt } from '@aztec/aztec.js/account';
10
+ import { type AccountWallet } from '@aztec/aztec.js/wallet';
11
+ import { Fr } from '@aztec/foundation/fields';
12
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
13
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
15
+ import { EcdsaRBaseAccountContract } from './account_contract.js';
16
+ /**
17
+ * Lazily loads the contract artifact
18
+ * @returns The contract artifact for the ecdsa K account contract
19
+ */
20
+ export declare function getEcdsaRAccountContractArtifact(): Promise<ContractArtifact>;
21
+ /**
22
+ * Account contract that authenticates transactions using ECDSA signatures
23
+ * verified against a secp256k1 public key stored in an immutable encrypted note.
24
+ * Lazily loads the contract artifact
25
+ */
26
+ export declare class EcdsaRAccountContract extends EcdsaRBaseAccountContract {
27
+ constructor(signingPrivateKey: Buffer);
28
+ getContractArtifact(): Promise<ContractArtifact>;
29
+ }
30
+ /**
31
+ * Creates an Account that relies on an ECDSA signing key for authentication.
32
+ * @param pxe - An PXE server instance.
33
+ * @param secretKey - Secret key used to derive all the keystore keys.
34
+ * @param signingPrivateKey - Secp256k1 key used for signing transactions.
35
+ * @param salt - Deployment salt.
36
+ * @returns An account manager initialized with the account contract and its deployment params
37
+ */
38
+ export declare function getEcdsaRAccount(pxe: PXE, secretKey: Fr, signingPrivateKey: Buffer, salt?: Salt): Promise<AccountManager>;
39
+ /**
40
+ * Gets a wallet for an already registered account using ECDSA signatures.
41
+ * @param pxe - An PXE server instance.
42
+ * @param address - Address for the account.
43
+ * @param signingPrivateKey - ECDSA key used for signing transactions.
44
+ * @returns A wallet for this account that can be used to interact with a contract instance.
45
+ */
46
+ export declare function getEcdsaRWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: Buffer): Promise<AccountWallet>;
47
+ //# sourceMappingURL=lazy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ecdsa_r/lazy.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;;GAGG;AACH,wBAAsB,gCAAgC,8BAQrD;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,yBAAyB;gBACtD,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AACD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,MAAM,EACzB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAElH"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
3
+ * Consider using this account type when working with integrations with Ethereum wallets.
4
+ *
5
+ * @packageDocumentation
6
+ */ import { AccountManager } from '@aztec/aztec.js/account';
7
+ import { getWallet } from '@aztec/aztec.js/wallet';
8
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
9
+ import { EcdsaRBaseAccountContract } from './account_contract.js';
10
+ /**
11
+ * Lazily loads the contract artifact
12
+ * @returns The contract artifact for the ecdsa K account contract
13
+ */ export async function getEcdsaRAccountContractArtifact() {
14
+ // Cannot assert this import as it's incompatible with browsers
15
+ // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
16
+ // Use the new "with" syntax once supported by firefox
17
+ // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
18
+ // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
19
+ const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaRAccount.json');
20
+ return loadContractArtifact(ecdsaKAccountContractJson);
21
+ }
22
+ /**
23
+ * Account contract that authenticates transactions using ECDSA signatures
24
+ * verified against a secp256k1 public key stored in an immutable encrypted note.
25
+ * Lazily loads the contract artifact
26
+ */ export class EcdsaRAccountContract extends EcdsaRBaseAccountContract {
27
+ constructor(signingPrivateKey){
28
+ super(signingPrivateKey);
29
+ }
30
+ getContractArtifact() {
31
+ return getEcdsaRAccountContractArtifact();
32
+ }
33
+ }
34
+ /**
35
+ * Creates an Account that relies on an ECDSA signing key for authentication.
36
+ * @param pxe - An PXE server instance.
37
+ * @param secretKey - Secret key used to derive all the keystore keys.
38
+ * @param signingPrivateKey - Secp256k1 key used for signing transactions.
39
+ * @param salt - Deployment salt.
40
+ * @returns An account manager initialized with the account contract and its deployment params
41
+ */ export function getEcdsaRAccount(pxe, secretKey, signingPrivateKey, salt) {
42
+ return AccountManager.create(pxe, secretKey, new EcdsaRAccountContract(signingPrivateKey), salt);
43
+ }
44
+ /**
45
+ * Gets a wallet for an already registered account using ECDSA signatures.
46
+ * @param pxe - An PXE server instance.
47
+ * @param address - Address for the account.
48
+ * @param signingPrivateKey - ECDSA key used for signing transactions.
49
+ * @returns A wallet for this account that can be used to interact with a contract instance.
50
+ */ export function getEcdsaRWallet(pxe, address, signingPrivateKey) {
51
+ return getWallet(pxe, address, new EcdsaRAccountContract(signingPrivateKey));
52
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './ecdsa_k/index.js';
2
+ export * from './ecdsa_r/index.js';
2
3
  export * from './ssh_ecdsa_r/index.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ecdsa/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ecdsa/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from './ecdsa_k/index.js';
2
+ export * from './ecdsa_r/index.js';
2
3
  export * from './ssh_ecdsa_r/index.js';
@@ -1,3 +1,4 @@
1
1
  export * from './ecdsa_k/lazy.js';
2
+ export * from './ecdsa_r/lazy.js';
2
3
  export * from './ssh_ecdsa_r/lazy.js';
3
4
  //# sourceMappingURL=lazy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/ecdsa/lazy.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/ecdsa/lazy.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from './ecdsa_k/lazy.js';
2
+ export * from './ecdsa_r/lazy.js';
2
3
  export * from './ssh_ecdsa_r/lazy.js';
@@ -13,7 +13,6 @@ import type { ContractArtifact } from '@aztec/stdlib/abi';
13
13
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
14
  import type { PXE } from '@aztec/stdlib/interfaces/client';
15
15
  import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
16
- export declare const EcdsaRAccountContractArtifact: ContractArtifact;
17
16
  /**
18
17
  * Account contract that authenticates transactions using ECDSA signatures
19
18
  * verified against a secp256r1 public key stored in an immutable encrypted note.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/index.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAI3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,eAAO,MAAM,6BAA6B,EAAE,gBAE3C,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,4BAA4B;gBAC5D,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,gBAAgB,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAEpH"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/index.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAG3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,4BAA4B;gBAC5D,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,gBAAgB,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAEpH"}
@@ -5,12 +5,8 @@
5
5
  * @packageDocumentation
6
6
  */ import { AccountManager } from '@aztec/aztec.js/account';
7
7
  import { getWallet } from '@aztec/aztec.js/wallet';
8
- import { loadContractArtifact } from '@aztec/stdlib/abi';
9
- import EcdsaRAccountContractJson from '../../../artifacts/EcdsaKAccount.json' assert {
10
- type: 'json'
11
- };
8
+ import { EcdsaRAccountContractArtifact } from '../ecdsa_r/index.js';
12
9
  import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
13
- export const EcdsaRAccountContractArtifact = loadContractArtifact(EcdsaRAccountContractJson);
14
10
  /**
15
11
  * Account contract that authenticates transactions using ECDSA signatures
16
12
  * verified against a secp256r1 public key stored in an immutable encrypted note.
@@ -13,10 +13,6 @@ import type { ContractArtifact } from '@aztec/stdlib/abi';
13
13
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
14
  import type { PXE } from '@aztec/stdlib/interfaces/client';
15
15
  import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
16
- /**
17
- *
18
- */
19
- export declare function getEcdsaRAccountContractArtifact(): Promise<ContractArtifact>;
20
16
  /**
21
17
  * Account contract that authenticates transactions using ECDSA signatures
22
18
  * verified against a secp256r1 public key stored in an immutable encrypted note.
@@ -1 +1 @@
1
- {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/lazy.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAMrE;;GAEG;AACH,wBAAsB,gCAAgC,8BAQrD;AAED;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,4BAA4B;gBAC5D,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,gBAAgB,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAEpH"}
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/lazy.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAG3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,4BAA4B;gBAC5D,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,gBAAgB,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAEpH"}
@@ -5,22 +5,8 @@
5
5
  * @packageDocumentation
6
6
  */ import { AccountManager } from '@aztec/aztec.js/account';
7
7
  import { getWallet } from '@aztec/aztec.js/wallet';
8
- import { loadContractArtifact } from '@aztec/stdlib/abi';
8
+ import { getEcdsaRAccountContractArtifact } from '../ecdsa_r/lazy.js';
9
9
  import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
10
- /*
11
- * Lazily loads the contract artifact
12
- * @returns The contract artifact for the ecdsa R account contract
13
- */ /**
14
- *
15
- */ export async function getEcdsaRAccountContractArtifact() {
16
- // Cannot assert this import as it's incompatible with browsers
17
- // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
18
- // Use the new "with" syntax once supported by firefox
19
- // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
20
- // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
21
- const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaRAccount.json');
22
- return loadContractArtifact(ecdsaKAccountContractJson);
23
- }
24
10
  /**
25
11
  * Account contract that authenticates transactions using ECDSA signatures
26
12
  * verified against a secp256r1 public key stored in an immutable encrypted note.
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
- import type { PXE } from '@aztec/aztec.js';
8
+ import { AccountManager, type PXE } from '@aztec/aztec.js';
9
9
  import type { AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
10
10
  import type { InitialAccountData } from './configuration.js';
11
11
  export { type InitialAccountData, INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS, } from './configuration.js';
@@ -13,6 +13,12 @@ export { type InitialAccountData, INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRY
13
13
  * Gets the basic information for initial test accounts.
14
14
  */
15
15
  export declare function getInitialTestAccounts(): Promise<InitialAccountData[]>;
16
+ /**
17
+ * Gets a collection of account managers for the Aztec accounts that are initially stored in the test environment.
18
+ * @param pxe - PXE instance.
19
+ * @returns A set of AccountManager implementations for each of the initial accounts.
20
+ */
21
+ export declare function getInitialTestAccountsManagers(pxe: PXE): Promise<AccountManager[]>;
16
22
  /**
17
23
  * Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
18
24
  * @param pxe - PXE instance.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAOzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAQ7D,OAAO,EACL,KAAK,kBAAkB,EACvB,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAatE;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAY7F;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAIrF;AAED;;;;GAIG;AACH,wBAAsB,8BAA8B,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAKpG;AAED,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAOzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAQ7D,OAAO,EACL,KAAK,kBAAkB,EACvB,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAatE;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAMlF;AAED;;;;GAIG;AACH,wBAAsB,6BAA6B,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAInG;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAIrF;AAED;;;;GAIG;AACH,wBAAsB,8BAA8B,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAKpG;AAED,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -17,15 +17,19 @@ export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_
17
17
  address: await getSchnorrAccountContractAddress(secret, INITIAL_TEST_ACCOUNT_SALTS[i], INITIAL_TEST_SIGNING_KEYS[i])
18
18
  })));
19
19
  }
20
+ /**
21
+ * Gets a collection of account managers for the Aztec accounts that are initially stored in the test environment.
22
+ * @param pxe - PXE instance.
23
+ * @returns A set of AccountManager implementations for each of the initial accounts.
24
+ */ export function getInitialTestAccountsManagers(pxe) {
25
+ return Promise.all(INITIAL_TEST_SECRET_KEYS.map((encryptionKey, i)=>getSchnorrAccount(pxe, encryptionKey, INITIAL_TEST_SIGNING_KEYS[i], INITIAL_TEST_ACCOUNT_SALTS[i])));
26
+ }
20
27
  /**
21
28
  * Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
22
29
  * @param pxe - PXE instance.
23
30
  * @returns A set of AccountWallet implementations for each of the initial accounts.
24
- */ export function getInitialTestAccountsWallets(pxe) {
25
- return Promise.all(INITIAL_TEST_SECRET_KEYS.map(async (encryptionKey, i)=>{
26
- const account = await getSchnorrAccount(pxe, encryptionKey, INITIAL_TEST_SIGNING_KEYS[i], INITIAL_TEST_ACCOUNT_SALTS[i]);
27
- return account.getWallet();
28
- }));
31
+ */ export async function getInitialTestAccountsWallets(pxe) {
32
+ return Promise.all((await Promise.all(await getInitialTestAccountsManagers(pxe))).map((accountManager)=>accountManager.getWallet()));
29
33
  }
30
34
  /**
31
35
  * Queries a PXE for it's registered accounts.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@aztec/accounts",
3
3
  "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/accounts",
4
4
  "description": "Implementation of sample account contracts for Aztec Network",
5
- "version": "0.82.2",
5
+ "version": "0.82.3",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  "./dapp": "./dest/dapp/index.js",
@@ -77,11 +77,11 @@
77
77
  ]
78
78
  },
79
79
  "dependencies": {
80
- "@aztec/aztec.js": "0.82.2",
81
- "@aztec/entrypoints": "0.82.2",
82
- "@aztec/ethereum": "0.82.2",
83
- "@aztec/foundation": "0.82.2",
84
- "@aztec/stdlib": "0.82.2",
80
+ "@aztec/aztec.js": "0.82.3",
81
+ "@aztec/entrypoints": "0.82.3",
82
+ "@aztec/ethereum": "0.82.3",
83
+ "@aztec/foundation": "0.82.3",
84
+ "@aztec/stdlib": "0.82.3",
85
85
  "tslib": "^2.4.0"
86
86
  },
87
87
  "devDependencies": {
@@ -0,0 +1,42 @@
1
+ import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2
+ import { Ecdsa } from '@aztec/foundation/crypto';
3
+ import type { Fr } from '@aztec/foundation/fields';
4
+ import { AuthWitness } from '@aztec/stdlib/auth-witness';
5
+ import { CompleteAddress } from '@aztec/stdlib/contract';
6
+
7
+ import { DefaultAccountContract } from '../../defaults/account_contract.js';
8
+
9
+ /**
10
+ * Account contract that authenticates transactions using ECDSA signatures
11
+ * verified against a secp256r1 public key stored in an immutable encrypted note.
12
+ * This abstract version does not provide a way to retrieve the artifact, as it
13
+ * can be implemented with or without lazy loading.
14
+ */
15
+ export abstract class EcdsaRBaseAccountContract extends DefaultAccountContract {
16
+ constructor(private signingPrivateKey: Buffer) {
17
+ super();
18
+ }
19
+
20
+ async getDeploymentFunctionAndArgs() {
21
+ const signingPublicKey = await new Ecdsa('secp256r1').computePublicKey(this.signingPrivateKey);
22
+ return {
23
+ constructorName: 'constructor',
24
+ constructorArgs: [signingPublicKey.subarray(0, 32), signingPublicKey.subarray(32, 64)],
25
+ };
26
+ }
27
+
28
+ getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider {
29
+ return new EcdsaRAuthWitnessProvider(this.signingPrivateKey);
30
+ }
31
+ }
32
+
33
+ /** Creates auth witnesses using ECDSA signatures. */
34
+ class EcdsaRAuthWitnessProvider implements AuthWitnessProvider {
35
+ constructor(private signingPrivateKey: Buffer) {}
36
+
37
+ async createAuthWit(messageHash: Fr): Promise<AuthWitness> {
38
+ const ecdsa = new Ecdsa('secp256r1');
39
+ const signature = await ecdsa.constructSignature(messageHash.toBuffer(), this.signingPrivateKey);
40
+ return Promise.resolve(new AuthWitness(messageHash, [...signature.r, ...signature.s]));
41
+ }
42
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
3
+ * Consider using this account type when working with integrations with Ethereum wallets.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ import { AccountManager, type Salt } from '@aztec/aztec.js/account';
8
+ import { type AccountWallet, getWallet } from '@aztec/aztec.js/wallet';
9
+ import { Fr } from '@aztec/foundation/fields';
10
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
11
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
12
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
13
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
14
+ import type { NoirCompiledContract } from '@aztec/stdlib/noir';
15
+
16
+ import EcdsaRAccountContractJson from '../../../artifacts/EcdsaRAccount.json' assert { type: 'json' };
17
+ import { EcdsaRBaseAccountContract } from './account_contract.js';
18
+
19
+ export const EcdsaRAccountContractArtifact: ContractArtifact = loadContractArtifact(
20
+ EcdsaRAccountContractJson as NoirCompiledContract,
21
+ );
22
+
23
+ /**
24
+ * Account contract that authenticates transactions using ECDSA signatures
25
+ * verified against a secp256k1 public key stored in an immutable encrypted note.
26
+ * Eagerly loads the contract artifact
27
+ */
28
+ export class EcdsaRAccountContract extends EcdsaRBaseAccountContract {
29
+ constructor(signingPrivateKey: Buffer) {
30
+ super(signingPrivateKey);
31
+ }
32
+
33
+ override getContractArtifact(): Promise<ContractArtifact> {
34
+ return Promise.resolve(EcdsaRAccountContractArtifact);
35
+ }
36
+ }
37
+ /**
38
+ * Creates an Account that relies on an ECDSA signing key for authentication.
39
+ * @param pxe - An PXE server instance.
40
+ * @param secretKey - Secret key used to derive all the keystore keys.
41
+ * @param signingPrivateKey - Secp256k1 key used for signing transactions.
42
+ * @param salt - Deployment salt.
43
+ * @returns An account manager initialized with the account contract and its deployment params
44
+ */
45
+ export function getEcdsaRAccount(
46
+ pxe: PXE,
47
+ secretKey: Fr,
48
+ signingPrivateKey: Buffer,
49
+ salt?: Salt,
50
+ ): Promise<AccountManager> {
51
+ return AccountManager.create(pxe, secretKey, new EcdsaRAccountContract(signingPrivateKey), salt);
52
+ }
53
+
54
+ /**
55
+ * Gets a wallet for an already registered account using ECDSA signatures.
56
+ * @param pxe - An PXE server instance.
57
+ * @param address - Address for the account.
58
+ * @param signingPrivateKey - ECDSA key used for signing transactions.
59
+ * @returns A wallet for this account that can be used to interact with a contract instance.
60
+ */
61
+ export function getEcdsaRWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: Buffer): Promise<AccountWallet> {
62
+ return getWallet(pxe, address, new EcdsaRAccountContract(signingPrivateKey));
63
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
3
+ * Consider using this account type when working with integrations with Ethereum wallets.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ import { AccountManager, type Salt } from '@aztec/aztec.js/account';
8
+ import { type AccountWallet, getWallet } from '@aztec/aztec.js/wallet';
9
+ import { Fr } from '@aztec/foundation/fields';
10
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
11
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
12
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
13
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
14
+
15
+ import { EcdsaRBaseAccountContract } from './account_contract.js';
16
+
17
+ /**
18
+ * Lazily loads the contract artifact
19
+ * @returns The contract artifact for the ecdsa K account contract
20
+ */
21
+ export async function getEcdsaRAccountContractArtifact() {
22
+ // Cannot assert this import as it's incompatible with browsers
23
+ // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
24
+ // Use the new "with" syntax once supported by firefox
25
+ // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
26
+ // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
27
+ const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaRAccount.json');
28
+ return loadContractArtifact(ecdsaKAccountContractJson);
29
+ }
30
+
31
+ /**
32
+ * Account contract that authenticates transactions using ECDSA signatures
33
+ * verified against a secp256k1 public key stored in an immutable encrypted note.
34
+ * Lazily loads the contract artifact
35
+ */
36
+ export class EcdsaRAccountContract extends EcdsaRBaseAccountContract {
37
+ constructor(signingPrivateKey: Buffer) {
38
+ super(signingPrivateKey);
39
+ }
40
+
41
+ override getContractArtifact(): Promise<ContractArtifact> {
42
+ return getEcdsaRAccountContractArtifact();
43
+ }
44
+ }
45
+ /**
46
+ * Creates an Account that relies on an ECDSA signing key for authentication.
47
+ * @param pxe - An PXE server instance.
48
+ * @param secretKey - Secret key used to derive all the keystore keys.
49
+ * @param signingPrivateKey - Secp256k1 key used for signing transactions.
50
+ * @param salt - Deployment salt.
51
+ * @returns An account manager initialized with the account contract and its deployment params
52
+ */
53
+ export function getEcdsaRAccount(
54
+ pxe: PXE,
55
+ secretKey: Fr,
56
+ signingPrivateKey: Buffer,
57
+ salt?: Salt,
58
+ ): Promise<AccountManager> {
59
+ return AccountManager.create(pxe, secretKey, new EcdsaRAccountContract(signingPrivateKey), salt);
60
+ }
61
+
62
+ /**
63
+ * Gets a wallet for an already registered account using ECDSA signatures.
64
+ * @param pxe - An PXE server instance.
65
+ * @param address - Address for the account.
66
+ * @param signingPrivateKey - ECDSA key used for signing transactions.
67
+ * @returns A wallet for this account that can be used to interact with a contract instance.
68
+ */
69
+ export function getEcdsaRWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: Buffer): Promise<AccountWallet> {
70
+ return getWallet(pxe, address, new EcdsaRAccountContract(signingPrivateKey));
71
+ }