@aztec/accounts 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa

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 (141) hide show
  1. package/README.md +1 -2
  2. package/artifacts/EcdsaKAccount.json +9971 -4275
  3. package/artifacts/EcdsaRAccount.json +9844 -4148
  4. package/artifacts/SchnorrAccount.json +10367 -4871
  5. package/artifacts/SchnorrInitializerlessAccount.json +8460 -0
  6. package/artifacts/SimulatedEcdsaAccount.json +10610 -0
  7. package/artifacts/SimulatedSchnorrAccount.d.json.ts +3 -0
  8. package/artifacts/SimulatedSchnorrAccount.json +10722 -0
  9. package/dest/defaults/account_contract.d.ts +9 -3
  10. package/dest/defaults/account_contract.d.ts.map +1 -1
  11. package/dest/defaults/account_contract.js +11 -3
  12. package/dest/defaults/index.d.ts +1 -2
  13. package/dest/defaults/index.d.ts.map +1 -1
  14. package/dest/defaults/index.js +1 -2
  15. package/dest/{stub/account_contract.d.ts → defaults/stub_account_contract.d.ts} +2 -2
  16. package/dest/defaults/stub_account_contract.d.ts.map +1 -0
  17. package/dest/ecdsa/ecdsa_k/account_contract.d.ts +2 -2
  18. package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
  19. package/dest/ecdsa/ecdsa_k/account_contract.js +7 -3
  20. package/dest/ecdsa/ecdsa_k/index.d.ts +1 -1
  21. package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
  22. package/dest/ecdsa/ecdsa_k/lazy.d.ts +1 -1
  23. package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -1
  24. package/dest/ecdsa/ecdsa_k/lazy.js +1 -1
  25. package/dest/ecdsa/ecdsa_r/account_contract.d.ts +2 -2
  26. package/dest/ecdsa/ecdsa_r/account_contract.d.ts.map +1 -1
  27. package/dest/ecdsa/ecdsa_r/account_contract.js +7 -3
  28. package/dest/ecdsa/ecdsa_r/index.d.ts +1 -1
  29. package/dest/ecdsa/ecdsa_r/index.d.ts.map +1 -1
  30. package/dest/ecdsa/ecdsa_r/lazy.d.ts +1 -1
  31. package/dest/ecdsa/ecdsa_r/lazy.d.ts.map +1 -1
  32. package/dest/ecdsa/ecdsa_r/lazy.js +1 -1
  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 +2 -2
  36. package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
  37. package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +7 -3
  38. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +1 -1
  39. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
  40. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +1 -1
  41. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -1
  42. package/dest/ecdsa/stub/index.d.ts +11 -0
  43. package/dest/ecdsa/stub/index.d.ts.map +1 -0
  44. package/dest/ecdsa/stub/index.js +18 -0
  45. package/dest/ecdsa/stub/lazy.d.ts +14 -0
  46. package/dest/ecdsa/stub/lazy.d.ts.map +1 -0
  47. package/dest/ecdsa/stub/lazy.js +22 -0
  48. package/dest/schnorr/account_contract.d.ts +10 -5
  49. package/dest/schnorr/account_contract.d.ts.map +1 -1
  50. package/dest/schnorr/account_contract.js +7 -6
  51. package/dest/schnorr/index.d.ts +3 -22
  52. package/dest/schnorr/index.d.ts.map +1 -1
  53. package/dest/schnorr/index.js +2 -35
  54. package/dest/schnorr/initializerless/index.d.ts +25 -0
  55. package/dest/schnorr/initializerless/index.d.ts.map +1 -0
  56. package/dest/schnorr/initializerless/index.js +46 -0
  57. package/dest/schnorr/initializerless/lazy.d.ts +29 -0
  58. package/dest/schnorr/initializerless/lazy.d.ts.map +1 -0
  59. package/dest/schnorr/initializerless/lazy.js +54 -0
  60. package/dest/schnorr/lazy.d.ts +3 -26
  61. package/dest/schnorr/lazy.d.ts.map +1 -1
  62. package/dest/schnorr/lazy.js +2 -43
  63. package/dest/schnorr/private_immutable/index.d.ts +23 -0
  64. package/dest/schnorr/private_immutable/index.d.ts.map +1 -0
  65. package/dest/schnorr/private_immutable/index.js +35 -0
  66. package/dest/schnorr/private_immutable/lazy.d.ts +27 -0
  67. package/dest/schnorr/private_immutable/lazy.d.ts.map +1 -0
  68. package/dest/schnorr/private_immutable/lazy.js +43 -0
  69. package/dest/schnorr/stub/index.d.ts +11 -0
  70. package/dest/schnorr/stub/index.d.ts.map +1 -0
  71. package/dest/schnorr/stub/index.js +18 -0
  72. package/dest/schnorr/stub/lazy.d.ts +14 -0
  73. package/dest/schnorr/stub/lazy.d.ts.map +1 -0
  74. package/dest/schnorr/stub/lazy.js +22 -0
  75. package/dest/testing/configuration.d.ts +13 -4
  76. package/dest/testing/configuration.d.ts.map +1 -1
  77. package/dest/testing/configuration.js +1 -1
  78. package/dest/testing/index.d.ts +5 -5
  79. package/dest/testing/index.d.ts.map +1 -1
  80. package/dest/testing/index.js +12 -6
  81. package/dest/testing/lazy.d.ts +4 -4
  82. package/dest/testing/lazy.d.ts.map +1 -1
  83. package/dest/testing/lazy.js +12 -6
  84. package/dest/utils/index.d.ts +1 -1
  85. package/dest/utils/ssh_agent.d.ts +1 -1
  86. package/dest/utils/ssh_agent.d.ts.map +1 -1
  87. package/dest/utils/ssh_agent.js +2 -0
  88. package/package.json +14 -16
  89. package/src/defaults/account_contract.ts +18 -5
  90. package/src/defaults/index.ts +0 -1
  91. package/src/{stub/account_contract.ts → defaults/stub_account_contract.ts} +1 -1
  92. package/src/ecdsa/ecdsa_k/account_contract.ts +3 -3
  93. package/src/ecdsa/ecdsa_k/lazy.ts +1 -1
  94. package/src/ecdsa/ecdsa_r/account_contract.ts +3 -3
  95. package/src/ecdsa/ecdsa_r/lazy.ts +1 -1
  96. package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +3 -3
  97. package/src/ecdsa/stub/index.ts +28 -0
  98. package/src/ecdsa/stub/lazy.ts +34 -0
  99. package/src/schnorr/account_contract.ts +21 -7
  100. package/src/schnorr/index.ts +2 -49
  101. package/src/schnorr/initializerless/index.ts +62 -0
  102. package/src/schnorr/initializerless/lazy.ts +70 -0
  103. package/src/schnorr/lazy.ts +2 -59
  104. package/src/schnorr/private_immutable/index.ts +50 -0
  105. package/src/schnorr/private_immutable/lazy.ts +60 -0
  106. package/src/schnorr/stub/index.ts +30 -0
  107. package/src/schnorr/stub/lazy.ts +34 -0
  108. package/src/testing/configuration.ts +11 -1
  109. package/src/testing/index.ts +22 -6
  110. package/src/testing/lazy.ts +21 -6
  111. package/src/utils/ssh_agent.ts +2 -0
  112. package/artifacts/SchnorrSingleKeyAccount.json +0 -4558
  113. package/artifacts/SimulatedAccount.json +0 -4494
  114. package/dest/defaults/account_interface.d.ts +0 -29
  115. package/dest/defaults/account_interface.d.ts.map +0 -1
  116. package/dest/defaults/account_interface.js +0 -36
  117. package/dest/single_key/account_contract.d.ts +0 -17
  118. package/dest/single_key/account_contract.d.ts.map +0 -1
  119. package/dest/single_key/account_contract.js +0 -42
  120. package/dest/single_key/index.d.ts +0 -20
  121. package/dest/single_key/index.d.ts.map +0 -1
  122. package/dest/single_key/index.js +0 -23
  123. package/dest/single_key/lazy.d.ts +0 -24
  124. package/dest/single_key/lazy.d.ts.map +0 -1
  125. package/dest/single_key/lazy.js +0 -31
  126. package/dest/stub/account_contract.d.ts.map +0 -1
  127. package/dest/stub/index.d.ts +0 -21
  128. package/dest/stub/index.d.ts.map +0 -1
  129. package/dest/stub/index.js +0 -29
  130. package/dest/stub/lazy.d.ts +0 -23
  131. package/dest/stub/lazy.d.ts.map +0 -1
  132. package/dest/stub/lazy.js +0 -35
  133. package/src/defaults/account_interface.ts +0 -64
  134. package/src/single_key/account_contract.ts +0 -46
  135. package/src/single_key/index.ts +0 -32
  136. package/src/single_key/lazy.ts +0 -40
  137. package/src/stub/index.ts +0 -41
  138. package/src/stub/lazy.ts +0 -49
  139. /package/artifacts/{SchnorrSingleKeyAccount.d.json.ts → SchnorrInitializerlessAccount.d.json.ts} +0 -0
  140. /package/artifacts/{SimulatedAccount.d.json.ts → SimulatedEcdsaAccount.d.json.ts} +0 -0
  141. /package/dest/{stub/account_contract.js → defaults/stub_account_contract.js} +0 -0
@@ -0,0 +1,50 @@
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
+ */
7
+ import { getAccountContractAddress } from '@aztec/aztec.js/account';
8
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
9
+ import { Fr } from '@aztec/foundation/curves/bn254';
10
+ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
11
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
12
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
13
+ import { deriveSigningKey } from '@aztec/stdlib/keys';
14
+ import type { NoirCompiledContract } from '@aztec/stdlib/noir';
15
+
16
+ import SchnorrAccountContractJson from '../../../artifacts/SchnorrAccount.json' with { type: 'json' };
17
+ import { SchnorrBaseAccountContract } from '../account_contract.js';
18
+
19
+ export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractJson as NoirCompiledContract);
20
+
21
+ /**
22
+ * Account contract that authenticates transactions using Schnorr signatures
23
+ * verified against a Grumpkin public key stored in an immutable encrypted note.
24
+ * Eagerly loads the contract artifact
25
+ */
26
+ export class SchnorrAccountContract extends SchnorrBaseAccountContract {
27
+ constructor(signingPrivateKey: GrumpkinScalar) {
28
+ super(signingPrivateKey);
29
+ }
30
+
31
+ override getContractArtifact(): Promise<ContractArtifact> {
32
+ return Promise.resolve(SchnorrAccountContractArtifact);
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Compute the address of a schnorr account contract.
38
+ * @param secret - A seed for deriving the signing key and public keys.
39
+ * @param salt - The contract address salt.
40
+ * @param signingPrivateKey - A specific signing private key that's not derived from the secret.
41
+ */
42
+ export async function getSchnorrAccountContractAddress(
43
+ secret: Fr,
44
+ salt: Fr,
45
+ signingPrivateKey?: GrumpkinScalar,
46
+ ): Promise<AztecAddress> {
47
+ const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
48
+ const accountContract = new SchnorrAccountContract(signingKey);
49
+ return await getAccountContractAddress(accountContract, secret, salt);
50
+ }
@@ -0,0 +1,60 @@
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
+ */
7
+ import { getAccountContractAddress } from '@aztec/aztec.js/account';
8
+ import { Fr } from '@aztec/foundation/curves/bn254';
9
+ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
10
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
11
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
12
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
13
+ import { deriveSigningKey } from '@aztec/stdlib/keys';
14
+
15
+ import { SchnorrBaseAccountContract } from '../account_contract.js';
16
+
17
+ /**
18
+ * Lazily loads the contract artifact
19
+ * @returns The contract artifact for the schnorr account contract
20
+ */
21
+ export async function getSchnorrAccountContractArtifact() {
22
+ // Cannot assert this import as it's incompatible with bundlers like vite
23
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
24
+ // Even if now supported by all major browsers, the MIME type is replaced with
25
+ // "text/javascript"
26
+ // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
27
+ const { default: schnorrAccountContractJson } = await import('../../../artifacts/SchnorrAccount.json');
28
+ return loadContractArtifact(schnorrAccountContractJson);
29
+ }
30
+
31
+ /**
32
+ * Account contract that authenticates transactions using Schnorr signatures
33
+ * verified against a Grumpkin public key stored in an immutable encrypted note.
34
+ * Lazily loads the contract artifact
35
+ */
36
+ export class SchnorrAccountContract extends SchnorrBaseAccountContract {
37
+ constructor(signingPrivateKey: GrumpkinScalar) {
38
+ super(signingPrivateKey);
39
+ }
40
+
41
+ override getContractArtifact(): Promise<ContractArtifact> {
42
+ return getSchnorrAccountContractArtifact();
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Compute the address of a schnorr account contract.
48
+ * @param secret - A seed for deriving the signing key and public keys.
49
+ * @param salt - The contract address salt.
50
+ * @param signingPrivateKey - A specific signing private key that's not derived from the secret.
51
+ */
52
+ export async function getSchnorrAccountContractAddress(
53
+ secret: Fr,
54
+ salt: Fr,
55
+ signingPrivateKey?: GrumpkinScalar,
56
+ ): Promise<AztecAddress> {
57
+ const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
58
+ const accountContract = new SchnorrAccountContract(signingKey);
59
+ return await getAccountContractAddress(accountContract, secret, salt);
60
+ }
@@ -0,0 +1,30 @@
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 { loadContractArtifact } from '@aztec/stdlib/abi';
5
+ import type { NoirCompiledContract } from '@aztec/stdlib/noir';
6
+
7
+ import SimulatedSchnorrAccountJson from '../../../artifacts/SimulatedSchnorrAccount.json' with { type: 'json' };
8
+ import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
9
+
10
+ export const StubSchnorrAccountContractArtifact = loadContractArtifact(
11
+ SimulatedSchnorrAccountJson as NoirCompiledContract,
12
+ );
13
+
14
+ /** Stub account contract for Schnorr accounts. Eagerly loads the contract artifact. */
15
+ export class StubSchnorrAccountContract extends StubBaseAccountContract {
16
+ override getContractArtifact() {
17
+ return Promise.resolve(StubSchnorrAccountContractArtifact);
18
+ }
19
+ }
20
+
21
+ /** Creates a Schnorr stub account that impersonates the one with the provided address. */
22
+ export function createStubSchnorrAccount(originalAddress: CompleteAddress) {
23
+ const accountContract = new StubSchnorrAccountContract();
24
+ const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
25
+ return new BaseAccount(
26
+ new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
27
+ authWitnessProvider,
28
+ originalAddress,
29
+ );
30
+ }
@@ -0,0 +1,34 @@
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 { loadContractArtifact } from '@aztec/stdlib/abi';
5
+
6
+ import { StubBaseAccountContract } from '../../defaults/stub_account_contract.js';
7
+
8
+ /**
9
+ * Lazily loads the Schnorr stub contract artifact (browser-compatible).
10
+ */
11
+ export async function getStubSchnorrAccountContractArtifact() {
12
+ // Cannot assert this import as it's incompatible with bundlers like vite
13
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
14
+ const { default: json } = await import('../../../artifacts/SimulatedSchnorrAccount.json');
15
+ return loadContractArtifact(json);
16
+ }
17
+
18
+ /** Stub account contract for Schnorr accounts. Lazily loads the contract artifact. */
19
+ export class StubSchnorrAccountContract extends StubBaseAccountContract {
20
+ override getContractArtifact() {
21
+ return getStubSchnorrAccountContractArtifact();
22
+ }
23
+ }
24
+
25
+ /** Creates a Schnorr stub account that impersonates the one with the provided address. */
26
+ export function createStubSchnorrAccount(originalAddress: CompleteAddress) {
27
+ const accountContract = new StubSchnorrAccountContract();
28
+ const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
29
+ return new BaseAccount(
30
+ new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
31
+ authWitnessProvider,
32
+ originalAddress,
33
+ );
34
+ }
@@ -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
 
@@ -16,6 +17,11 @@ export const INITIAL_TEST_SIGNING_KEYS = INITIAL_TEST_ENCRYPTION_KEYS;
16
17
 
17
18
  export const INITIAL_TEST_ACCOUNT_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];
18
19
 
20
+ /**
21
+ * The schnorr account contract variant a test account uses.
22
+ */
23
+ export type InitialAccountType = 'schnorr' | 'schnorr_initializerless';
24
+
19
25
  /**
20
26
  * Data for generating an initial account.
21
27
  */
@@ -36,4 +42,8 @@ export interface InitialAccountData {
36
42
  * Address of the schnorr account contract.
37
43
  */
38
44
  address: AztecAddress;
45
+ /**
46
+ * Account contract variant.
47
+ */
48
+ type?: InitialAccountType;
39
49
  }
@@ -1,18 +1,21 @@
1
1
  /**
2
- * The `@aztec/accounts/testing` export provides utility methods for testing, in particular in a Sandbox environment.
2
+ * The `@aztec/accounts/testing` export provides utility methods for testing, in particular in a local network environment.
3
3
  *
4
4
  * @packageDocumentation
5
5
  */
6
6
  import { Fr } from '@aztec/aztec.js/fields';
7
+ import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
7
8
  import { deriveSigningKey } from '@aztec/stdlib/keys';
8
9
 
9
- import { getSchnorrAccountContractAddress } from '../schnorr/index.js';
10
+ import { getSchnorrInitializerlessAccountContractAddress } from '../schnorr/initializerless/index.js';
11
+ import { getSchnorrAccountContractAddress } from '../schnorr/private_immutable/index.js';
10
12
  import {
11
13
  INITIAL_TEST_ACCOUNT_SALTS,
12
14
  INITIAL_TEST_ENCRYPTION_KEYS,
13
15
  INITIAL_TEST_SECRET_KEYS,
14
16
  INITIAL_TEST_SIGNING_KEYS,
15
17
  type InitialAccountData,
18
+ type InitialAccountType,
16
19
  } from './configuration.js';
17
20
 
18
21
  export {
@@ -21,8 +24,16 @@ export {
21
24
  INITIAL_TEST_SECRET_KEYS,
22
25
  INITIAL_TEST_SIGNING_KEYS,
23
26
  type InitialAccountData,
27
+ type InitialAccountType,
24
28
  } from './configuration.js';
25
29
 
30
+ /** Derives the account contract address for the given type */
31
+ function getTestAccountAddress(type: InitialAccountType, secret: Fr, salt: Fr, signingKey?: GrumpkinScalar) {
32
+ return type === 'schnorr'
33
+ ? getSchnorrAccountContractAddress(secret, salt, signingKey)
34
+ : getSchnorrInitializerlessAccountContractAddress(secret, salt, signingKey);
35
+ }
36
+
26
37
  /**
27
38
  * Gets the basic information for initial test accounts.
28
39
  */
@@ -32,7 +43,8 @@ export function getInitialTestAccountsData(): Promise<InitialAccountData[]> {
32
43
  secret,
33
44
  signingKey: INITIAL_TEST_ENCRYPTION_KEYS[i],
34
45
  salt: INITIAL_TEST_ACCOUNT_SALTS[i],
35
- address: await getSchnorrAccountContractAddress(
46
+ type: 'schnorr_initializerless' as const,
47
+ address: await getSchnorrInitializerlessAccountContractAddress(
36
48
  secret,
37
49
  INITIAL_TEST_ACCOUNT_SALTS[i],
38
50
  INITIAL_TEST_SIGNING_KEYS[i],
@@ -42,9 +54,12 @@ export function getInitialTestAccountsData(): Promise<InitialAccountData[]> {
42
54
  }
43
55
 
44
56
  /**
45
- * Generate a fixed amount of random schnorr account contract instance.
57
+ * Generate a fixed amount of random schnorr account contract instances of the given type
46
58
  */
47
- export async function generateSchnorrAccounts(numberOfAccounts: number): Promise<Promise<InitialAccountData[]>> {
59
+ export async function generateSchnorrAccounts(
60
+ numberOfAccounts: number,
61
+ type: InitialAccountType = 'schnorr_initializerless',
62
+ ): Promise<InitialAccountData[]> {
48
63
  const secrets = Array.from({ length: numberOfAccounts }, () => Fr.random());
49
64
  return await Promise.all(
50
65
  secrets.map(async secret => {
@@ -53,7 +68,8 @@ export async function generateSchnorrAccounts(numberOfAccounts: number): Promise
53
68
  secret,
54
69
  signingKey: deriveSigningKey(secret),
55
70
  salt,
56
- address: await getSchnorrAccountContractAddress(secret, salt),
71
+ type,
72
+ address: await getTestAccountAddress(type, secret, salt),
57
73
  };
58
74
  }),
59
75
  );
@@ -1,22 +1,32 @@
1
1
  /**
2
- * The `@aztec/accounts/testing/lazy` export provides utility methods for testing, in particular in a Sandbox environment.
2
+ * The `@aztec/accounts/testing/lazy` export provides utility methods for testing, in particular in a local network environment.
3
3
  *
4
4
  * @packageDocumentation
5
5
  */
6
6
  import { Fr } from '@aztec/aztec.js/fields';
7
+ import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
7
8
  import { deriveSigningKey } from '@aztec/stdlib/keys';
8
9
 
9
- import { getSchnorrAccountContractAddress } from '../schnorr/lazy.js';
10
+ import { getSchnorrInitializerlessAccountContractAddress } from '../schnorr/initializerless/lazy.js';
11
+ import { getSchnorrAccountContractAddress } from '../schnorr/private_immutable/lazy.js';
10
12
  import {
11
13
  INITIAL_TEST_ACCOUNT_SALTS,
12
14
  INITIAL_TEST_ENCRYPTION_KEYS,
13
15
  INITIAL_TEST_SECRET_KEYS,
14
16
  INITIAL_TEST_SIGNING_KEYS,
15
17
  type InitialAccountData,
18
+ type InitialAccountType,
16
19
  } from './configuration.js';
17
20
 
18
21
  export { INITIAL_TEST_ACCOUNT_SALTS, INITIAL_TEST_SECRET_KEYS } from './configuration.js';
19
22
 
23
+ /** Derives the account contract address for the given type */
24
+ function getTestAccountAddress(type: InitialAccountType, secret: Fr, salt: Fr, signingKey?: GrumpkinScalar) {
25
+ return type === 'schnorr'
26
+ ? getSchnorrAccountContractAddress(secret, salt, signingKey)
27
+ : getSchnorrInitializerlessAccountContractAddress(secret, salt, signingKey);
28
+ }
29
+
20
30
  /**
21
31
  * Gets the basic information for initial test accounts.
22
32
  */
@@ -26,7 +36,8 @@ export function getInitialTestAccountsData(): Promise<InitialAccountData[]> {
26
36
  secret,
27
37
  signingKey: INITIAL_TEST_ENCRYPTION_KEYS[i],
28
38
  salt: INITIAL_TEST_ACCOUNT_SALTS[i],
29
- address: await getSchnorrAccountContractAddress(
39
+ type: 'schnorr_initializerless' as const,
40
+ address: await getSchnorrInitializerlessAccountContractAddress(
30
41
  secret,
31
42
  INITIAL_TEST_ACCOUNT_SALTS[i],
32
43
  INITIAL_TEST_SIGNING_KEYS[i],
@@ -36,9 +47,12 @@ export function getInitialTestAccountsData(): Promise<InitialAccountData[]> {
36
47
  }
37
48
 
38
49
  /**
39
- * Generate a fixed amount of random schnorr account contract instance.
50
+ * Generate a fixed amount of random schnorr account contract instances of the given type
40
51
  */
41
- export async function generateSchnorrAccounts(numberOfAccounts: number): Promise<InitialAccountData[]> {
52
+ export async function generateSchnorrAccounts(
53
+ numberOfAccounts: number,
54
+ type: InitialAccountType = 'schnorr_initializerless',
55
+ ): Promise<InitialAccountData[]> {
42
56
  const secrets = Array.from({ length: numberOfAccounts }, () => Fr.random());
43
57
  return await Promise.all(
44
58
  secrets.map(async secret => {
@@ -47,7 +61,8 @@ export async function generateSchnorrAccounts(numberOfAccounts: number): Promise
47
61
  secret,
48
62
  signingKey: deriveSigningKey(secret),
49
63
  salt,
50
- address: await getSchnorrAccountContractAddress(secret, salt),
64
+ type,
65
+ address: await getTestAccountAddress(type, secret, salt),
51
66
  };
52
67
  }),
53
68
  );
@@ -41,6 +41,7 @@ type StoredKey = {
41
41
  export function getIdentities(): Promise<StoredKey[]> {
42
42
  return new Promise((resolve, reject) => {
43
43
  const stream = connectToAgent();
44
+ stream.on('error', reject);
44
45
  stream.on('connect', () => {
45
46
  const request = Buffer.concat([
46
47
  Buffer.from([0, 0, 0, 5 + 4]), // length
@@ -96,6 +97,7 @@ export function getIdentities(): Promise<StoredKey[]> {
96
97
  export function signWithAgent(keyType: Buffer, curveName: Buffer, publicKey: Buffer, data: Buffer) {
97
98
  return new Promise<Buffer>((resolve, reject) => {
98
99
  const stream = connectToAgent();
100
+ stream.on('error', reject);
99
101
  stream.on('connect', () => {
100
102
  // Construct the key blob
101
103
  const keyBlob = Buffer.concat([