@aztec/accounts 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108

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 (122) hide show
  1. package/README.md +1 -1
  2. package/artifacts/EcdsaKAccount.json +3200 -3634
  3. package/artifacts/EcdsaRAccount.json +3200 -3634
  4. package/artifacts/SchnorrAccount.json +3215 -3822
  5. package/artifacts/SchnorrSingleKeyAccount.json +2555 -2634
  6. package/artifacts/SimulatedAccount.json +2108 -2330
  7. package/dest/defaults/account_contract.d.ts +4 -4
  8. package/dest/defaults/account_contract.d.ts.map +1 -1
  9. package/dest/defaults/account_contract.js +2 -2
  10. package/dest/defaults/account_interface.d.ts +8 -8
  11. package/dest/defaults/account_interface.d.ts.map +1 -1
  12. package/dest/defaults/account_interface.js +6 -7
  13. package/dest/defaults/index.d.ts +2 -2
  14. package/dest/defaults/index.js +1 -1
  15. package/dest/ecdsa/ecdsa_k/account_contract.d.ts +1 -1
  16. package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
  17. package/dest/ecdsa/ecdsa_k/account_contract.js +1 -1
  18. package/dest/ecdsa/ecdsa_k/index.d.ts +1 -23
  19. package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
  20. package/dest/ecdsa/ecdsa_k/index.js +1 -22
  21. package/dest/ecdsa/ecdsa_k/lazy.d.ts +1 -23
  22. package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -1
  23. package/dest/ecdsa/ecdsa_k/lazy.js +5 -26
  24. package/dest/ecdsa/ecdsa_r/account_contract.d.ts +1 -1
  25. package/dest/ecdsa/ecdsa_r/account_contract.d.ts.map +1 -1
  26. package/dest/ecdsa/ecdsa_r/account_contract.js +1 -1
  27. package/dest/ecdsa/ecdsa_r/index.d.ts +1 -23
  28. package/dest/ecdsa/ecdsa_r/index.d.ts.map +1 -1
  29. package/dest/ecdsa/ecdsa_r/index.js +1 -22
  30. package/dest/ecdsa/ecdsa_r/lazy.d.ts +1 -23
  31. package/dest/ecdsa/ecdsa_r/lazy.d.ts.map +1 -1
  32. package/dest/ecdsa/ecdsa_r/lazy.js +5 -26
  33. package/dest/ecdsa/index.d.ts +1 -1
  34. package/dest/ecdsa/lazy.d.ts +1 -1
  35. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +1 -1
  36. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
  37. package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +1 -1
  38. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +2 -24
  39. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
  40. package/dest/ecdsa/ssh_ecdsa_r/index.js +3 -24
  41. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +2 -24
  42. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -1
  43. package/dest/ecdsa/ssh_ecdsa_r/lazy.js +3 -24
  44. package/dest/schnorr/account_contract.d.ts +3 -2
  45. package/dest/schnorr/account_contract.d.ts.map +1 -1
  46. package/dest/schnorr/account_contract.js +1 -1
  47. package/dest/schnorr/index.d.ts +4 -38
  48. package/dest/schnorr/index.d.ts.map +1 -1
  49. package/dest/schnorr/index.js +1 -32
  50. package/dest/schnorr/lazy.d.ts +4 -38
  51. package/dest/schnorr/lazy.d.ts.map +1 -1
  52. package/dest/schnorr/lazy.js +5 -36
  53. package/dest/single_key/account_contract.d.ts +2 -2
  54. package/dest/single_key/account_contract.d.ts.map +1 -1
  55. package/dest/single_key/account_contract.js +1 -1
  56. package/dest/single_key/index.d.ts +2 -21
  57. package/dest/single_key/index.d.ts.map +1 -1
  58. package/dest/single_key/index.js +1 -23
  59. package/dest/single_key/lazy.d.ts +2 -21
  60. package/dest/single_key/lazy.d.ts.map +1 -1
  61. package/dest/single_key/lazy.js +5 -27
  62. package/dest/stub/account_contract.d.ts +29 -0
  63. package/dest/stub/account_contract.d.ts.map +1 -0
  64. package/dest/stub/account_contract.js +30 -0
  65. package/dest/stub/index.d.ts +21 -0
  66. package/dest/stub/index.d.ts.map +1 -0
  67. package/dest/stub/index.js +29 -0
  68. package/dest/stub/lazy.d.ts +23 -0
  69. package/dest/stub/lazy.d.ts.map +1 -0
  70. package/dest/stub/lazy.js +35 -0
  71. package/dest/testing/configuration.d.ts +5 -4
  72. package/dest/testing/configuration.d.ts.map +1 -1
  73. package/dest/testing/configuration.js +1 -1
  74. package/dest/testing/index.d.ts +6 -36
  75. package/dest/testing/index.d.ts.map +1 -1
  76. package/dest/testing/index.js +19 -35
  77. package/dest/testing/lazy.d.ts +5 -28
  78. package/dest/testing/lazy.d.ts.map +1 -1
  79. package/dest/testing/lazy.js +19 -30
  80. package/dest/utils/index.d.ts +1 -1
  81. package/dest/utils/ssh_agent.d.ts +1 -1
  82. package/package.json +13 -10
  83. package/src/defaults/account_contract.ts +4 -4
  84. package/src/defaults/account_interface.ts +13 -14
  85. package/src/defaults/index.ts +1 -1
  86. package/src/ecdsa/ecdsa_k/account_contract.ts +2 -2
  87. package/src/ecdsa/ecdsa_k/index.ts +0 -32
  88. package/src/ecdsa/ecdsa_k/lazy.ts +4 -36
  89. package/src/ecdsa/ecdsa_r/account_contract.ts +2 -2
  90. package/src/ecdsa/ecdsa_r/index.ts +0 -32
  91. package/src/ecdsa/ecdsa_r/lazy.ts +4 -36
  92. package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +2 -2
  93. package/src/ecdsa/ssh_ecdsa_r/index.ts +2 -35
  94. package/src/ecdsa/ssh_ecdsa_r/lazy.ts +2 -35
  95. package/src/schnorr/account_contract.ts +3 -2
  96. package/src/schnorr/index.ts +9 -56
  97. package/src/schnorr/lazy.ts +13 -60
  98. package/src/single_key/account_contract.ts +3 -2
  99. package/src/single_key/index.ts +1 -32
  100. package/src/single_key/lazy.ts +5 -36
  101. package/src/stub/account_contract.ts +39 -0
  102. package/src/stub/index.ts +41 -0
  103. package/src/stub/lazy.ts +49 -0
  104. package/src/testing/configuration.ts +2 -1
  105. package/src/testing/index.ts +20 -57
  106. package/src/testing/lazy.ts +18 -50
  107. package/dest/copy_cat/base.d.ts +0 -18
  108. package/dest/copy_cat/base.d.ts.map +0 -1
  109. package/dest/copy_cat/base.js +0 -28
  110. package/dest/copy_cat/index.d.ts +0 -10
  111. package/dest/copy_cat/index.d.ts.map +0 -1
  112. package/dest/copy_cat/index.js +0 -31
  113. package/dest/copy_cat/lazy.d.ts +0 -9
  114. package/dest/copy_cat/lazy.d.ts.map +0 -1
  115. package/dest/copy_cat/lazy.js +0 -29
  116. package/dest/testing/create_account.d.ts +0 -43
  117. package/dest/testing/create_account.d.ts.map +0 -1
  118. package/dest/testing/create_account.js +0 -61
  119. package/src/copy_cat/base.ts +0 -47
  120. package/src/copy_cat/index.ts +0 -44
  121. package/src/copy_cat/lazy.ts +0 -40
  122. package/src/testing/create_account.ts +0 -111
@@ -4,13 +4,9 @@
4
4
  *
5
5
  * @packageDocumentation
6
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, getWallet } from '@aztec/aztec.js/wallet';
7
+ import type { GrumpkinScalar } from '@aztec/aztec.js/fields';
10
8
  import type { ContractArtifact } from '@aztec/stdlib/abi';
11
9
  import { loadContractArtifact } from '@aztec/stdlib/abi';
12
- import type { PXE } from '@aztec/stdlib/interfaces/client';
13
- import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
14
10
 
15
11
  import { SingleKeyBaseAccountContract } from './account_contract.js';
16
12
 
@@ -19,10 +15,10 @@ import { SingleKeyBaseAccountContract } from './account_contract.js';
19
15
  * @returns The contract artifact for the single key account contract
20
16
  */
21
17
  export async function getSingleKeyAccountContractArtifact() {
22
- // Cannot assert this import as it's incompatible with browsers
23
- // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
24
- // Use the new "with" syntax once supported by firefox
25
- // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
18
+ // Cannot assert this import as it's incompatible with bundlers like vite
19
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
20
+ // Even if now supported by al major browsers, the MIME type is replaced with
21
+ // "text/javascript"
26
22
  // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
27
23
  const { default: schnorrAccountContractJson } = await import('../../artifacts/SchnorrAccount.json');
28
24
  return loadContractArtifact(schnorrAccountContractJson);
@@ -42,30 +38,3 @@ export class SingleKeyAccountContract extends SingleKeyBaseAccountContract {
42
38
  return getSingleKeyAccountContractArtifact();
43
39
  }
44
40
  }
45
-
46
- /**
47
- * Creates an Account that uses the same Grumpkin key for encryption and authentication.
48
- * @param pxe - An PXE server instance.
49
- * @param secretKey - Secret key used to derive all the keystore keys (in this case also used to get signing key).
50
- * @param salt - Deployment salt.
51
- * @returns An account manager initialized with the account contract and its deployment params
52
- */
53
- export function getUnsafeSchnorrAccount(pxe: PXE, secretKey: Fr, salt?: Salt) {
54
- const encryptionPrivateKey = deriveMasterIncomingViewingSecretKey(secretKey);
55
- return AccountManager.create(pxe, secretKey, new SingleKeyAccountContract(encryptionPrivateKey), salt);
56
- }
57
-
58
- /**
59
- * Gets a wallet for an already registered account using Schnorr signatures with a single key for encryption and authentication.
60
- * @param pxe - An PXE server instance.
61
- * @param address - Address for the account.
62
- * @param signingPrivateKey - Grumpkin key used for note encryption and signing transactions.
63
- * @returns A wallet for this account that can be used to interact with a contract instance.
64
- */
65
- export function getUnsafeSchnorrWallet(
66
- pxe: PXE,
67
- address: AztecAddress,
68
- signingPrivateKey: GrumpkinScalar,
69
- ): Promise<AccountWallet> {
70
- return getWallet(pxe, address, new SingleKeyAccountContract(signingPrivateKey));
71
- }
@@ -0,0 +1,39 @@
1
+ import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { AuthWitness } from '@aztec/stdlib/auth-witness';
4
+ import { CompleteAddress } from '@aztec/stdlib/contract';
5
+
6
+ import { DefaultAccountContract } from '../defaults/account_contract.js';
7
+
8
+ /**
9
+ * An Account contract that does not perform any authentication of authwits
10
+ * (`is_valid` always returns `true`)
11
+ * It is used to capture authorization data during simulations
12
+ */
13
+ export abstract class StubBaseAccountContract extends DefaultAccountContract {
14
+ constructor() {
15
+ super();
16
+ }
17
+
18
+ getInitializationFunctionAndArgs() {
19
+ return Promise.resolve({ constructorName: 'constructor', constructorArgs: [] });
20
+ }
21
+
22
+ getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider {
23
+ return new StubAuthWitnessProvider();
24
+ }
25
+ }
26
+
27
+ /** Creates auth witnesses using Stub signatures. */
28
+ export class StubAuthWitnessProvider implements AuthWitnessProvider {
29
+ constructor() {}
30
+
31
+ /**
32
+ * A fake account always returns an empty authwitness, since it doesn't
33
+ * perform any verification whatsoever
34
+ * @param messageHash - The outer hash of the message for which the auth witness is created
35
+ */
36
+ createAuthWit(messageHash: Fr): Promise<AuthWitness> {
37
+ return Promise.resolve(new AuthWitness(messageHash, []));
38
+ }
39
+ }
@@ -0,0 +1,41 @@
1
+ import { BaseAccount, type ChainInfo } from '@aztec/aztec.js/account';
2
+ import type { CompleteAddress } from '@aztec/aztec.js/addresses';
3
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
4
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
5
+ import type { NoirCompiledContract } from '@aztec/stdlib/noir';
6
+
7
+ import SimulatedAccountContract from '../../artifacts/SimulatedAccount.json' with { type: 'json' };
8
+ import { DefaultAccountInterface } from '../defaults/account_interface.js';
9
+ import { StubBaseAccountContract } from './account_contract.js';
10
+
11
+ export const StubAccountContractArtifact = loadContractArtifact(SimulatedAccountContract as NoirCompiledContract);
12
+
13
+ /**
14
+ * Stub account contract
15
+ * Eagerly loads the contract artifact
16
+ */
17
+ export class StubAccountContract extends StubBaseAccountContract {
18
+ constructor() {
19
+ super();
20
+ }
21
+
22
+ override getContractArtifact(): Promise<ContractArtifact> {
23
+ return Promise.resolve(StubAccountContractArtifact);
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Creates a stub account that impersonates the one with the provided originalAddress.
29
+ * @param originalAddress - The address of the account to stub
30
+ * @param chainInfo - The chain info that the account is connected to
31
+ * @returns A stub account that can be used for kernelless simulations
32
+ */
33
+ export function createStubAccount(originalAddress: CompleteAddress, chainInfo: ChainInfo) {
34
+ const accountContract = new StubAccountContract();
35
+ const accountInterface = new DefaultAccountInterface(
36
+ accountContract.getAuthWitnessProvider(originalAddress),
37
+ originalAddress,
38
+ chainInfo,
39
+ );
40
+ return new BaseAccount(accountInterface);
41
+ }
@@ -0,0 +1,49 @@
1
+ import { BaseAccount, type ChainInfo } from '@aztec/aztec.js/account';
2
+ import type { CompleteAddress } from '@aztec/aztec.js/addresses';
3
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
4
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
5
+
6
+ import { DefaultAccountInterface } from '../defaults/account_interface.js';
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
+ *
40
+ */
41
+ export function createStubAccount(originalAddress: CompleteAddress, chainInfo: ChainInfo) {
42
+ const accountContract = new StubAccountContract();
43
+ const accountInterface = new DefaultAccountInterface(
44
+ accountContract.getAuthWitnessProvider(originalAddress),
45
+ originalAddress,
46
+ chainInfo,
47
+ );
48
+ return new BaseAccount(accountInterface);
49
+ }
@@ -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 { AccountManager, 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,50 +42,19 @@ export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
48
42
  }
49
43
 
50
44
  /**
51
- * Gets a collection of account managers for the Aztec accounts that are initially stored in the test environment.
52
- * @param pxe - PXE instance.
53
- * @returns A set of AccountManager implementations for each of the initial accounts.
54
- */
55
- export function getInitialTestAccountsManagers(pxe: PXE): Promise<AccountManager[]> {
56
- return Promise.all(
57
- INITIAL_TEST_SECRET_KEYS.map((encryptionKey, i) =>
58
- getSchnorrAccount(pxe, encryptionKey!, INITIAL_TEST_SIGNING_KEYS[i]!, INITIAL_TEST_ACCOUNT_SALTS[i]),
59
- ),
60
- );
61
- }
62
-
63
- /**
64
- * Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
65
- * @param pxe - PXE instance.
66
- * @returns A set of AccountWallet implementations for each of the initial accounts.
67
- */
68
- export async function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
69
- return Promise.all(
70
- (await Promise.all(await getInitialTestAccountsManagers(pxe))).map(accountManager => accountManager.getWallet()),
71
- );
72
- }
73
-
74
- /**
75
- * Queries a PXE for it's registered accounts.
76
- * @param pxe - PXE instance.
77
- * @returns A set of key data for each of the initial accounts.
78
- */
79
- export async function getDeployedTestAccounts(pxe: PXE): Promise<InitialAccountData[]> {
80
- const registeredAccounts = await pxe.getRegisteredAccounts();
81
- const testAccounts = await getInitialTestAccounts();
82
- return testAccounts.filter(t => registeredAccounts.some(r => r.address.equals(t.address)));
83
- }
84
-
85
- /**
86
- * Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
87
- * @param pxe - PXE instance.
88
- * @returns A set of AccountWallet implementations for each of the initial accounts.
45
+ * Generate a fixed amount of random schnorr account contract instance.
89
46
  */
90
- export async function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
91
- const testAccounts = await getDeployedTestAccounts(pxe);
92
- return Promise.all(
93
- testAccounts.map(({ secret, signingKey, salt }) => getSchnorrWalletWithSecretKey(pxe, secret, signingKey, salt)),
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
+ };
58
+ }),
94
59
  );
95
60
  }
96
-
97
- 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
- }
@@ -1,18 +0,0 @@
1
- import { type AccountInterface, AccountWalletWithSecretKey, type ContractArtifact, type PXE, TxExecutionRequest } from '@aztec/aztec.js';
2
- import type { CompleteAddress, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
- import type { SimulationOverrides, TxSimulationResult } from '@aztec/stdlib/tx';
4
- /**
5
- * An AccountWallet that copies the address of another account, and then
6
- * uses the simulation overrides feature to execute different contract code under
7
- * the copied address. This is used to bypass authwit verification entirely
8
- * (`is_valid` always returns `true`)
9
- */
10
- export declare abstract class CopyCatAccountWalletBase extends AccountWalletWithSecretKey {
11
- private originalAddress;
12
- private artifact;
13
- private instance;
14
- constructor(pxe: PXE, account: AccountInterface, originalAddress: CompleteAddress, artifact: ContractArtifact, instance: ContractInstanceWithAddress);
15
- getCompleteAddress(): CompleteAddress;
16
- simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, _skipTxValidation?: boolean, _skipFeeEnforcement?: boolean, _overrides?: SimulationOverrides): Promise<TxSimulationResult>;
17
- }
18
- //# sourceMappingURL=base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/copy_cat/base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,0BAA0B,EAC1B,KAAK,gBAAgB,EAErB,KAAK,GAAG,EACR,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEhF;;;;;GAKG;AACH,8BAAsB,wBAAyB,SAAQ,0BAA0B;IAI7E,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,QAAQ;gBAJhB,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,gBAAgB,EACjB,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,2BAA2B;IAKtC,kBAAkB,IAAI,eAAe;IAIrC,UAAU,CACjB,SAAS,EAAE,kBAAkB,EAC7B,cAAc,EAAE,OAAO,EACvB,iBAAiB,CAAC,EAAE,OAAO,EAC3B,mBAAmB,CAAC,EAAE,OAAO,EAC7B,UAAU,CAAC,EAAE,mBAAmB,GAC/B,OAAO,CAAC,kBAAkB,CAAC;CAQ/B"}
@@ -1,28 +0,0 @@
1
- import { AccountWalletWithSecretKey, Fr } from '@aztec/aztec.js';
2
- /**
3
- * An AccountWallet that copies the address of another account, and then
4
- * uses the simulation overrides feature to execute different contract code under
5
- * the copied address. This is used to bypass authwit verification entirely
6
- * (`is_valid` always returns `true`)
7
- */ export class CopyCatAccountWalletBase extends AccountWalletWithSecretKey {
8
- originalAddress;
9
- artifact;
10
- instance;
11
- constructor(pxe, account, originalAddress, artifact, instance){
12
- super(pxe, account, Fr.ZERO, Fr.ZERO), this.originalAddress = originalAddress, this.artifact = artifact, this.instance = instance;
13
- }
14
- getCompleteAddress() {
15
- return this.originalAddress;
16
- }
17
- simulateTx(txRequest, simulatePublic, _skipTxValidation, _skipFeeEnforcement, _overrides) {
18
- const contractOverrides = {
19
- [this.originalAddress.address.toString()]: {
20
- instance: this.instance,
21
- artifact: this.artifact
22
- }
23
- };
24
- return this.pxe.simulateTx(txRequest, simulatePublic, true, true, {
25
- contracts: contractOverrides
26
- });
27
- }
28
- }
@@ -1,10 +0,0 @@
1
- import { AccountWallet, type PXE } from '@aztec/aztec.js';
2
- import { CopyCatAccountWalletBase } from './base.js';
3
- export declare const SimulatedAccountContractArtifact: import("@aztec/aztec.js").ContractArtifact;
4
- /**
5
- * A CopyCatAccountWallet that loads the contract artifact eagerly.
6
- */
7
- export declare class CopyCatAccountWallet extends CopyCatAccountWalletBase {
8
- static create(pxe: PXE, originalAccount: AccountWallet): Promise<CopyCatAccountWallet>;
9
- }
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/copy_cat/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAIb,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD,eAAO,MAAM,gCAAgC,4CAE5C,CAAC;AAEF;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,wBAAwB;WACnD,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAqB7F"}
@@ -1,31 +0,0 @@
1
- import { DefaultAccountInterface } from '@aztec/accounts/defaults';
2
- import { AuthWitness, getContractInstanceFromInstantiationParams, loadContractArtifact } from '@aztec/aztec.js';
3
- import SimulatedAccountContractJson from '../../artifacts/SimulatedAccount.json' with {
4
- type: 'json'
5
- };
6
- import { CopyCatAccountWalletBase } from './base.js';
7
- export const SimulatedAccountContractArtifact = loadContractArtifact(SimulatedAccountContractJson);
8
- /**
9
- * A CopyCatAccountWallet that loads the contract artifact eagerly.
10
- */ export class CopyCatAccountWallet extends CopyCatAccountWalletBase {
11
- static async create(pxe, originalAccount) {
12
- const simulatedAuthWitnessProvider = {
13
- /**
14
- * A copycat wallet always returns an empty authwitness, since it doesn't
15
- * perform any verification whatsoever
16
- * @param messageHash - The outer hash of the message for which the auth witness is created
17
- */ createAuthWit (messageHash) {
18
- return Promise.resolve(new AuthWitness(messageHash, []));
19
- }
20
- };
21
- const nodeInfo = await pxe.getNodeInfo();
22
- const originalAddress = originalAccount.getCompleteAddress();
23
- const { contractInstance } = await pxe.getContractMetadata(originalAddress.address);
24
- if (!contractInstance) {
25
- throw new Error(`No contract instance found for address: ${originalAddress.address}`);
26
- }
27
- const accountInterface = new DefaultAccountInterface(simulatedAuthWitnessProvider, originalAddress, nodeInfo);
28
- const instance = await getContractInstanceFromInstantiationParams(SimulatedAccountContractArtifact, {});
29
- return new CopyCatAccountWallet(pxe, accountInterface, originalAddress, SimulatedAccountContractArtifact, instance);
30
- }
31
- }
@@ -1,9 +0,0 @@
1
- import { AccountWallet, type PXE } from '@aztec/aztec.js';
2
- import { CopyCatAccountWalletBase } from './base.js';
3
- /**
4
- * A CopyCatAccountWallet that loads the contract artifact lazily.
5
- */
6
- export declare class CopyCatAccountWallet extends CopyCatAccountWalletBase {
7
- static create(pxe: PXE, originalAccount: AccountWallet): Promise<CopyCatAccountWallet>;
8
- }
9
- //# sourceMappingURL=lazy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/copy_cat/lazy.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAGb,KAAK,GAAG,EAGT,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,wBAAwB;WACnD,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAuB7F"}
@@ -1,29 +0,0 @@
1
- import { DefaultAccountInterface } from '@aztec/accounts/defaults';
2
- import { AuthWitness, getContractInstanceFromInstantiationParams, loadContractArtifact } from '@aztec/aztec.js';
3
- import { CopyCatAccountWalletBase } from './base.js';
4
- /**
5
- * A CopyCatAccountWallet that loads the contract artifact lazily.
6
- */ export class CopyCatAccountWallet extends CopyCatAccountWalletBase {
7
- static async create(pxe, originalAccount) {
8
- const simulatedAuthWitnessProvider = {
9
- /**
10
- * A copycat wallet always returns an empty authwitness, since it doesn't
11
- * perform any verification whatsoever
12
- * @param messageHash - The outer hash of the message for which the auth witness is created
13
- */ createAuthWit (messageHash) {
14
- return Promise.resolve(new AuthWitness(messageHash, []));
15
- }
16
- };
17
- const nodeInfo = await pxe.getNodeInfo();
18
- const originalAddress = originalAccount.getCompleteAddress();
19
- const { contractInstance } = await pxe.getContractMetadata(originalAddress.address);
20
- if (!contractInstance) {
21
- throw new Error(`No contract instance found for address: ${originalAddress.address}`);
22
- }
23
- const accountInterface = new DefaultAccountInterface(simulatedAuthWitnessProvider, originalAddress, nodeInfo);
24
- const { default: simulatedAccountContractJson } = await import('../../artifacts/SimulatedAccount.json');
25
- const simulatedAccountContractArtifact = loadContractArtifact(simulatedAccountContractJson);
26
- const instance = await getContractInstanceFromInstantiationParams(simulatedAccountContractArtifact, {});
27
- return new CopyCatAccountWallet(pxe, accountInterface, originalAddress, simulatedAccountContractArtifact, instance);
28
- }
29
- }
@@ -1,43 +0,0 @@
1
- import { type AccountManager, type PXE, type WaitForProvenOpts, 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 publishing the contract class.
29
- */
30
- skipClassPublication?: boolean;
31
- }, waitForProvenOptions?: WaitForProvenOpts): 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 publishing the contract class.
39
- */
40
- skipClassPublication?: boolean;
41
- }, waitForProvenOptions?: WaitForProvenOpts): Promise<AccountManager[]>;
42
- export {};
43
- //# sourceMappingURL=create_account.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/testing/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EAEd,MAAM,iBAAiB,CAAC;AACzB,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,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACiB,EAClD,oBAAoB,CAAC,EAAE,iBAAiB,GACvC,OAAO,CAAC,cAAc,CAAC,CAqBzB;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,IAAI,GAAE,QAAQ,GAAG;IACf;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACiB,EAClD,oBAAoB,CAAC,EAAE,iBAAiB,GACvC,OAAO,CAAC,cAAc,EAAE,CAAC,CAiB3B"}