@aztec/node-keystore 0.0.1-fake-ceab37513c → 0.0.2-commit.217f559981
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/dest/config.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/keystore_manager.d.ts +6 -6
- package/dest/keystore_manager.d.ts.map +1 -1
- package/dest/keystore_manager.js +29 -11
- package/dest/loader.d.ts +1 -1
- package/dest/loader.d.ts.map +1 -1
- package/dest/loader.js +76 -20
- package/dest/schemas.d.ts +2372 -426
- package/dest/schemas.d.ts.map +1 -1
- package/dest/schemas.js +61 -17
- package/dest/signer.d.ts +2 -17
- package/dest/signer.d.ts.map +1 -1
- package/dest/signer.js +7 -6
- package/dest/types.d.ts +25 -16
- package/dest/types.d.ts.map +1 -1
- package/package.json +10 -7
- package/src/keystore_manager.ts +46 -14
- package/src/loader.ts +77 -13
- package/src/schemas.ts +110 -46
- package/src/signer.ts +8 -11
- package/src/types.ts +24 -14
package/dest/schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG/D,eAAO,MAAM,mBAAmB,kDAGK,CAAC;AACtC,eAAO,MAAM,mBAAmB,kDAGK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAgD,CAAC"}
|
package/dest/schemas.js
CHANGED
|
@@ -14,7 +14,7 @@ const remoteSignerConfigSchema = z.union([
|
|
|
14
14
|
remoteSignerUrl: urlSchema,
|
|
15
15
|
certPath: optional(z.string()),
|
|
16
16
|
certPass: optional(z.string())
|
|
17
|
-
})
|
|
17
|
+
}).strict()
|
|
18
18
|
]);
|
|
19
19
|
// Remote signer account schema
|
|
20
20
|
const remoteSignerAccountSchema = z.union([
|
|
@@ -24,13 +24,13 @@ const remoteSignerAccountSchema = z.union([
|
|
|
24
24
|
remoteSignerUrl: urlSchema,
|
|
25
25
|
certPath: optional(z.string()),
|
|
26
26
|
certPass: optional(z.string())
|
|
27
|
-
})
|
|
27
|
+
}).strict()
|
|
28
28
|
]);
|
|
29
|
-
// JSON V3
|
|
30
|
-
const
|
|
29
|
+
// Encrypted keystore file schema (used for both JSON V3 ETH keys and EIP-2335 BLS keys)
|
|
30
|
+
const encryptedKeyFileSchema = z.object({
|
|
31
31
|
path: z.string(),
|
|
32
32
|
password: optional(z.string())
|
|
33
|
-
});
|
|
33
|
+
}).strict();
|
|
34
34
|
// Mnemonic config schema
|
|
35
35
|
const mnemonicConfigSchema = z.object({
|
|
36
36
|
mnemonic: z.string().min(1, 'Mnemonic cannot be empty'),
|
|
@@ -38,12 +38,12 @@ const mnemonicConfigSchema = z.object({
|
|
|
38
38
|
accountIndex: z.number().int().min(0).default(0),
|
|
39
39
|
addressCount: z.number().int().min(1).default(1),
|
|
40
40
|
accountCount: z.number().int().min(1).default(1)
|
|
41
|
-
});
|
|
41
|
+
}).strict();
|
|
42
42
|
// EthAccount schema
|
|
43
43
|
const ethAccountSchema = z.union([
|
|
44
44
|
ethPrivateKeySchema,
|
|
45
45
|
remoteSignerAccountSchema,
|
|
46
|
-
|
|
46
|
+
encryptedKeyFileSchema
|
|
47
47
|
]);
|
|
48
48
|
// EthAccounts schema
|
|
49
49
|
const ethAccountsSchema = z.union([
|
|
@@ -54,7 +54,7 @@ const ethAccountsSchema = z.union([
|
|
|
54
54
|
// BLSAccount schema
|
|
55
55
|
const blsAccountSchema = z.union([
|
|
56
56
|
blsPrivateKeySchema,
|
|
57
|
-
|
|
57
|
+
encryptedKeyFileSchema
|
|
58
58
|
]);
|
|
59
59
|
// AttesterAccount schema: either EthAccount or { eth: EthAccount, bls?: BLSAccount }
|
|
60
60
|
const attesterAccountSchema = z.union([
|
|
@@ -62,7 +62,7 @@ const attesterAccountSchema = z.union([
|
|
|
62
62
|
z.object({
|
|
63
63
|
eth: ethAccountSchema,
|
|
64
64
|
bls: optional(blsAccountSchema)
|
|
65
|
-
})
|
|
65
|
+
}).strict()
|
|
66
66
|
]);
|
|
67
67
|
// AttesterAccounts schema: AttesterAccount | AttesterAccount[] | MnemonicConfig
|
|
68
68
|
const attesterAccountsSchema = z.union([
|
|
@@ -76,28 +76,72 @@ const proverKeyStoreSchema = z.union([
|
|
|
76
76
|
z.object({
|
|
77
77
|
id: schemas.EthAddress,
|
|
78
78
|
publisher: ethAccountsSchema
|
|
79
|
-
})
|
|
79
|
+
}).strict()
|
|
80
80
|
]);
|
|
81
|
-
// Validator keystore schema
|
|
82
|
-
const
|
|
81
|
+
// Validator keystore schema for v1 (feeRecipient required)
|
|
82
|
+
const validatorKeyStoreSchemaV1 = z.object({
|
|
83
83
|
attester: attesterAccountsSchema,
|
|
84
84
|
coinbase: optional(schemas.EthAddress),
|
|
85
85
|
publisher: optional(ethAccountsSchema),
|
|
86
86
|
feeRecipient: AztecAddress.schema,
|
|
87
87
|
remoteSigner: optional(remoteSignerConfigSchema),
|
|
88
88
|
fundingAccount: optional(ethAccountSchema)
|
|
89
|
-
});
|
|
90
|
-
//
|
|
91
|
-
|
|
89
|
+
}).strict();
|
|
90
|
+
// Validator keystore schema for v2 (feeRecipient optional, can fall back to top-level)
|
|
91
|
+
const validatorKeyStoreSchemaV2 = z.object({
|
|
92
|
+
attester: attesterAccountsSchema,
|
|
93
|
+
coinbase: optional(schemas.EthAddress),
|
|
94
|
+
publisher: optional(ethAccountsSchema),
|
|
95
|
+
feeRecipient: optional(AztecAddress.schema),
|
|
96
|
+
remoteSigner: optional(remoteSignerConfigSchema),
|
|
97
|
+
fundingAccount: optional(ethAccountSchema)
|
|
98
|
+
}).strict();
|
|
99
|
+
// Schema v1 - original format
|
|
100
|
+
const keystoreSchemaV1 = z.object({
|
|
92
101
|
schemaVersion: z.literal(1),
|
|
93
|
-
validators: optional(z.array(
|
|
102
|
+
validators: optional(z.array(validatorKeyStoreSchemaV1)),
|
|
94
103
|
slasher: optional(ethAccountsSchema),
|
|
95
104
|
remoteSigner: optional(remoteSignerConfigSchema),
|
|
96
105
|
prover: optional(proverKeyStoreSchema),
|
|
97
106
|
fundingAccount: optional(ethAccountSchema)
|
|
98
|
-
}).refine((data)=>data.validators || data.prover, {
|
|
107
|
+
}).strict().refine((data)=>data.validators || data.prover, {
|
|
99
108
|
message: 'Keystore must have at least validators or prover configuration',
|
|
100
109
|
path: [
|
|
101
110
|
'root'
|
|
102
111
|
]
|
|
103
112
|
});
|
|
113
|
+
// Schema v2 - adds top-level publisher, coinbase, feeRecipient
|
|
114
|
+
const keystoreSchemaV2 = z.object({
|
|
115
|
+
schemaVersion: z.literal(2),
|
|
116
|
+
validators: optional(z.array(validatorKeyStoreSchemaV2)),
|
|
117
|
+
slasher: optional(ethAccountsSchema),
|
|
118
|
+
remoteSigner: optional(remoteSignerConfigSchema),
|
|
119
|
+
prover: optional(proverKeyStoreSchema),
|
|
120
|
+
fundingAccount: optional(ethAccountSchema),
|
|
121
|
+
publisher: optional(ethAccountsSchema),
|
|
122
|
+
coinbase: optional(schemas.EthAddress),
|
|
123
|
+
feeRecipient: optional(AztecAddress.schema)
|
|
124
|
+
}).strict().refine((data)=>data.validators || data.prover, {
|
|
125
|
+
message: 'Keystore must have at least validators or prover configuration',
|
|
126
|
+
path: [
|
|
127
|
+
'root'
|
|
128
|
+
]
|
|
129
|
+
}).refine((data)=>{
|
|
130
|
+
// If validators are present, ensure each validator has a feeRecipient or there's a top-level feeRecipient
|
|
131
|
+
if (data.validators) {
|
|
132
|
+
const hasTopLevelFeeRecipient = !!data.feeRecipient;
|
|
133
|
+
const allValidatorsHaveFeeRecipient = data.validators.every((v)=>v.feeRecipient);
|
|
134
|
+
return hasTopLevelFeeRecipient || allValidatorsHaveFeeRecipient;
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}, {
|
|
138
|
+
message: 'Each validator must have a feeRecipient, or a top-level feeRecipient must be set for all validators',
|
|
139
|
+
path: [
|
|
140
|
+
'feeRecipient'
|
|
141
|
+
]
|
|
142
|
+
});
|
|
143
|
+
// Main keystore schema - accepts both v1 and v2
|
|
144
|
+
export const keystoreSchema = z.union([
|
|
145
|
+
keystoreSchemaV1,
|
|
146
|
+
keystoreSchemaV2
|
|
147
|
+
]);
|
package/dest/signer.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Common interface for different signing backends (local, remote, encrypted)
|
|
5
5
|
*/
|
|
6
|
-
import type { EthSigner } from '@aztec/ethereum';
|
|
6
|
+
import type { EthSigner } from '@aztec/ethereum/eth-signer';
|
|
7
7
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
8
8
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
9
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
@@ -56,24 +56,9 @@ export declare class RemoteSigner implements EthSigner {
|
|
|
56
56
|
*/
|
|
57
57
|
signTypedData(typedData: TypedDataDefinition): Promise<Signature>;
|
|
58
58
|
signTransaction(transaction: TransactionSerializable): Promise<Signature>;
|
|
59
|
-
/**
|
|
60
|
-
* Make a JSON-RPC sign request using eth_sign
|
|
61
|
-
*/
|
|
62
|
-
/**
|
|
63
|
-
* Make a JSON-RPC eth_sign request.
|
|
64
|
-
*/
|
|
65
59
|
private makeJsonRpcSignRequest;
|
|
66
|
-
/**
|
|
67
|
-
* Make a JSON-RPC eth_signTypedData_v4 request.
|
|
68
|
-
*/
|
|
69
60
|
private makeJsonRpcSignTypedDataRequest;
|
|
70
|
-
/**
|
|
71
|
-
* Make a JSON-RPC eth_signTransaction request.
|
|
72
|
-
*/
|
|
73
61
|
private makeJsonRpcSignTransactionRequest;
|
|
74
|
-
/**
|
|
75
|
-
* Sends a JSON-RPC request and returns its result
|
|
76
|
-
*/
|
|
77
62
|
private makeJsonRpcRequest;
|
|
78
63
|
/**
|
|
79
64
|
* Resolve the effective remote signer URL from config.
|
|
@@ -84,4 +69,4 @@ export declare class RemoteSigner implements EthSigner {
|
|
|
84
69
|
*/
|
|
85
70
|
private generateId;
|
|
86
71
|
}
|
|
87
|
-
//# sourceMappingURL=
|
|
72
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvc2lnbmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7O0dBSUc7QUFDSCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUM1RCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFHcEQsT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ACnC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,KAAK;IAHf,YACkB,OAAO,EAAE,UAAU,EAClB,MAAM,EAAE,qBAAqB,EACtC,KAAK,GAAE,OAAO,UAAU,CAAC,KAAwB,EACvD;IAEJ;;;;;;OAMG;IACH,OAAa,cAAc,CACzB,eAAe,EAAE,qBAAqB,EACtC,SAAS,EAAE,MAAM,EAAE,EACnB,KAAK,GAAE,OAAO,UAAU,CAAC,KAAwB,GAChD,OAAO,CAAC,IAAI,CAAC,CA+Df;IAED;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAEvD;IAED;;OAEG;IACG,aAAa,CAAC,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,SAAS,CAAC,CAEtE;IAED,eAAe,CAAC,WAAW,EAAE,uBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,CAExE;YAQa,sBAAsB;YAiBtB,+BAA+B;YAqB/B,iCAAiC;YA8CjC,kBAAkB;IAyChC;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,OAAO,CAAC,UAAU;CAGnB"}
|
package/dest/signer.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Common interface for different signing backends (local, remote, encrypted)
|
|
5
5
|
*/ import { Buffer32 } from '@aztec/foundation/buffer';
|
|
6
|
-
import {
|
|
6
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
7
|
+
import { Secp256k1Signer, toRecoveryBit } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
7
8
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
8
9
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
9
|
-
import { withHexPrefix } from '@aztec/foundation/string';
|
|
10
|
+
import { bufferToHex, withHexPrefix } from '@aztec/foundation/string';
|
|
10
11
|
import { hashTypedData, keccak256, parseTransaction, serializeTransaction } from 'viem';
|
|
11
12
|
/**
|
|
12
13
|
* Error thrown for remote signer HTTP or JSON-RPC failures
|
|
@@ -155,9 +156,6 @@ import { hashTypedData, keccak256, parseTransaction, serializeTransaction } from
|
|
|
155
156
|
/**
|
|
156
157
|
* Make a JSON-RPC eth_signTransaction request.
|
|
157
158
|
*/ async makeJsonRpcSignTransactionRequest(tx) {
|
|
158
|
-
if (tx.type !== 'eip1559') {
|
|
159
|
-
throw new Error('This signer does not support tx type: ' + tx.type);
|
|
160
|
-
}
|
|
161
159
|
const txObject = {
|
|
162
160
|
from: this.address.toString(),
|
|
163
161
|
to: tx.to ?? null,
|
|
@@ -166,7 +164,10 @@ import { hashTypedData, keccak256, parseTransaction, serializeTransaction } from
|
|
|
166
164
|
nonce: typeof tx.nonce !== 'undefined' ? withHexPrefix(tx.nonce.toString(16)) : undefined,
|
|
167
165
|
gas: typeof tx.gas !== 'undefined' ? withHexPrefix(tx.gas.toString(16)) : undefined,
|
|
168
166
|
maxFeePerGas: typeof tx.maxFeePerGas !== 'undefined' ? withHexPrefix(tx.maxFeePerGas.toString(16)) : undefined,
|
|
169
|
-
maxPriorityFeePerGas: typeof tx.maxPriorityFeePerGas !== 'undefined' ? withHexPrefix(tx.maxPriorityFeePerGas.toString(16)) : undefined
|
|
167
|
+
maxPriorityFeePerGas: typeof tx.maxPriorityFeePerGas !== 'undefined' ? withHexPrefix(tx.maxPriorityFeePerGas.toString(16)) : undefined,
|
|
168
|
+
maxFeePerBlobGas: typeof tx.maxFeePerBlobGas !== 'undefined' ? withHexPrefix(tx.maxFeePerBlobGas.toString(16)) : undefined,
|
|
169
|
+
blobVersionedHashes: tx.blobVersionedHashes,
|
|
170
|
+
blobs: tx.blobs?.map((blob)=>typeof blob === 'string' ? blob : bufferToHex(Buffer.from(blob)))
|
|
170
171
|
};
|
|
171
172
|
let rawTxHex = await this.makeJsonRpcRequest('eth_signTransaction', txObject);
|
|
172
173
|
if (typeof rawTxHex !== 'string') {
|
package/dest/types.d.ts
CHANGED
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
* their associated keys and addresses.
|
|
7
7
|
*/
|
|
8
8
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
|
+
import type { Hex } from '@aztec/foundation/string';
|
|
9
10
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
/**
|
|
12
|
+
* An encrypted keystore file config points to a local file with an encrypted private key.
|
|
13
|
+
* The file may be in different formats:
|
|
14
|
+
* - JSON V3 format for ETH keys (Ethereum wallet standard)
|
|
15
|
+
* - EIP-2335 format for BLS keys (Ethereum 2.0 validator standard)
|
|
16
|
+
*/
|
|
17
|
+
export type EncryptedKeyFileConfig = {
|
|
16
18
|
path: string;
|
|
17
19
|
password?: string;
|
|
18
20
|
};
|
|
@@ -40,8 +42,8 @@ export type EthRemoteSignerAccount = EthAddress | {
|
|
|
40
42
|
certPath?: string;
|
|
41
43
|
certPass?: string;
|
|
42
44
|
};
|
|
43
|
-
/** An L1 account is a private key, a remote signer configuration, or
|
|
44
|
-
export type EthAccount = EthPrivateKey | EthRemoteSignerAccount |
|
|
45
|
+
/** An L1 account is a private key, a remote signer configuration, or an encrypted keystore file (JSON V3 format) */
|
|
46
|
+
export type EthAccount = EthPrivateKey | EthRemoteSignerAccount | EncryptedKeyFileConfig;
|
|
45
47
|
/** A mnemonic can be used to define a set of accounts */
|
|
46
48
|
export type MnemonicConfig = {
|
|
47
49
|
mnemonic: string;
|
|
@@ -59,8 +61,8 @@ export type ProverKeyStoreWithId = {
|
|
|
59
61
|
publisher: EthAccounts;
|
|
60
62
|
};
|
|
61
63
|
export type ProverKeyStore = ProverKeyStoreWithId | EthAccount;
|
|
62
|
-
/** A BLS account is either a private key, or
|
|
63
|
-
export type BLSAccount = BLSPrivateKey |
|
|
64
|
+
/** A BLS account is either a private key, or an EIP-2335 encrypted keystore file */
|
|
65
|
+
export type BLSAccount = BLSPrivateKey | EncryptedKeyFileConfig;
|
|
64
66
|
/** An AttesterAccount is a combined EthAccount and optional BLSAccount */
|
|
65
67
|
export type AttesterAccount = {
|
|
66
68
|
eth: EthAccount;
|
|
@@ -76,18 +78,19 @@ export type ValidatorKeyStore = {
|
|
|
76
78
|
attester: AttesterAccounts;
|
|
77
79
|
/**
|
|
78
80
|
* Coinbase address to use when proposing an L2 block as any of the validators in this configuration block.
|
|
79
|
-
* Falls back to the attester address if not set.
|
|
81
|
+
* Falls back to the keystore-level coinbase, then to the attester address if not set.
|
|
80
82
|
*/
|
|
81
83
|
coinbase?: EthAddress;
|
|
82
84
|
/**
|
|
83
85
|
* One or more EOAs used for sending block proposal L1 txs for all validators in this configuration block.
|
|
84
|
-
* Falls back to the attester account if not set.
|
|
86
|
+
* Falls back to the keystore-level publisher, then to the attester account if not set.
|
|
85
87
|
*/
|
|
86
88
|
publisher?: EthAccounts;
|
|
87
89
|
/**
|
|
88
90
|
* Fee recipient address to use when proposing an L2 block as any of the validators in this configuration block.
|
|
91
|
+
* Falls back to the keystore-level feeRecipient if not set.
|
|
89
92
|
*/
|
|
90
|
-
feeRecipient
|
|
93
|
+
feeRecipient?: AztecAddress;
|
|
91
94
|
/**
|
|
92
95
|
* Default remote signer for all accounts in this block.
|
|
93
96
|
*/
|
|
@@ -98,8 +101,8 @@ export type ValidatorKeyStore = {
|
|
|
98
101
|
fundingAccount?: EthAccount;
|
|
99
102
|
};
|
|
100
103
|
export type KeyStore = {
|
|
101
|
-
/** Schema version of this keystore file (
|
|
102
|
-
schemaVersion:
|
|
104
|
+
/** Schema version of this keystore file (1 or 2). */
|
|
105
|
+
schemaVersion: 1 | 2;
|
|
103
106
|
/** Validator configurations. */
|
|
104
107
|
validators?: ValidatorKeyStore[];
|
|
105
108
|
/** One or more accounts used for creating slash payloads on L1. Does not create slash payloads if not set. */
|
|
@@ -110,5 +113,11 @@ export type KeyStore = {
|
|
|
110
113
|
prover?: ProverKeyStore;
|
|
111
114
|
/** Used for automatically funding publisher accounts if there is none defined in the corresponding ValidatorKeyStore*/
|
|
112
115
|
fundingAccount?: EthAccount;
|
|
116
|
+
/** Default publisher accounts for all validators in this keystore. Can be overridden by individual validator configs. */
|
|
117
|
+
publisher?: EthAccounts;
|
|
118
|
+
/** Default coinbase address for all validators in this keystore. Can be overridden by individual validator configs. */
|
|
119
|
+
coinbase?: EthAddress;
|
|
120
|
+
/** Default fee recipient address for all validators in this keystore. Can be overridden by individual validator configs. */
|
|
121
|
+
feeRecipient?: AztecAddress;
|
|
113
122
|
};
|
|
114
|
-
//# sourceMappingURL=
|
|
123
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFDSCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxHQUFHLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUNwRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVoRTs7Ozs7R0FLRztBQUNILE1BQU0sTUFBTSxzQkFBc0IsR0FBRztJQUFFLElBQUksRUFBRSxNQUFNLENBQUM7SUFBQyxRQUFRLENBQUMsRUFBRSxNQUFNLENBQUE7Q0FBRSxDQUFDO0FBRXpFLGlEQUFpRDtBQUNqRCxNQUFNLE1BQU0sYUFBYSxHQUFHLEdBQUcsQ0FBQyxFQUFFLENBQUMsQ0FBQztBQUVwQyxxREFBcUQ7QUFDckQsTUFBTSxNQUFNLGFBQWEsR0FBRyxHQUFHLENBQUMsRUFBRSxDQUFDLENBQUM7QUFFcEMsa0NBQWtDO0FBQ2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UFPLENBQUMsRUFBRSxXQUFXLENBQUM7SUFDdEIsMEVBQTBFO0lBQzFFLFlBQVksQ0FBQyxFQUFFLHFCQUFxQixDQUFDO0lBQ3JDLHNFQUFzRTtJQUN0RSxNQUFNLENBQUMsRUFBRSxjQUFjLENBQUM7SUFDeEIsd0hBQXdIO0lBQ3hILGNBQWMsQ0FBQyxFQUFFLFVBQVUsQ0FBQztJQUM1Qix5SEFBeUg7SUFDekgsU0FBUyxDQUFDLEVBQUUsV0FBVyxDQUFDO0lBQ3hCLHVIQUF1SDtJQUN2SCxRQUFRLENBQUMsRUFBRSxVQUFVLENBQUM7SUFDdEIsNEhBQTRIO0lBQzVILFlBQVksQ0FBQyxFQUFFLFlBQVksQ0FBQztDQUM3QixDQUFDIn0=
|
package/dest/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,iDAAiD;AACjD,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC;AAEpC,qDAAqD;AACrD,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC;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U,CAAC;AAEjF,+DAA+D;AAC/D,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,eAAe,EAAE,GAAG,cAAc,CAAC;AAEpF,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;OAEG;IACH,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC;;OAEG;IACH,cAAc,CAAC,EAAE,UAAU,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,qDAAqD;IACrD,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC;IACrB,gCAAgC;IAChC,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACjC,8GAA8G;IAC9G,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,qBAAqB,CAAC;IACrC,sEAAsE;IACtE,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,wHAAwH;IACxH,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,yHAAyH;IACzH,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,uHAAuH;IACvH,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,4HAA4H;IAC5H,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/node-keystore",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-commit.217f559981",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
|
+
"./config": "./dest/config.js",
|
|
8
|
+
"./schemas": "./dest/schemas.js",
|
|
7
9
|
"./types": "./dest/types.js",
|
|
8
10
|
"./validation": "./dest/validation.js",
|
|
9
11
|
"./loader": "./dest/loader.js"
|
|
@@ -16,8 +18,8 @@
|
|
|
16
18
|
"tsconfig": "./tsconfig.json"
|
|
17
19
|
},
|
|
18
20
|
"scripts": {
|
|
19
|
-
"build": "yarn clean && tsc
|
|
20
|
-
"build:dev": "tsc
|
|
21
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
22
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
21
23
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
22
24
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
23
25
|
},
|
|
@@ -62,18 +64,19 @@
|
|
|
62
64
|
]
|
|
63
65
|
},
|
|
64
66
|
"dependencies": {
|
|
65
|
-
"@aztec/ethereum": "0.0.
|
|
66
|
-
"@aztec/foundation": "0.0.
|
|
67
|
-
"@aztec/stdlib": "0.0.
|
|
67
|
+
"@aztec/ethereum": "0.0.2-commit.217f559981",
|
|
68
|
+
"@aztec/foundation": "0.0.2-commit.217f559981",
|
|
69
|
+
"@aztec/stdlib": "0.0.2-commit.217f559981",
|
|
68
70
|
"@ethersproject/wallet": "^5.7.0",
|
|
69
71
|
"tslib": "^2.4.0",
|
|
70
|
-
"viem": "npm:@
|
|
72
|
+
"viem": "npm:@aztec/viem@2.38.2",
|
|
71
73
|
"zod": "^3.23.8"
|
|
72
74
|
},
|
|
73
75
|
"devDependencies": {
|
|
74
76
|
"@jest/globals": "^30.0.0",
|
|
75
77
|
"@types/jest": "^30.0.0",
|
|
76
78
|
"@types/node": "^22.15.17",
|
|
79
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
77
80
|
"jest": "^30.0.0",
|
|
78
81
|
"ts-node": "^10.9.1",
|
|
79
82
|
"typescript": "^5.3.3"
|
package/src/keystore_manager.ts
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Manages keystore configuration and delegates signing operations to appropriate signers.
|
|
5
5
|
*/
|
|
6
|
-
import type { EthSigner } from '@aztec/ethereum';
|
|
6
|
+
import type { EthSigner } from '@aztec/ethereum/eth-signer';
|
|
7
7
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
8
8
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
9
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
10
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
10
11
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
12
|
|
|
12
13
|
import { Wallet } from '@ethersproject/wallet';
|
|
@@ -19,11 +20,11 @@ import { ethPrivateKeySchema } from './schemas.js';
|
|
|
19
20
|
import { LocalSigner, RemoteSigner } from './signer.js';
|
|
20
21
|
import type {
|
|
21
22
|
AttesterAccounts,
|
|
23
|
+
EncryptedKeyFileConfig,
|
|
22
24
|
EthAccount,
|
|
23
25
|
EthAccounts,
|
|
24
26
|
EthRemoteSignerAccount,
|
|
25
27
|
EthRemoteSignerConfig,
|
|
26
|
-
JsonKeyFileV3Config,
|
|
27
28
|
KeyStore,
|
|
28
29
|
MnemonicConfig,
|
|
29
30
|
ProverKeyStore,
|
|
@@ -61,7 +62,7 @@ export class KeystoreManager {
|
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
64
|
* Validates all remote signers in the keystore are accessible and have the required addresses.
|
|
64
|
-
*
|
|
65
|
+
* Retries each web3signer URL with backoff to tolerate transient unavailability at boot time.
|
|
65
66
|
*/
|
|
66
67
|
async validateSigners(): Promise<void> {
|
|
67
68
|
// Collect all remote signers with their addresses grouped by URL
|
|
@@ -127,12 +128,18 @@ export class KeystoreManager {
|
|
|
127
128
|
collectRemoteSigners(this.keystore.prover.publisher, this.keystore.remoteSigner);
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
// Validate each remote signer URL with all its addresses
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
// Validate each remote signer URL with all its addresses, retrying on transient failures
|
|
132
|
+
await Promise.all(
|
|
133
|
+
Array.from(remoteSignersByUrl.entries())
|
|
134
|
+
.filter(([, addresses]) => addresses.size > 0)
|
|
135
|
+
.map(([url, addresses]) =>
|
|
136
|
+
retry(
|
|
137
|
+
() => RemoteSigner.validateAccess(url, Array.from(addresses)),
|
|
138
|
+
`Validating web3signer at ${url}`,
|
|
139
|
+
makeBackoff([1, 2, 4, 8, 16]),
|
|
140
|
+
),
|
|
141
|
+
),
|
|
142
|
+
);
|
|
136
143
|
}
|
|
137
144
|
|
|
138
145
|
/**
|
|
@@ -228,7 +235,7 @@ export class KeystoreManager {
|
|
|
228
235
|
}
|
|
229
236
|
|
|
230
237
|
/**
|
|
231
|
-
* Create signers for validator publisher accounts (falls back to attester if not specified)
|
|
238
|
+
* Create signers for validator publisher accounts (falls back to keystore-level publisher, then to attester if not specified)
|
|
232
239
|
*/
|
|
233
240
|
createPublisherSigners(validatorIndex: number): EthSigner[] {
|
|
234
241
|
const validator = this.getValidator(validatorIndex);
|
|
@@ -240,6 +247,14 @@ export class KeystoreManager {
|
|
|
240
247
|
);
|
|
241
248
|
}
|
|
242
249
|
|
|
250
|
+
// Fall back to keystore-level publisher
|
|
251
|
+
if (this.keystore.publisher) {
|
|
252
|
+
return this.createSignersFromEthAccounts(
|
|
253
|
+
this.keystore.publisher,
|
|
254
|
+
validator.remoteSigner || this.keystore.remoteSigner,
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
243
258
|
// Fall back to attester signers
|
|
244
259
|
return this.createAttesterSigners(validatorIndex);
|
|
245
260
|
}
|
|
@@ -320,7 +335,7 @@ export class KeystoreManager {
|
|
|
320
335
|
}
|
|
321
336
|
|
|
322
337
|
/**
|
|
323
|
-
* Get coinbase address for validator (falls back to the specific attester address)
|
|
338
|
+
* Get coinbase address for validator (falls back to keystore-level coinbase, then to the specific attester address)
|
|
324
339
|
*/
|
|
325
340
|
getCoinbaseAddress(validatorIndex: number, attesterAddress: EthAddress): EthAddress {
|
|
326
341
|
const validator = this.getValidator(validatorIndex);
|
|
@@ -329,16 +344,33 @@ export class KeystoreManager {
|
|
|
329
344
|
return validator.coinbase;
|
|
330
345
|
}
|
|
331
346
|
|
|
347
|
+
// Fall back to keystore-level coinbase
|
|
348
|
+
if (this.keystore.coinbase) {
|
|
349
|
+
return this.keystore.coinbase;
|
|
350
|
+
}
|
|
351
|
+
|
|
332
352
|
// Fall back to the specific attester address
|
|
333
353
|
return attesterAddress;
|
|
334
354
|
}
|
|
335
355
|
|
|
336
356
|
/**
|
|
337
|
-
* Get fee recipient for validator
|
|
357
|
+
* Get fee recipient for validator (falls back to keystore-level feeRecipient)
|
|
338
358
|
*/
|
|
339
359
|
getFeeRecipient(validatorIndex: number): AztecAddress {
|
|
340
360
|
const validator = this.getValidator(validatorIndex);
|
|
341
|
-
|
|
361
|
+
|
|
362
|
+
if (validator.feeRecipient) {
|
|
363
|
+
return validator.feeRecipient;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Fall back to keystore-level feeRecipient
|
|
367
|
+
if (this.keystore.feeRecipient) {
|
|
368
|
+
return this.keystore.feeRecipient;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
throw new KeystoreError(
|
|
372
|
+
`No feeRecipient configured for validator ${validatorIndex}. You can set it at validator or keystore level.`,
|
|
373
|
+
);
|
|
342
374
|
}
|
|
343
375
|
|
|
344
376
|
/**
|
|
@@ -465,7 +497,7 @@ export class KeystoreManager {
|
|
|
465
497
|
/**
|
|
466
498
|
* Create signer from JSON V3 keystore file or directory
|
|
467
499
|
*/
|
|
468
|
-
private createSignerFromJsonV3(config:
|
|
500
|
+
private createSignerFromJsonV3(config: EncryptedKeyFileConfig): EthSigner[] {
|
|
469
501
|
try {
|
|
470
502
|
const stats = statSync(config.path);
|
|
471
503
|
|