@aztec/accounts 0.0.0-test.1 → 0.0.1-commit.017a351
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 +9402 -3941
- package/artifacts/EcdsaRAccount.json +9622 -4161
- package/artifacts/SchnorrAccount.json +9534 -4113
- package/artifacts/SimulatedEcdsaAccount.json +10122 -0
- package/artifacts/SimulatedSchnorrAccount.d.json.ts +3 -0
- package/artifacts/SimulatedSchnorrAccount.json +10214 -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 +13 -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 +45 -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 +13 -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 +11 -10
- 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/ecdsa/index.d.ts +11 -0
- package/dest/stub/ecdsa/index.d.ts.map +1 -0
- package/dest/stub/ecdsa/index.js +18 -0
- package/dest/stub/ecdsa/lazy.d.ts +14 -0
- package/dest/stub/ecdsa/lazy.d.ts.map +1 -0
- package/dest/stub/ecdsa/lazy.js +22 -0
- package/dest/stub/schnorr/index.d.ts +11 -0
- package/dest/stub/schnorr/index.d.ts.map +1 -0
- package/dest/stub/schnorr/index.js +18 -0
- package/dest/stub/schnorr/lazy.d.ts +14 -0
- package/dest/stub/schnorr/lazy.d.ts.map +1 -0
- package/dest/stub/schnorr/lazy.js +22 -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/dest/utils/ssh_agent.js +2 -0
- package/package.json +28 -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 +7 -6
- 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/ecdsa/index.ts +28 -0
- package/src/stub/ecdsa/lazy.ts +34 -0
- package/src/stub/schnorr/index.ts +30 -0
- package/src/stub/schnorr/lazy.ts +34 -0
- package/src/testing/configuration.ts +2 -1
- package/src/testing/index.ts +19 -51
- package/src/testing/lazy.ts +18 -50
- package/src/utils/ssh_agent.ts +2 -0
- 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 → SimulatedEcdsaAccount.d.json.ts} +0 -0
|
@@ -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,28 @@
|
|
|
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 SimulatedEcdsaAccountJson from '../../../artifacts/SimulatedEcdsaAccount.json' with { type: 'json' };
|
|
8
|
+
import { StubBaseAccountContract } from '../account_contract.js';
|
|
9
|
+
|
|
10
|
+
export const StubEcdsaAccountContractArtifact = loadContractArtifact(SimulatedEcdsaAccountJson as NoirCompiledContract);
|
|
11
|
+
|
|
12
|
+
/** Stub account contract for ECDSA accounts (secp256k1 and secp256r1). Eagerly loads the contract artifact. */
|
|
13
|
+
export class StubEcdsaAccountContract extends StubBaseAccountContract {
|
|
14
|
+
override getContractArtifact() {
|
|
15
|
+
return Promise.resolve(StubEcdsaAccountContractArtifact);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Creates an ECDSA stub account that impersonates the one with the provided address. */
|
|
20
|
+
export function createStubEcdsaAccount(originalAddress: CompleteAddress) {
|
|
21
|
+
const accountContract = new StubEcdsaAccountContract();
|
|
22
|
+
const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
|
|
23
|
+
return new BaseAccount(
|
|
24
|
+
new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
|
|
25
|
+
authWitnessProvider,
|
|
26
|
+
originalAddress,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -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 '../account_contract.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Lazily loads the ECDSA stub contract artifact (browser-compatible).
|
|
10
|
+
*/
|
|
11
|
+
export async function getStubEcdsaAccountContractArtifact() {
|
|
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/SimulatedEcdsaAccount.json');
|
|
15
|
+
return loadContractArtifact(json);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Stub account contract for ECDSA accounts (secp256k1 and secp256r1). Lazily loads the contract artifact. */
|
|
19
|
+
export class StubEcdsaAccountContract extends StubBaseAccountContract {
|
|
20
|
+
override getContractArtifact() {
|
|
21
|
+
return getStubEcdsaAccountContractArtifact();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Creates an ECDSA stub account that impersonates the one with the provided address. */
|
|
26
|
+
export function createStubEcdsaAccount(originalAddress: CompleteAddress) {
|
|
27
|
+
const accountContract = new StubEcdsaAccountContract();
|
|
28
|
+
const authWitnessProvider = accountContract.getAuthWitnessProvider(originalAddress);
|
|
29
|
+
return new BaseAccount(
|
|
30
|
+
new DefaultAccountEntrypoint(originalAddress.address, authWitnessProvider),
|
|
31
|
+
authWitnessProvider,
|
|
32
|
+
originalAddress,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -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 '../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 '../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
|
|
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
|
-
}
|
package/src/utils/ssh_agent.ts
CHANGED
|
@@ -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([
|