@aztec/accounts 0.0.0-test.0

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 (110) hide show
  1. package/README.md +41 -0
  2. package/artifacts/EcdsaKAccount.d.json.ts +3 -0
  3. package/artifacts/EcdsaKAccount.json +6257 -0
  4. package/artifacts/EcdsaRAccount.d.json.ts +3 -0
  5. package/artifacts/EcdsaRAccount.json +6257 -0
  6. package/artifacts/SchnorrAccount.d.json.ts +3 -0
  7. package/artifacts/SchnorrAccount.json +6354 -0
  8. package/artifacts/SchnorrSingleKeyAccount.d.json.ts +3 -0
  9. package/artifacts/SchnorrSingleKeyAccount.json +3937 -0
  10. package/dest/dapp/dapp_interface.d.ts +10 -0
  11. package/dest/dapp/dapp_interface.d.ts.map +1 -0
  12. package/dest/dapp/dapp_interface.js +16 -0
  13. package/dest/dapp/index.d.ts +2 -0
  14. package/dest/dapp/index.d.ts.map +1 -0
  15. package/dest/dapp/index.js +1 -0
  16. package/dest/defaults/account_contract.d.ts +15 -0
  17. package/dest/defaults/account_contract.d.ts.map +1 -0
  18. package/dest/defaults/account_contract.js +10 -0
  19. package/dest/defaults/account_interface.d.ts +27 -0
  20. package/dest/defaults/account_interface.d.ts.map +1 -0
  21. package/dest/defaults/account_interface.js +37 -0
  22. package/dest/defaults/index.d.ts +10 -0
  23. package/dest/defaults/index.d.ts.map +1 -0
  24. package/dest/defaults/index.js +8 -0
  25. package/dest/ecdsa/ecdsa_k/account_contract.d.ts +18 -0
  26. package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -0
  27. package/dest/ecdsa/ecdsa_k/account_contract.js +38 -0
  28. package/dest/ecdsa/ecdsa_k/index.d.ts +43 -0
  29. package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -0
  30. package/dest/ecdsa/ecdsa_k/index.js +44 -0
  31. package/dest/ecdsa/ecdsa_k/lazy.d.ts +47 -0
  32. package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -0
  33. package/dest/ecdsa/ecdsa_k/lazy.js +52 -0
  34. package/dest/ecdsa/index.d.ts +3 -0
  35. package/dest/ecdsa/index.d.ts.map +1 -0
  36. package/dest/ecdsa/index.js +2 -0
  37. package/dest/ecdsa/lazy.d.ts +3 -0
  38. package/dest/ecdsa/lazy.d.ts.map +1 -0
  39. package/dest/ecdsa/lazy.js +2 -0
  40. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +21 -0
  41. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -0
  42. package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +80 -0
  43. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +46 -0
  44. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -0
  45. package/dest/ecdsa/ssh_ecdsa_r/index.js +47 -0
  46. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +49 -0
  47. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -0
  48. package/dest/ecdsa/ssh_ecdsa_r/lazy.js +57 -0
  49. package/dest/schnorr/account_contract.d.ts +24 -0
  50. package/dest/schnorr/account_contract.d.ts.map +1 -0
  51. package/dest/schnorr/account_contract.js +37 -0
  52. package/dest/schnorr/index.d.ts +57 -0
  53. package/dest/schnorr/index.d.ts.map +1 -0
  54. package/dest/schnorr/index.js +66 -0
  55. package/dest/schnorr/lazy.d.ts +61 -0
  56. package/dest/schnorr/lazy.d.ts.map +1 -0
  57. package/dest/schnorr/lazy.js +74 -0
  58. package/dest/single_key/account_contract.d.ts +17 -0
  59. package/dest/single_key/account_contract.d.ts.map +1 -0
  60. package/dest/single_key/account_contract.js +42 -0
  61. package/dest/single_key/index.d.ts +39 -0
  62. package/dest/single_key/index.d.ts.map +1 -0
  63. package/dest/single_key/index.js +45 -0
  64. package/dest/single_key/lazy.d.ts +43 -0
  65. package/dest/single_key/lazy.d.ts.map +1 -0
  66. package/dest/single_key/lazy.js +53 -0
  67. package/dest/testing/configuration.d.ts +28 -0
  68. package/dest/testing/configuration.d.ts.map +1 -0
  69. package/dest/testing/configuration.js +15 -0
  70. package/dest/testing/create_account.d.ts +43 -0
  71. package/dest/testing/create_account.d.ts.map +1 -0
  72. package/dest/testing/create_account.js +58 -0
  73. package/dest/testing/index.d.ts +35 -0
  74. package/dest/testing/index.d.ts.map +1 -0
  75. package/dest/testing/index.js +47 -0
  76. package/dest/testing/lazy.d.ts +34 -0
  77. package/dest/testing/lazy.d.ts.map +1 -0
  78. package/dest/testing/lazy.js +46 -0
  79. package/dest/utils/index.d.ts +2 -0
  80. package/dest/utils/index.d.ts.map +1 -0
  81. package/dest/utils/index.js +1 -0
  82. package/dest/utils/ssh_agent.d.ts +36 -0
  83. package/dest/utils/ssh_agent.d.ts.map +1 -0
  84. package/dest/utils/ssh_agent.js +153 -0
  85. package/package.json +106 -0
  86. package/src/dapp/dapp_interface.ts +38 -0
  87. package/src/dapp/index.ts +1 -0
  88. package/src/defaults/account_contract.ts +21 -0
  89. package/src/defaults/account_interface.ts +59 -0
  90. package/src/defaults/index.ts +10 -0
  91. package/src/ecdsa/ecdsa_k/account_contract.ts +39 -0
  92. package/src/ecdsa/ecdsa_k/index.ts +63 -0
  93. package/src/ecdsa/ecdsa_k/lazy.ts +71 -0
  94. package/src/ecdsa/index.ts +2 -0
  95. package/src/ecdsa/lazy.ts +2 -0
  96. package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +89 -0
  97. package/src/ecdsa/ssh_ecdsa_r/index.ts +67 -0
  98. package/src/ecdsa/ssh_ecdsa_r/lazy.ts +78 -0
  99. package/src/schnorr/account_contract.ts +39 -0
  100. package/src/schnorr/index.ts +97 -0
  101. package/src/schnorr/lazy.ts +107 -0
  102. package/src/single_key/account_contract.ts +43 -0
  103. package/src/single_key/index.ts +63 -0
  104. package/src/single_key/lazy.ts +71 -0
  105. package/src/testing/configuration.ts +39 -0
  106. package/src/testing/create_account.ts +93 -0
  107. package/src/testing/index.ts +92 -0
  108. package/src/testing/lazy.ts +86 -0
  109. package/src/utils/index.ts +1 -0
  110. package/src/utils/ssh_agent.ts +136 -0
@@ -0,0 +1,45 @@
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 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
+ }
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
+ */ export function getUnsafeSchnorrAccount(pxe, secretKey, salt) {
34
+ const encryptionPrivateKey = deriveMasterIncomingViewingSecretKey(secretKey);
35
+ return AccountManager.create(pxe, secretKey, new SingleKeyAccountContract(encryptionPrivateKey), salt);
36
+ }
37
+ /**
38
+ * Gets a wallet for an already registered account using Schnorr signatures with a single key for encryption and authentication.
39
+ * @param pxe - An PXE server instance.
40
+ * @param address - Address for the account.
41
+ * @param signingPrivateKey - Grumpkin key used for note encryption and signing transactions.
42
+ * @returns A wallet for this account that can be used to interact with a contract instance.
43
+ */ export function getUnsafeSchnorrWallet(pxe, address, signingPrivateKey) {
44
+ return getWallet(pxe, address, new SingleKeyAccountContract(signingPrivateKey));
45
+ }
@@ -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
+ }
@@ -0,0 +1,28 @@
1
+ import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ export declare const INITIAL_TEST_SECRET_KEYS: Fr[];
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[];
6
+ export declare const INITIAL_TEST_ACCOUNT_SALTS: Fr[];
7
+ /**
8
+ * Data for generating an initial account.
9
+ */
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
+ }
28
+ //# sourceMappingURL=configuration.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,15 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
3
+ export const INITIAL_TEST_SECRET_KEYS = [
4
+ Fr.fromHexString('2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281'),
5
+ Fr.fromHexString('aebd1b4be76efa44f5ee655c20bf9ea60f7ae44b9a7fd1fd9f189c7a0b0cdae'),
6
+ Fr.fromHexString('0f6addf0da06c33293df974a565b03d1ab096090d907d98055a8b7f4954e120c')
7
+ ];
8
+ export const INITIAL_TEST_ENCRYPTION_KEYS = INITIAL_TEST_SECRET_KEYS.map((secretKey)=>deriveMasterIncomingViewingSecretKey(secretKey));
9
+ // TODO(#5837): come up with a standard signing key derivation scheme instead of using ivsk_m as signing keys here
10
+ export const INITIAL_TEST_SIGNING_KEYS = INITIAL_TEST_ENCRYPTION_KEYS;
11
+ export const INITIAL_TEST_ACCOUNT_SALTS = [
12
+ Fr.ZERO,
13
+ Fr.ZERO,
14
+ Fr.ZERO
15
+ ];
@@ -0,0 +1,43 @@
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';
4
+ /**
5
+ * Generate a fixed amount of random schnorr account contract instance.
6
+ */
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
+ }[]>;
13
+ /**
14
+ * Data for deploying funded account.
15
+ */
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 {};
43
+ //# sourceMappingURL=create_account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/testing/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAyB,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACtG,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,gBAAgB,EAAE,MAAM;;;;;KAarE;AAED;;GAEG;AACH,KAAK,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,MAAM,CAAC,GAAG;IACrE;;OAEG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,iBAAiB,EAC1B,IAAI,GAAE,QAAQ,GAAG;IACf;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACiB,GAClD,OAAO,CAAC,cAAc,CAAC,CAiBzB;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,IAAI,GAAE,QAAQ,GAAG;IACf;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACiB,GAClD,OAAO,CAAC,cAAc,EAAE,CAAC,CAY3B"}
@@ -0,0 +1,58 @@
1
+ import { FeeJuicePaymentMethod } from '@aztec/aztec.js';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ import { deriveSigningKey } from '@aztec/stdlib/keys';
4
+ import { getSchnorrAccount, getSchnorrAccountContractAddress } from '../schnorr/index.js';
5
+ /**
6
+ * Generate a fixed amount of random schnorr account contract instance.
7
+ */ export async function generateSchnorrAccounts(numberOfAccounts) {
8
+ const secrets = Array.from({
9
+ length: numberOfAccounts
10
+ }, ()=>Fr.random());
11
+ return await Promise.all(secrets.map(async (secret)=>{
12
+ const salt = Fr.random();
13
+ return {
14
+ secret,
15
+ signingKey: deriveSigningKey(secret),
16
+ salt,
17
+ address: await getSchnorrAccountContractAddress(secret, salt)
18
+ };
19
+ }));
20
+ }
21
+ /**
22
+ * Deploy schnorr account contract.
23
+ * It will pay for the fee for the deployment itself. So it must be funded with the prefilled public data.
24
+ */ export async function deployFundedSchnorrAccount(pxe, account, opts = {
25
+ interval: 0.1,
26
+ skipClassRegistration: false
27
+ }) {
28
+ const signingKey = account.signingKey ?? deriveSigningKey(account.secret);
29
+ const accountManager = await getSchnorrAccount(pxe, account.secret, signingKey, account.salt);
30
+ // Pay the fee by the account itself.
31
+ // This only works when the world state is prefilled with the balance for the account in test environment.
32
+ const paymentMethod = new FeeJuicePaymentMethod(accountManager.getAddress());
33
+ await accountManager.deploy({
34
+ skipClassRegistration: opts.skipClassRegistration,
35
+ skipPublicDeployment: true,
36
+ fee: {
37
+ paymentMethod
38
+ }
39
+ }).wait(opts);
40
+ return accountManager;
41
+ }
42
+ /**
43
+ * Deploy schnorr account contracts.
44
+ * They will pay for the fees for the deployment themselves. So they must be funded with the prefilled public data.
45
+ */ export async function deployFundedSchnorrAccounts(pxe, accounts, opts = {
46
+ interval: 0.1,
47
+ skipClassRegistration: false
48
+ }) {
49
+ const accountManagers = [];
50
+ // Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
51
+ for(let i = 0; i < accounts.length; i++){
52
+ accountManagers.push(await deployFundedSchnorrAccount(pxe, accounts[i], {
53
+ ...opts,
54
+ skipClassRegistration: i !== 0 || opts.skipClassRegistration
55
+ }));
56
+ }
57
+ return accountManagers;
58
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The `@aztec/accounts/testing` 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.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import type { PXE } from '@aztec/aztec.js';
9
+ import type { AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
10
+ import type { InitialAccountData } from './configuration.js';
11
+ export { type InitialAccountData, INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS, } from './configuration.js';
12
+ /**
13
+ * Gets the basic information for initial test accounts.
14
+ */
15
+ export declare function getInitialTestAccounts(): Promise<InitialAccountData[]>;
16
+ /**
17
+ * Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
18
+ * @param pxe - PXE instance.
19
+ * @returns A set of AccountWallet implementations for each of the initial accounts.
20
+ */
21
+ export declare function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]>;
22
+ /**
23
+ * Queries a PXE for it's registered accounts.
24
+ * @param pxe - PXE instance.
25
+ * @returns A set of key data for each of the initial accounts.
26
+ */
27
+ export declare function getDeployedTestAccounts(pxe: PXE): Promise<InitialAccountData[]>;
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 declare function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]>;
34
+ export { deployFundedSchnorrAccount, deployFundedSchnorrAccounts, generateSchnorrAccounts } from './create_account.js';
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The `@aztec/accounts/testing` 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.
5
+ *
6
+ * @packageDocumentation
7
+ */ import { getSchnorrAccount, getSchnorrAccountContractAddress, getSchnorrWalletWithSecretKey } from '../schnorr/index.js';
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';
10
+ /**
11
+ * Gets the basic information for initial test accounts.
12
+ */ export function getInitialTestAccounts() {
13
+ return Promise.all(INITIAL_TEST_SECRET_KEYS.map(async (secret, i)=>({
14
+ secret,
15
+ signingKey: INITIAL_TEST_ENCRYPTION_KEYS[i],
16
+ salt: INITIAL_TEST_ACCOUNT_SALTS[i],
17
+ address: await getSchnorrAccountContractAddress(secret, INITIAL_TEST_ACCOUNT_SALTS[i], INITIAL_TEST_SIGNING_KEYS[i])
18
+ })));
19
+ }
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();
28
+ }));
29
+ }
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
+ }
47
+ export { deployFundedSchnorrAccount, deployFundedSchnorrAccounts, generateSchnorrAccounts } from './create_account.js';
@@ -0,0 +1,34 @@
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.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import type { PXE } from '@aztec/aztec.js';
9
+ import type { AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
10
+ import { type InitialAccountData } from './configuration.js';
11
+ export { type InitialAccountData, INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_ENCRYPTION_KEYS, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS, } from './configuration.js';
12
+ /**
13
+ * Gets the basic information for initial test accounts.
14
+ */
15
+ export declare function getInitialTestAccounts(): Promise<InitialAccountData[]>;
16
+ /**
17
+ * Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
18
+ * @param pxe - PXE instance.
19
+ * @returns A set of AccountWallet implementations for each of the initial accounts.
20
+ */
21
+ export declare function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]>;
22
+ /**
23
+ * Queries a PXE for it's registered accounts.
24
+ * @param pxe - PXE instance.
25
+ * @returns A set of key data for each of the initial accounts.
26
+ */
27
+ export declare function getDeployedTestAccounts(pxe: PXE): Promise<InitialAccountData[]>;
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 declare function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]>;
34
+ //# sourceMappingURL=lazy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/testing/lazy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAE5B,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"}
@@ -0,0 +1,46 @@
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.
5
+ *
6
+ * @packageDocumentation
7
+ */ import { getSchnorrAccount, getSchnorrAccountContractAddress, getSchnorrWalletWithSecretKey } from '../schnorr/lazy.js';
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';
10
+ /**
11
+ * Gets the basic information for initial test accounts.
12
+ */ export function getInitialTestAccounts() {
13
+ return Promise.all(INITIAL_TEST_SECRET_KEYS.map(async (secret, i)=>({
14
+ secret,
15
+ signingKey: INITIAL_TEST_ENCRYPTION_KEYS[i],
16
+ salt: INITIAL_TEST_ACCOUNT_SALTS[i],
17
+ address: await getSchnorrAccountContractAddress(secret, INITIAL_TEST_ACCOUNT_SALTS[i], INITIAL_TEST_SIGNING_KEYS[i])
18
+ })));
19
+ }
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();
28
+ }));
29
+ }
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
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ssh_agent.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './ssh_agent.js';
@@ -0,0 +1,36 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ /// <reference types="node" resolution-mode="require"/>
4
+ import { Buffer } from 'buffer';
5
+ import net from 'net';
6
+ /**
7
+ * Connect to the SSH agent via a TCP socket using the standard env variable
8
+ */
9
+ export declare function connectToAgent(): net.Socket;
10
+ /**
11
+ * Type representing a stored key in the SSH agent.
12
+ */
13
+ type StoredKey = {
14
+ /**
15
+ * Type of the key.
16
+ */
17
+ type: string;
18
+ /**
19
+ * Public key in base64 encoding.
20
+ */
21
+ publicKey: string;
22
+ /**
23
+ * Comment associated with the key.
24
+ */
25
+ comment: string;
26
+ };
27
+ /**
28
+ * Retrieve the identities stored in the SSH agent.
29
+ */
30
+ export declare function getIdentities(): Promise<StoredKey[]>;
31
+ /**
32
+ * Sign data using a key stored in the SSH agent. The private signing key is identified by its corresponding public key.
33
+ */
34
+ export declare function signWithAgent(keyType: Buffer, curveName: Buffer, publicKey: Buffer, data: Buffer): Promise<Buffer>;
35
+ export {};
36
+ //# sourceMappingURL=ssh_agent.d.ts.map
@@ -0,0 +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"}