@aztec/accounts 2.1.0-rc.9 → 3.0.0-devnet.2

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 (90) hide show
  1. package/artifacts/EcdsaKAccount.json +888 -1159
  2. package/artifacts/EcdsaRAccount.json +888 -1159
  3. package/artifacts/SchnorrAccount.json +992 -1262
  4. package/artifacts/SchnorrSingleKeyAccount.json +456 -672
  5. package/artifacts/SimulatedAccount.json +420 -644
  6. package/dest/defaults/account_contract.d.ts +3 -3
  7. package/dest/defaults/account_contract.d.ts.map +1 -1
  8. package/dest/defaults/account_contract.js +2 -2
  9. package/dest/defaults/account_interface.d.ts +5 -4
  10. package/dest/defaults/account_interface.d.ts.map +1 -1
  11. package/dest/defaults/account_interface.js +6 -7
  12. package/dest/ecdsa/ecdsa_k/index.d.ts +0 -22
  13. package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
  14. package/dest/ecdsa/ecdsa_k/index.js +1 -22
  15. package/dest/ecdsa/ecdsa_k/lazy.d.ts +0 -22
  16. package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -1
  17. package/dest/ecdsa/ecdsa_k/lazy.js +5 -26
  18. package/dest/ecdsa/ecdsa_r/index.d.ts +0 -22
  19. package/dest/ecdsa/ecdsa_r/index.d.ts.map +1 -1
  20. package/dest/ecdsa/ecdsa_r/index.js +1 -22
  21. package/dest/ecdsa/ecdsa_r/lazy.d.ts +0 -22
  22. package/dest/ecdsa/ecdsa_r/lazy.d.ts.map +1 -1
  23. package/dest/ecdsa/ecdsa_r/lazy.js +5 -26
  24. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +1 -23
  25. package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
  26. package/dest/ecdsa/ssh_ecdsa_r/index.js +3 -24
  27. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +1 -23
  28. package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -1
  29. package/dest/ecdsa/ssh_ecdsa_r/lazy.js +3 -24
  30. package/dest/schnorr/index.d.ts +1 -36
  31. package/dest/schnorr/index.d.ts.map +1 -1
  32. package/dest/schnorr/index.js +1 -32
  33. package/dest/schnorr/lazy.d.ts +1 -36
  34. package/dest/schnorr/lazy.d.ts.map +1 -1
  35. package/dest/schnorr/lazy.js +5 -36
  36. package/dest/single_key/index.d.ts +1 -20
  37. package/dest/single_key/index.d.ts.map +1 -1
  38. package/dest/single_key/index.js +1 -23
  39. package/dest/single_key/lazy.d.ts +1 -20
  40. package/dest/single_key/lazy.d.ts.map +1 -1
  41. package/dest/single_key/lazy.js +5 -27
  42. package/dest/stub/account_contract.d.ts +29 -0
  43. package/dest/stub/account_contract.d.ts.map +1 -0
  44. package/dest/stub/account_contract.js +30 -0
  45. package/dest/stub/index.d.ts +21 -0
  46. package/dest/stub/index.d.ts.map +1 -0
  47. package/dest/stub/index.js +29 -0
  48. package/dest/stub/lazy.d.ts +23 -0
  49. package/dest/stub/lazy.d.ts.map +1 -0
  50. package/dest/stub/lazy.js +35 -0
  51. package/dest/testing/index.d.ts +5 -35
  52. package/dest/testing/index.d.ts.map +1 -1
  53. package/dest/testing/index.js +18 -34
  54. package/dest/testing/lazy.d.ts +4 -27
  55. package/dest/testing/lazy.d.ts.map +1 -1
  56. package/dest/testing/lazy.js +18 -29
  57. package/package.json +8 -6
  58. package/src/defaults/account_contract.ts +4 -4
  59. package/src/defaults/account_interface.ts +11 -11
  60. package/src/ecdsa/ecdsa_k/index.ts +0 -32
  61. package/src/ecdsa/ecdsa_k/lazy.ts +4 -36
  62. package/src/ecdsa/ecdsa_r/index.ts +0 -32
  63. package/src/ecdsa/ecdsa_r/lazy.ts +4 -36
  64. package/src/ecdsa/ssh_ecdsa_r/index.ts +2 -35
  65. package/src/ecdsa/ssh_ecdsa_r/lazy.ts +2 -35
  66. package/src/schnorr/index.ts +7 -55
  67. package/src/schnorr/lazy.ts +11 -59
  68. package/src/single_key/index.ts +1 -32
  69. package/src/single_key/lazy.ts +5 -36
  70. package/src/stub/account_contract.ts +39 -0
  71. package/src/stub/index.ts +41 -0
  72. package/src/stub/lazy.ts +49 -0
  73. package/src/testing/index.ts +19 -56
  74. package/src/testing/lazy.ts +17 -49
  75. package/dest/copy_cat/base.d.ts +0 -18
  76. package/dest/copy_cat/base.d.ts.map +0 -1
  77. package/dest/copy_cat/base.js +0 -28
  78. package/dest/copy_cat/index.d.ts +0 -10
  79. package/dest/copy_cat/index.d.ts.map +0 -1
  80. package/dest/copy_cat/index.js +0 -31
  81. package/dest/copy_cat/lazy.d.ts +0 -9
  82. package/dest/copy_cat/lazy.d.ts.map +0 -1
  83. package/dest/copy_cat/lazy.js +0 -29
  84. package/dest/testing/create_account.d.ts +0 -43
  85. package/dest/testing/create_account.d.ts.map +0 -1
  86. package/dest/testing/create_account.js +0 -61
  87. package/src/copy_cat/base.ts +0 -47
  88. package/src/copy_cat/index.ts +0 -44
  89. package/src/copy_cat/lazy.ts +0 -40
  90. package/src/testing/create_account.ts +0 -111
@@ -4,13 +4,11 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
- import { AccountManager, type Salt, getAccountContractAddress } from '@aztec/aztec.js/account';
8
- import { type AccountWallet, type AccountWalletWithSecretKey, getWallet } from '@aztec/aztec.js/wallet';
7
+ import { getAccountContractAddress } from '@aztec/aztec.js/account';
8
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
9
9
  import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
10
10
  import type { ContractArtifact } from '@aztec/stdlib/abi';
11
11
  import { loadContractArtifact } from '@aztec/stdlib/abi';
12
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
13
- import type { PXE } from '@aztec/stdlib/interfaces/client';
14
12
  import { deriveSigningKey } from '@aztec/stdlib/keys';
15
13
  import type { NoirCompiledContract } from '@aztec/stdlib/noir';
16
14
 
@@ -34,63 +32,17 @@ export class SchnorrAccountContract extends SchnorrBaseAccountContract {
34
32
  }
35
33
  }
36
34
 
37
- /**
38
- * Creates an Account Manager that relies on a Grumpkin signing key for authentication.
39
- * @param pxe - An PXE server instance.
40
- * @param secretKey - Secret key used to derive all the keystore keys.
41
- * @param signingPrivateKey - Grumpkin key used for signing transactions.
42
- * @param salt - Deployment salt.
43
- * @returns An account manager initialized with the account contract and its deployment params
44
- */
45
- export function getSchnorrAccount(
46
- pxe: PXE,
47
- secretKey: Fr,
48
- signingPrivateKey: GrumpkinScalar,
49
- salt?: Salt,
50
- ): Promise<AccountManager> {
51
- return AccountManager.create(pxe, secretKey, new SchnorrAccountContract(signingPrivateKey), salt);
52
- }
53
-
54
- /**
55
- * Gets a wallet for an already registered account using Schnorr signatures.
56
- * @param pxe - An PXE server instance.
57
- * @param address - Address for the account.
58
- * @param signingPrivateKey - Grumpkin key used for signing transactions.
59
- * @returns A wallet for this account that can be used to interact with a contract instance.
60
- */
61
- export function getSchnorrWallet(
62
- pxe: PXE,
63
- address: AztecAddress,
64
- signingPrivateKey: GrumpkinScalar,
65
- ): Promise<AccountWallet> {
66
- return getWallet(pxe, address, new SchnorrAccountContract(signingPrivateKey));
67
- }
68
-
69
- /**
70
- * Gets a wallet for an already registered account using Schnorr signatures.
71
- * @param pxe - An PXE server instance.
72
- * @param secretKey - Secret key used to derive all the keystore keys.
73
- * @param signingPrivateKey - Grumpkin key used for signing transactions.
74
- * @param salt - Deployment salt.
75
- * @returns A wallet for this account that can be used to interact with a contract instance.
76
- */
77
- export async function getSchnorrWalletWithSecretKey(
78
- pxe: PXE,
79
- secretKey: Fr,
80
- signingPrivateKey: GrumpkinScalar,
81
- salt: Salt,
82
- ): Promise<AccountWalletWithSecretKey> {
83
- const account = await getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt);
84
- return account.getWallet();
85
- }
86
-
87
35
  /**
88
36
  * Compute the address of a schnorr account contract.
89
37
  * @param secret - A seed for deriving the signing key and public keys.
90
38
  * @param salt - The contract address salt.
91
39
  * @param signingPrivateKey - A specific signing private key that's not derived from the secret.
92
40
  */
93
- export async function getSchnorrAccountContractAddress(secret: Fr, salt: Fr, signingPrivateKey?: GrumpkinScalar) {
41
+ export async function getSchnorrAccountContractAddress(
42
+ secret: Fr,
43
+ salt: Fr,
44
+ signingPrivateKey?: GrumpkinScalar,
45
+ ): Promise<AztecAddress> {
94
46
  const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
95
47
  const accountContract = new SchnorrAccountContract(signingKey);
96
48
  return await getAccountContractAddress(accountContract, secret, salt);
@@ -4,13 +4,11 @@
4
4
  *
5
5
  * @packageDocumentation
6
6
  */
7
- import { AccountManager, type Salt, getAccountContractAddress } from '@aztec/aztec.js/account';
8
- import { type AccountWallet, type AccountWalletWithSecretKey, getWallet } from '@aztec/aztec.js/wallet';
7
+ import { getAccountContractAddress } from '@aztec/aztec.js/account';
9
8
  import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
10
9
  import type { ContractArtifact } from '@aztec/stdlib/abi';
11
10
  import { loadContractArtifact } from '@aztec/stdlib/abi';
12
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
13
- import type { PXE } from '@aztec/stdlib/interfaces/client';
11
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
14
12
  import { deriveSigningKey } from '@aztec/stdlib/keys';
15
13
 
16
14
  import { SchnorrBaseAccountContract } from './account_contract.js';
@@ -20,10 +18,10 @@ import { SchnorrBaseAccountContract } from './account_contract.js';
20
18
  * @returns The contract artifact for the schnorr account contract
21
19
  */
22
20
  export async function getSchnorrAccountContractArtifact() {
23
- // Cannot assert this import as it's incompatible with browsers
24
- // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
25
- // Use the new "with" syntax once supported by firefox
26
- // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
21
+ // Cannot assert this import as it's incompatible with bundlers like vite
22
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
23
+ // Even if now supported by al major browsers, the MIME type is replaced with
24
+ // "text/javascript"
27
25
  // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
28
26
  const { default: schnorrAccountContractJson } = await import('../../artifacts/SchnorrAccount.json');
29
27
  return loadContractArtifact(schnorrAccountContractJson);
@@ -44,63 +42,17 @@ export class SchnorrAccountContract extends SchnorrBaseAccountContract {
44
42
  }
45
43
  }
46
44
 
47
- /**
48
- * Creates an Account Manager that relies on a Grumpkin signing key for authentication.
49
- * @param pxe - An PXE server instance.
50
- * @param secretKey - Secret key used to derive all the keystore keys.
51
- * @param signingPrivateKey - Grumpkin key used for signing transactions.
52
- * @param salt - Deployment salt.
53
- * @returns An account manager initialized with the account contract and its deployment params
54
- */
55
- export function getSchnorrAccount(
56
- pxe: PXE,
57
- secretKey: Fr,
58
- signingPrivateKey: GrumpkinScalar,
59
- salt?: Salt,
60
- ): Promise<AccountManager> {
61
- return AccountManager.create(pxe, secretKey, new SchnorrAccountContract(signingPrivateKey), salt);
62
- }
63
-
64
- /**
65
- * Gets a wallet for an already registered account using Schnorr signatures.
66
- * @param pxe - An PXE server instance.
67
- * @param address - Address for the account.
68
- * @param signingPrivateKey - Grumpkin key used for signing transactions.
69
- * @returns A wallet for this account that can be used to interact with a contract instance.
70
- */
71
- export function getSchnorrWallet(
72
- pxe: PXE,
73
- address: AztecAddress,
74
- signingPrivateKey: GrumpkinScalar,
75
- ): Promise<AccountWallet> {
76
- return getWallet(pxe, address, new SchnorrAccountContract(signingPrivateKey));
77
- }
78
-
79
- /**
80
- * Gets a wallet for an already registered account using Schnorr signatures.
81
- * @param pxe - An PXE server instance.
82
- * @param secretKey - Secret key used to derive all the keystore keys.
83
- * @param signingPrivateKey - Grumpkin key used for signing transactions.
84
- * @param salt - Deployment salt.
85
- * @returns A wallet for this account that can be used to interact with a contract instance.
86
- */
87
- export async function getSchnorrWalletWithSecretKey(
88
- pxe: PXE,
89
- secretKey: Fr,
90
- signingPrivateKey: GrumpkinScalar,
91
- salt: Salt,
92
- ): Promise<AccountWalletWithSecretKey> {
93
- const account = await getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt);
94
- return account.getWallet();
95
- }
96
-
97
45
  /**
98
46
  * Compute the address of a schnorr account contract.
99
47
  * @param secret - A seed for deriving the signing key and public keys.
100
48
  * @param salt - The contract address salt.
101
49
  * @param signingPrivateKey - A specific signing private key that's not derived from the secret.
102
50
  */
103
- export async function getSchnorrAccountContractAddress(secret: Fr, salt: Fr, signingPrivateKey?: GrumpkinScalar) {
51
+ export async function getSchnorrAccountContractAddress(
52
+ secret: Fr,
53
+ salt: Fr,
54
+ signingPrivateKey?: GrumpkinScalar,
55
+ ): Promise<AztecAddress> {
104
56
  const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
105
57
  const accountContract = new SchnorrAccountContract(signingKey);
106
58
  return await getAccountContractAddress(accountContract, secret, salt);
@@ -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
  import type { NoirCompiledContract } from '@aztec/stdlib/noir';
15
11
 
16
12
  import SchnorrSingleKeyAccountContractJson from '../../artifacts/SchnorrSingleKeyAccount.json' with { type: 'json' };
@@ -34,30 +30,3 @@ export class SingleKeyAccountContract extends SingleKeyBaseAccountContract {
34
30
  return Promise.resolve(SchnorrSingleKeyAccountContractArtifact);
35
31
  }
36
32
  }
37
-
38
- /**
39
- * Creates an Account that uses the same Grumpkin key for encryption and authentication.
40
- * @param pxe - An PXE server instance.
41
- * @param secretKey - Secret key used to derive all the keystore keys (in this case also used to get signing key).
42
- * @param salt - Deployment salt.
43
- * @returns An account manager initialized with the account contract and its deployment params
44
- */
45
- export function getUnsafeSchnorrAccount(pxe: PXE, secretKey: Fr, salt?: Salt) {
46
- const encryptionPrivateKey = deriveMasterIncomingViewingSecretKey(secretKey);
47
- return AccountManager.create(pxe, secretKey, new SingleKeyAccountContract(encryptionPrivateKey), salt);
48
- }
49
-
50
- /**
51
- * Gets a wallet for an already registered account using Schnorr signatures with a single key for encryption and authentication.
52
- * @param pxe - An PXE server instance.
53
- * @param address - Address for the account.
54
- * @param signingPrivateKey - Grumpkin key used for note encryption and signing transactions.
55
- * @returns A wallet for this account that can be used to interact with a contract instance.
56
- */
57
- export function getUnsafeSchnorrWallet(
58
- pxe: PXE,
59
- address: AztecAddress,
60
- signingPrivateKey: GrumpkinScalar,
61
- ): Promise<AccountWallet> {
62
- return getWallet(pxe, address, new SingleKeyAccountContract(signingPrivateKey));
63
- }
@@ -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/fields';
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,38 +1,32 @@
1
1
  /**
2
2
  * The `@aztec/accounts/testing` export provides utility methods for testing, in particular in a Sandbox environment.
3
3
  *
4
- * Use {@link getInitialTestAccountsWallets} to obtain a list of wallets for the Sandbox pre-seeded accounts.
5
- *
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
2
  * The `@aztec/accounts/testing/lazy` export provides utility methods for testing, in particular in a Sandbox environment.
3
3
  *
4
- * Use {@link getInitialTestAccountsWallets} to obtain a list of wallets for the Sandbox pre-seeded accounts.
5
- *
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"}