@aztec/accounts 0.0.0-test.0 → 0.0.1-commit.001888fc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/artifacts/EcdsaKAccount.json +4753 -3882
- package/artifacts/EcdsaRAccount.json +5162 -4291
- package/artifacts/SchnorrAccount.json +5021 -4164
- package/artifacts/SimulatedAccount.json +4745 -0
- package/dest/defaults/account_contract.d.ts +10 -5
- package/dest/defaults/account_contract.d.ts.map +1 -1
- package/dest/defaults/account_contract.js +5 -3
- package/dest/defaults/index.d.ts +2 -3
- package/dest/defaults/index.d.ts.map +1 -1
- package/dest/defaults/index.js +2 -3
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts +5 -4
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.js +9 -6
- package/dest/ecdsa/ecdsa_k/index.d.ts +1 -25
- package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/index.js +2 -23
- package/dest/ecdsa/ecdsa_k/lazy.d.ts +1 -25
- package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/lazy.js +5 -26
- package/dest/ecdsa/ecdsa_r/account_contract.d.ts +19 -0
- package/dest/ecdsa/ecdsa_r/account_contract.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_r/account_contract.js +41 -0
- package/dest/ecdsa/ecdsa_r/index.d.ts +19 -0
- package/dest/ecdsa/ecdsa_r/index.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_r/index.js +23 -0
- package/dest/ecdsa/ecdsa_r/lazy.d.ts +23 -0
- package/dest/ecdsa/ecdsa_r/lazy.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_r/lazy.js +31 -0
- package/dest/ecdsa/index.d.ts +2 -1
- package/dest/ecdsa/index.d.ts.map +1 -1
- package/dest/ecdsa/index.js +1 -0
- package/dest/ecdsa/lazy.d.ts +2 -1
- package/dest/ecdsa/lazy.d.ts.map +1 -1
- package/dest/ecdsa/lazy.js +1 -0
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +5 -4
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +9 -6
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +2 -27
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/index.js +3 -28
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +2 -30
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/lazy.js +3 -38
- package/dest/schnorr/account_contract.d.ts +7 -3
- package/dest/schnorr/account_contract.d.ts.map +1 -1
- package/dest/schnorr/account_contract.js +9 -6
- package/dest/schnorr/index.d.ts +4 -38
- package/dest/schnorr/index.d.ts.map +1 -1
- package/dest/schnorr/index.js +2 -33
- package/dest/schnorr/lazy.d.ts +4 -38
- package/dest/schnorr/lazy.d.ts.map +1 -1
- package/dest/schnorr/lazy.js +5 -36
- package/dest/stub/account_contract.d.ts +29 -0
- package/dest/stub/account_contract.d.ts.map +1 -0
- package/dest/stub/account_contract.js +30 -0
- package/dest/stub/index.d.ts +20 -0
- package/dest/stub/index.d.ts.map +1 -0
- package/dest/stub/index.js +28 -0
- package/dest/stub/lazy.d.ts +25 -0
- package/dest/stub/lazy.d.ts.map +1 -0
- package/dest/stub/lazy.js +37 -0
- package/dest/testing/configuration.d.ts +5 -4
- package/dest/testing/configuration.d.ts.map +1 -1
- package/dest/testing/configuration.js +1 -1
- package/dest/testing/index.d.ts +6 -30
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +18 -30
- package/dest/testing/lazy.d.ts +5 -28
- package/dest/testing/lazy.d.ts.map +1 -1
- package/dest/testing/lazy.js +19 -30
- package/dest/utils/index.d.ts +1 -1
- package/dest/utils/ssh_agent.d.ts +2 -5
- package/dest/utils/ssh_agent.d.ts.map +1 -1
- package/package.json +26 -23
- package/src/defaults/account_contract.ts +19 -7
- package/src/defaults/index.ts +1 -2
- package/src/ecdsa/ecdsa_k/account_contract.ts +7 -4
- package/src/ecdsa/ecdsa_k/index.ts +1 -33
- package/src/ecdsa/ecdsa_k/lazy.ts +4 -36
- package/src/ecdsa/ecdsa_r/account_contract.ts +42 -0
- package/src/ecdsa/ecdsa_r/index.ts +31 -0
- package/src/ecdsa/ecdsa_r/lazy.ts +39 -0
- package/src/ecdsa/index.ts +1 -0
- package/src/ecdsa/lazy.ts +1 -0
- package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +7 -4
- package/src/ecdsa/ssh_ecdsa_r/index.ts +3 -42
- package/src/ecdsa/ssh_ecdsa_r/lazy.ts +3 -53
- package/src/schnorr/account_contract.ts +5 -4
- package/src/schnorr/index.ts +10 -57
- package/src/schnorr/lazy.ts +13 -60
- package/src/stub/account_contract.ts +39 -0
- package/src/stub/index.ts +40 -0
- package/src/stub/lazy.ts +51 -0
- package/src/testing/configuration.ts +2 -1
- package/src/testing/index.ts +19 -51
- package/src/testing/lazy.ts +18 -50
- package/artifacts/SchnorrSingleKeyAccount.json +0 -3937
- package/dest/dapp/dapp_interface.d.ts +0 -10
- package/dest/dapp/dapp_interface.d.ts.map +0 -1
- package/dest/dapp/dapp_interface.js +0 -16
- package/dest/dapp/index.d.ts +0 -2
- package/dest/dapp/index.d.ts.map +0 -1
- package/dest/dapp/index.js +0 -1
- package/dest/defaults/account_interface.d.ts +0 -27
- package/dest/defaults/account_interface.d.ts.map +0 -1
- package/dest/defaults/account_interface.js +0 -37
- package/dest/single_key/account_contract.d.ts +0 -17
- package/dest/single_key/account_contract.d.ts.map +0 -1
- package/dest/single_key/account_contract.js +0 -42
- package/dest/single_key/index.d.ts +0 -39
- package/dest/single_key/index.d.ts.map +0 -1
- package/dest/single_key/index.js +0 -45
- package/dest/single_key/lazy.d.ts +0 -43
- package/dest/single_key/lazy.d.ts.map +0 -1
- package/dest/single_key/lazy.js +0 -53
- package/dest/testing/create_account.d.ts +0 -43
- package/dest/testing/create_account.d.ts.map +0 -1
- package/dest/testing/create_account.js +0 -58
- package/src/dapp/dapp_interface.ts +0 -38
- package/src/dapp/index.ts +0 -1
- package/src/defaults/account_interface.ts +0 -59
- package/src/single_key/account_contract.ts +0 -43
- package/src/single_key/index.ts +0 -63
- package/src/single_key/lazy.ts +0 -71
- package/src/testing/create_account.ts +0 -93
- /package/artifacts/{SchnorrSingleKeyAccount.d.json.ts → SimulatedAccount.d.json.ts} +0 -0
package/src/stub/lazy.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BaseAccount } from '@aztec/aztec.js/account';
|
|
2
|
+
import type { CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
|
|
4
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
5
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
6
|
+
|
|
7
|
+
import { StubBaseAccountContract } from './account_contract.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Lazily loads the contract artifact
|
|
11
|
+
* @returns The contract artifact for the Stub account contract
|
|
12
|
+
*/
|
|
13
|
+
export async function getStubAccountContractArtifact() {
|
|
14
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
15
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
16
|
+
// Even if now supported by al major browsers, the MIME type is replaced with
|
|
17
|
+
// "text/javascript"
|
|
18
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
19
|
+
const { default: StubAccountContractJson } = await import('../../artifacts/SimulatedAccount.json');
|
|
20
|
+
return loadContractArtifact(StubAccountContractJson);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Account contract that authenticates transactions using Stub signatures
|
|
25
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
26
|
+
* Lazily loads the contract artifact
|
|
27
|
+
*/
|
|
28
|
+
export class StubAccountContract extends StubBaseAccountContract {
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override getContractArtifact(): Promise<ContractArtifact> {
|
|
34
|
+
return getStubAccountContractArtifact();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a stub account that impersonates the one with the provided originalAddress.
|
|
40
|
+
* @param originalAddress - The address of the account to stub
|
|
41
|
+
* @returns A stub account that can be used for kernelless simulations
|
|
42
|
+
*/
|
|
43
|
+
export function createStubAccount(originalAddress: CompleteAddress) {
|
|
44
|
+
const accountContract = new StubAccountContract();
|
|
45
|
+
const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
|
|
46
|
+
return new BaseAccount(
|
|
47
|
+
new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
|
|
48
|
+
authWitnessProvider,
|
|
49
|
+
originalAddress,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Fr
|
|
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
|
|
package/src/testing/index.ts
CHANGED
|
@@ -1,38 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `@aztec/accounts/testing` export provides utility methods for testing, in particular in a
|
|
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
|
|
9
|
-
import
|
|
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
|
|
29
|
+
export function getInitialTestAccountsData(): Promise<InitialAccountData[]> {
|
|
36
30
|
return Promise.all(
|
|
37
31
|
INITIAL_TEST_SECRET_KEYS.map(async (secret, i) => ({
|
|
38
32
|
secret,
|
|
@@ -48,45 +42,19 @@ export function getInitialTestAccounts(): Promise<InitialAccountData[]> {
|
|
|
48
42
|
}
|
|
49
43
|
|
|
50
44
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @param pxe - PXE instance.
|
|
53
|
-
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
45
|
+
* Generate a fixed amount of random schnorr account contract instance.
|
|
54
46
|
*/
|
|
55
|
-
export function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
47
|
+
export async function generateSchnorrAccounts(numberOfAccounts: number): Promise<Promise<InitialAccountData[]>> {
|
|
48
|
+
const secrets = Array.from({ length: numberOfAccounts }, () => Fr.random());
|
|
49
|
+
return await Promise.all(
|
|
50
|
+
secrets.map(async secret => {
|
|
51
|
+
const salt = Fr.random();
|
|
52
|
+
return {
|
|
53
|
+
secret,
|
|
54
|
+
signingKey: deriveSigningKey(secret),
|
|
55
|
+
salt,
|
|
56
|
+
address: await getSchnorrAccountContractAddress(secret, salt),
|
|
57
|
+
};
|
|
65
58
|
}),
|
|
66
59
|
);
|
|
67
60
|
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Queries a PXE for it's registered accounts.
|
|
71
|
-
* @param pxe - PXE instance.
|
|
72
|
-
* @returns A set of key data for each of the initial accounts.
|
|
73
|
-
*/
|
|
74
|
-
export async function getDeployedTestAccounts(pxe: PXE): Promise<InitialAccountData[]> {
|
|
75
|
-
const registeredAccounts = await pxe.getRegisteredAccounts();
|
|
76
|
-
const testAccounts = await getInitialTestAccounts();
|
|
77
|
-
return testAccounts.filter(t => registeredAccounts.some(r => r.address.equals(t.address)));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
|
|
82
|
-
* @param pxe - PXE instance.
|
|
83
|
-
* @returns A set of AccountWallet implementations for each of the initial accounts.
|
|
84
|
-
*/
|
|
85
|
-
export async function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
|
|
86
|
-
const testAccounts = await getDeployedTestAccounts(pxe);
|
|
87
|
-
return Promise.all(
|
|
88
|
-
testAccounts.map(({ secret, signingKey, salt }) => getSchnorrWalletWithSecretKey(pxe, secret, signingKey, salt)),
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export { deployFundedSchnorrAccount, deployFundedSchnorrAccounts, generateSchnorrAccounts } from './create_account.js';
|
package/src/testing/lazy.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `@aztec/accounts/testing/lazy` export provides utility methods for testing, in particular in a
|
|
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
|
|
9
|
-
import
|
|
6
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
7
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
10
8
|
|
|
11
|
-
import {
|
|
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
|
|
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
|
-
*
|
|
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
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
}
|