@aztec/accounts 0.0.0-test.1 → 0.0.1-commit.001888fc

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 (127) hide show
  1. package/README.md +1 -2
  2. package/artifacts/EcdsaKAccount.json +4753 -3882
  3. package/artifacts/EcdsaRAccount.json +5162 -4291
  4. package/artifacts/SchnorrAccount.json +5021 -4164
  5. package/artifacts/SimulatedAccount.json +4745 -0
  6. package/dest/defaults/account_contract.d.ts +10 -5
  7. package/dest/defaults/account_contract.d.ts.map +1 -1
  8. package/dest/defaults/account_contract.js +5 -3
  9. package/dest/defaults/index.d.ts +2 -3
  10. package/dest/defaults/index.d.ts.map +1 -1
  11. package/dest/defaults/index.js +2 -3
  12. package/dest/ecdsa/ecdsa_k/account_contract.d.ts +5 -4
  13. package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
  14. package/dest/ecdsa/ecdsa_k/account_contract.js +9 -6
  15. package/dest/ecdsa/ecdsa_k/index.d.ts +1 -25
  16. package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
  17. package/dest/ecdsa/ecdsa_k/index.js +2 -23
  18. package/dest/ecdsa/ecdsa_k/lazy.d.ts +1 -25
  19. package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -1
  20. package/dest/ecdsa/ecdsa_k/lazy.js +5 -26
  21. package/dest/ecdsa/ecdsa_r/account_contract.d.ts +19 -0
  22. package/dest/ecdsa/ecdsa_r/account_contract.d.ts.map +1 -0
  23. package/dest/ecdsa/ecdsa_r/account_contract.js +41 -0
  24. package/dest/ecdsa/ecdsa_r/index.d.ts +19 -0
  25. package/dest/ecdsa/ecdsa_r/index.d.ts.map +1 -0
  26. package/dest/ecdsa/ecdsa_r/index.js +23 -0
  27. package/dest/ecdsa/ecdsa_r/lazy.d.ts +23 -0
  28. package/dest/ecdsa/ecdsa_r/lazy.d.ts.map +1 -0
  29. package/dest/ecdsa/ecdsa_r/lazy.js +31 -0
  30. package/dest/ecdsa/index.d.ts +2 -1
  31. package/dest/ecdsa/index.d.ts.map +1 -1
  32. package/dest/ecdsa/index.js +1 -0
  33. package/dest/ecdsa/lazy.d.ts +2 -1
  34. package/dest/ecdsa/lazy.d.ts.map +1 -1
  35. package/dest/ecdsa/lazy.js +1 -0
  36. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +5 -4
  37. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
  38. package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +9 -6
  39. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +2 -27
  40. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
  41. package/dest/ecdsa/ssh_ecdsa_r/index.js +3 -28
  42. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +2 -30
  43. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -1
  44. package/dest/ecdsa/ssh_ecdsa_r/lazy.js +3 -38
  45. package/dest/schnorr/account_contract.d.ts +7 -3
  46. package/dest/schnorr/account_contract.d.ts.map +1 -1
  47. package/dest/schnorr/account_contract.js +9 -6
  48. package/dest/schnorr/index.d.ts +4 -38
  49. package/dest/schnorr/index.d.ts.map +1 -1
  50. package/dest/schnorr/index.js +2 -33
  51. package/dest/schnorr/lazy.d.ts +4 -38
  52. package/dest/schnorr/lazy.d.ts.map +1 -1
  53. package/dest/schnorr/lazy.js +5 -36
  54. package/dest/stub/account_contract.d.ts +29 -0
  55. package/dest/stub/account_contract.d.ts.map +1 -0
  56. package/dest/stub/account_contract.js +30 -0
  57. package/dest/stub/index.d.ts +20 -0
  58. package/dest/stub/index.d.ts.map +1 -0
  59. package/dest/stub/index.js +28 -0
  60. package/dest/stub/lazy.d.ts +25 -0
  61. package/dest/stub/lazy.d.ts.map +1 -0
  62. package/dest/stub/lazy.js +37 -0
  63. package/dest/testing/configuration.d.ts +5 -4
  64. package/dest/testing/configuration.d.ts.map +1 -1
  65. package/dest/testing/configuration.js +1 -1
  66. package/dest/testing/index.d.ts +6 -30
  67. package/dest/testing/index.d.ts.map +1 -1
  68. package/dest/testing/index.js +18 -30
  69. package/dest/testing/lazy.d.ts +5 -28
  70. package/dest/testing/lazy.d.ts.map +1 -1
  71. package/dest/testing/lazy.js +19 -30
  72. package/dest/utils/index.d.ts +1 -1
  73. package/dest/utils/ssh_agent.d.ts +2 -5
  74. package/dest/utils/ssh_agent.d.ts.map +1 -1
  75. package/package.json +26 -23
  76. package/src/defaults/account_contract.ts +19 -7
  77. package/src/defaults/index.ts +1 -2
  78. package/src/ecdsa/ecdsa_k/account_contract.ts +7 -4
  79. package/src/ecdsa/ecdsa_k/index.ts +1 -33
  80. package/src/ecdsa/ecdsa_k/lazy.ts +4 -36
  81. package/src/ecdsa/ecdsa_r/account_contract.ts +42 -0
  82. package/src/ecdsa/ecdsa_r/index.ts +31 -0
  83. package/src/ecdsa/ecdsa_r/lazy.ts +39 -0
  84. package/src/ecdsa/index.ts +1 -0
  85. package/src/ecdsa/lazy.ts +1 -0
  86. package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +7 -4
  87. package/src/ecdsa/ssh_ecdsa_r/index.ts +3 -42
  88. package/src/ecdsa/ssh_ecdsa_r/lazy.ts +3 -53
  89. package/src/schnorr/account_contract.ts +5 -4
  90. package/src/schnorr/index.ts +10 -57
  91. package/src/schnorr/lazy.ts +13 -60
  92. package/src/stub/account_contract.ts +39 -0
  93. package/src/stub/index.ts +40 -0
  94. package/src/stub/lazy.ts +51 -0
  95. package/src/testing/configuration.ts +2 -1
  96. package/src/testing/index.ts +19 -51
  97. package/src/testing/lazy.ts +18 -50
  98. package/artifacts/SchnorrSingleKeyAccount.json +0 -3937
  99. package/dest/dapp/dapp_interface.d.ts +0 -10
  100. package/dest/dapp/dapp_interface.d.ts.map +0 -1
  101. package/dest/dapp/dapp_interface.js +0 -16
  102. package/dest/dapp/index.d.ts +0 -2
  103. package/dest/dapp/index.d.ts.map +0 -1
  104. package/dest/dapp/index.js +0 -1
  105. package/dest/defaults/account_interface.d.ts +0 -27
  106. package/dest/defaults/account_interface.d.ts.map +0 -1
  107. package/dest/defaults/account_interface.js +0 -37
  108. package/dest/single_key/account_contract.d.ts +0 -17
  109. package/dest/single_key/account_contract.d.ts.map +0 -1
  110. package/dest/single_key/account_contract.js +0 -42
  111. package/dest/single_key/index.d.ts +0 -39
  112. package/dest/single_key/index.d.ts.map +0 -1
  113. package/dest/single_key/index.js +0 -45
  114. package/dest/single_key/lazy.d.ts +0 -43
  115. package/dest/single_key/lazy.d.ts.map +0 -1
  116. package/dest/single_key/lazy.js +0 -53
  117. package/dest/testing/create_account.d.ts +0 -43
  118. package/dest/testing/create_account.d.ts.map +0 -1
  119. package/dest/testing/create_account.js +0 -58
  120. package/src/dapp/dapp_interface.ts +0 -38
  121. package/src/dapp/index.ts +0 -1
  122. package/src/defaults/account_interface.ts +0 -59
  123. package/src/single_key/account_contract.ts +0 -43
  124. package/src/single_key/index.ts +0 -63
  125. package/src/single_key/lazy.ts +0 -71
  126. package/src/testing/create_account.ts +0 -93
  127. /package/artifacts/{SchnorrSingleKeyAccount.d.json.ts → SimulatedAccount.d.json.ts} +0 -0
@@ -0,0 +1,51 @@
1
+ import { BaseAccount } from '@aztec/aztec.js/account';
2
+ import type { CompleteAddress } from '@aztec/aztec.js/addresses';
3
+ import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
4
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
5
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
6
+
7
+ import { StubBaseAccountContract } from './account_contract.js';
8
+
9
+ /**
10
+ * Lazily loads the contract artifact
11
+ * @returns The contract artifact for the Stub account contract
12
+ */
13
+ export async function getStubAccountContractArtifact() {
14
+ // Cannot assert this import as it's incompatible with bundlers like vite
15
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
16
+ // Even if now supported by al major browsers, the MIME type is replaced with
17
+ // "text/javascript"
18
+ // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
19
+ const { default: StubAccountContractJson } = await import('../../artifacts/SimulatedAccount.json');
20
+ return loadContractArtifact(StubAccountContractJson);
21
+ }
22
+
23
+ /**
24
+ * Account contract that authenticates transactions using Stub signatures
25
+ * verified against a Grumpkin public key stored in an immutable encrypted note.
26
+ * Lazily loads the contract artifact
27
+ */
28
+ export class StubAccountContract extends StubBaseAccountContract {
29
+ constructor() {
30
+ super();
31
+ }
32
+
33
+ override getContractArtifact(): Promise<ContractArtifact> {
34
+ return getStubAccountContractArtifact();
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Creates a stub account that impersonates the one with the provided originalAddress.
40
+ * @param originalAddress - The address of the account to stub
41
+ * @returns A stub account that can be used for kernelless simulations
42
+ */
43
+ export function createStubAccount(originalAddress: CompleteAddress) {
44
+ const accountContract = new StubAccountContract();
45
+ const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
46
+ return new BaseAccount(
47
+ new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
48
+ authWitnessProvider,
49
+ originalAddress,
50
+ );
51
+ }
@@ -1,4 +1,5 @@
1
- import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
2
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
4
  import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
4
5
 
@@ -1,38 +1,32 @@
1
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.
2
+ * The `@aztec/accounts/testing` export provides utility methods for testing, in particular in a local network environment.
5
3
  *
6
4
  * @packageDocumentation
7
5
  */
8
- import type { PXE } from '@aztec/aztec.js';
9
- import type { AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
6
+ import { Fr } from '@aztec/aztec.js/fields';
7
+ import { deriveSigningKey } from '@aztec/stdlib/keys';
10
8
 
11
- import {
12
- getSchnorrAccount,
13
- getSchnorrAccountContractAddress,
14
- getSchnorrWalletWithSecretKey,
15
- } from '../schnorr/index.js';
16
- import type { InitialAccountData } from './configuration.js';
9
+ import { getSchnorrAccountContractAddress } from '../schnorr/index.js';
17
10
  import {
18
11
  INITIAL_TEST_ACCOUNT_SALTS,
19
12
  INITIAL_TEST_ENCRYPTION_KEYS,
20
13
  INITIAL_TEST_SECRET_KEYS,
21
14
  INITIAL_TEST_SIGNING_KEYS,
15
+ type InitialAccountData,
22
16
  } from './configuration.js';
23
17
 
24
18
  export {
25
- type InitialAccountData,
26
19
  INITIAL_TEST_ACCOUNT_SALTS,
27
20
  INITIAL_TEST_ENCRYPTION_KEYS,
28
21
  INITIAL_TEST_SECRET_KEYS,
29
22
  INITIAL_TEST_SIGNING_KEYS,
23
+ type InitialAccountData,
30
24
  } from './configuration.js';
31
25
 
32
26
  /**
33
27
  * Gets the basic information for initial test accounts.
34
28
  */
35
- export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
29
+ export function getInitialTestAccountsData(): Promise<InitialAccountData[]> {
36
30
  return Promise.all(
37
31
  INITIAL_TEST_SECRET_KEYS.map(async (secret, i) => ({
38
32
  secret,
@@ -48,45 +42,19 @@ export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
48
42
  }
49
43
 
50
44
  /**
51
- * Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
52
- * @param pxe - PXE instance.
53
- * @returns A set of AccountWallet implementations for each of the initial accounts.
45
+ * Generate a fixed amount of random schnorr account contract instance.
54
46
  */
55
- export function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
56
- return Promise.all(
57
- INITIAL_TEST_SECRET_KEYS.map(async (encryptionKey, i) => {
58
- const account = await getSchnorrAccount(
59
- pxe,
60
- encryptionKey!,
61
- INITIAL_TEST_SIGNING_KEYS[i]!,
62
- INITIAL_TEST_ACCOUNT_SALTS[i],
63
- );
64
- return account.getWallet();
47
+ export async function generateSchnorrAccounts(numberOfAccounts: number): Promise<Promise<InitialAccountData[]>> {
48
+ const secrets = Array.from({ length: numberOfAccounts }, () => Fr.random());
49
+ return await Promise.all(
50
+ secrets.map(async secret => {
51
+ const salt = Fr.random();
52
+ return {
53
+ secret,
54
+ signingKey: deriveSigningKey(secret),
55
+ salt,
56
+ address: await getSchnorrAccountContractAddress(secret, salt),
57
+ };
65
58
  }),
66
59
  );
67
60
  }
68
-
69
- /**
70
- * Queries a PXE for it's registered accounts.
71
- * @param pxe - PXE instance.
72
- * @returns A set of key data for each of the initial accounts.
73
- */
74
- export async function getDeployedTestAccounts(pxe: PXE): Promise<InitialAccountData[]> {
75
- const registeredAccounts = await pxe.getRegisteredAccounts();
76
- const testAccounts = await getInitialTestAccounts();
77
- return testAccounts.filter(t => registeredAccounts.some(r => r.address.equals(t.address)));
78
- }
79
-
80
- /**
81
- * Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
82
- * @param pxe - PXE instance.
83
- * @returns A set of AccountWallet implementations for each of the initial accounts.
84
- */
85
- export async function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
86
- const testAccounts = await getDeployedTestAccounts(pxe);
87
- return Promise.all(
88
- testAccounts.map(({ secret, signingKey, salt }) => getSchnorrWalletWithSecretKey(pxe, secret, signingKey, salt)),
89
- );
90
- }
91
-
92
- export { deployFundedSchnorrAccount, deployFundedSchnorrAccounts, generateSchnorrAccounts } from './create_account.js';
@@ -1,14 +1,12 @@
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
5
  */
8
- import type { PXE } from '@aztec/aztec.js';
9
- import type { AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
6
+ import { Fr } from '@aztec/aztec.js/fields';
7
+ import { deriveSigningKey } from '@aztec/stdlib/keys';
10
8
 
11
- import { getSchnorrAccount, getSchnorrAccountContractAddress, getSchnorrWalletWithSecretKey } from '../schnorr/lazy.js';
9
+ import { getSchnorrAccountContractAddress } from '../schnorr/lazy.js';
12
10
  import {
13
11
  INITIAL_TEST_ACCOUNT_SALTS,
14
12
  INITIAL_TEST_ENCRYPTION_KEYS,
@@ -17,18 +15,12 @@ import {
17
15
  type InitialAccountData,
18
16
  } from './configuration.js';
19
17
 
20
- export {
21
- type InitialAccountData,
22
- INITIAL_TEST_ACCOUNT_SALTS,
23
- INITIAL_TEST_ENCRYPTION_KEYS,
24
- INITIAL_TEST_SECRET_KEYS,
25
- INITIAL_TEST_SIGNING_KEYS,
26
- } from './configuration.js';
18
+ export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_SECRET_KEYS } from './configuration.js';
27
19
 
28
20
  /**
29
21
  * Gets the basic information for initial test accounts.
30
22
  */
31
- export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
23
+ export function getInitialTestAccountsData(): Promise<InitialAccountData[]> {
32
24
  return Promise.all(
33
25
  INITIAL_TEST_SECRET_KEYS.map(async (secret, i) => ({
34
26
  secret,
@@ -44,43 +36,19 @@ export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
44
36
  }
45
37
 
46
38
  /**
47
- * Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
48
- * @param pxe - PXE instance.
49
- * @returns A set of AccountWallet implementations for each of the initial accounts.
39
+ * Generate a fixed amount of random schnorr account contract instance.
50
40
  */
51
- export function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
52
- return Promise.all(
53
- INITIAL_TEST_SECRET_KEYS.map(async (encryptionKey, i) => {
54
- const account = await getSchnorrAccount(
55
- pxe,
56
- encryptionKey!,
57
- INITIAL_TEST_SIGNING_KEYS[i]!,
58
- INITIAL_TEST_ACCOUNT_SALTS[i],
59
- );
60
- return account.getWallet();
41
+ export async function generateSchnorrAccounts(numberOfAccounts: number): Promise<InitialAccountData[]> {
42
+ const secrets = Array.from({ length: numberOfAccounts }, () => Fr.random());
43
+ return await Promise.all(
44
+ secrets.map(async secret => {
45
+ const salt = Fr.random();
46
+ return {
47
+ secret,
48
+ signingKey: deriveSigningKey(secret),
49
+ salt,
50
+ address: await getSchnorrAccountContractAddress(secret, salt),
51
+ };
61
52
  }),
62
53
  );
63
54
  }
64
-
65
- /**
66
- * Queries a PXE for it's registered accounts.
67
- * @param pxe - PXE instance.
68
- * @returns A set of key data for each of the initial accounts.
69
- */
70
- export async function getDeployedTestAccounts(pxe: PXE): Promise<InitialAccountData[]> {
71
- const registeredAccounts = await pxe.getRegisteredAccounts();
72
- const testAccounts = await getInitialTestAccounts();
73
- return testAccounts.filter(t => registeredAccounts.some(r => r.address.equals(t.address)));
74
- }
75
-
76
- /**
77
- * Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
78
- * @param pxe - PXE instance.
79
- * @returns A set of AccountWallet implementations for each of the initial accounts.
80
- */
81
- export async function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
82
- const testAccounts = await getDeployedTestAccounts(pxe);
83
- return Promise.all(
84
- testAccounts.map(({ secret, signingKey, salt }) => getSchnorrWalletWithSecretKey(pxe, secret, signingKey, salt)),
85
- );
86
- }