@aztec/accounts 0.76.4 → 0.77.0-testnet-ignition.21

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 (111) hide show
  1. package/README.md +11 -8
  2. package/artifacts/EcdsaKAccount.d.json.ts +1 -1
  3. package/artifacts/EcdsaKAccount.json +850 -690
  4. package/artifacts/EcdsaRAccount.d.json.ts +1 -1
  5. package/artifacts/EcdsaRAccount.json +684 -524
  6. package/artifacts/SchnorrAccount.d.json.ts +1 -1
  7. package/artifacts/SchnorrAccount.json +692 -459
  8. package/artifacts/SchnorrSingleKeyAccount.d.json.ts +1 -1
  9. package/artifacts/SchnorrSingleKeyAccount.json +227 -301
  10. package/dest/dapp/dapp_interface.d.ts +1 -2
  11. package/dest/dapp/dapp_interface.d.ts.map +1 -1
  12. package/dest/dapp/dapp_interface.js +3 -5
  13. package/dest/dapp/index.js +0 -1
  14. package/dest/defaults/account_contract.d.ts +5 -7
  15. package/dest/defaults/account_contract.d.ts.map +1 -1
  16. package/dest/defaults/account_contract.js +2 -9
  17. package/dest/defaults/account_interface.d.ts +8 -4
  18. package/dest/defaults/account_interface.d.ts.map +1 -1
  19. package/dest/defaults/account_interface.js +8 -5
  20. package/dest/defaults/index.js +1 -3
  21. package/dest/ecdsa/ecdsa_k/account_contract.d.ts +5 -3
  22. package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
  23. package/dest/ecdsa/ecdsa_k/account_contract.js +19 -14
  24. package/dest/ecdsa/ecdsa_k/index.d.ts +15 -5
  25. package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
  26. package/dest/ecdsa/ecdsa_k/index.js +21 -10
  27. package/dest/ecdsa/ecdsa_k/lazy.d.ts +47 -0
  28. package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -0
  29. package/dest/ecdsa/ecdsa_k/lazy.js +52 -0
  30. package/dest/ecdsa/index.js +0 -1
  31. package/dest/ecdsa/lazy.d.ts +3 -0
  32. package/dest/ecdsa/lazy.d.ts.map +1 -0
  33. package/dest/ecdsa/lazy.js +2 -0
  34. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +5 -3
  35. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
  36. package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +55 -51
  37. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +18 -5
  38. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
  39. package/dest/ecdsa/ssh_ecdsa_r/index.js +24 -10
  40. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +49 -0
  41. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -0
  42. package/dest/ecdsa/ssh_ecdsa_r/lazy.js +57 -0
  43. package/dest/schnorr/account_contract.d.ts +13 -4
  44. package/dest/schnorr/account_contract.d.ts.map +1 -1
  45. package/dest/schnorr/account_contract.js +18 -14
  46. package/dest/schnorr/index.d.ts +32 -6
  47. package/dest/schnorr/index.d.ts.map +1 -1
  48. package/dest/schnorr/index.js +43 -10
  49. package/dest/schnorr/lazy.d.ts +61 -0
  50. package/dest/schnorr/lazy.d.ts.map +1 -0
  51. package/dest/schnorr/lazy.js +74 -0
  52. package/dest/single_key/account_contract.d.ts +6 -3
  53. package/dest/single_key/account_contract.d.ts.map +1 -1
  54. package/dest/single_key/account_contract.js +17 -13
  55. package/dest/single_key/index.d.ts +16 -8
  56. package/dest/single_key/index.d.ts.map +1 -1
  57. package/dest/single_key/index.js +23 -13
  58. package/dest/single_key/lazy.d.ts +43 -0
  59. package/dest/single_key/lazy.d.ts.map +1 -0
  60. package/dest/single_key/lazy.js +53 -0
  61. package/dest/testing/configuration.d.ts +23 -24
  62. package/dest/testing/configuration.d.ts.map +1 -1
  63. package/dest/testing/configuration.js +8 -79
  64. package/dest/testing/create_account.d.ts +38 -15
  65. package/dest/testing/create_account.d.ts.map +1 -1
  66. package/dest/testing/create_account.js +53 -49
  67. package/dest/testing/index.d.ts +28 -4
  68. package/dest/testing/index.d.ts.map +1 -1
  69. package/dest/testing/index.js +42 -6
  70. package/dest/testing/lazy.d.ts +34 -0
  71. package/dest/testing/lazy.d.ts.map +1 -0
  72. package/dest/testing/lazy.js +46 -0
  73. package/dest/utils/index.js +0 -1
  74. package/dest/utils/ssh_agent.js +75 -31
  75. package/package.json +12 -10
  76. package/src/dapp/dapp_interface.ts +7 -2
  77. package/src/defaults/account_contract.ts +5 -9
  78. package/src/defaults/account_interface.ts +8 -4
  79. package/src/ecdsa/ecdsa_k/account_contract.ts +9 -8
  80. package/src/ecdsa/ecdsa_k/index.ts +25 -5
  81. package/src/ecdsa/ecdsa_k/lazy.ts +71 -0
  82. package/src/ecdsa/lazy.ts +2 -0
  83. package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +9 -8
  84. package/src/ecdsa/ssh_ecdsa_r/index.ts +29 -5
  85. package/src/ecdsa/ssh_ecdsa_r/lazy.ts +78 -0
  86. package/src/schnorr/account_contract.ts +10 -9
  87. package/src/schnorr/index.ts +56 -7
  88. package/src/schnorr/lazy.ts +107 -0
  89. package/src/single_key/account_contract.ts +9 -8
  90. package/src/single_key/index.ts +29 -11
  91. package/src/single_key/lazy.ts +71 -0
  92. package/src/testing/configuration.ts +21 -103
  93. package/src/testing/create_account.ts +79 -57
  94. package/src/testing/index.ts +85 -4
  95. package/src/testing/lazy.ts +86 -0
  96. package/dest/ecdsa/ecdsa_k/artifact.d.ts +0 -3
  97. package/dest/ecdsa/ecdsa_k/artifact.d.ts.map +0 -1
  98. package/dest/ecdsa/ecdsa_k/artifact.js +0 -4
  99. package/dest/ecdsa/ssh_ecdsa_r/artifact.d.ts +0 -2
  100. package/dest/ecdsa/ssh_ecdsa_r/artifact.d.ts.map +0 -1
  101. package/dest/ecdsa/ssh_ecdsa_r/artifact.js +0 -4
  102. package/dest/schnorr/artifact.d.ts +0 -2
  103. package/dest/schnorr/artifact.d.ts.map +0 -1
  104. package/dest/schnorr/artifact.js +0 -4
  105. package/dest/single_key/artifact.d.ts +0 -2
  106. package/dest/single_key/artifact.d.ts.map +0 -1
  107. package/dest/single_key/artifact.js +0 -4
  108. package/src/ecdsa/ecdsa_k/artifact.ts +0 -7
  109. package/src/ecdsa/ssh_ecdsa_r/artifact.ts +0 -5
  110. package/src/schnorr/artifact.ts +0 -5
  111. package/src/single_key/artifact.ts +0 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/schnorr/lazy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAA6B,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,0BAA0B,EAAa,MAAM,wBAAwB,CAAC;AACxG,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9D,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;AAG3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE;;;GAGG;AACH,wBAAsB,iCAAiC,8BAQtD;AAED;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,0BAA0B;gBACxD,iBAAiB,EAAE,cAAc;IAIpC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,cAAc,EACjC,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,cAAc,GAChC,OAAO,CAAC,aAAa,CAAC,CAExB;AAED;;;;;;;GAOG;AACH,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,cAAc,EACjC,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,0BAA0B,CAAC,CAGrC;AAED;;;;;GAKG;AACH,wBAAsB,gCAAgC,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,iBAAiB,CAAC,EAAE,cAAc,yBAI9G"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The `@aztec/accounts/schnorr` export provides an account contract implementation that uses Schnorr signatures with a Grumpkin key for authentication, and a separate Grumpkin key for encryption.
3
+ * This is the suggested account contract type for most use cases within Aztec.
4
+ *
5
+ * @packageDocumentation
6
+ */ import { AccountManager, getAccountContractAddress } from '@aztec/aztec.js/account';
7
+ import { getWallet } from '@aztec/aztec.js/wallet';
8
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
9
+ import { deriveSigningKey } from '@aztec/stdlib/keys';
10
+ import { SchnorrBaseAccountContract } from './account_contract.js';
11
+ /**
12
+ * Lazily loads the contract artifact
13
+ * @returns The contract artifact for the schnorr account contract
14
+ */ export async function getSchnorrAccountContractArtifact() {
15
+ // Cannot assert this import as it's incompatible with browsers
16
+ // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
17
+ // Use the new "with" syntax once supported by firefox
18
+ // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
19
+ // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
20
+ const { default: schnorrAccountContractJson } = await import('../../artifacts/SchnorrAccount.json');
21
+ return loadContractArtifact(schnorrAccountContractJson);
22
+ }
23
+ /**
24
+ * Account contract that authenticates transactions using Schnorr signatures
25
+ * verified against a Grumpkin public key stored in an immutable encrypted note.
26
+ * Lazily loads the contract artifact
27
+ */ export class SchnorrAccountContract extends SchnorrBaseAccountContract {
28
+ constructor(signingPrivateKey){
29
+ super(signingPrivateKey);
30
+ }
31
+ getContractArtifact() {
32
+ return getSchnorrAccountContractArtifact();
33
+ }
34
+ }
35
+ /**
36
+ * Creates an Account Manager that relies on a Grumpkin signing key for authentication.
37
+ * @param pxe - An PXE server instance.
38
+ * @param secretKey - Secret key used to derive all the keystore keys.
39
+ * @param signingPrivateKey - Grumpkin key used for signing transactions.
40
+ * @param salt - Deployment salt.
41
+ * @returns An account manager initialized with the account contract and its deployment params
42
+ */ export function getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt) {
43
+ return AccountManager.create(pxe, secretKey, new SchnorrAccountContract(signingPrivateKey), salt);
44
+ }
45
+ /**
46
+ * Gets a wallet for an already registered account using Schnorr signatures.
47
+ * @param pxe - An PXE server instance.
48
+ * @param address - Address for the account.
49
+ * @param signingPrivateKey - Grumpkin key used for signing transactions.
50
+ * @returns A wallet for this account that can be used to interact with a contract instance.
51
+ */ export function getSchnorrWallet(pxe, address, signingPrivateKey) {
52
+ return getWallet(pxe, address, new SchnorrAccountContract(signingPrivateKey));
53
+ }
54
+ /**
55
+ * Gets a wallet for an already registered account using Schnorr signatures.
56
+ * @param pxe - An PXE server instance.
57
+ * @param secretKey - Secret key used to derive all the keystore keys.
58
+ * @param signingPrivateKey - Grumpkin key used for signing transactions.
59
+ * @param salt - Deployment salt.
60
+ * @returns A wallet for this account that can be used to interact with a contract instance.
61
+ */ export async function getSchnorrWalletWithSecretKey(pxe, secretKey, signingPrivateKey, salt) {
62
+ const account = await getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt);
63
+ return account.getWallet();
64
+ }
65
+ /**
66
+ * Compute the address of a schnorr account contract.
67
+ * @param secret - A seed for deriving the signing key and public keys.
68
+ * @param salt - The contract address salt.
69
+ * @param signingPrivateKey - A specific signing private key that's not derived from the secret.
70
+ */ export async function getSchnorrAccountContractAddress(secret, salt, signingPrivateKey) {
71
+ const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
72
+ const accountContract = new SchnorrAccountContract(signingKey);
73
+ return await getAccountContractAddress(accountContract, secret, salt);
74
+ }
@@ -1,11 +1,14 @@
1
- import { type AuthWitnessProvider } from '@aztec/aztec.js/account';
2
- import { type CompleteAddress, type GrumpkinScalar } from '@aztec/circuit-types';
1
+ import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2
+ import { GrumpkinScalar } from '@aztec/foundation/fields';
3
+ import { CompleteAddress } from '@aztec/stdlib/contract';
3
4
  import { DefaultAccountContract } from '../defaults/account_contract.js';
4
5
  /**
5
6
  * Account contract that authenticates transactions using Schnorr signatures verified against
6
7
  * the note encryption key, relying on a single private key for both encryption and authentication.
8
+ * This abstract version does not provide a way to retrieve the artifact, as it
9
+ * can be implemented with or without lazy loading.
7
10
  */
8
- export declare class SingleKeyAccountContract extends DefaultAccountContract {
11
+ export declare abstract class SingleKeyBaseAccountContract extends DefaultAccountContract {
9
12
  private encryptionPrivateKey;
10
13
  constructor(encryptionPrivateKey: GrumpkinScalar);
11
14
  getDeploymentArgs(): Promise<undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/single_key/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAe,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAGzE;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,sBAAsB;IACtD,OAAO,CAAC,oBAAoB;gBAApB,oBAAoB,EAAE,cAAc;IAIxD,iBAAiB;IAIjB,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,mBAAmB;CAGtE"}
1
+ {"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/single_key/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAW,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE;;;;;GAKG;AACH,8BAAsB,4BAA6B,SAAQ,sBAAsB;IACnE,OAAO,CAAC,oBAAoB;gBAApB,oBAAoB,EAAE,cAAc;IAIxD,iBAAiB;IAIjB,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,mBAAmB;CAGtE"}
@@ -1,15 +1,15 @@
1
- import { AuthWitness } from '@aztec/circuit-types';
2
- import { Schnorr } from '@aztec/circuits.js/barretenberg';
1
+ import { Schnorr } from '@aztec/foundation/crypto';
2
+ import { AuthWitness } from '@aztec/stdlib/auth-witness';
3
3
  import { DefaultAccountContract } from '../defaults/account_contract.js';
4
- import { SchnorrSingleKeyAccountContractArtifact } from './artifact.js';
5
4
  /**
6
5
  * Account contract that authenticates transactions using Schnorr signatures verified against
7
6
  * the note encryption key, relying on a single private key for both encryption and authentication.
8
- */
9
- export class SingleKeyAccountContract extends DefaultAccountContract {
10
- constructor(encryptionPrivateKey) {
11
- super(SchnorrSingleKeyAccountContractArtifact);
12
- this.encryptionPrivateKey = encryptionPrivateKey;
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 SingleKeyBaseAccountContract extends DefaultAccountContract {
10
+ encryptionPrivateKey;
11
+ constructor(encryptionPrivateKey){
12
+ super(), this.encryptionPrivateKey = encryptionPrivateKey;
13
13
  }
14
14
  getDeploymentArgs() {
15
15
  return Promise.resolve(undefined);
@@ -22,17 +22,21 @@ export class SingleKeyAccountContract extends DefaultAccountContract {
22
22
  * Creates auth witnesses using Schnorr signatures and including the partial address and public key
23
23
  * in the witness, so verifiers do not need to store the public key and can instead validate it
24
24
  * by reconstructing the current address.
25
- */
26
- class SingleKeyAuthWitnessProvider {
27
- constructor(privateKey, account) {
25
+ */ class SingleKeyAuthWitnessProvider {
26
+ privateKey;
27
+ account;
28
+ constructor(privateKey, account){
28
29
  this.privateKey = privateKey;
29
30
  this.account = account;
30
31
  }
31
32
  async createAuthWit(messageHash) {
32
33
  const schnorr = new Schnorr();
33
34
  const signature = await schnorr.constructSignature(messageHash.toBuffer(), this.privateKey);
34
- const witness = [...this.account.publicKeys.toFields(), ...signature.toBuffer(), this.account.partialAddress];
35
+ const witness = [
36
+ ...this.account.publicKeys.toFields(),
37
+ ...signature.toBuffer(),
38
+ this.account.partialAddress
39
+ ];
35
40
  return Promise.resolve(new AuthWitness(messageHash, witness));
36
41
  }
37
42
  }
38
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3VudF9jb250cmFjdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zaW5nbGVfa2V5L2FjY291bnRfY29udHJhY3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFdBQVcsRUFBNkMsTUFBTSxzQkFBc0IsQ0FBQztBQUM5RixPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFJMUQsT0FBTyxFQUFFLHNCQUFzQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDekUsT0FBTyxFQUFFLHVDQUF1QyxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRXhFOzs7R0FHRztBQUNILE1BQU0sT0FBTyx3QkFBeUIsU0FBUSxzQkFBc0I7SUFDbEUsWUFBb0Isb0JBQW9DO1FBQ3RELEtBQUssQ0FBQyx1Q0FBMkQsQ0FBQyxDQUFDO1FBRGpELHlCQUFvQixHQUFwQixvQkFBb0IsQ0FBZ0I7SUFFeEQsQ0FBQztJQUVELGlCQUFpQjtRQUNmLE9BQU8sT0FBTyxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUNwQyxDQUFDO0lBRUQsc0JBQXNCLENBQUMsT0FBd0I7UUFDN0MsT0FBTyxJQUFJLDRCQUE0QixDQUFDLElBQUksQ0FBQyxvQkFBb0IsRUFBRSxPQUFPLENBQUMsQ0FBQztJQUM5RSxDQUFDO0NBQ0Y7QUFFRDs7OztHQUlHO0FBQ0gsTUFBTSw0QkFBNEI7SUFDaEMsWUFBb0IsVUFBMEIsRUFBVSxPQUF3QjtRQUE1RCxlQUFVLEdBQVYsVUFBVSxDQUFnQjtRQUFVLFlBQU8sR0FBUCxPQUFPLENBQWlCO0lBQUcsQ0FBQztJQUVwRixLQUFLLENBQUMsYUFBYSxDQUFDLFdBQWU7UUFDakMsTUFBTSxPQUFPLEdBQUcsSUFBSSxPQUFPLEVBQUUsQ0FBQztRQUM5QixNQUFNLFNBQVMsR0FBRyxNQUFNLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxXQUFXLENBQUMsUUFBUSxFQUFFLEVBQUUsSUFBSSxDQUFDLFVBQVUsQ0FBQyxDQUFDO1FBQzVGLE1BQU0sT0FBTyxHQUFHLENBQUMsR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxRQUFRLEVBQUUsRUFBRSxHQUFHLFNBQVMsQ0FBQyxRQUFRLEVBQUUsRUFBRSxJQUFJLENBQUMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxDQUFDO1FBQzlHLE9BQU8sT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLFdBQVcsQ0FBQyxXQUFXLEVBQUUsT0FBTyxDQUFDLENBQUMsQ0FBQztJQUNoRSxDQUFDO0NBQ0YifQ==
@@ -4,13 +4,22 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
+ import type { AztecAddress, Fr, GrumpkinScalar } from '@aztec/aztec.js';
7
8
  import { AccountManager, type Salt } from '@aztec/aztec.js/account';
8
9
  import { type AccountWallet } from '@aztec/aztec.js/wallet';
9
- import { type GrumpkinScalar, type PXE } from '@aztec/circuit-types';
10
- import { type AztecAddress, type Fr } from '@aztec/circuits.js';
11
- import { SingleKeyAccountContract } from './account_contract.js';
12
- export { SingleKeyAccountContract };
13
- export { SchnorrSingleKeyAccountContractArtifact as SingleKeyAccountContractArtifact } from './artifact.js';
10
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
11
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
12
+ import { SingleKeyBaseAccountContract } from './account_contract.js';
13
+ export declare const SchnorrSingleKeyAccountContractArtifact: ContractArtifact;
14
+ /**
15
+ * Account contract that authenticates transactions using Schnorr signatures verified against
16
+ * the note encryption key, relying on a single private key for both encryption and authentication.
17
+ * Eagerly loads the contract artifact
18
+ */
19
+ export declare class SingleKeyAccountContract extends SingleKeyBaseAccountContract {
20
+ constructor(signingPrivateKey: GrumpkinScalar);
21
+ getContractArtifact(): Promise<ContractArtifact>;
22
+ }
14
23
  /**
15
24
  * Creates an Account that uses the same Grumpkin key for encryption and authentication.
16
25
  * @param pxe - An PXE server instance.
@@ -18,7 +27,7 @@ export { SchnorrSingleKeyAccountContractArtifact as SingleKeyAccountContractArti
18
27
  * @param salt - Deployment salt.
19
28
  * @returns An account manager initialized with the account contract and its deployment params
20
29
  */
21
- export declare function getSingleKeyAccount(pxe: PXE, secretKey: Fr, salt?: Salt): Promise<AccountManager>;
30
+ export declare function getUnsafeSchnorrAccount(pxe: PXE, secretKey: Fr, salt?: Salt): Promise<AccountManager>;
22
31
  /**
23
32
  * Gets a wallet for an already registered account using Schnorr signatures with a single key for encryption and authentication.
24
33
  * @param pxe - An PXE server instance.
@@ -26,6 +35,5 @@ export declare function getSingleKeyAccount(pxe: PXE, secretKey: Fr, salt?: Salt
26
35
  * @param signingPrivateKey - Grumpkin key used for note encryption and signing transactions.
27
36
  * @returns A wallet for this account that can be used to interact with a contract instance.
28
37
  */
29
- export declare function getSingleKeyWallet(pxe: PXE, address: AztecAddress, signingKey: GrumpkinScalar): Promise<AccountWallet>;
30
- export { getSingleKeyAccount as getUnsafeSchnorrAccount, getSingleKeyWallet as getUnsafeSchnorrWallet };
38
+ export declare function getUnsafeSchnorrWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: GrumpkinScalar): Promise<AccountWallet>;
31
39
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/single_key/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,KAAK,cAAc,EAAE,KAAK,GAAG,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,EAAE,EAAwC,MAAM,oBAAoB,CAAC;AAEtG,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,CAAC;AAEpC,OAAO,EAAE,uCAAuC,IAAI,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAE5G;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,2BAGvE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,cAAc,GACzB,OAAO,CAAC,aAAa,CAAC,CAExB;AAED,OAAO,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/single_key/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAK3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,eAAO,MAAM,uCAAuC,kBAEnD,CAAC;AAEF;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,4BAA4B;gBAC5D,iBAAiB,EAAE,cAAc;IAIpC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,2BAG3E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,cAAc,GAChC,OAAO,CAAC,aAAa,CAAC,CAExB"}
@@ -3,21 +3,34 @@
3
3
  * It is not recommended to use this account type in production.
4
4
  *
5
5
  * @packageDocumentation
6
- */
7
- import { AccountManager } from '@aztec/aztec.js/account';
6
+ */ import { AccountManager } from '@aztec/aztec.js/account';
8
7
  import { getWallet } from '@aztec/aztec.js/wallet';
9
- import { deriveMasterIncomingViewingSecretKey } from '@aztec/circuits.js';
10
- import { SingleKeyAccountContract } from './account_contract.js';
11
- export { SingleKeyAccountContract };
12
- export { SchnorrSingleKeyAccountContractArtifact as SingleKeyAccountContractArtifact } from './artifact.js';
8
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
9
+ import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
10
+ import SchnorrSingleKeyAccountContractJson from '../../artifacts/SchnorrSingleKeyAccount.json' assert {
11
+ type: 'json'
12
+ };
13
+ import { SingleKeyBaseAccountContract } from './account_contract.js';
14
+ export const SchnorrSingleKeyAccountContractArtifact = loadContractArtifact(SchnorrSingleKeyAccountContractJson);
15
+ /**
16
+ * Account contract that authenticates transactions using Schnorr signatures verified against
17
+ * the note encryption key, relying on a single private key for both encryption and authentication.
18
+ * Eagerly loads the contract artifact
19
+ */ export class SingleKeyAccountContract extends SingleKeyBaseAccountContract {
20
+ constructor(signingPrivateKey){
21
+ super(signingPrivateKey);
22
+ }
23
+ getContractArtifact() {
24
+ return Promise.resolve(SchnorrSingleKeyAccountContractArtifact);
25
+ }
26
+ }
13
27
  /**
14
28
  * Creates an Account that uses the same Grumpkin key for encryption and authentication.
15
29
  * @param pxe - An PXE server instance.
16
30
  * @param secretKey - Secret key used to derive all the keystore keys (in this case also used to get signing key).
17
31
  * @param salt - Deployment salt.
18
32
  * @returns An account manager initialized with the account contract and its deployment params
19
- */
20
- export function getSingleKeyAccount(pxe, secretKey, salt) {
33
+ */ export function getUnsafeSchnorrAccount(pxe, secretKey, salt) {
21
34
  const encryptionPrivateKey = deriveMasterIncomingViewingSecretKey(secretKey);
22
35
  return AccountManager.create(pxe, secretKey, new SingleKeyAccountContract(encryptionPrivateKey), salt);
23
36
  }
@@ -27,9 +40,6 @@ export function getSingleKeyAccount(pxe, secretKey, salt) {
27
40
  * @param address - Address for the account.
28
41
  * @param signingPrivateKey - Grumpkin key used for note encryption and signing transactions.
29
42
  * @returns A wallet for this account that can be used to interact with a contract instance.
30
- */
31
- export function getSingleKeyWallet(pxe, address, signingKey) {
32
- return getWallet(pxe, address, new SingleKeyAccountContract(signingKey));
43
+ */ export function getUnsafeSchnorrWallet(pxe, address, signingPrivateKey) {
44
+ return getWallet(pxe, address, new SingleKeyAccountContract(signingPrivateKey));
33
45
  }
34
- export { getSingleKeyAccount as getUnsafeSchnorrAccount, getSingleK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DLFVBQVUsQ0FBQyxDQUFDLENBQUM7QUFDM0UsQ0FBQztBQUVELE9BQU8sRUFBRSxtQkFBbUIsSUFBSSx1QkFBdUIsRUFBRSxrQkFBa0IsSUFBSSxzQkFBc0IsRUFBRSxDQUFDIn0=
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The `@aztec/accounts/single_key` export provides a testing account contract implementation that uses a single Grumpkin key for both authentication and encryption.
3
+ * It is not recommended to use this account type in production.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ import type { AztecAddress, Fr, GrumpkinScalar } from '@aztec/aztec.js';
8
+ import { AccountManager, type Salt } from '@aztec/aztec.js/account';
9
+ import { type AccountWallet } from '@aztec/aztec.js/wallet';
10
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
11
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
12
+ import { SingleKeyBaseAccountContract } from './account_contract.js';
13
+ /**
14
+ * Lazily loads the contract artifact
15
+ * @returns The contract artifact for the single key account contract
16
+ */
17
+ export declare function getSingleKeyAccountContractArtifact(): Promise<ContractArtifact>;
18
+ /**
19
+ * Account contract that authenticates transactions using Schnorr signatures verified against
20
+ * the note encryption key, relying on a single private key for both encryption and authentication.
21
+ * Lazily loads the contract artifact
22
+ */
23
+ export declare class SingleKeyAccountContract extends SingleKeyBaseAccountContract {
24
+ constructor(signingPrivateKey: GrumpkinScalar);
25
+ getContractArtifact(): Promise<ContractArtifact>;
26
+ }
27
+ /**
28
+ * Creates an Account that uses the same Grumpkin key for encryption and authentication.
29
+ * @param pxe - An PXE server instance.
30
+ * @param secretKey - Secret key used to derive all the keystore keys (in this case also used to get signing key).
31
+ * @param salt - Deployment salt.
32
+ * @returns An account manager initialized with the account contract and its deployment params
33
+ */
34
+ export declare function getUnsafeSchnorrAccount(pxe: PXE, secretKey: Fr, salt?: Salt): Promise<AccountManager>;
35
+ /**
36
+ * Gets a wallet for an already registered account using Schnorr signatures with a single key for encryption and authentication.
37
+ * @param pxe - An PXE server instance.
38
+ * @param address - Address for the account.
39
+ * @param signingPrivateKey - Grumpkin key used for note encryption and signing transactions.
40
+ * @returns A wallet for this account that can be used to interact with a contract instance.
41
+ */
42
+ export declare function getUnsafeSchnorrWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: GrumpkinScalar): Promise<AccountWallet>;
43
+ //# sourceMappingURL=lazy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/single_key/lazy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAG3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE;;;GAGG;AACH,wBAAsB,mCAAmC,8BAQxD;AAED;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,4BAA4B;gBAC5D,iBAAiB,EAAE,cAAc;IAIpC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,2BAG3E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,cAAc,GAChC,OAAO,CAAC,aAAa,CAAC,CAExB"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The `@aztec/accounts/single_key` export provides a testing account contract implementation that uses a single Grumpkin key for both authentication and encryption.
3
+ * It is not recommended to use this account type in production.
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 { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
10
+ import { SingleKeyBaseAccountContract } from './account_contract.js';
11
+ /**
12
+ * Lazily loads the contract artifact
13
+ * @returns The contract artifact for the single key account contract
14
+ */ export async function getSingleKeyAccountContractArtifact() {
15
+ // Cannot assert this import as it's incompatible with browsers
16
+ // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
17
+ // Use the new "with" syntax once supported by firefox
18
+ // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
19
+ // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
20
+ const { default: schnorrAccountContractJson } = await import('../../artifacts/SchnorrAccount.json');
21
+ return loadContractArtifact(schnorrAccountContractJson);
22
+ }
23
+ /**
24
+ * Account contract that authenticates transactions using Schnorr signatures verified against
25
+ * the note encryption key, relying on a single private key for both encryption and authentication.
26
+ * Lazily loads the contract artifact
27
+ */ export class SingleKeyAccountContract extends SingleKeyBaseAccountContract {
28
+ constructor(signingPrivateKey){
29
+ super(signingPrivateKey);
30
+ }
31
+ getContractArtifact() {
32
+ return getSingleKeyAccountContractArtifact();
33
+ }
34
+ }
35
+ /**
36
+ * Creates an Account that uses the same Grumpkin key for encryption and authentication.
37
+ * @param pxe - An PXE server instance.
38
+ * @param secretKey - Secret key used to derive all the keystore keys (in this case also used to get signing key).
39
+ * @param salt - Deployment salt.
40
+ * @returns An account manager initialized with the account contract and its deployment params
41
+ */ export function getUnsafeSchnorrAccount(pxe, secretKey, salt) {
42
+ const encryptionPrivateKey = deriveMasterIncomingViewingSecretKey(secretKey);
43
+ return AccountManager.create(pxe, secretKey, new SingleKeyAccountContract(encryptionPrivateKey), salt);
44
+ }
45
+ /**
46
+ * Gets a wallet for an already registered account using Schnorr signatures with a single key for encryption and authentication.
47
+ * @param pxe - An PXE server instance.
48
+ * @param address - Address for the account.
49
+ * @param signingPrivateKey - Grumpkin key used for note encryption and signing transactions.
50
+ * @returns A wallet for this account that can be used to interact with a contract instance.
51
+ */ export function getUnsafeSchnorrWallet(pxe, address, signingPrivateKey) {
52
+ return getWallet(pxe, address, new SingleKeyAccountContract(signingPrivateKey));
53
+ }
@@ -1,29 +1,28 @@
1
- import { type AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
2
- import { type PXE } from '@aztec/circuit-types';
3
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
3
  export declare const INITIAL_TEST_SECRET_KEYS: Fr[];
5
- export declare const INITIAL_TEST_ENCRYPTION_KEYS: import("@aztec/aztec.js").Fq[];
6
- export declare const INITIAL_TEST_SIGNING_KEYS: import("@aztec/aztec.js").Fq[];
4
+ export declare const INITIAL_TEST_ENCRYPTION_KEYS: import("@aztec/foundation/fields").Fq[];
5
+ export declare const INITIAL_TEST_SIGNING_KEYS: import("@aztec/foundation/fields").Fq[];
7
6
  export declare const INITIAL_TEST_ACCOUNT_SALTS: Fr[];
8
7
  /**
9
- * Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
10
- * @param pxe - PXE instance.
11
- * @returns A set of AccountWallet implementations for each of the initial accounts.
8
+ * Data for generating an initial account.
12
9
  */
13
- export declare function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]>;
14
- /**
15
- * Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
16
- * @param pxe - PXE instance.
17
- * @returns A set of AccountWallet implementations for each of the initial accounts.
18
- */
19
- export declare function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]>;
20
- /**
21
- * Deploys the initial set of schnorr signature accounts to the test environment
22
- * @param pxe - PXE instance.
23
- * @returns The set of deployed Account objects and associated private encryption keys
24
- */
25
- export declare function deployInitialTestAccounts(pxe: PXE): Promise<{
26
- account: import("@aztec/aztec.js").AccountManager;
27
- secretKey: Fr;
28
- }[]>;
10
+ export interface InitialAccountData {
11
+ /**
12
+ * Secret to derive the keys for the account.
13
+ */
14
+ secret: Fr;
15
+ /**
16
+ * Signing key od the account.
17
+ */
18
+ signingKey: GrumpkinScalar;
19
+ /**
20
+ * Contract address salt.
21
+ */
22
+ salt: Fr;
23
+ /**
24
+ * Address of the schnorr account contract.
25
+ */
26
+ address: AztecAddress;
27
+ }
29
28
  //# sourceMappingURL=configuration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/testing/configuration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,0BAA0B,EAAoB,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,eAAO,MAAM,wBAAwB,MAIpC,CAAC;AAEF,eAAO,MAAM,4BAA4B,gCAExC,CAAC;AAEF,eAAO,MAAM,yBAAyB,gCAA+B,CAAC;AAEtE,eAAO,MAAM,0BAA0B,MAA8B,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAY7F;AAED;;;;GAIG;AACH,wBAAsB,8BAA8B,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAyBpG;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,GAAG,EAAE,GAAG;;;KAwCvD"}
1
+ {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/testing/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,eAAO,MAAM,wBAAwB,MAIpC,CAAC;AAEF,eAAO,MAAM,4BAA4B,yCAExC,CAAC;AAEF,eAAO,MAAM,yBAAyB,yCAA+B,CAAC;AAEtE,eAAO,MAAM,0BAA0B,MAA8B,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,MAAM,EAAE,EAAE,CAAC;IACX;;OAEG;IACH,UAAU,EAAE,cAAc,CAAC;IAC3B;;OAEG;IACH,IAAI,EAAE,EAAE,CAAC;IACT;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;CACvB"}
@@ -1,86 +1,15 @@
1
- import { generatePublicKey } from '@aztec/aztec.js';
2
- import { registerContractClass } from '@aztec/aztec.js/deployment';
3
- import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
4
- import { SignerlessWallet } from '@aztec/aztec.js/wallet';
5
- import { deriveMasterIncomingViewingSecretKey, deriveSigningKey } from '@aztec/circuits.js/keys';
6
1
  import { Fr } from '@aztec/foundation/fields';
7
- import { SchnorrAccountContractArtifact, getSchnorrAccount } from '../schnorr/index.js';
2
+ import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
8
3
  export const INITIAL_TEST_SECRET_KEYS = [
9
4
  Fr.fromHexString('2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281'),
10
5
  Fr.fromHexString('aebd1b4be76efa44f5ee655c20bf9ea60f7ae44b9a7fd1fd9f189c7a0b0cdae'),
11
- Fr.fromHexString('0f6addf0da06c33293df974a565b03d1ab096090d907d98055a8b7f4954e120c'),
6
+ Fr.fromHexString('0f6addf0da06c33293df974a565b03d1ab096090d907d98055a8b7f4954e120c')
12
7
  ];
13
- export const INITIAL_TEST_ENCRYPTION_KEYS = INITIAL_TEST_SECRET_KEYS.map(secretKey => deriveMasterIncomingViewingSecretKey(secretKey));
8
+ export const INITIAL_TEST_ENCRYPTION_KEYS = INITIAL_TEST_SECRET_KEYS.map((secretKey)=>deriveMasterIncomingViewingSecretKey(secretKey));
14
9
  // TODO(#5837): come up with a standard signing key derivation scheme instead of using ivsk_m as signing keys here
15
10
  export const INITIAL_TEST_SIGNING_KEYS = INITIAL_TEST_ENCRYPTION_KEYS;
16
- export const INITIAL_TEST_ACCOUNT_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];
17
- /**
18
- * Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
19
- * @param pxe - PXE instance.
20
- * @returns A set of AccountWallet implementations for each of the initial accounts.
21
- */
22
- export function getInitialTestAccountsWallets(pxe) {
23
- return Promise.all(INITIAL_TEST_SECRET_KEYS.map(async (encryptionKey, i) => {
24
- const account = await getSchnorrAccount(pxe, encryptionKey, INITIAL_TEST_SIGNING_KEYS[i], INITIAL_TEST_ACCOUNT_SALTS[i]);
25
- return account.getWallet();
26
- }));
27
- }
28
- /**
29
- * Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
30
- * @param pxe - PXE instance.
31
- * @returns A set of AccountWallet implementations for each of the initial accounts.
32
- */
33
- export async function getDeployedTestAccountsWallets(pxe) {
34
- const registeredAccounts = await pxe.getRegisteredAccounts();
35
- const publicKeys = await Promise.all(INITIAL_TEST_SECRET_KEYS.map(async (initialSecretKey) => {
36
- const initialEncryptionKey = deriveMasterIncomingViewingSecretKey(initialSecretKey);
37
- const publicKey = await generatePublicKey(initialEncryptionKey);
38
- return { sk: initialSecretKey, pk: publicKey };
39
- }));
40
- return Promise.all(publicKeys
41
- .filter(keyPairs => {
42
- return (registeredAccounts.find(registered => registered.publicKeys.masterIncomingViewingPublicKey.equals(keyPairs.pk)) != undefined);
43
- })
44
- .map(async (keyPairs) => {
45
- const signingKey = deriveSigningKey(keyPairs.sk);
46
- // TODO(#5726): use actual salt here instead of hardcoding Fr.ZERO
47
- const account = await getSchnorrAccount(pxe, keyPairs.sk, signingKey, Fr.ZERO);
48
- return account.getWallet();
49
- }));
50
- }
51
- /**
52
- * Deploys the initial set of schnorr signature accounts to the test environment
53
- * @param pxe - PXE instance.
54
- * @returns The set of deployed Account objects and associated private encryption keys
55
- */
56
- export async function deployInitialTestAccounts(pxe) {
57
- const accounts = await Promise.all(INITIAL_TEST_SECRET_KEYS.map(async (secretKey, i) => {
58
- const account = await getSchnorrAccount(pxe, secretKey, INITIAL_TEST_SIGNING_KEYS[i], INITIAL_TEST_ACCOUNT_SALTS[i]);
59
- return {
60
- account,
61
- secretKey,
62
- };
63
- }));
64
- // Register contract class to avoid duplicate nullifier errors
65
- const { l1ChainId: chainId, protocolVersion } = await pxe.getNodeInfo();
66
- const deployWallet = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(chainId, protocolVersion));
67
- await (await registerContractClass(deployWallet, SchnorrAccountContractArtifact)).send().wait();
68
- // Attempt to get as much parallelism as possible
69
- const deployTxs = await Promise.all(accounts.map(async (x) => {
70
- const deployMethod = await x.account.getDeployMethod();
71
- const tx = await deployMethod.prove({
72
- contractAddressSalt: new Fr(x.account.salt),
73
- universalDeploy: true,
74
- });
75
- return tx;
76
- }));
77
- // Send tx together to try and get them in the same rollup
78
- const sentTxs = deployTxs.map(tx => {
79
- return tx.send();
80
- });
81
- await Promise.all(sentTxs.map(tx => {
82
- return tx.wait();
83
- }));
84
- return accounts;
85
- }
86
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlndXJhdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0aW5nL2NvbmZpZ3VyYXRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDcEQsT0FBTyxFQUFFLHFCQUFxQixFQUF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BQUU7UUFDZixPQUFPLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUNuQixDQUFDLENBQUMsQ0FDSCxDQUFDO0lBQ0YsT0FBTyxRQUFRLENBQUM7QUFDbEIsQ0FBQyJ9
11
+ export const INITIAL_TEST_ACCOUNT_SALTS = [
12
+ Fr.ZERO,
13
+ Fr.ZERO,
14
+ Fr.ZERO
15
+ ];
@@ -1,20 +1,43 @@
1
- import { type WaitOpts } from '@aztec/aztec.js';
2
- import { type AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
3
- import { type PXE } from '@aztec/circuit-types';
4
- import { Fr } from '@aztec/circuits.js';
1
+ import { type AccountManager, type PXE, type WaitOpts } from '@aztec/aztec.js';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ import type { InitialAccountData } from './configuration.js';
5
4
  /**
6
- * Deploys and registers a new account using random private keys and returns the associated Schnorr account wallet. Useful for testing.
7
- * @param pxe - PXE.
8
- * @returns - A wallet for a fresh account.
5
+ * Generate a fixed amount of random schnorr account contract instance.
9
6
  */
10
- export declare function createAccount(pxe: PXE): Promise<AccountWalletWithSecretKey>;
7
+ export declare function generateSchnorrAccounts(numberOfAccounts: number): Promise<{
8
+ secret: Fr;
9
+ signingKey: import("@aztec/aztec.js").Fq;
10
+ salt: Fr;
11
+ address: import("@aztec/aztec.js").AztecAddress;
12
+ }[]>;
11
13
  /**
12
- * Creates a given number of random accounts using the Schnorr account wallet.
13
- * @param pxe - PXE.
14
- * @param numberOfAccounts - How many accounts to create.
15
- * @param secrets - Optional array of secrets to use for the accounts. If empty, random secrets will be generated.
16
- * @throws If the secrets array is not empty and does not have the same length as the number of accounts.
17
- * @returns The created account wallets.
14
+ * Data for deploying funded account.
18
15
  */
19
- export declare function createAccounts(pxe: PXE, numberOfAccounts?: number, secrets?: Fr[], waitOpts?: WaitOpts): Promise<AccountWalletWithSecretKey[]>;
16
+ type DeployAccountData = Pick<InitialAccountData, 'secret' | 'salt'> & {
17
+ /**
18
+ * An optional signingKey if it's not derived from the secret.
19
+ */
20
+ signingKey?: InitialAccountData['signingKey'];
21
+ };
22
+ /**
23
+ * Deploy schnorr account contract.
24
+ * It will pay for the fee for the deployment itself. So it must be funded with the prefilled public data.
25
+ */
26
+ export declare function deployFundedSchnorrAccount(pxe: PXE, account: DeployAccountData, opts?: WaitOpts & {
27
+ /**
28
+ * Whether or not to skip registering contract class.
29
+ */
30
+ skipClassRegistration?: boolean;
31
+ }): Promise<AccountManager>;
32
+ /**
33
+ * Deploy schnorr account contracts.
34
+ * They will pay for the fees for the deployment themselves. So they must be funded with the prefilled public data.
35
+ */
36
+ export declare function deployFundedSchnorrAccounts(pxe: PXE, accounts: DeployAccountData[], opts?: WaitOpts & {
37
+ /**
38
+ * Whether or not to skip registering contract class.
39
+ */
40
+ skipClassRegistration?: boolean;
41
+ }): Promise<AccountManager[]>;
42
+ export {};
20
43
  //# sourceMappingURL=create_account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/testing/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,EAAE,EAAoB,MAAM,oBAAoB,CAAC;AAI1D;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAKjF;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,GAAG,EACR,gBAAgB,SAAI,EACpB,OAAO,GAAE,EAAE,EAAO,EAClB,QAAQ,GAAE,QAA4B,GACrC,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAsCvC"}
1
+ {"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/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