@aztec/accounts 0.71.0 → 0.73.0
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/artifacts/EcdsaKAccount.json +494 -497
- package/artifacts/EcdsaRAccount.json +492 -495
- package/artifacts/SchnorrAccount.json +749 -756
- package/artifacts/SchnorrSingleKeyAccount.json +126 -126
- package/dest/defaults/account_contract.d.ts +1 -1
- package/dest/defaults/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.js +5 -5
- package/dest/ecdsa/ecdsa_k/index.d.ts +2 -1
- package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/index.js +3 -2
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +2 -2
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +2 -1
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/index.js +3 -2
- package/dest/schnorr/account_contract.d.ts +1 -1
- package/dest/schnorr/account_contract.d.ts.map +1 -1
- package/dest/schnorr/account_contract.js +6 -6
- package/dest/schnorr/index.d.ts +2 -1
- package/dest/schnorr/index.d.ts.map +1 -1
- package/dest/schnorr/index.js +3 -2
- package/dest/single_key/account_contract.d.ts +1 -1
- package/dest/single_key/account_contract.d.ts.map +1 -1
- package/dest/single_key/account_contract.js +4 -4
- package/dest/single_key/index.d.ts +2 -1
- package/dest/single_key/index.d.ts.map +1 -1
- package/dest/single_key/index.js +3 -2
- package/dest/testing/configuration.d.ts.map +1 -1
- package/dest/testing/configuration.js +21 -13
- package/dest/testing/create_account.d.ts.map +1 -1
- package/dest/testing/create_account.js +7 -6
- package/package.json +8 -8
- package/src/defaults/account_contract.ts +1 -1
- package/src/ecdsa/ecdsa_k/account_contract.ts +4 -4
- package/src/ecdsa/ecdsa_k/index.ts +8 -2
- package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +1 -1
- package/src/ecdsa/ssh_ecdsa_r/index.ts +8 -2
- package/src/schnorr/account_contract.ts +5 -5
- package/src/schnorr/index.ts +3 -2
- package/src/single_key/account_contract.ts +4 -4
- package/src/single_key/index.ts +3 -2
- package/src/testing/configuration.ts +44 -22
- package/src/testing/create_account.ts +8 -5
|
@@ -20,9 +20,15 @@ export { EcdsaKAccountContract };
|
|
|
20
20
|
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
21
21
|
* @param signingPrivateKey - Secp256k1 key used for signing transactions.
|
|
22
22
|
* @param salt - Deployment salt.
|
|
23
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
23
24
|
*/
|
|
24
|
-
export function getEcdsaKAccount(
|
|
25
|
-
|
|
25
|
+
export function getEcdsaKAccount(
|
|
26
|
+
pxe: PXE,
|
|
27
|
+
secretKey: Fr,
|
|
28
|
+
signingPrivateKey: Buffer,
|
|
29
|
+
salt?: Salt,
|
|
30
|
+
): Promise<AccountManager> {
|
|
31
|
+
return AccountManager.create(pxe, secretKey, new EcdsaKAccountContract(signingPrivateKey), salt);
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
/**
|
|
@@ -22,7 +22,7 @@ export class EcdsaRSSHAccountContract extends DefaultAccountContract {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
getDeploymentArgs() {
|
|
25
|
-
return [this.signingPublicKey.subarray(0, 32), this.signingPublicKey.subarray(32, 64)];
|
|
25
|
+
return Promise.resolve([this.signingPublicKey.subarray(0, 32), this.signingPublicKey.subarray(32, 64)]);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider {
|
|
@@ -20,9 +20,15 @@ export { EcdsaRSSHAccountContract };
|
|
|
20
20
|
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
21
21
|
* @param signingPublicKey - Secp2561 key used to identify its corresponding private key in the SSH Agent.
|
|
22
22
|
* @param salt - Deployment salt.
|
|
23
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
23
24
|
*/
|
|
24
|
-
export function getEcdsaRSSHAccount(
|
|
25
|
-
|
|
25
|
+
export function getEcdsaRSSHAccount(
|
|
26
|
+
pxe: PXE,
|
|
27
|
+
secretKey: Fr,
|
|
28
|
+
signingPublicKey: Buffer,
|
|
29
|
+
salt?: Salt,
|
|
30
|
+
): Promise<AccountManager> {
|
|
31
|
+
return AccountManager.create(pxe, secretKey, new EcdsaRSSHAccountContract(signingPublicKey), salt);
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
/**
|
|
@@ -16,8 +16,8 @@ export class SchnorrAccountContract extends DefaultAccountContract {
|
|
|
16
16
|
super(SchnorrAccountContractArtifact as ContractArtifact);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
getDeploymentArgs() {
|
|
20
|
-
const signingPublicKey = new Schnorr().computePublicKey(this.signingPrivateKey);
|
|
19
|
+
async getDeploymentArgs() {
|
|
20
|
+
const signingPublicKey = await new Schnorr().computePublicKey(this.signingPrivateKey);
|
|
21
21
|
return [signingPublicKey.x, signingPublicKey.y];
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -30,9 +30,9 @@ export class SchnorrAccountContract extends DefaultAccountContract {
|
|
|
30
30
|
class SchnorrAuthWitnessProvider implements AuthWitnessProvider {
|
|
31
31
|
constructor(private signingPrivateKey: GrumpkinScalar) {}
|
|
32
32
|
|
|
33
|
-
createAuthWit(messageHash: Fr): Promise<AuthWitness> {
|
|
33
|
+
async createAuthWit(messageHash: Fr): Promise<AuthWitness> {
|
|
34
34
|
const schnorr = new Schnorr();
|
|
35
|
-
const signature = schnorr.constructSignature(messageHash.toBuffer(), this.signingPrivateKey)
|
|
36
|
-
return
|
|
35
|
+
const signature = await schnorr.constructSignature(messageHash.toBuffer(), this.signingPrivateKey);
|
|
36
|
+
return new AuthWitness(messageHash, [...signature.toBuffer()]);
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/schnorr/index.ts
CHANGED
|
@@ -21,14 +21,15 @@ export { SchnorrAccountContractArtifact } from './artifact.js';
|
|
|
21
21
|
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
22
22
|
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
23
23
|
* @param salt - Deployment salt.
|
|
24
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
24
25
|
*/
|
|
25
26
|
export function getSchnorrAccount(
|
|
26
27
|
pxe: PXE,
|
|
27
28
|
secretKey: Fr,
|
|
28
29
|
signingPrivateKey: GrumpkinScalar,
|
|
29
30
|
salt?: Salt,
|
|
30
|
-
): AccountManager {
|
|
31
|
-
return
|
|
31
|
+
): Promise<AccountManager> {
|
|
32
|
+
return AccountManager.create(pxe, secretKey, new SchnorrAccountContract(signingPrivateKey), salt);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -16,8 +16,8 @@ export class SingleKeyAccountContract extends DefaultAccountContract {
|
|
|
16
16
|
super(SchnorrSingleKeyAccountContractArtifact as ContractArtifact);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
getDeploymentArgs()
|
|
20
|
-
return undefined;
|
|
19
|
+
getDeploymentArgs() {
|
|
20
|
+
return Promise.resolve(undefined);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
getAuthWitnessProvider(account: CompleteAddress): AuthWitnessProvider {
|
|
@@ -33,9 +33,9 @@ export class SingleKeyAccountContract extends DefaultAccountContract {
|
|
|
33
33
|
class SingleKeyAuthWitnessProvider implements AuthWitnessProvider {
|
|
34
34
|
constructor(private privateKey: GrumpkinScalar, private account: CompleteAddress) {}
|
|
35
35
|
|
|
36
|
-
createAuthWit(messageHash: Fr): Promise<AuthWitness> {
|
|
36
|
+
async createAuthWit(messageHash: Fr): Promise<AuthWitness> {
|
|
37
37
|
const schnorr = new Schnorr();
|
|
38
|
-
const signature = schnorr.constructSignature(messageHash.toBuffer(), this.privateKey);
|
|
38
|
+
const signature = await schnorr.constructSignature(messageHash.toBuffer(), this.privateKey);
|
|
39
39
|
const witness = [...this.account.publicKeys.toFields(), ...signature.toBuffer(), this.account.partialAddress];
|
|
40
40
|
return Promise.resolve(new AuthWitness(messageHash, witness));
|
|
41
41
|
}
|
package/src/single_key/index.ts
CHANGED
|
@@ -20,10 +20,11 @@ export { SchnorrSingleKeyAccountContractArtifact as SingleKeyAccountContractArti
|
|
|
20
20
|
* @param pxe - An PXE server instance.
|
|
21
21
|
* @param secretKey - Secret key used to derive all the keystore keys (in this case also used to get signing key).
|
|
22
22
|
* @param salt - Deployment salt.
|
|
23
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
23
24
|
*/
|
|
24
|
-
export function getSingleKeyAccount(pxe: PXE, secretKey: Fr, salt?: Salt)
|
|
25
|
+
export function getSingleKeyAccount(pxe: PXE, secretKey: Fr, salt?: Salt) {
|
|
25
26
|
const encryptionPrivateKey = deriveMasterIncomingViewingSecretKey(secretKey);
|
|
26
|
-
return
|
|
27
|
+
return AccountManager.create(pxe, secretKey, new SingleKeyAccountContract(encryptionPrivateKey), salt);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -29,9 +29,15 @@ export const INITIAL_TEST_ACCOUNT_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];
|
|
|
29
29
|
*/
|
|
30
30
|
export function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
|
|
31
31
|
return Promise.all(
|
|
32
|
-
INITIAL_TEST_SECRET_KEYS.map((encryptionKey, i) =>
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
INITIAL_TEST_SECRET_KEYS.map(async (encryptionKey, i) => {
|
|
33
|
+
const account = await getSchnorrAccount(
|
|
34
|
+
pxe,
|
|
35
|
+
encryptionKey!,
|
|
36
|
+
INITIAL_TEST_SIGNING_KEYS[i]!,
|
|
37
|
+
INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
38
|
+
);
|
|
39
|
+
return account.getWallet();
|
|
40
|
+
}),
|
|
35
41
|
);
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -42,20 +48,29 @@ export function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWi
|
|
|
42
48
|
*/
|
|
43
49
|
export async function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithSecretKey[]> {
|
|
44
50
|
const registeredAccounts = await pxe.getRegisteredAccounts();
|
|
45
|
-
|
|
46
|
-
INITIAL_TEST_SECRET_KEYS.
|
|
51
|
+
const publicKeys = await Promise.all(
|
|
52
|
+
INITIAL_TEST_SECRET_KEYS.map(async initialSecretKey => {
|
|
47
53
|
const initialEncryptionKey = deriveMasterIncomingViewingSecretKey(initialSecretKey);
|
|
48
|
-
const publicKey = generatePublicKey(initialEncryptionKey);
|
|
49
|
-
return
|
|
50
|
-
registeredAccounts.find(registered => registered.publicKeys.masterIncomingViewingPublicKey.equals(publicKey)) !=
|
|
51
|
-
undefined
|
|
52
|
-
);
|
|
53
|
-
}).map(secretKey => {
|
|
54
|
-
const signingKey = deriveSigningKey(secretKey);
|
|
55
|
-
// TODO(#5726): use actual salt here instead of hardcoding Fr.ZERO
|
|
56
|
-
return getSchnorrAccount(pxe, secretKey, signingKey, Fr.ZERO).getWallet();
|
|
54
|
+
const publicKey = await generatePublicKey(initialEncryptionKey);
|
|
55
|
+
return { sk: initialSecretKey, pk: publicKey };
|
|
57
56
|
}),
|
|
58
57
|
);
|
|
58
|
+
return Promise.all(
|
|
59
|
+
publicKeys
|
|
60
|
+
.filter(keyPairs => {
|
|
61
|
+
return (
|
|
62
|
+
registeredAccounts.find(registered =>
|
|
63
|
+
registered.publicKeys.masterIncomingViewingPublicKey.equals(keyPairs.pk),
|
|
64
|
+
) != undefined
|
|
65
|
+
);
|
|
66
|
+
})
|
|
67
|
+
.map(async keyPairs => {
|
|
68
|
+
const signingKey = deriveSigningKey(keyPairs.sk);
|
|
69
|
+
// TODO(#5726): use actual salt here instead of hardcoding Fr.ZERO
|
|
70
|
+
const account = await getSchnorrAccount(pxe, keyPairs.sk, signingKey, Fr.ZERO);
|
|
71
|
+
return account.getWallet();
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
59
74
|
}
|
|
60
75
|
|
|
61
76
|
/**
|
|
@@ -64,13 +79,20 @@ export async function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountW
|
|
|
64
79
|
* @returns The set of deployed Account objects and associated private encryption keys
|
|
65
80
|
*/
|
|
66
81
|
export async function deployInitialTestAccounts(pxe: PXE) {
|
|
67
|
-
const accounts =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
const accounts = await Promise.all(
|
|
83
|
+
INITIAL_TEST_SECRET_KEYS.map(async (secretKey, i) => {
|
|
84
|
+
const account = await getSchnorrAccount(
|
|
85
|
+
pxe,
|
|
86
|
+
secretKey,
|
|
87
|
+
INITIAL_TEST_SIGNING_KEYS[i],
|
|
88
|
+
INITIAL_TEST_ACCOUNT_SALTS[i],
|
|
89
|
+
);
|
|
90
|
+
return {
|
|
91
|
+
account,
|
|
92
|
+
secretKey,
|
|
93
|
+
};
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
74
96
|
// Register contract class to avoid duplicate nullifier errors
|
|
75
97
|
const { l1ChainId: chainId, protocolVersion } = await pxe.getNodeInfo();
|
|
76
98
|
const deployWallet = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(chainId, protocolVersion));
|
|
@@ -80,7 +102,7 @@ export async function deployInitialTestAccounts(pxe: PXE) {
|
|
|
80
102
|
accounts.map(async x => {
|
|
81
103
|
const deployMethod = await x.account.getDeployMethod();
|
|
82
104
|
const tx = await deployMethod.prove({
|
|
83
|
-
contractAddressSalt: x.account.salt,
|
|
105
|
+
contractAddressSalt: new Fr(x.account.salt),
|
|
84
106
|
universalDeploy: true,
|
|
85
107
|
});
|
|
86
108
|
return tx;
|
|
@@ -10,10 +10,11 @@ import { getSchnorrAccount } from '../schnorr/index.js';
|
|
|
10
10
|
* @param pxe - PXE.
|
|
11
11
|
* @returns - A wallet for a fresh account.
|
|
12
12
|
*/
|
|
13
|
-
export function createAccount(pxe: PXE): Promise<AccountWalletWithSecretKey> {
|
|
13
|
+
export async function createAccount(pxe: PXE): Promise<AccountWalletWithSecretKey> {
|
|
14
14
|
const secretKey = Fr.random();
|
|
15
15
|
const signingKey = deriveSigningKey(secretKey);
|
|
16
|
-
|
|
16
|
+
const account = await getSchnorrAccount(pxe, secretKey, signingKey);
|
|
17
|
+
return account.waitSetup();
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -40,20 +41,22 @@ export async function createAccounts(
|
|
|
40
41
|
const accountsAndDeployments = await Promise.all(
|
|
41
42
|
secrets.map(async (secret, index) => {
|
|
42
43
|
const signingKey = deriveSigningKey(secret);
|
|
43
|
-
const account = getSchnorrAccount(pxe, secret, signingKey);
|
|
44
|
+
const account = await getSchnorrAccount(pxe, secret, signingKey);
|
|
44
45
|
|
|
45
46
|
// only register the contract class once
|
|
46
47
|
let skipClassRegistration = true;
|
|
47
48
|
if (index === 0) {
|
|
48
49
|
// for the first account, check if the contract class is already registered, otherwise we should register now
|
|
49
|
-
if (
|
|
50
|
+
if (
|
|
51
|
+
!(await pxe.getContractClassMetadata(account.getInstance().contractClassId)).isContractClassPubliclyRegistered
|
|
52
|
+
) {
|
|
50
53
|
skipClassRegistration = false;
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
const deployMethod = await account.getDeployMethod();
|
|
55
58
|
const provenTx = await deployMethod.prove({
|
|
56
|
-
contractAddressSalt: account.salt,
|
|
59
|
+
contractAddressSalt: new Fr(account.salt),
|
|
57
60
|
skipClassRegistration,
|
|
58
61
|
skipPublicDeployment: true,
|
|
59
62
|
universalDeploy: true,
|