@aztec/node-keystore 0.0.1-commit.21caa21
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 +7 -0
- package/dest/config.d.ts.map +1 -0
- package/dest/config.js +10 -0
- package/dest/index.d.ts +7 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +6 -0
- package/dest/keystore_manager.d.ts +139 -0
- package/dest/keystore_manager.d.ts.map +1 -0
- package/dest/keystore_manager.js +579 -0
- package/dest/loader.d.ts +62 -0
- package/dest/loader.d.ts.map +1 -0
- package/dest/loader.js +274 -0
- package/dest/schemas.d.ts +1404 -0
- package/dest/schemas.d.ts.map +1 -0
- package/dest/schemas.js +103 -0
- package/dest/signer.d.ts +72 -0
- package/dest/signer.d.ts.map +1 -0
- package/dest/signer.js +228 -0
- package/dest/types.d.ts +116 -0
- package/dest/types.d.ts.map +1 -0
- package/dest/types.js +7 -0
- package/package.json +91 -0
- package/src/config.ts +16 -0
- package/src/index.ts +6 -0
- package/src/keystore_manager.ts +731 -0
- package/src/loader.ts +321 -0
- package/src/schemas.ts +126 -0
- package/src/signer.ts +352 -0
- package/src/types.ts +129 -0
|
@@ -0,0 +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;AA8FtC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAavB,CAAC"}
|
package/dest/schemas.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for keystore validation using Aztec's validation functions
|
|
3
|
+
*/ import { optional, schemas } from '@aztec/foundation/schemas';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
// Use Aztec's validation functions but return string types to match our TypeScript interfaces
|
|
7
|
+
export const ethPrivateKeySchema = z.string().regex(/^0x[0-9a-fA-F]{64}$/, 'Invalid private key (must be 32 bytes with 0x prefix)').transform((s)=>s);
|
|
8
|
+
export const blsPrivateKeySchema = z.string().regex(/^0x[0-9a-fA-F]{64}$/, 'Invalid BLS private key (must be 32 bytes with 0x prefix)').transform((s)=>s);
|
|
9
|
+
const urlSchema = z.string().url('Invalid URL');
|
|
10
|
+
// Remote signer config schema
|
|
11
|
+
const remoteSignerConfigSchema = z.union([
|
|
12
|
+
urlSchema,
|
|
13
|
+
z.object({
|
|
14
|
+
remoteSignerUrl: urlSchema,
|
|
15
|
+
certPath: optional(z.string()),
|
|
16
|
+
certPass: optional(z.string())
|
|
17
|
+
}).strict()
|
|
18
|
+
]);
|
|
19
|
+
// Remote signer account schema
|
|
20
|
+
const remoteSignerAccountSchema = z.union([
|
|
21
|
+
schemas.EthAddress,
|
|
22
|
+
z.object({
|
|
23
|
+
address: schemas.EthAddress,
|
|
24
|
+
remoteSignerUrl: urlSchema,
|
|
25
|
+
certPath: optional(z.string()),
|
|
26
|
+
certPass: optional(z.string())
|
|
27
|
+
}).strict()
|
|
28
|
+
]);
|
|
29
|
+
// Encrypted keystore file schema (used for both JSON V3 ETH keys and EIP-2335 BLS keys)
|
|
30
|
+
const encryptedKeyFileSchema = z.object({
|
|
31
|
+
path: z.string(),
|
|
32
|
+
password: optional(z.string())
|
|
33
|
+
}).strict();
|
|
34
|
+
// Mnemonic config schema
|
|
35
|
+
const mnemonicConfigSchema = z.object({
|
|
36
|
+
mnemonic: z.string().min(1, 'Mnemonic cannot be empty'),
|
|
37
|
+
addressIndex: z.number().int().min(0).default(0),
|
|
38
|
+
accountIndex: z.number().int().min(0).default(0),
|
|
39
|
+
addressCount: z.number().int().min(1).default(1),
|
|
40
|
+
accountCount: z.number().int().min(1).default(1)
|
|
41
|
+
}).strict();
|
|
42
|
+
// EthAccount schema
|
|
43
|
+
const ethAccountSchema = z.union([
|
|
44
|
+
ethPrivateKeySchema,
|
|
45
|
+
remoteSignerAccountSchema,
|
|
46
|
+
encryptedKeyFileSchema
|
|
47
|
+
]);
|
|
48
|
+
// EthAccounts schema
|
|
49
|
+
const ethAccountsSchema = z.union([
|
|
50
|
+
ethAccountSchema,
|
|
51
|
+
z.array(ethAccountSchema),
|
|
52
|
+
mnemonicConfigSchema
|
|
53
|
+
]);
|
|
54
|
+
// BLSAccount schema
|
|
55
|
+
const blsAccountSchema = z.union([
|
|
56
|
+
blsPrivateKeySchema,
|
|
57
|
+
encryptedKeyFileSchema
|
|
58
|
+
]);
|
|
59
|
+
// AttesterAccount schema: either EthAccount or { eth: EthAccount, bls?: BLSAccount }
|
|
60
|
+
const attesterAccountSchema = z.union([
|
|
61
|
+
ethAccountSchema,
|
|
62
|
+
z.object({
|
|
63
|
+
eth: ethAccountSchema,
|
|
64
|
+
bls: optional(blsAccountSchema)
|
|
65
|
+
}).strict()
|
|
66
|
+
]);
|
|
67
|
+
// AttesterAccounts schema: AttesterAccount | AttesterAccount[] | MnemonicConfig
|
|
68
|
+
const attesterAccountsSchema = z.union([
|
|
69
|
+
attesterAccountSchema,
|
|
70
|
+
z.array(attesterAccountSchema),
|
|
71
|
+
mnemonicConfigSchema
|
|
72
|
+
]);
|
|
73
|
+
// Prover keystore schema
|
|
74
|
+
const proverKeyStoreSchema = z.union([
|
|
75
|
+
ethAccountSchema,
|
|
76
|
+
z.object({
|
|
77
|
+
id: schemas.EthAddress,
|
|
78
|
+
publisher: ethAccountsSchema
|
|
79
|
+
}).strict()
|
|
80
|
+
]);
|
|
81
|
+
// Validator keystore schema
|
|
82
|
+
const validatorKeyStoreSchema = z.object({
|
|
83
|
+
attester: attesterAccountsSchema,
|
|
84
|
+
coinbase: optional(schemas.EthAddress),
|
|
85
|
+
publisher: optional(ethAccountsSchema),
|
|
86
|
+
feeRecipient: AztecAddress.schema,
|
|
87
|
+
remoteSigner: optional(remoteSignerConfigSchema),
|
|
88
|
+
fundingAccount: optional(ethAccountSchema)
|
|
89
|
+
}).strict();
|
|
90
|
+
// Main keystore schema
|
|
91
|
+
export const keystoreSchema = z.object({
|
|
92
|
+
schemaVersion: z.literal(1),
|
|
93
|
+
validators: optional(z.array(validatorKeyStoreSchema)),
|
|
94
|
+
slasher: optional(ethAccountsSchema),
|
|
95
|
+
remoteSigner: optional(remoteSignerConfigSchema),
|
|
96
|
+
prover: optional(proverKeyStoreSchema),
|
|
97
|
+
fundingAccount: optional(ethAccountSchema)
|
|
98
|
+
}).strict().refine((data)=>data.validators || data.prover, {
|
|
99
|
+
message: 'Keystore must have at least validators or prover configuration',
|
|
100
|
+
path: [
|
|
101
|
+
'root'
|
|
102
|
+
]
|
|
103
|
+
});
|
package/dest/signer.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signer Interface and Implementations
|
|
3
|
+
*
|
|
4
|
+
* Common interface for different signing backends (local, remote, encrypted)
|
|
5
|
+
*/
|
|
6
|
+
import type { EthSigner } from '@aztec/ethereum';
|
|
7
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
8
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
10
|
+
import { type TransactionSerializable, type TypedDataDefinition } from 'viem';
|
|
11
|
+
import type { EthRemoteSignerConfig } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Error thrown for remote signer HTTP or JSON-RPC failures
|
|
14
|
+
*/
|
|
15
|
+
export declare class SignerError extends Error {
|
|
16
|
+
method: string;
|
|
17
|
+
url: string;
|
|
18
|
+
statusCode?: number | undefined;
|
|
19
|
+
errorCode?: number | undefined;
|
|
20
|
+
constructor(message: string, method: string, url: string, statusCode?: number | undefined, errorCode?: number | undefined);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Local signer that holds an in-memory Secp256k1 private key.
|
|
24
|
+
*/
|
|
25
|
+
export declare class LocalSigner implements EthSigner {
|
|
26
|
+
private privateKey;
|
|
27
|
+
private readonly signer;
|
|
28
|
+
constructor(privateKey: Buffer32);
|
|
29
|
+
get address(): EthAddress;
|
|
30
|
+
signMessage(message: Buffer32): Promise<Signature>;
|
|
31
|
+
signTypedData(typedData: TypedDataDefinition): Promise<Signature>;
|
|
32
|
+
signTransaction(transaction: TransactionSerializable): Promise<Signature>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Remote signer that proxies signing operations to a Web3Signer-compatible HTTP endpoint.
|
|
36
|
+
*/
|
|
37
|
+
export declare class RemoteSigner implements EthSigner {
|
|
38
|
+
readonly address: EthAddress;
|
|
39
|
+
private readonly config;
|
|
40
|
+
private fetch;
|
|
41
|
+
constructor(address: EthAddress, config: EthRemoteSignerConfig, fetch?: typeof globalThis.fetch);
|
|
42
|
+
/**
|
|
43
|
+
* Validates that a web3signer is accessible and that the given addresses are available.
|
|
44
|
+
* @param remoteSignerUrl - The URL of the web3signer (can be string or EthRemoteSignerConfig)
|
|
45
|
+
* @param addresses - The addresses to check for availability
|
|
46
|
+
* @param fetch - Optional fetch implementation for testing
|
|
47
|
+
* @throws Error if the web3signer is not accessible or if any address is not available
|
|
48
|
+
*/
|
|
49
|
+
static validateAccess(remoteSignerUrl: EthRemoteSignerConfig, addresses: string[], fetch?: typeof globalThis.fetch): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Sign a message using eth_sign via remote JSON-RPC.
|
|
52
|
+
*/
|
|
53
|
+
signMessage(message: Buffer32): Promise<Signature>;
|
|
54
|
+
/**
|
|
55
|
+
* Sign typed data using eth_signTypedData_v4 via remote JSON-RPC.
|
|
56
|
+
*/
|
|
57
|
+
signTypedData(typedData: TypedDataDefinition): Promise<Signature>;
|
|
58
|
+
signTransaction(transaction: TransactionSerializable): Promise<Signature>;
|
|
59
|
+
private makeJsonRpcSignRequest;
|
|
60
|
+
private makeJsonRpcSignTypedDataRequest;
|
|
61
|
+
private makeJsonRpcSignTransactionRequest;
|
|
62
|
+
private makeJsonRpcRequest;
|
|
63
|
+
/**
|
|
64
|
+
* Resolve the effective remote signer URL from config.
|
|
65
|
+
*/
|
|
66
|
+
private getSignerUrl;
|
|
67
|
+
/**
|
|
68
|
+
* Generate an id to use for a JSON-RPC call
|
|
69
|
+
*/
|
|
70
|
+
private generateId;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvc2lnbmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7O0dBSUc7QUFDSCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUNqRCxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFcEQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0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ACzB,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;YAkDjC,kBAAkB;IAyChC;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,OAAO,CAAC,UAAU;CAGnB"}
|
package/dest/signer.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signer Interface and Implementations
|
|
3
|
+
*
|
|
4
|
+
* Common interface for different signing backends (local, remote, encrypted)
|
|
5
|
+
*/ import { Buffer32 } from '@aztec/foundation/buffer';
|
|
6
|
+
import { Secp256k1Signer, randomBytes, toRecoveryBit } from '@aztec/foundation/crypto';
|
|
7
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
8
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
9
|
+
import { withHexPrefix } from '@aztec/foundation/string';
|
|
10
|
+
import { hashTypedData, keccak256, parseTransaction, serializeTransaction } from 'viem';
|
|
11
|
+
/**
|
|
12
|
+
* Error thrown for remote signer HTTP or JSON-RPC failures
|
|
13
|
+
*/ export class SignerError extends Error {
|
|
14
|
+
method;
|
|
15
|
+
url;
|
|
16
|
+
statusCode;
|
|
17
|
+
errorCode;
|
|
18
|
+
constructor(message, method, url, statusCode, errorCode){
|
|
19
|
+
super(message), this.method = method, this.url = url, this.statusCode = statusCode, this.errorCode = errorCode;
|
|
20
|
+
this.name = 'SignerError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Local signer that holds an in-memory Secp256k1 private key.
|
|
25
|
+
*/ export class LocalSigner {
|
|
26
|
+
privateKey;
|
|
27
|
+
signer;
|
|
28
|
+
constructor(privateKey){
|
|
29
|
+
this.privateKey = privateKey;
|
|
30
|
+
this.signer = new Secp256k1Signer(privateKey);
|
|
31
|
+
}
|
|
32
|
+
get address() {
|
|
33
|
+
return this.signer.address;
|
|
34
|
+
}
|
|
35
|
+
signMessage(message) {
|
|
36
|
+
return Promise.resolve(this.signer.signMessage(message));
|
|
37
|
+
}
|
|
38
|
+
signTypedData(typedData) {
|
|
39
|
+
const digest = hashTypedData(typedData);
|
|
40
|
+
return Promise.resolve(this.signer.sign(Buffer32.fromString(digest)));
|
|
41
|
+
}
|
|
42
|
+
signTransaction(transaction) {
|
|
43
|
+
// Taken from viem's `signTransaction` implementation
|
|
44
|
+
const tx = transaction.type === 'eip4844' ? {
|
|
45
|
+
...transaction,
|
|
46
|
+
sidecars: false
|
|
47
|
+
} : transaction;
|
|
48
|
+
const serializedTx = serializeTransaction(tx);
|
|
49
|
+
const txHash = keccak256(serializedTx);
|
|
50
|
+
const sig = this.signer.sign(Buffer32.fromString(txHash.slice(2)));
|
|
51
|
+
return Promise.resolve(new Signature(sig.r, sig.s, toRecoveryBit(sig.v)));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Remote signer that proxies signing operations to a Web3Signer-compatible HTTP endpoint.
|
|
56
|
+
*/ export class RemoteSigner {
|
|
57
|
+
address;
|
|
58
|
+
config;
|
|
59
|
+
fetch;
|
|
60
|
+
constructor(address, config, fetch = globalThis.fetch){
|
|
61
|
+
this.address = address;
|
|
62
|
+
this.config = config;
|
|
63
|
+
this.fetch = fetch;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validates that a web3signer is accessible and that the given addresses are available.
|
|
67
|
+
* @param remoteSignerUrl - The URL of the web3signer (can be string or EthRemoteSignerConfig)
|
|
68
|
+
* @param addresses - The addresses to check for availability
|
|
69
|
+
* @param fetch - Optional fetch implementation for testing
|
|
70
|
+
* @throws Error if the web3signer is not accessible or if any address is not available
|
|
71
|
+
*/ static async validateAccess(remoteSignerUrl, addresses, fetch = globalThis.fetch) {
|
|
72
|
+
const url = typeof remoteSignerUrl === 'string' ? remoteSignerUrl : remoteSignerUrl.remoteSignerUrl;
|
|
73
|
+
try {
|
|
74
|
+
// Check if the web3signer is reachable by calling eth_accounts
|
|
75
|
+
const response = await fetch(url, {
|
|
76
|
+
method: 'POST',
|
|
77
|
+
headers: {
|
|
78
|
+
'Content-Type': 'application/json'
|
|
79
|
+
},
|
|
80
|
+
body: JSON.stringify({
|
|
81
|
+
jsonrpc: '2.0',
|
|
82
|
+
method: 'eth_accounts',
|
|
83
|
+
params: [],
|
|
84
|
+
id: 1
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
const errorText = await response.text();
|
|
89
|
+
throw new SignerError(`Web3Signer validation failed: ${response.status} ${response.statusText} - ${errorText}`, 'eth_accounts', url, response.status);
|
|
90
|
+
}
|
|
91
|
+
const result = await response.json();
|
|
92
|
+
if (result.error) {
|
|
93
|
+
throw new SignerError(`Web3Signer JSON-RPC error during validation: ${result.error.code} - ${result.error.message}`, 'eth_accounts', url, 200, result.error.code);
|
|
94
|
+
}
|
|
95
|
+
if (!result.result || !Array.isArray(result.result)) {
|
|
96
|
+
throw new Error('Invalid response from Web3Signer: expected array of accounts');
|
|
97
|
+
}
|
|
98
|
+
// Normalize addresses to lowercase for comparison
|
|
99
|
+
const availableAccounts = result.result.map((addr)=>addr.toLowerCase());
|
|
100
|
+
const requestedAddresses = addresses.map((addr)=>addr.toLowerCase());
|
|
101
|
+
// Check if all requested addresses are available
|
|
102
|
+
const missingAddresses = requestedAddresses.filter((addr)=>!availableAccounts.includes(addr));
|
|
103
|
+
if (missingAddresses.length > 0) {
|
|
104
|
+
throw new Error(`The following addresses are not available in the web3signer: ${missingAddresses.join(', ')}`);
|
|
105
|
+
}
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (error instanceof SignerError) {
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
if (error.code === 'ECONNREFUSED' || error.cause?.code === 'ECONNREFUSED') {
|
|
111
|
+
throw new Error(`Unable to connect to web3signer at ${url}. Please ensure it is running and accessible.`);
|
|
112
|
+
}
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Sign a message using eth_sign via remote JSON-RPC.
|
|
118
|
+
*/ async signMessage(message) {
|
|
119
|
+
return await this.makeJsonRpcSignRequest(message);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Sign typed data using eth_signTypedData_v4 via remote JSON-RPC.
|
|
123
|
+
*/ async signTypedData(typedData) {
|
|
124
|
+
return await this.makeJsonRpcSignTypedDataRequest(typedData);
|
|
125
|
+
}
|
|
126
|
+
signTransaction(transaction) {
|
|
127
|
+
return this.makeJsonRpcSignTransactionRequest(transaction);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Make a JSON-RPC sign request using eth_sign
|
|
131
|
+
*/ /**
|
|
132
|
+
* Make a JSON-RPC eth_sign request.
|
|
133
|
+
*/ async makeJsonRpcSignRequest(data) {
|
|
134
|
+
let signatureHex = await this.makeJsonRpcRequest('eth_sign', this.address.toString(), data.toString());
|
|
135
|
+
if (typeof signatureHex !== 'string') {
|
|
136
|
+
throw new Error('Invalid signature');
|
|
137
|
+
}
|
|
138
|
+
if (!signatureHex.startsWith('0x')) {
|
|
139
|
+
signatureHex = '0x' + signatureHex;
|
|
140
|
+
}
|
|
141
|
+
return Signature.fromString(signatureHex);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Make a JSON-RPC eth_signTypedData_v4 request.
|
|
145
|
+
*/ async makeJsonRpcSignTypedDataRequest(typedData) {
|
|
146
|
+
let signatureHex = await this.makeJsonRpcRequest('eth_signTypedData', this.address.toString(), jsonStringify(typedData));
|
|
147
|
+
if (typeof signatureHex !== 'string') {
|
|
148
|
+
throw new Error('Invalid signature');
|
|
149
|
+
}
|
|
150
|
+
if (!signatureHex.startsWith('0x')) {
|
|
151
|
+
signatureHex = '0x' + signatureHex;
|
|
152
|
+
}
|
|
153
|
+
return Signature.fromString(signatureHex);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Make a JSON-RPC eth_signTransaction request.
|
|
157
|
+
*/ async makeJsonRpcSignTransactionRequest(tx) {
|
|
158
|
+
if (tx.type !== 'eip1559') {
|
|
159
|
+
throw new Error('This signer does not support tx type: ' + tx.type);
|
|
160
|
+
}
|
|
161
|
+
const txObject = {
|
|
162
|
+
from: this.address.toString(),
|
|
163
|
+
to: tx.to ?? null,
|
|
164
|
+
data: tx.data,
|
|
165
|
+
value: typeof tx.value !== 'undefined' ? withHexPrefix(tx.value.toString(16)) : undefined,
|
|
166
|
+
nonce: typeof tx.nonce !== 'undefined' ? withHexPrefix(tx.nonce.toString(16)) : undefined,
|
|
167
|
+
gas: typeof tx.gas !== 'undefined' ? withHexPrefix(tx.gas.toString(16)) : undefined,
|
|
168
|
+
maxFeePerGas: typeof tx.maxFeePerGas !== 'undefined' ? withHexPrefix(tx.maxFeePerGas.toString(16)) : undefined,
|
|
169
|
+
maxPriorityFeePerGas: typeof tx.maxPriorityFeePerGas !== 'undefined' ? withHexPrefix(tx.maxPriorityFeePerGas.toString(16)) : undefined
|
|
170
|
+
};
|
|
171
|
+
let rawTxHex = await this.makeJsonRpcRequest('eth_signTransaction', txObject);
|
|
172
|
+
if (typeof rawTxHex !== 'string') {
|
|
173
|
+
throw new Error('Invalid signed tx');
|
|
174
|
+
}
|
|
175
|
+
if (!rawTxHex.startsWith('0x')) {
|
|
176
|
+
rawTxHex = '0x' + rawTxHex;
|
|
177
|
+
}
|
|
178
|
+
// we get back to whole signed tx. Deserialize it in order to read the signature
|
|
179
|
+
const parsedTxWithSignature = parseTransaction(rawTxHex);
|
|
180
|
+
if (parsedTxWithSignature.r === undefined || parsedTxWithSignature.s === undefined || parsedTxWithSignature.v === undefined) {
|
|
181
|
+
throw new Error('Tx not signed by Web3Signer');
|
|
182
|
+
}
|
|
183
|
+
return Signature.fromViemTransactionSignature(parsedTxWithSignature);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Sends a JSON-RPC request and returns its result
|
|
187
|
+
*/ async makeJsonRpcRequest(method, ...params) {
|
|
188
|
+
const url = this.getSignerUrl();
|
|
189
|
+
const id = this.generateId();
|
|
190
|
+
const response = await this.fetch(url, {
|
|
191
|
+
method: 'POST',
|
|
192
|
+
headers: {
|
|
193
|
+
'Content-Type': 'application/json'
|
|
194
|
+
},
|
|
195
|
+
body: jsonStringify({
|
|
196
|
+
jsonrpc: '2.0',
|
|
197
|
+
method,
|
|
198
|
+
params,
|
|
199
|
+
id
|
|
200
|
+
})
|
|
201
|
+
});
|
|
202
|
+
if (!response.ok) {
|
|
203
|
+
const errorText = await response.text();
|
|
204
|
+
throw new SignerError(`Web3Signer request failed for ${method} at ${url}: ${response.status} ${response.statusText} - ${errorText}`, method, url, response.status);
|
|
205
|
+
}
|
|
206
|
+
const result = await response.json();
|
|
207
|
+
if (result.error) {
|
|
208
|
+
throw new SignerError(`Web3Signer JSON-RPC error for ${method} at ${url}: ${result.error.code} - ${result.error.message}`, method, url, response.status, result.error.code);
|
|
209
|
+
}
|
|
210
|
+
if (!result.result) {
|
|
211
|
+
throw new Error('Invalid response from Web3Signer: no result found');
|
|
212
|
+
}
|
|
213
|
+
return result.result;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Resolve the effective remote signer URL from config.
|
|
217
|
+
*/ getSignerUrl() {
|
|
218
|
+
if (typeof this.config === 'string') {
|
|
219
|
+
return this.config;
|
|
220
|
+
}
|
|
221
|
+
return this.config.remoteSignerUrl;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Generate an id to use for a JSON-RPC call
|
|
225
|
+
*/ generateId() {
|
|
226
|
+
return randomBytes(4).toString('hex');
|
|
227
|
+
}
|
|
228
|
+
}
|
package/dest/types.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys and Addresses Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* TypeScript definitions based on the specification for validator keystore files.
|
|
5
|
+
* These types define the JSON structure for configuring validators, provers, and
|
|
6
|
+
* their associated keys and addresses.
|
|
7
|
+
*/
|
|
8
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
|
+
import type { Hex } from '@aztec/foundation/string';
|
|
10
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
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 = {
|
|
18
|
+
path: string;
|
|
19
|
+
password?: string;
|
|
20
|
+
};
|
|
21
|
+
/** A private key is a 32-byte 0x-prefixed hex */
|
|
22
|
+
export type EthPrivateKey = Hex<32>;
|
|
23
|
+
/** A BLS private key is a 32-byte 0x-prefixed hex */
|
|
24
|
+
export type BLSPrivateKey = Hex<32>;
|
|
25
|
+
/** URL type for remote signers */
|
|
26
|
+
export type Url = string;
|
|
27
|
+
/**
|
|
28
|
+
* A remote signer is configured as an URL to connect to, and optionally a client certificate to use for auth
|
|
29
|
+
*/
|
|
30
|
+
export type EthRemoteSignerConfig = Url | {
|
|
31
|
+
remoteSignerUrl: Url;
|
|
32
|
+
certPath?: string;
|
|
33
|
+
certPass?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A remote signer account config is equal to the remote signer config, but requires an address to be specified.
|
|
37
|
+
* If only the address is set, then the default remote signer config from the parent config is used.
|
|
38
|
+
*/
|
|
39
|
+
export type EthRemoteSignerAccount = EthAddress | {
|
|
40
|
+
address: EthAddress;
|
|
41
|
+
remoteSignerUrl: Url;
|
|
42
|
+
certPath?: string;
|
|
43
|
+
certPass?: string;
|
|
44
|
+
};
|
|
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;
|
|
47
|
+
/** A mnemonic can be used to define a set of accounts */
|
|
48
|
+
export type MnemonicConfig = {
|
|
49
|
+
mnemonic: string;
|
|
50
|
+
addressIndex?: number;
|
|
51
|
+
accountIndex?: number;
|
|
52
|
+
addressCount?: number;
|
|
53
|
+
accountCount?: number;
|
|
54
|
+
};
|
|
55
|
+
/** One or more L1 accounts */
|
|
56
|
+
export type EthAccounts = EthAccount | EthAccount[] | MnemonicConfig;
|
|
57
|
+
export type ProverKeyStoreWithId = {
|
|
58
|
+
/** Address that identifies the prover. This address will receive the rewards. */
|
|
59
|
+
id: EthAddress;
|
|
60
|
+
/** One or more EOAs used for sending proof L1 txs. */
|
|
61
|
+
publisher: EthAccounts;
|
|
62
|
+
};
|
|
63
|
+
export type ProverKeyStore = ProverKeyStoreWithId | EthAccount;
|
|
64
|
+
/** A BLS account is either a private key, or an EIP-2335 encrypted keystore file */
|
|
65
|
+
export type BLSAccount = BLSPrivateKey | EncryptedKeyFileConfig;
|
|
66
|
+
/** An AttesterAccount is a combined EthAccount and optional BLSAccount */
|
|
67
|
+
export type AttesterAccount = {
|
|
68
|
+
eth: EthAccount;
|
|
69
|
+
bls?: BLSAccount;
|
|
70
|
+
} | EthAccount;
|
|
71
|
+
/** One or more attester accounts combining ETH and BLS keys */
|
|
72
|
+
export type AttesterAccounts = AttesterAccount | AttesterAccount[] | MnemonicConfig;
|
|
73
|
+
export type ValidatorKeyStore = {
|
|
74
|
+
/**
|
|
75
|
+
* One or more validator attester keys to handle in this configuration block.
|
|
76
|
+
* An attester address may only appear once across all configuration blocks across all keystore files.
|
|
77
|
+
*/
|
|
78
|
+
attester: AttesterAccounts;
|
|
79
|
+
/**
|
|
80
|
+
* Coinbase address to use when proposing an L2 block as any of the validators in this configuration block.
|
|
81
|
+
* Falls back to the attester address if not set.
|
|
82
|
+
*/
|
|
83
|
+
coinbase?: EthAddress;
|
|
84
|
+
/**
|
|
85
|
+
* One or more EOAs used for sending block proposal L1 txs for all validators in this configuration block.
|
|
86
|
+
* Falls back to the attester account if not set.
|
|
87
|
+
*/
|
|
88
|
+
publisher?: EthAccounts;
|
|
89
|
+
/**
|
|
90
|
+
* Fee recipient address to use when proposing an L2 block as any of the validators in this configuration block.
|
|
91
|
+
*/
|
|
92
|
+
feeRecipient: AztecAddress;
|
|
93
|
+
/**
|
|
94
|
+
* Default remote signer for all accounts in this block.
|
|
95
|
+
*/
|
|
96
|
+
remoteSigner?: EthRemoteSignerConfig;
|
|
97
|
+
/**
|
|
98
|
+
* Used for automatically funding publisher accounts in this block.
|
|
99
|
+
*/
|
|
100
|
+
fundingAccount?: EthAccount;
|
|
101
|
+
};
|
|
102
|
+
export type KeyStore = {
|
|
103
|
+
/** Schema version of this keystore file (initially 1). */
|
|
104
|
+
schemaVersion: number;
|
|
105
|
+
/** Validator configurations. */
|
|
106
|
+
validators?: ValidatorKeyStore[];
|
|
107
|
+
/** One or more accounts used for creating slash payloads on L1. Does not create slash payloads if not set. */
|
|
108
|
+
slasher?: EthAccounts;
|
|
109
|
+
/** Default config for the remote signer for all accounts in this file. */
|
|
110
|
+
remoteSigner?: EthRemoteSignerConfig;
|
|
111
|
+
/** Prover configuration. Only one prover configuration is allowed. */
|
|
112
|
+
prover?: ProverKeyStore;
|
|
113
|
+
/** Used for automatically funding publisher accounts if there is none defined in the corresponding ValidatorKeyStore*/
|
|
114
|
+
fundingAccount?: EthAccount;
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/types.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keys and Addresses Configuration Types
|
|
3
|
+
*
|
|
4
|
+
* TypeScript definitions based on the specification for validator keystore files.
|
|
5
|
+
* These types define the JSON structure for configuring validators, provers, and
|
|
6
|
+
* their associated keys and addresses.
|
|
7
|
+
*/ export { };
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aztec/node-keystore",
|
|
3
|
+
"version": "0.0.1-commit.21caa21",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dest/index.js",
|
|
7
|
+
"./types": "./dest/types.js",
|
|
8
|
+
"./validation": "./dest/validation.js",
|
|
9
|
+
"./loader": "./dest/loader.js"
|
|
10
|
+
},
|
|
11
|
+
"typedocOptions": {
|
|
12
|
+
"entryPoints": [
|
|
13
|
+
"./src/index.ts"
|
|
14
|
+
],
|
|
15
|
+
"name": "Node Keystore",
|
|
16
|
+
"tsconfig": "./tsconfig.json"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "yarn clean && tsgo -b",
|
|
20
|
+
"build:dev": "tsgo -b --watch",
|
|
21
|
+
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
22
|
+
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
23
|
+
},
|
|
24
|
+
"inherits": [
|
|
25
|
+
"../package.common.json"
|
|
26
|
+
],
|
|
27
|
+
"jest": {
|
|
28
|
+
"moduleNameMapper": {
|
|
29
|
+
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
|
|
30
|
+
},
|
|
31
|
+
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
|
|
32
|
+
"rootDir": "./src",
|
|
33
|
+
"transform": {
|
|
34
|
+
"^.+\\.tsx?$": [
|
|
35
|
+
"@swc/jest",
|
|
36
|
+
{
|
|
37
|
+
"jsc": {
|
|
38
|
+
"parser": {
|
|
39
|
+
"syntax": "typescript",
|
|
40
|
+
"decorators": true
|
|
41
|
+
},
|
|
42
|
+
"transform": {
|
|
43
|
+
"decoratorVersion": "2022-03"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"extensionsToTreatAsEsm": [
|
|
50
|
+
".ts"
|
|
51
|
+
],
|
|
52
|
+
"reporters": [
|
|
53
|
+
"default"
|
|
54
|
+
],
|
|
55
|
+
"testTimeout": 120000,
|
|
56
|
+
"setupFiles": [
|
|
57
|
+
"../../foundation/src/jest/setup.mjs"
|
|
58
|
+
],
|
|
59
|
+
"testEnvironment": "../../foundation/src/jest/env.mjs",
|
|
60
|
+
"setupFilesAfterEnv": [
|
|
61
|
+
"../../foundation/src/jest/setupAfterEnv.mjs"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@aztec/ethereum": "0.0.1-commit.21caa21",
|
|
66
|
+
"@aztec/foundation": "0.0.1-commit.21caa21",
|
|
67
|
+
"@aztec/stdlib": "0.0.1-commit.21caa21",
|
|
68
|
+
"@ethersproject/wallet": "^5.7.0",
|
|
69
|
+
"tslib": "^2.4.0",
|
|
70
|
+
"viem": "npm:@aztec/viem@2.38.2",
|
|
71
|
+
"zod": "^3.23.8"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@jest/globals": "^30.0.0",
|
|
75
|
+
"@types/jest": "^30.0.0",
|
|
76
|
+
"@types/node": "^22.15.17",
|
|
77
|
+
"@typescript/native-preview": "7.0.0-dev.20251126.1",
|
|
78
|
+
"jest": "^30.0.0",
|
|
79
|
+
"ts-node": "^10.9.1",
|
|
80
|
+
"typescript": "^5.3.3"
|
|
81
|
+
},
|
|
82
|
+
"files": [
|
|
83
|
+
"dest",
|
|
84
|
+
"src",
|
|
85
|
+
"!*.test.*"
|
|
86
|
+
],
|
|
87
|
+
"types": "./dest/index.d.ts",
|
|
88
|
+
"engines": {
|
|
89
|
+
"node": ">=20.10"
|
|
90
|
+
}
|
|
91
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';
|
|
2
|
+
|
|
3
|
+
export type KeyStoreConfig = {
|
|
4
|
+
keyStoreDirectory: string | undefined;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const keyStoreConfigMappings: ConfigMappingsType<KeyStoreConfig> = {
|
|
8
|
+
keyStoreDirectory: {
|
|
9
|
+
env: 'KEY_STORE_DIRECTORY',
|
|
10
|
+
description: 'Location of key store directory',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function getKeyStoreConfigFromEnv(): KeyStoreConfig {
|
|
15
|
+
return getConfigFromMappings<KeyStoreConfig>(keyStoreConfigMappings);
|
|
16
|
+
}
|