@aztec/accounts 0.0.0-test.1 → 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/single_key/index.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `@aztec/accounts/single_key` export provides a testing account contract implementation that uses a single Grumpkin key for both authentication and encryption.
|
|
3
|
-
* It is not recommended to use this account type in production.
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
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';
|
|
10
|
-
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
-
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
12
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
13
|
-
import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
|
|
14
|
-
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
15
|
-
|
|
16
|
-
import SchnorrSingleKeyAccountContractJson from '../../artifacts/SchnorrSingleKeyAccount.json' assert { type: 'json' };
|
|
17
|
-
import { SingleKeyBaseAccountContract } from './account_contract.js';
|
|
18
|
-
|
|
19
|
-
export const SchnorrSingleKeyAccountContractArtifact = loadContractArtifact(
|
|
20
|
-
SchnorrSingleKeyAccountContractJson as NoirCompiledContract,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Account contract that authenticates transactions using Schnorr signatures verified against
|
|
25
|
-
* the note encryption key, relying on a single private key for both encryption and authentication.
|
|
26
|
-
* Eagerly loads the contract artifact
|
|
27
|
-
*/
|
|
28
|
-
export class SingleKeyAccountContract extends SingleKeyBaseAccountContract {
|
|
29
|
-
constructor(signingPrivateKey: GrumpkinScalar) {
|
|
30
|
-
super(signingPrivateKey);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
override getContractArtifact(): Promise<ContractArtifact> {
|
|
34
|
-
return Promise.resolve(SchnorrSingleKeyAccountContractArtifact);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
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
|
-
}
|
package/src/single_key/lazy.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `@aztec/accounts/single_key` export provides a testing account contract implementation that uses a single Grumpkin key for both authentication and encryption.
|
|
3
|
-
* It is not recommended to use this account type in production.
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
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';
|
|
10
|
-
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
-
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
12
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
13
|
-
import { deriveMasterIncomingViewingSecretKey } from '@aztec/stdlib/keys';
|
|
14
|
-
|
|
15
|
-
import { SingleKeyBaseAccountContract } from './account_contract.js';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Lazily loads the contract artifact
|
|
19
|
-
* @returns The contract artifact for the single key account contract
|
|
20
|
-
*/
|
|
21
|
-
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
|
|
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 verified against
|
|
33
|
-
* the note encryption key, relying on a single private key for both encryption and authentication.
|
|
34
|
-
* Lazily loads the contract artifact
|
|
35
|
-
*/
|
|
36
|
-
export class SingleKeyAccountContract extends SingleKeyBaseAccountContract {
|
|
37
|
-
constructor(signingPrivateKey: GrumpkinScalar) {
|
|
38
|
-
super(signingPrivateKey);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
override getContractArtifact(): Promise<ContractArtifact> {
|
|
42
|
-
return getSingleKeyAccountContractArtifact();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
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
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { type AccountManager, FeeJuicePaymentMethod, type PXE, type WaitOpts } from '@aztec/aztec.js';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
4
|
-
|
|
5
|
-
import { getSchnorrAccount, getSchnorrAccountContractAddress } from '../schnorr/index.js';
|
|
6
|
-
import type { InitialAccountData } from './configuration.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Generate a fixed amount of random schnorr account contract instance.
|
|
10
|
-
*/
|
|
11
|
-
export async function generateSchnorrAccounts(numberOfAccounts: number) {
|
|
12
|
-
const secrets = Array.from({ length: numberOfAccounts }, () => Fr.random());
|
|
13
|
-
return await Promise.all(
|
|
14
|
-
secrets.map(async secret => {
|
|
15
|
-
const salt = Fr.random();
|
|
16
|
-
return {
|
|
17
|
-
secret,
|
|
18
|
-
signingKey: deriveSigningKey(secret),
|
|
19
|
-
salt,
|
|
20
|
-
address: await getSchnorrAccountContractAddress(secret, salt),
|
|
21
|
-
};
|
|
22
|
-
}),
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Data for deploying funded account.
|
|
28
|
-
*/
|
|
29
|
-
type DeployAccountData = Pick<InitialAccountData, 'secret' | 'salt'> & {
|
|
30
|
-
/**
|
|
31
|
-
* An optional signingKey if it's not derived from the secret.
|
|
32
|
-
*/
|
|
33
|
-
signingKey?: InitialAccountData['signingKey'];
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Deploy schnorr account contract.
|
|
38
|
-
* It will pay for the fee for the deployment itself. So it must be funded with the prefilled public data.
|
|
39
|
-
*/
|
|
40
|
-
export async function deployFundedSchnorrAccount(
|
|
41
|
-
pxe: PXE,
|
|
42
|
-
account: DeployAccountData,
|
|
43
|
-
opts: WaitOpts & {
|
|
44
|
-
/**
|
|
45
|
-
* Whether or not to skip registering contract class.
|
|
46
|
-
*/
|
|
47
|
-
skipClassRegistration?: boolean;
|
|
48
|
-
} = { interval: 0.1, skipClassRegistration: false },
|
|
49
|
-
): Promise<AccountManager> {
|
|
50
|
-
const signingKey = account.signingKey ?? deriveSigningKey(account.secret);
|
|
51
|
-
const accountManager = await getSchnorrAccount(pxe, account.secret, signingKey, account.salt);
|
|
52
|
-
|
|
53
|
-
// Pay the fee by the account itself.
|
|
54
|
-
// This only works when the world state is prefilled with the balance for the account in test environment.
|
|
55
|
-
const paymentMethod = new FeeJuicePaymentMethod(accountManager.getAddress());
|
|
56
|
-
|
|
57
|
-
await accountManager
|
|
58
|
-
.deploy({
|
|
59
|
-
skipClassRegistration: opts.skipClassRegistration,
|
|
60
|
-
skipPublicDeployment: true,
|
|
61
|
-
fee: { paymentMethod },
|
|
62
|
-
})
|
|
63
|
-
.wait(opts);
|
|
64
|
-
|
|
65
|
-
return accountManager;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Deploy schnorr account contracts.
|
|
70
|
-
* They will pay for the fees for the deployment themselves. So they must be funded with the prefilled public data.
|
|
71
|
-
*/
|
|
72
|
-
export async function deployFundedSchnorrAccounts(
|
|
73
|
-
pxe: PXE,
|
|
74
|
-
accounts: DeployAccountData[],
|
|
75
|
-
opts: WaitOpts & {
|
|
76
|
-
/**
|
|
77
|
-
* Whether or not to skip registering contract class.
|
|
78
|
-
*/
|
|
79
|
-
skipClassRegistration?: boolean;
|
|
80
|
-
} = { interval: 0.1, skipClassRegistration: false },
|
|
81
|
-
): Promise<AccountManager[]> {
|
|
82
|
-
const accountManagers: AccountManager[] = [];
|
|
83
|
-
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
|
|
84
|
-
for (let i = 0; i < accounts.length; i++) {
|
|
85
|
-
accountManagers.push(
|
|
86
|
-
await deployFundedSchnorrAccount(pxe, accounts[i], {
|
|
87
|
-
...opts,
|
|
88
|
-
skipClassRegistration: i !== 0 || opts.skipClassRegistration, // Register the contract class at most once.
|
|
89
|
-
}),
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
return accountManagers;
|
|
93
|
-
}
|
|
File without changes
|