@aztec/node-keystore 0.0.1-fake-c83136db25

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.
@@ -0,0 +1,7 @@
1
+ import { type ConfigMappingsType } from '@aztec/foundation/config';
2
+ export type KeyStoreConfig = {
3
+ keyStoreDirectory: string | undefined;
4
+ };
5
+ export declare const keyStoreConfigMappings: ConfigMappingsType<KeyStoreConfig>;
6
+ export declare function getKeyStoreConfigFromEnv(): KeyStoreConfig;
7
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,0BAA0B,CAAC;AAE1F,MAAM,MAAM,cAAc,GAAG;IAC3B,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,cAAc,CAKrE,CAAC;AAEF,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD"}
package/dest/config.js ADDED
@@ -0,0 +1,10 @@
1
+ import { getConfigFromMappings } from '@aztec/foundation/config';
2
+ export const keyStoreConfigMappings = {
3
+ keyStoreDirectory: {
4
+ env: 'KEY_STORE_DIRECTORY',
5
+ description: 'Location of key store directory'
6
+ }
7
+ };
8
+ export function getKeyStoreConfigFromEnv() {
9
+ return getConfigFromMappings(keyStoreConfigMappings);
10
+ }
@@ -0,0 +1,7 @@
1
+ export * from './types.js';
2
+ export * from './loader.js';
3
+ export * from './schemas.js';
4
+ export * from './signer.js';
5
+ export * from './keystore_manager.js';
6
+ export * from './config.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
package/dest/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from './types.js';
2
+ export * from './loader.js';
3
+ export * from './schemas.js';
4
+ export * from './signer.js';
5
+ export * from './keystore_manager.js';
6
+ export * from './config.js';
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Keystore Manager
3
+ *
4
+ * Manages keystore configuration and delegates signing operations to appropriate signers.
5
+ */
6
+ import type { EthSigner } from '@aztec/ethereum';
7
+ import { Buffer32 } from '@aztec/foundation/buffer';
8
+ import { EthAddress } from '@aztec/foundation/eth-address';
9
+ import type { Signature } from '@aztec/foundation/eth-signature';
10
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
11
+ import type { TypedDataDefinition } from 'viem';
12
+ import type { EthAccounts, EthRemoteSignerConfig, KeyStore, ProverKeyStore, ValidatorKeyStore as ValidatorKeystoreConfig } from './types.js';
13
+ /**
14
+ * Error thrown when keystore operations fail
15
+ */
16
+ export declare class KeystoreError extends Error {
17
+ cause?: Error | undefined;
18
+ constructor(message: string, cause?: Error | undefined);
19
+ }
20
+ /**
21
+ * Keystore Manager - coordinates signing operations based on keystore configuration
22
+ */
23
+ export declare class KeystoreManager {
24
+ private readonly keystore;
25
+ /**
26
+ * Create a keystore manager from a parsed configuration.
27
+ * Performs a lightweight duplicate-attester check without decrypting JSON V3 or deriving mnemonics.
28
+ * @param keystore Parsed keystore configuration
29
+ */
30
+ constructor(keystore: KeyStore);
31
+ /**
32
+ * Validates all remote signers in the keystore are accessible and have the required addresses.
33
+ * Should be called after construction if validation is needed.
34
+ */
35
+ validateSigners(): Promise<void>;
36
+ /**
37
+ * Validates that attester addresses are unique across all validators
38
+ * Only checks simple private key attesters, not JSON-V3 or mnemonic attesters,
39
+ * these are validated when decrypting the JSON-V3 keystore files
40
+ * @throws KeystoreError if duplicate attester addresses are found
41
+ */
42
+ private validateUniqueAttesterAddresses;
43
+ /**
44
+ * Best-effort address extraction that avoids decryption/derivation (no JSON-V3 or mnemonic processing).
45
+ * This is used at construction time to check for obvious duplicates without throwing for invalid inputs.
46
+ */
47
+ private extractAddressesWithoutSensitiveOperations;
48
+ /**
49
+ * Extract addresses from EthAccounts without sensitive operations (no decryption/derivation).
50
+ */
51
+ private extractAddressesFromEthAccountsNonSensitive;
52
+ /**
53
+ * Create signers for validator attester accounts
54
+ */
55
+ createAttesterSigners(validatorIndex: number): EthSigner[];
56
+ /**
57
+ * Create signers for validator publisher accounts (falls back to attester if not specified)
58
+ */
59
+ createPublisherSigners(validatorIndex: number): EthSigner[];
60
+ createAllValidatorPublisherSigners(): EthSigner[];
61
+ /**
62
+ * Create signers for slasher accounts
63
+ */
64
+ createSlasherSigners(): EthSigner[];
65
+ /**
66
+ * Create signers for prover accounts
67
+ */
68
+ createProverSigners(): {
69
+ id: EthAddress | undefined;
70
+ signers: EthSigner[];
71
+ } | undefined;
72
+ /**
73
+ * Get validator configuration by index
74
+ */
75
+ getValidator(index: number): ValidatorKeystoreConfig;
76
+ /**
77
+ * Get validator count
78
+ */
79
+ getValidatorCount(): number;
80
+ /**
81
+ * Get coinbase address for validator (falls back to the specific attester address)
82
+ */
83
+ getCoinbaseAddress(validatorIndex: number, attesterAddress: EthAddress): EthAddress;
84
+ /**
85
+ * Get fee recipient for validator
86
+ */
87
+ getFeeRecipient(validatorIndex: number): AztecAddress;
88
+ /**
89
+ * Get the raw slasher configuration as provided in the keystore file.
90
+ * @returns The slasher accounts configuration or undefined if not set
91
+ */
92
+ getSlasherAccounts(): EthAccounts | undefined;
93
+ /**
94
+ * Get the raw prover configuration as provided in the keystore file.
95
+ * @returns The prover configuration or undefined if not set
96
+ */
97
+ getProverConfig(): ProverKeyStore | undefined;
98
+ /**
99
+ * Resolves attester accounts (including JSON V3 and mnemonic) and checks for duplicate addresses across validators.
100
+ * Throws if the same resolved address appears in more than one validator configuration.
101
+ */
102
+ validateResolvedUniqueAttesterAddresses(): void;
103
+ /**
104
+ * Create signers from EthAccounts configuration
105
+ */
106
+ private createSignersFromEthAccounts;
107
+ /**
108
+ * Create a signer from a single EthAccount configuration
109
+ */
110
+ private createSignerFromEthAccount;
111
+ /**
112
+ * Create signer from JSON V3 keystore file or directory
113
+ */
114
+ private createSignerFromJsonV3;
115
+ /**
116
+ * Create signer from a single JSON V3 keystore file
117
+ */
118
+ private createSignerFromSingleJsonV3File;
119
+ /**
120
+ * Create signers from mnemonic configuration using BIP44 derivation
121
+ */
122
+ private createSignersFromMnemonic;
123
+ /**
124
+ * Sign message with a specific signer
125
+ */
126
+ signMessage(signer: EthSigner, message: Buffer32): Promise<Signature>;
127
+ /**
128
+ * Sign typed data with a specific signer
129
+ */
130
+ signTypedData(signer: EthSigner, typedData: TypedDataDefinition): Promise<Signature>;
131
+ /**
132
+ * Get the effective remote signer configuration for a specific attester address
133
+ * Precedence: account-level override > validator-level config > file-level default
134
+ */
135
+ getEffectiveRemoteSignerConfig(validatorIndex: number, attesterAddress: EthAddress): EthRemoteSignerConfig | undefined;
136
+ /** Extract ETH accounts from AttesterAccounts */
137
+ private extractEthAccountsFromAttester;
138
+ }
139
+ //# sourceMappingURL=keystore_manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keystore_manager.d.ts","sourceRoot":"","sources":["../src/keystore_manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAKhD,OAAO,KAAK,EAGV,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