@aztec/accounts 0.0.0-test.0 → 0.0.1-commit.03f7ef2

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 (126) hide show
  1. package/README.md +1 -1
  2. package/artifacts/EcdsaKAccount.json +4967 -3959
  3. package/artifacts/EcdsaRAccount.json +5259 -4251
  4. package/artifacts/SchnorrAccount.json +5271 -4131
  5. package/artifacts/SchnorrSingleKeyAccount.json +3162 -2408
  6. package/artifacts/SimulatedAccount.d.json.ts +3 -0
  7. package/artifacts/SimulatedAccount.json +4635 -0
  8. package/dest/defaults/account_contract.d.ts +10 -5
  9. package/dest/defaults/account_contract.d.ts.map +1 -1
  10. package/dest/defaults/account_contract.js +2 -2
  11. package/dest/defaults/account_interface.d.ts +8 -7
  12. package/dest/defaults/account_interface.d.ts.map +1 -1
  13. package/dest/defaults/account_interface.js +6 -7
  14. package/dest/defaults/index.d.ts +2 -2
  15. package/dest/defaults/index.js +1 -1
  16. package/dest/ecdsa/ecdsa_k/account_contract.d.ts +5 -4
  17. package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
  18. package/dest/ecdsa/ecdsa_k/account_contract.js +9 -6
  19. package/dest/ecdsa/ecdsa_k/index.d.ts +1 -25
  20. package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
  21. package/dest/ecdsa/ecdsa_k/index.js +2 -23
  22. package/dest/ecdsa/ecdsa_k/lazy.d.ts +1 -25
  23. package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -1
  24. package/dest/ecdsa/ecdsa_k/lazy.js +5 -26
  25. package/dest/ecdsa/ecdsa_r/account_contract.d.ts +19 -0
  26. package/dest/ecdsa/ecdsa_r/account_contract.d.ts.map +1 -0
  27. package/dest/ecdsa/ecdsa_r/account_contract.js +41 -0
  28. package/dest/ecdsa/ecdsa_r/index.d.ts +19 -0
  29. package/dest/ecdsa/ecdsa_r/index.d.ts.map +1 -0
  30. package/dest/ecdsa/ecdsa_r/index.js +23 -0
  31. package/dest/ecdsa/ecdsa_r/lazy.d.ts +23 -0
  32. package/dest/ecdsa/ecdsa_r/lazy.d.ts.map +1 -0
  33. package/dest/ecdsa/ecdsa_r/lazy.js +31 -0
  34. package/dest/ecdsa/index.d.ts +2 -1
  35. package/dest/ecdsa/index.d.ts.map +1 -1
  36. package/dest/ecdsa/index.js +1 -0
  37. package/dest/ecdsa/lazy.d.ts +2 -1
  38. package/dest/ecdsa/lazy.d.ts.map +1 -1
  39. package/dest/ecdsa/lazy.js +1 -0
  40. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +5 -4
  41. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
  42. package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +9 -6
  43. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +2 -27
  44. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
  45. package/dest/ecdsa/ssh_ecdsa_r/index.js +3 -28
  46. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +2 -30
  47. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -1
  48. package/dest/ecdsa/ssh_ecdsa_r/lazy.js +3 -38
  49. package/dest/schnorr/account_contract.d.ts +7 -3
  50. package/dest/schnorr/account_contract.d.ts.map +1 -1
  51. package/dest/schnorr/account_contract.js +9 -6
  52. package/dest/schnorr/index.d.ts +4 -38
  53. package/dest/schnorr/index.d.ts.map +1 -1
  54. package/dest/schnorr/index.js +2 -33
  55. package/dest/schnorr/lazy.d.ts +4 -38
  56. package/dest/schnorr/lazy.d.ts.map +1 -1
  57. package/dest/schnorr/lazy.js +5 -36
  58. package/dest/single_key/account_contract.d.ts +3 -3
  59. package/dest/single_key/account_contract.d.ts.map +1 -1
  60. package/dest/single_key/account_contract.js +2 -2
  61. package/dest/single_key/index.d.ts +2 -21
  62. package/dest/single_key/index.d.ts.map +1 -1
  63. package/dest/single_key/index.js +2 -24
  64. package/dest/single_key/lazy.d.ts +2 -21
  65. package/dest/single_key/lazy.d.ts.map +1 -1
  66. package/dest/single_key/lazy.js +5 -27
  67. package/dest/stub/account_contract.d.ts +29 -0
  68. package/dest/stub/account_contract.d.ts.map +1 -0
  69. package/dest/stub/account_contract.js +30 -0
  70. package/dest/stub/index.d.ts +21 -0
  71. package/dest/stub/index.d.ts.map +1 -0
  72. package/dest/stub/index.js +29 -0
  73. package/dest/stub/lazy.d.ts +23 -0
  74. package/dest/stub/lazy.d.ts.map +1 -0
  75. package/dest/stub/lazy.js +35 -0
  76. package/dest/testing/configuration.d.ts +5 -4
  77. package/dest/testing/configuration.d.ts.map +1 -1
  78. package/dest/testing/configuration.js +1 -1
  79. package/dest/testing/index.d.ts +6 -30
  80. package/dest/testing/index.d.ts.map +1 -1
  81. package/dest/testing/index.js +18 -30
  82. package/dest/testing/lazy.d.ts +5 -28
  83. package/dest/testing/lazy.d.ts.map +1 -1
  84. package/dest/testing/lazy.js +19 -30
  85. package/dest/utils/index.d.ts +1 -1
  86. package/dest/utils/ssh_agent.d.ts +2 -5
  87. package/dest/utils/ssh_agent.d.ts.map +1 -1
  88. package/package.json +26 -20
  89. package/src/defaults/account_contract.ts +13 -5
  90. package/src/defaults/account_interface.ts +16 -12
  91. package/src/defaults/index.ts +1 -1
  92. package/src/ecdsa/ecdsa_k/account_contract.ts +7 -4
  93. package/src/ecdsa/ecdsa_k/index.ts +1 -33
  94. package/src/ecdsa/ecdsa_k/lazy.ts +4 -36
  95. package/src/ecdsa/ecdsa_r/account_contract.ts +42 -0
  96. package/src/ecdsa/ecdsa_r/index.ts +31 -0
  97. package/src/ecdsa/ecdsa_r/lazy.ts +39 -0
  98. package/src/ecdsa/index.ts +1 -0
  99. package/src/ecdsa/lazy.ts +1 -0
  100. package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +7 -4
  101. package/src/ecdsa/ssh_ecdsa_r/index.ts +3 -42
  102. package/src/ecdsa/ssh_ecdsa_r/lazy.ts +3 -53
  103. package/src/schnorr/account_contract.ts +5 -4
  104. package/src/schnorr/index.ts +10 -57
  105. package/src/schnorr/lazy.ts +13 -60
  106. package/src/single_key/account_contract.ts +8 -4
  107. package/src/single_key/index.ts +2 -33
  108. package/src/single_key/lazy.ts +5 -36
  109. package/src/stub/account_contract.ts +39 -0
  110. package/src/stub/index.ts +41 -0
  111. package/src/stub/lazy.ts +49 -0
  112. package/src/testing/configuration.ts +2 -1
  113. package/src/testing/index.ts +19 -51
  114. package/src/testing/lazy.ts +18 -50
  115. package/dest/dapp/dapp_interface.d.ts +0 -10
  116. package/dest/dapp/dapp_interface.d.ts.map +0 -1
  117. package/dest/dapp/dapp_interface.js +0 -16
  118. package/dest/dapp/index.d.ts +0 -2
  119. package/dest/dapp/index.d.ts.map +0 -1
  120. package/dest/dapp/index.js +0 -1
  121. package/dest/testing/create_account.d.ts +0 -43
  122. package/dest/testing/create_account.d.ts.map +0 -1
  123. package/dest/testing/create_account.js +0 -58
  124. package/src/dapp/dapp_interface.ts +0 -38
  125. package/src/dapp/index.ts +0 -1
  126. package/src/testing/create_account.ts +0 -93
@@ -1,15 +1,15 @@
1
1
  /**
2
- * The `@aztec/accounts/testing/lazy` export provides utility methods for testing, in particular in a Sandbox environment.
3
- *
4
- * Use {@link getInitialTestAccountsWallets} to obtain a list of wallets for the Sandbox pre-seeded accounts.
2
+ * The `@aztec/accounts/testing/lazy` export provides utility methods for testing, in particular in a local network environment.
5
3
  *
6
4
  * @packageDocumentation
7
- */ import { getSchnorrAccount, getSchnorrAccountContractAddress, getSchnorrWalletWithSecretKey } from '../schnorr/lazy.js';
5
+ */ import { Fr } from '@aztec/aztec.js/fields';
6
+ import { deriveSigningKey } from '@aztec/stdlib/keys';
7
+ import { getSchnorrAccountContractAddress } from '../schnorr/lazy.js';
8
8
  import { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS } from './configuration.js';
9
- export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS } from './configuration.js';
9
+ export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_SECRET_KEYS } from './configuration.js';
10
10
  /**
11
11
  * Gets the basic information for initial test accounts.
12
- */ export function getInitialTestAccounts() {
12
+ */ export function getInitialTestAccountsData() {
13
13
  return Promise.all(INITIAL_TEST_SECRET_KEYS.map(async (secret, i)=>({
14
14
  secret,
15
15
  signingKey: INITIAL_TEST_ENCRYPTION_KEYS[i],
@@ -18,29 +18,18 @@ export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_
18
18
  })));
19
19
  }
20
20
  /**
21
- * Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
22
- * @param pxe - PXE instance.
23
- * @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();
21
+ * Generate a fixed amount of random schnorr account contract instance.
22
+ */ export async function generateSchnorrAccounts(numberOfAccounts) {
23
+ const secrets = Array.from({
24
+ length: numberOfAccounts
25
+ }, ()=>Fr.random());
26
+ return await Promise.all(secrets.map(async (secret)=>{
27
+ const salt = Fr.random();
28
+ return {
29
+ secret,
30
+ signingKey: deriveSigningKey(secret),
31
+ salt,
32
+ address: await getSchnorrAccountContractAddress(secret, salt)
33
+ };
28
34
  }));
29
35
  }
30
- /**
31
- * Queries a PXE for it's registered accounts.
32
- * @param pxe - PXE instance.
33
- * @returns A set of key data for each of the initial accounts.
34
- */ export async function getDeployedTestAccounts(pxe) {
35
- const registeredAccounts = await pxe.getRegisteredAccounts();
36
- const testAccounts = await getInitialTestAccounts();
37
- return testAccounts.filter((t)=>registeredAccounts.some((r)=>r.address.equals(t.address)));
38
- }
39
- /**
40
- * Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
41
- * @param pxe - PXE instance.
42
- * @returns A set of AccountWallet implementations for each of the initial accounts.
43
- */ export async function getDeployedTestAccountsWallets(pxe) {
44
- const testAccounts = await getDeployedTestAccounts(pxe);
45
- return Promise.all(testAccounts.map(({ secret, signingKey, salt })=>getSchnorrWalletWithSecretKey(pxe, secret, signingKey, salt)));
46
- }
@@ -1,2 +1,2 @@
1
1
  export * from './ssh_agent.js';
2
- //# sourceMappingURL=index.d.ts.map
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGdCQUFnQixDQUFDIn0=
@@ -1,6 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- /// <reference types="node" resolution-mode="require"/>
4
1
  import { Buffer } from 'buffer';
5
2
  import net from 'net';
6
3
  /**
@@ -31,6 +28,6 @@ export declare function getIdentities(): Promise<StoredKey[]>;
31
28
  /**
32
29
  * Sign data using a key stored in the SSH agent. The private signing key is identified by its corresponding public key.
33
30
  */
34
- export declare function signWithAgent(keyType: Buffer, curveName: Buffer, publicKey: Buffer, data: Buffer): Promise<Buffer>;
31
+ export declare function signWithAgent(keyType: Buffer, curveName: Buffer, publicKey: Buffer, data: Buffer): Promise<Buffer<ArrayBufferLike>>;
35
32
  export {};
36
- //# sourceMappingURL=ssh_agent.d.ts.map
33
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3NoX2FnZW50LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvc3NoX2FnZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxRQUFRLENBQUM7QUFDaEMsT0FBTyxHQUFHLE1BQU0sS0FBSyxDQUFDO0FBT3RCOztHQUVHO0FBQ0gsd0JBQWdCLGNBQWMsZUFNN0I7QUFFRDs7R0FFRztBQUNILEtBQUssU0FBUyxHQUFHO0lBQ2Y7O09BRUc7SUFDSCxJQUFJLEVBQUUsTUFBTSxDQUFDO0lBQ2I7O09BRUc7SUFDSCxTQUFTLEVBQUUsTUFBTSxDQUFDO0lBQ2xCOztPQUVHO0lBQ0gsT0FBTyxFQUFFLE1BQU0sQ0FBQztDQUNqQixDQUFDO0FBRUY7O0dBRUc7QUFDSCx3QkFBZ0IsYUFBYSxJQUFJLE9BQU8sQ0FBQyxTQUFTLEVBQUUsQ0FBQyxDQWtEcEQ7QUFFRDs7R0FFRztBQUNILHdCQUFnQixhQUFhLENBQUMsT0FBTyxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsTUFBTSxFQUFFLFNBQVMsRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFLE1BQU0sb0NBd0NoRyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"ssh_agent.d.ts","sourceRoot":"","sources":["../../src/utils/ssh_agent.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AAOtB;;GAEG;AACH,wBAAgB,cAAc,eAM7B;AAED;;GAEG;AACH,KAAK,SAAS,GAAG;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAkDpD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAwChG"}
1
+ {"version":3,"file":"ssh_agent.d.ts","sourceRoot":"","sources":["../../src/utils/ssh_agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AAOtB;;GAEG;AACH,wBAAgB,cAAc,eAM7B;AAED;;GAEG;AACH,KAAK,SAAS,GAAG;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAkDpD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oCAwChG"}
package/package.json CHANGED
@@ -2,10 +2,9 @@
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.0.0-test.0",
5
+ "version": "0.0.1-commit.03f7ef2",
6
6
  "type": "module",
7
7
  "exports": {
8
- "./dapp": "./dest/dapp/index.js",
9
8
  "./defaults": "./dest/defaults/index.js",
10
9
  "./ecdsa": "./dest/ecdsa/index.js",
11
10
  "./ecdsa/lazy": "./dest/ecdsa/lazy.js",
@@ -13,8 +12,12 @@
13
12
  "./schnorr/lazy": "./dest/schnorr/lazy.js",
14
13
  "./single_key": "./dest/single_key/index.js",
15
14
  "./single_key/lazy": "./dest/single_key/lazy.js",
15
+ "./stub": "./dest/stub/index.js",
16
+ "./stub/lazy": "./dest/stub/lazy.js",
16
17
  "./testing": "./dest/testing/index.js",
17
18
  "./testing/lazy": "./dest/testing/lazy.js",
19
+ "./copy-cat": "./dest/copy_cat/index.js",
20
+ "./copy-cat/lazy": "./dest/copy_cat/lazy.js",
18
21
  "./utils": "./dest/utils/index.js"
19
22
  },
20
23
  "typedocOptions": {
@@ -29,14 +32,12 @@
29
32
  "tsconfig": "./tsconfig.json"
30
33
  },
31
34
  "scripts": {
32
- "build": "yarn clean && yarn generate && tsc -b",
35
+ "build": "yarn clean && yarn generate && ../scripts/tsc.sh",
33
36
  "generate": "yarn generate:noir-contracts",
34
37
  "generate:noir-contracts": "./scripts/copy-contracts.sh",
35
- "build:dev": "tsc -b --watch",
36
- "build:ts": "tsc -b",
38
+ "build:dev": "../scripts/tsc.sh --watch",
39
+ "build:ts": "tsgo -b",
37
40
  "clean": "rm -rf ./dest .tsbuildinfo ./artifacts",
38
- "formatting": "run -T prettier --check ./src && run -T eslint ./src",
39
- "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
40
41
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
41
42
  },
42
43
  "inherits": [
@@ -74,25 +75,30 @@
74
75
  "testTimeout": 120000,
75
76
  "setupFiles": [
76
77
  "../../foundation/src/jest/setup.mjs"
78
+ ],
79
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
80
+ "setupFilesAfterEnv": [
81
+ "../../foundation/src/jest/setupAfterEnv.mjs"
77
82
  ]
78
83
  },
79
84
  "dependencies": {
80
- "@aztec/aztec.js": "0.0.0-test.0",
81
- "@aztec/entrypoints": "0.0.0-test.0",
82
- "@aztec/ethereum": "0.0.0-test.0",
83
- "@aztec/foundation": "0.0.0-test.0",
84
- "@aztec/stdlib": "0.0.0-test.0",
85
+ "@aztec/aztec.js": "0.0.1-commit.03f7ef2",
86
+ "@aztec/entrypoints": "0.0.1-commit.03f7ef2",
87
+ "@aztec/ethereum": "0.0.1-commit.03f7ef2",
88
+ "@aztec/foundation": "0.0.1-commit.03f7ef2",
89
+ "@aztec/stdlib": "0.0.1-commit.03f7ef2",
85
90
  "tslib": "^2.4.0"
86
91
  },
87
92
  "devDependencies": {
88
- "@jest/globals": "^29.5.0",
89
- "@types/jest": "^29.5.0",
90
- "@types/node": "^18.7.23",
91
- "jest": "^29.5.0",
92
- "jest-mock-extended": "^3.0.3",
93
- "ts-loader": "^9.4.4",
93
+ "@jest/globals": "^30.0.0",
94
+ "@types/jest": "^30.0.0",
95
+ "@types/node": "^22.15.17",
96
+ "@typescript/native-preview": "7.0.0-dev.20251126.1",
97
+ "jest": "^30.0.0",
98
+ "jest-mock-extended": "^4.0.0",
99
+ "ts-loader": "^9.5.4",
94
100
  "ts-node": "^10.9.1",
95
- "typescript": "^5.0.4"
101
+ "typescript": "^5.3.3"
96
102
  },
97
103
  "files": [
98
104
  "dest",
@@ -101,6 +107,6 @@
101
107
  "artifacts"
102
108
  ],
103
109
  "engines": {
104
- "node": ">=18"
110
+ "node": ">=20.10"
105
111
  }
106
112
  }
@@ -1,6 +1,6 @@
1
- import type { AccountContract, AccountInterface, AuthWitnessProvider } from '@aztec/aztec.js/account';
1
+ import type { AccountContract, AccountInterface, AuthWitnessProvider, ChainInfo } from '@aztec/aztec.js/account';
2
2
  import type { ContractArtifact } from '@aztec/stdlib/abi';
3
- import type { CompleteAddress, NodeInfo } from '@aztec/stdlib/contract';
3
+ import type { CompleteAddress } from '@aztec/stdlib/contract';
4
4
 
5
5
  import { DefaultAccountInterface } from '../defaults/account_interface.js';
6
6
 
@@ -10,12 +10,20 @@ import { DefaultAccountInterface } from '../defaults/account_interface.js';
10
10
  */
11
11
  export abstract class DefaultAccountContract implements AccountContract {
12
12
  abstract getAuthWitnessProvider(address: CompleteAddress): AuthWitnessProvider;
13
- abstract getDeploymentArgs(): Promise<any[] | undefined>;
13
+ abstract getInitializationFunctionAndArgs(): Promise<
14
+ | {
15
+ /** The name of the function used to initialize the contract */
16
+ constructorName: string;
17
+ /** The args to the function used to initialize the contract */
18
+ constructorArgs: any[];
19
+ }
20
+ | undefined
21
+ >;
14
22
  abstract getContractArtifact(): Promise<ContractArtifact>;
15
23
 
16
24
  constructor() {}
17
25
 
18
- getInterface(address: CompleteAddress, nodeInfo: NodeInfo): AccountInterface {
19
- return new DefaultAccountInterface(this.getAuthWitnessProvider(address), address, nodeInfo);
26
+ getInterface(address: CompleteAddress, chainInfo: ChainInfo): AccountInterface {
27
+ return new DefaultAccountInterface(this.getAuthWitnessProvider(address), address, chainInfo);
20
28
  }
21
29
  }
@@ -1,12 +1,12 @@
1
1
  import type { AccountInterface, AuthWitnessProvider } from '@aztec/aztec.js/account';
2
- import type { EntrypointInterface, ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
3
- import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
4
- import { Fr } from '@aztec/foundation/fields';
2
+ import { DefaultAccountEntrypoint, type DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
3
+ import type { ChainInfo, EntrypointInterface } from '@aztec/entrypoints/interfaces';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
6
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
7
  import { CompleteAddress } from '@aztec/stdlib/contract';
8
- import type { NodeInfo } from '@aztec/stdlib/contract';
9
- import type { TxExecutionRequest } from '@aztec/stdlib/tx';
8
+ import type { GasSettings } from '@aztec/stdlib/gas';
9
+ import type { ExecutionPayload, TxExecutionRequest } from '@aztec/stdlib/tx';
10
10
 
11
11
  /**
12
12
  * Default implementation for an account interface. Requires that the account uses the default
@@ -21,20 +21,24 @@ export class DefaultAccountInterface implements AccountInterface {
21
21
  constructor(
22
22
  private authWitnessProvider: AuthWitnessProvider,
23
23
  private address: CompleteAddress,
24
- nodeInfo: Pick<NodeInfo, 'l1ChainId' | 'protocolVersion'>,
24
+ chainInfo: ChainInfo,
25
25
  ) {
26
26
  this.entrypoint = new DefaultAccountEntrypoint(
27
27
  address.address,
28
28
  authWitnessProvider,
29
- nodeInfo.l1ChainId,
30
- nodeInfo.protocolVersion,
29
+ chainInfo.chainId.toNumber(),
30
+ chainInfo.version.toNumber(),
31
31
  );
32
- this.chainId = new Fr(nodeInfo.l1ChainId);
33
- this.version = new Fr(nodeInfo.protocolVersion);
32
+ this.chainId = chainInfo.chainId;
33
+ this.version = chainInfo.version;
34
34
  }
35
35
 
36
- createTxExecutionRequest(execution: ExecutionRequestInit): Promise<TxExecutionRequest> {
37
- return this.entrypoint.createTxExecutionRequest(execution);
36
+ createTxExecutionRequest(
37
+ exec: ExecutionPayload,
38
+ gasSettings: GasSettings,
39
+ options: DefaultAccountEntrypointOptions,
40
+ ): Promise<TxExecutionRequest> {
41
+ return this.entrypoint.createTxExecutionRequest(exec, gasSettings, options);
38
42
  }
39
43
 
40
44
  createAuthWit(messageHash: Fr): Promise<AuthWitness> {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The `@aztec/accounts/defaults` export provides the base class {@link DefaultAccountContract} for implementing account contracts that use the default entrypoint payload module.
3
3
  *
4
- * Read more in {@link https://docs.aztec.network/developers/tutorials/codealong/contract_tutorials/write_accounts_contract | Writing an account contract}.
4
+ * Read more in {@link https://docs.aztec.network/developers/tutorials/contract_tutorials/counter_contract | Writing an account contract}.
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
@@ -1,6 +1,6 @@
1
1
  import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2
- import { Ecdsa } from '@aztec/foundation/crypto';
3
- import type { Fr } from '@aztec/foundation/fields';
2
+ import { Ecdsa } from '@aztec/foundation/crypto/ecdsa';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
5
5
  import { CompleteAddress } from '@aztec/stdlib/contract';
6
6
 
@@ -17,9 +17,12 @@ export abstract class EcdsaKBaseAccountContract extends DefaultAccountContract {
17
17
  super();
18
18
  }
19
19
 
20
- async getDeploymentArgs() {
20
+ async getInitializationFunctionAndArgs() {
21
21
  const signingPublicKey = await new Ecdsa().computePublicKey(this.signingPrivateKey);
22
- return [signingPublicKey.subarray(0, 32), signingPublicKey.subarray(32, 64)];
22
+ return {
23
+ constructorName: 'constructor',
24
+ constructorArgs: [signingPublicKey.subarray(0, 32), signingPublicKey.subarray(32, 64)],
25
+ };
23
26
  }
24
27
 
25
28
  getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider {
@@ -4,16 +4,11 @@
4
4
  *
5
5
  * @packageDocumentation
6
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
7
  import type { ContractArtifact } from '@aztec/stdlib/abi';
11
8
  import { loadContractArtifact } from '@aztec/stdlib/abi';
12
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
13
- import type { PXE } from '@aztec/stdlib/interfaces/client';
14
9
  import type { NoirCompiledContract } from '@aztec/stdlib/noir';
15
10
 
16
- import EcdsaKAccountContractJson from '../../../artifacts/EcdsaKAccount.json' assert { type: 'json' };
11
+ import EcdsaKAccountContractJson from '../../../artifacts/EcdsaKAccount.json' with { type: 'json' };
17
12
  import { EcdsaKBaseAccountContract } from './account_contract.js';
18
13
 
19
14
  export const EcdsaKAccountContractArtifact: ContractArtifact = loadContractArtifact(
@@ -34,30 +29,3 @@ export class EcdsaKAccountContract extends EcdsaKBaseAccountContract {
34
29
  return Promise.resolve(EcdsaKAccountContractArtifact);
35
30
  }
36
31
  }
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 getEcdsaKAccount(
46
- pxe: PXE,
47
- secretKey: Fr,
48
- signingPrivateKey: Buffer,
49
- salt?: Salt,
50
- ): Promise<AccountManager> {
51
- return AccountManager.create(pxe, secretKey, new EcdsaKAccountContract(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 getEcdsaKWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: Buffer): Promise<AccountWallet> {
62
- return getWallet(pxe, address, new EcdsaKAccountContract(signingPrivateKey));
63
- }
@@ -4,13 +4,8 @@
4
4
  *
5
5
  * @packageDocumentation
6
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
7
  import type { ContractArtifact } from '@aztec/stdlib/abi';
11
8
  import { loadContractArtifact } from '@aztec/stdlib/abi';
12
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
13
- import type { PXE } from '@aztec/stdlib/interfaces/client';
14
9
 
15
10
  import { EcdsaKBaseAccountContract } from './account_contract.js';
16
11
 
@@ -19,10 +14,10 @@ import { EcdsaKBaseAccountContract } from './account_contract.js';
19
14
  * @returns The contract artifact for the ecdsa K account contract
20
15
  */
21
16
  export async function getEcdsaKAccountContractArtifact() {
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
17
+ // Cannot assert this import as it's incompatible with bundlers like vite
18
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
19
+ // Even if now supported by al major browsers, the MIME type is replaced with
20
+ // "text/javascript"
26
21
  // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
27
22
  const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaKAccount.json');
28
23
  return loadContractArtifact(ecdsaKAccountContractJson);
@@ -42,30 +37,3 @@ export class EcdsaKAccountContract extends EcdsaKBaseAccountContract {
42
37
  return getEcdsaKAccountContractArtifact();
43
38
  }
44
39
  }
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 getEcdsaKAccount(
54
- pxe: PXE,
55
- secretKey: Fr,
56
- signingPrivateKey: Buffer,
57
- salt?: Salt,
58
- ): Promise<AccountManager> {
59
- return AccountManager.create(pxe, secretKey, new EcdsaKAccountContract(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 getEcdsaKWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: Buffer): Promise<AccountWallet> {
70
- return getWallet(pxe, address, new EcdsaKAccountContract(signingPrivateKey));
71
- }
@@ -0,0 +1,42 @@
1
+ import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2
+ import { Ecdsa } from '@aztec/foundation/crypto/ecdsa';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
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 getInitializationFunctionAndArgs() {
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,31 @@
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 type { ContractArtifact } from '@aztec/stdlib/abi';
8
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
9
+ import type { NoirCompiledContract } from '@aztec/stdlib/noir';
10
+
11
+ import EcdsaRAccountContractJson from '../../../artifacts/EcdsaRAccount.json' with { type: 'json' };
12
+ import { EcdsaRBaseAccountContract } from './account_contract.js';
13
+
14
+ export const EcdsaRAccountContractArtifact: ContractArtifact = loadContractArtifact(
15
+ EcdsaRAccountContractJson as NoirCompiledContract,
16
+ );
17
+
18
+ /**
19
+ * Account contract that authenticates transactions using ECDSA signatures
20
+ * verified against a secp256k1 public key stored in an immutable encrypted note.
21
+ * Eagerly loads the contract artifact
22
+ */
23
+ export class EcdsaRAccountContract extends EcdsaRBaseAccountContract {
24
+ constructor(signingPrivateKey: Buffer) {
25
+ super(signingPrivateKey);
26
+ }
27
+
28
+ override getContractArtifact(): Promise<ContractArtifact> {
29
+ return Promise.resolve(EcdsaRAccountContractArtifact);
30
+ }
31
+ }
@@ -0,0 +1,39 @@
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 type { ContractArtifact } from '@aztec/stdlib/abi';
8
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
9
+
10
+ import { EcdsaRBaseAccountContract } from './account_contract.js';
11
+
12
+ /**
13
+ * Lazily loads the contract artifact
14
+ * @returns The contract artifact for the ecdsa K account contract
15
+ */
16
+ export async function getEcdsaRAccountContractArtifact() {
17
+ // Cannot assert this import as it's incompatible with bundlers like vite
18
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
19
+ // Even if now supported by al major browsers, the MIME type is replaced with
20
+ // "text/javascript"
21
+ // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
22
+ const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaRAccount.json');
23
+ return loadContractArtifact(ecdsaKAccountContractJson);
24
+ }
25
+
26
+ /**
27
+ * Account contract that authenticates transactions using ECDSA signatures
28
+ * verified against a secp256k1 public key stored in an immutable encrypted note.
29
+ * Lazily loads the contract artifact
30
+ */
31
+ export class EcdsaRAccountContract extends EcdsaRBaseAccountContract {
32
+ constructor(signingPrivateKey: Buffer) {
33
+ super(signingPrivateKey);
34
+ }
35
+
36
+ override getContractArtifact(): Promise<ContractArtifact> {
37
+ return getEcdsaRAccountContractArtifact();
38
+ }
39
+ }
@@ -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';
package/src/ecdsa/lazy.ts CHANGED
@@ -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';
@@ -1,6 +1,6 @@
1
1
  import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2
- import { EcdsaSignature } from '@aztec/foundation/crypto';
3
- import type { Fr } from '@aztec/foundation/fields';
2
+ import { EcdsaSignature } from '@aztec/foundation/crypto/ecdsa';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
5
5
  import { CompleteAddress } from '@aztec/stdlib/contract';
6
6
 
@@ -22,8 +22,11 @@ export abstract class EcdsaRSSHBaseAccountContract extends DefaultAccountContrac
22
22
  super();
23
23
  }
24
24
 
25
- getDeploymentArgs() {
26
- return Promise.resolve([this.signingPublicKey.subarray(0, 32), this.signingPublicKey.subarray(32, 64)]);
25
+ getInitializationFunctionAndArgs() {
26
+ return Promise.resolve({
27
+ constructorName: 'constructor',
28
+ constructorArgs: [this.signingPublicKey.subarray(0, 32), this.signingPublicKey.subarray(32, 64)],
29
+ });
27
30
  }
28
31
 
29
32
  getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider {
@@ -4,22 +4,11 @@
4
4
  *
5
5
  * @packageDocumentation
6
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
7
  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
8
 
16
- import EcdsaRAccountContractJson from '../../../artifacts/EcdsaKAccount.json' assert { type: 'json' };
9
+ import { EcdsaRAccountContractArtifact } from '../ecdsa_r/index.js';
17
10
  import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
18
11
 
19
- export const EcdsaRAccountContractArtifact: ContractArtifact = loadContractArtifact(
20
- EcdsaRAccountContractJson as NoirCompiledContract,
21
- );
22
-
23
12
  /**
24
13
  * Account contract that authenticates transactions using ECDSA signatures
25
14
  * verified against a secp256r1 public key stored in an immutable encrypted note.
@@ -29,39 +18,11 @@ export const EcdsaRAccountContractArtifact: ContractArtifact = loadContractArtif
29
18
  * Eagerly loads the contract artifact
30
19
  */
31
20
  export class EcdsaRSSHAccountContract extends EcdsaRSSHBaseAccountContract {
32
- constructor(signingPrivateKey: Buffer) {
33
- super(signingPrivateKey);
21
+ constructor(signingPublicKey: Buffer) {
22
+ super(signingPublicKey);
34
23
  }
35
24
 
36
25
  override getContractArtifact(): Promise<ContractArtifact> {
37
26
  return Promise.resolve(EcdsaRAccountContractArtifact);
38
27
  }
39
28
  }
40
-
41
- /**
42
- * Creates an Account that relies on an ECDSA signing key for authentication.
43
- * @param pxe - An PXE server instance.
44
- * @param secretKey - Secret key used to derive all the keystore keys.
45
- * @param signingPublicKey - Secp2561 key used to identify its corresponding private key in the SSH Agent.
46
- * @param salt - Deployment salt.
47
- * @returns An account manager initialized with the account contract and its deployment params
48
- */
49
- export function getEcdsaRSSHAccount(
50
- pxe: PXE,
51
- secretKey: Fr,
52
- signingPublicKey: Buffer,
53
- salt?: Salt,
54
- ): Promise<AccountManager> {
55
- return AccountManager.create(pxe, secretKey, new EcdsaRSSHAccountContract(signingPublicKey), salt);
56
- }
57
-
58
- /**
59
- * Gets a wallet for an already registered account using ECDSA signatures.
60
- * @param pxe - An PXE server instance.
61
- * @param address - Address for the account.
62
- * @param signingPrivateKey - ECDSA key used for signing transactions.
63
- * @returns A wallet for this account that can be used to interact with a contract instance.
64
- */
65
- export function getEcdsaRSSHWallet(pxe: PXE, address: AztecAddress, signingPublicKey: Buffer): Promise<AccountWallet> {
66
- return getWallet(pxe, address, new EcdsaRSSHAccountContract(signingPublicKey));
67
- }