@aztec/cli 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108

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.
Files changed (252) hide show
  1. package/README.md +2 -428
  2. package/dest/cmds/aztec_node/block_number.d.ts +3 -0
  3. package/dest/cmds/aztec_node/block_number.d.ts.map +1 -0
  4. package/dest/cmds/aztec_node/block_number.js +10 -0
  5. package/dest/cmds/aztec_node/get_block.d.ts +3 -0
  6. package/dest/cmds/aztec_node/get_block.d.ts.map +1 -0
  7. package/dest/cmds/aztec_node/get_block.js +10 -0
  8. package/dest/cmds/aztec_node/get_current_min_fee.d.ts +3 -0
  9. package/dest/cmds/aztec_node/get_current_min_fee.d.ts.map +1 -0
  10. package/dest/cmds/aztec_node/get_current_min_fee.js +7 -0
  11. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts +5 -0
  12. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.d.ts.map +1 -0
  13. package/dest/cmds/aztec_node/get_l1_to_l2_message_witness.js +12 -0
  14. package/dest/cmds/aztec_node/get_logs.d.ts +7 -0
  15. package/dest/cmds/aztec_node/get_logs.d.ts.map +1 -0
  16. package/dest/cmds/{pxe → aztec_node}/get_logs.js +4 -4
  17. package/dest/cmds/aztec_node/get_node_info.d.ts +3 -0
  18. package/dest/cmds/aztec_node/get_node_info.d.ts.map +1 -0
  19. package/dest/cmds/{pxe → aztec_node}/get_node_info.js +3 -8
  20. package/dest/cmds/aztec_node/index.d.ts +4 -0
  21. package/dest/cmds/aztec_node/index.d.ts.map +1 -0
  22. package/dest/cmds/aztec_node/index.js +28 -0
  23. package/dest/cmds/contracts/index.d.ts +1 -1
  24. package/dest/cmds/contracts/inspect_contract.d.ts +1 -1
  25. package/dest/cmds/contracts/inspect_contract.d.ts.map +1 -1
  26. package/dest/cmds/contracts/inspect_contract.js +4 -10
  27. package/dest/cmds/contracts/parse_parameter_struct.d.ts +1 -1
  28. package/dest/cmds/infrastructure/index.d.ts +3 -3
  29. package/dest/cmds/infrastructure/index.d.ts.map +1 -1
  30. package/dest/cmds/infrastructure/index.js +7 -9
  31. package/dest/cmds/infrastructure/sequencers.d.ts +3 -5
  32. package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
  33. package/dest/cmds/infrastructure/sequencers.js +15 -7
  34. package/dest/cmds/infrastructure/setup_l2_contract.d.ts +2 -2
  35. package/dest/cmds/infrastructure/setup_l2_contract.d.ts.map +1 -1
  36. package/dest/cmds/infrastructure/setup_l2_contract.js +10 -25
  37. package/dest/cmds/l1/advance_epoch.d.ts +2 -2
  38. package/dest/cmds/l1/advance_epoch.d.ts.map +1 -1
  39. package/dest/cmds/l1/advance_epoch.js +6 -5
  40. package/dest/cmds/l1/assume_proven_through.d.ts +2 -2
  41. package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
  42. package/dest/cmds/l1/assume_proven_through.js +8 -6
  43. package/dest/cmds/l1/bridge_erc20.d.ts +2 -2
  44. package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
  45. package/dest/cmds/l1/bridge_erc20.js +3 -2
  46. package/dest/cmds/l1/create_l1_account.d.ts +1 -1
  47. package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts +4 -0
  48. package/dest/cmds/l1/deploy_l1_contracts_cmd.d.ts.map +1 -0
  49. package/dest/cmds/l1/{deploy_l1_contracts.js → deploy_l1_contracts_cmd.js} +42 -7
  50. package/dest/cmds/l1/deploy_new_rollup.d.ts +4 -4
  51. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
  52. package/dest/cmds/l1/deploy_new_rollup.js +5 -5
  53. package/dest/cmds/l1/get_l1_addresses.d.ts +2 -2
  54. package/dest/cmds/l1/get_l1_addresses.d.ts.map +1 -1
  55. package/dest/cmds/l1/get_l1_addresses.js +5 -2
  56. package/dest/cmds/l1/get_l1_balance.d.ts +1 -1
  57. package/dest/cmds/l1/get_l1_balance.js +4 -2
  58. package/dest/cmds/l1/governance_utils.d.ts +5 -5
  59. package/dest/cmds/l1/governance_utils.d.ts.map +1 -1
  60. package/dest/cmds/l1/governance_utils.js +3 -1
  61. package/dest/cmds/l1/index.d.ts +1 -2
  62. package/dest/cmds/l1/index.d.ts.map +1 -1
  63. package/dest/cmds/l1/index.js +22 -36
  64. package/dest/cmds/l1/prover_stats.d.ts +1 -1
  65. package/dest/cmds/l1/prover_stats.d.ts.map +1 -1
  66. package/dest/cmds/l1/prover_stats.js +32 -30
  67. package/dest/cmds/l1/trigger_seed_snapshot.d.ts +2 -2
  68. package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -1
  69. package/dest/cmds/l1/trigger_seed_snapshot.js +2 -1
  70. package/dest/cmds/l1/update_l1_validators.d.ts +10 -5
  71. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
  72. package/dest/cmds/l1/update_l1_validators.js +74 -9
  73. package/dest/cmds/misc/compute_selector.d.ts +1 -1
  74. package/dest/cmds/misc/example_contracts.d.ts +1 -1
  75. package/dest/cmds/misc/generate_bootnode_enr.d.ts +1 -1
  76. package/dest/cmds/misc/generate_p2p_private_key.d.ts +1 -1
  77. package/dest/cmds/misc/generate_secret_and_hash.d.ts +1 -1
  78. package/dest/cmds/misc/generate_secret_and_hash.js +2 -2
  79. package/dest/cmds/misc/generate_secret_key.d.ts +2 -2
  80. package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -1
  81. package/dest/cmds/misc/generate_secret_key.js +1 -1
  82. package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts +1 -1
  83. package/dest/cmds/misc/index.d.ts +1 -1
  84. package/dest/cmds/misc/index.d.ts.map +1 -1
  85. package/dest/cmds/misc/index.js +1 -1
  86. package/dest/cmds/misc/update/common.d.ts +1 -1
  87. package/dest/cmds/misc/update/github.d.ts +1 -1
  88. package/dest/cmds/misc/update/noir.d.ts +1 -1
  89. package/dest/cmds/misc/update/npm.d.ts +1 -1
  90. package/dest/cmds/misc/update/npm.js +1 -1
  91. package/dest/cmds/misc/update/utils.d.ts +1 -1
  92. package/dest/cmds/misc/update.d.ts +1 -1
  93. package/dest/cmds/validator_keys/add.d.ts +5 -0
  94. package/dest/cmds/validator_keys/add.d.ts.map +1 -0
  95. package/dest/cmds/validator_keys/add.js +83 -0
  96. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +12 -0
  97. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -0
  98. package/dest/cmds/validator_keys/generate_bls_keypair.js +27 -0
  99. package/dest/cmds/validator_keys/index.d.ts +4 -0
  100. package/dest/cmds/validator_keys/index.d.ts.map +1 -0
  101. package/dest/cmds/validator_keys/index.js +32 -0
  102. package/dest/cmds/validator_keys/new.d.ts +29 -0
  103. package/dest/cmds/validator_keys/new.d.ts.map +1 -0
  104. package/dest/cmds/validator_keys/new.js +134 -0
  105. package/dest/cmds/validator_keys/shared.d.ts +68 -0
  106. package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
  107. package/dest/cmds/validator_keys/shared.js +274 -0
  108. package/dest/cmds/validator_keys/staker.d.ts +38 -0
  109. package/dest/cmds/validator_keys/staker.d.ts.map +1 -0
  110. package/dest/cmds/validator_keys/staker.js +210 -0
  111. package/dest/cmds/validator_keys/utils.d.ts +25 -0
  112. package/dest/cmds/validator_keys/utils.d.ts.map +1 -0
  113. package/dest/cmds/validator_keys/utils.js +52 -0
  114. package/dest/config/cached_fetch.d.ts +18 -0
  115. package/dest/config/cached_fetch.d.ts.map +1 -0
  116. package/dest/config/cached_fetch.js +54 -0
  117. package/dest/config/chain_l2_config.d.ts +41 -0
  118. package/dest/config/chain_l2_config.d.ts.map +1 -0
  119. package/dest/config/chain_l2_config.js +524 -0
  120. package/dest/config/enrich_env.d.ts +4 -0
  121. package/dest/config/enrich_env.d.ts.map +1 -0
  122. package/dest/config/enrich_env.js +12 -0
  123. package/dest/config/get_l1_config.d.ts +9 -0
  124. package/dest/config/get_l1_config.d.ts.map +1 -0
  125. package/dest/config/get_l1_config.js +24 -0
  126. package/dest/config/index.d.ts +5 -0
  127. package/dest/config/index.d.ts.map +1 -0
  128. package/dest/config/index.js +4 -0
  129. package/dest/config/network_config.d.ts +22 -0
  130. package/dest/config/network_config.d.ts.map +1 -0
  131. package/dest/config/network_config.js +115 -0
  132. package/dest/utils/aztec.d.ts +8 -20
  133. package/dest/utils/aztec.d.ts.map +1 -1
  134. package/dest/utils/aztec.js +22 -67
  135. package/dest/utils/commands.d.ts +21 -12
  136. package/dest/utils/commands.d.ts.map +1 -1
  137. package/dest/utils/commands.js +38 -11
  138. package/dest/utils/encoding.d.ts +1 -1
  139. package/dest/utils/encoding.js +1 -1
  140. package/dest/utils/github.d.ts +1 -1
  141. package/dest/utils/index.d.ts +1 -1
  142. package/dest/utils/inspect.d.ts +5 -11
  143. package/dest/utils/inspect.d.ts.map +1 -1
  144. package/dest/utils/inspect.js +13 -95
  145. package/dest/utils/setup_contracts.d.ts +2 -4
  146. package/dest/utils/setup_contracts.d.ts.map +1 -1
  147. package/dest/utils/setup_contracts.js +2 -22
  148. package/package.json +43 -28
  149. package/public_include_metric_prefixes.json +1 -0
  150. package/src/cmds/aztec_node/block_number.ts +9 -0
  151. package/src/cmds/aztec_node/get_block.ts +11 -0
  152. package/src/cmds/aztec_node/get_current_min_fee.ts +9 -0
  153. package/src/cmds/aztec_node/get_l1_to_l2_message_witness.ts +27 -0
  154. package/src/cmds/{pxe → aztec_node}/get_logs.ts +11 -9
  155. package/src/cmds/{pxe → aztec_node}/get_node_info.ts +5 -16
  156. package/src/cmds/aztec_node/index.ts +87 -0
  157. package/src/cmds/contracts/inspect_contract.ts +4 -11
  158. package/src/cmds/infrastructure/index.ts +7 -18
  159. package/src/cmds/infrastructure/sequencers.ts +13 -11
  160. package/src/cmds/infrastructure/setup_l2_contract.ts +13 -30
  161. package/src/cmds/l1/advance_epoch.ts +6 -5
  162. package/src/cmds/l1/assume_proven_through.ts +10 -6
  163. package/src/cmds/l1/bridge_erc20.ts +5 -2
  164. package/src/cmds/l1/{deploy_l1_contracts.ts → deploy_l1_contracts_cmd.ts} +44 -24
  165. package/src/cmds/l1/deploy_new_rollup.ts +6 -9
  166. package/src/cmds/l1/get_l1_addresses.ts +5 -3
  167. package/src/cmds/l1/get_l1_balance.ts +2 -2
  168. package/src/cmds/l1/governance_utils.ts +3 -8
  169. package/src/cmds/l1/index.ts +28 -66
  170. package/src/cmds/l1/prover_stats.ts +42 -31
  171. package/src/cmds/l1/trigger_seed_snapshot.ts +2 -1
  172. package/src/cmds/l1/update_l1_validators.ts +88 -18
  173. package/src/cmds/misc/generate_secret_and_hash.ts +2 -2
  174. package/src/cmds/misc/generate_secret_key.ts +1 -1
  175. package/src/cmds/misc/index.ts +1 -1
  176. package/src/cmds/misc/update/npm.ts +1 -1
  177. package/src/cmds/validator_keys/add.ts +123 -0
  178. package/src/cmds/validator_keys/generate_bls_keypair.ts +34 -0
  179. package/src/cmds/validator_keys/index.ts +142 -0
  180. package/src/cmds/validator_keys/new.ts +207 -0
  181. package/src/cmds/validator_keys/shared.ts +326 -0
  182. package/src/cmds/validator_keys/staker.ts +301 -0
  183. package/src/cmds/validator_keys/utils.ts +81 -0
  184. package/src/config/cached_fetch.ts +67 -0
  185. package/src/config/chain_l2_config.ts +694 -0
  186. package/src/config/enrich_env.ts +15 -0
  187. package/src/config/get_l1_config.ts +31 -0
  188. package/src/config/index.ts +4 -0
  189. package/src/config/network_config.ts +147 -0
  190. package/src/utils/aztec.ts +27 -118
  191. package/src/utils/commands.ts +52 -15
  192. package/src/utils/encoding.ts +1 -1
  193. package/src/utils/inspect.ts +19 -111
  194. package/src/utils/setup_contracts.ts +4 -43
  195. package/dest/cmds/devnet/bootstrap_network.d.ts +0 -3
  196. package/dest/cmds/devnet/bootstrap_network.d.ts.map +0 -1
  197. package/dest/cmds/devnet/bootstrap_network.js +0 -216
  198. package/dest/cmds/devnet/faucet.d.ts +0 -4
  199. package/dest/cmds/devnet/faucet.d.ts.map +0 -1
  200. package/dest/cmds/devnet/faucet.js +0 -26
  201. package/dest/cmds/devnet/index.d.ts +0 -4
  202. package/dest/cmds/devnet/index.d.ts.map +0 -1
  203. package/dest/cmds/devnet/index.js +0 -14
  204. package/dest/cmds/l1/deploy_l1_contracts.d.ts +0 -4
  205. package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +0 -1
  206. package/dest/cmds/pxe/add_contract.d.ts +0 -5
  207. package/dest/cmds/pxe/add_contract.d.ts.map +0 -1
  208. package/dest/cmds/pxe/add_contract.js +0 -29
  209. package/dest/cmds/pxe/block_number.d.ts +0 -3
  210. package/dest/cmds/pxe/block_number.d.ts.map +0 -1
  211. package/dest/cmds/pxe/block_number.js +0 -10
  212. package/dest/cmds/pxe/get_account.d.ts +0 -4
  213. package/dest/cmds/pxe/get_account.d.ts.map +0 -1
  214. package/dest/cmds/pxe/get_account.js +0 -10
  215. package/dest/cmds/pxe/get_accounts.d.ts +0 -3
  216. package/dest/cmds/pxe/get_accounts.d.ts.map +0 -1
  217. package/dest/cmds/pxe/get_accounts.js +0 -25
  218. package/dest/cmds/pxe/get_block.d.ts +0 -3
  219. package/dest/cmds/pxe/get_block.d.ts.map +0 -1
  220. package/dest/cmds/pxe/get_block.js +0 -9
  221. package/dest/cmds/pxe/get_contract_data.d.ts +0 -4
  222. package/dest/cmds/pxe/get_contract_data.d.ts.map +0 -1
  223. package/dest/cmds/pxe/get_contract_data.js +0 -31
  224. package/dest/cmds/pxe/get_current_base_fee.d.ts +0 -3
  225. package/dest/cmds/pxe/get_current_base_fee.d.ts.map +0 -1
  226. package/dest/cmds/pxe/get_current_base_fee.js +0 -7
  227. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts +0 -4
  228. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts.map +0 -1
  229. package/dest/cmds/pxe/get_l1_to_l2_message_witness.js +0 -11
  230. package/dest/cmds/pxe/get_logs.d.ts +0 -4
  231. package/dest/cmds/pxe/get_logs.d.ts.map +0 -1
  232. package/dest/cmds/pxe/get_node_info.d.ts +0 -3
  233. package/dest/cmds/pxe/get_node_info.d.ts.map +0 -1
  234. package/dest/cmds/pxe/get_pxe_info.d.ts +0 -3
  235. package/dest/cmds/pxe/get_pxe_info.d.ts.map +0 -1
  236. package/dest/cmds/pxe/get_pxe_info.js +0 -11
  237. package/dest/cmds/pxe/index.d.ts +0 -4
  238. package/dest/cmds/pxe/index.d.ts.map +0 -1
  239. package/dest/cmds/pxe/index.js +0 -55
  240. package/src/cmds/devnet/bootstrap_network.ts +0 -321
  241. package/src/cmds/devnet/faucet.ts +0 -33
  242. package/src/cmds/devnet/index.ts +0 -60
  243. package/src/cmds/pxe/add_contract.ts +0 -41
  244. package/src/cmds/pxe/block_number.ts +0 -9
  245. package/src/cmds/pxe/get_account.ts +0 -16
  246. package/src/cmds/pxe/get_accounts.ts +0 -35
  247. package/src/cmds/pxe/get_block.ts +0 -10
  248. package/src/cmds/pxe/get_contract_data.ts +0 -51
  249. package/src/cmds/pxe/get_current_base_fee.ts +0 -9
  250. package/src/cmds/pxe/get_l1_to_l2_message_witness.ts +0 -25
  251. package/src/cmds/pxe/get_pxe_info.ts +0 -13
  252. package/src/cmds/pxe/index.ts +0 -170
@@ -0,0 +1,142 @@
1
+ import type { LogFn } from '@aztec/foundation/log';
2
+
3
+ import { Command } from 'commander';
4
+
5
+ import { parseAztecAddress, parseEthereumAddress, parseHex, parseOptionalInteger } from '../../utils/commands.js';
6
+ import { defaultBlsPath } from './utils.js';
7
+
8
+ export function injectCommands(program: Command, log: LogFn) {
9
+ const group = program
10
+ .command('validator-keys')
11
+ .aliases(['valKeys', 'valkeys'])
12
+ .description('Manage validator keystores for node operators');
13
+
14
+ group
15
+ .command('new')
16
+ .summary('Generate a new validator keystore JSON')
17
+ .description('Generates a new validator keystore with ETH secp256k1 accounts and optional BLS accounts')
18
+ .option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore')
19
+ .option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)')
20
+ .option('--count <N>', 'Number of validators to generate', parseOptionalInteger)
21
+ .option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', value =>
22
+ parseOptionalInteger(value, 0),
23
+ )
24
+ .option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', value =>
25
+ value.split(',').map((key: string) => key.trim()),
26
+ )
27
+ .option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
28
+ .option('--passphrase <str>', 'Optional passphrase for mnemonic')
29
+ .option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger)
30
+ .option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger)
31
+ .option(
32
+ '--coinbase <address>',
33
+ 'Coinbase ETH address to use when proposing. Defaults to attester address.',
34
+ parseEthereumAddress,
35
+ )
36
+ // TODO: add funding account back in when implemented
37
+ // .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
38
+ .option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
39
+ .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
40
+ .option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
41
+ .option(
42
+ '--password <str>',
43
+ 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
44
+ )
45
+ .option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)')
46
+ .option('--json', 'Echo resulting JSON to stdout')
47
+ .option('--staker-output', 'Generate a single staker output JSON file with an array of validator entries')
48
+ .option('--gse-address <address>', 'GSE contract address (required with --staker-output)', parseEthereumAddress)
49
+ .option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated, required with --staker-output)', value =>
50
+ value.split(','),
51
+ )
52
+ .option(
53
+ '-c, --l1-chain-id <number>',
54
+ 'L1 chain ID (required with --staker-output)',
55
+ value => parseInt(value),
56
+ 31337,
57
+ )
58
+ .requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
59
+ .action(async options => {
60
+ const { newValidatorKeystore } = await import('./new.js');
61
+
62
+ await newValidatorKeystore(options, log);
63
+ });
64
+
65
+ group
66
+ .command('add')
67
+ .summary('Augment an existing validator keystore JSON')
68
+ .description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new')
69
+ .argument('<existing>', 'Path to existing keystore JSON')
70
+ .option('--data-dir <path>', 'Directory where keystore(s) live. (default: ~/.aztec/keystore)')
71
+ .option('--file <name>', 'Override output file name. (default: key<N>.json)')
72
+ .option('--count <N>', 'Number of validators to add. (default: 1)', parseOptionalInteger)
73
+ .option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', value =>
74
+ parseOptionalInteger(value, 0),
75
+ )
76
+ .option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', value =>
77
+ value.split(',').map((key: string) => key.trim()),
78
+ )
79
+ .option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
80
+ .option('--passphrase <str>', 'Optional passphrase for mnemonic')
81
+ .option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger)
82
+ .option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger)
83
+ .option(
84
+ '--coinbase <address>',
85
+ 'Coinbase ETH address to use when proposing. Defaults to attester address.',
86
+ parseEthereumAddress,
87
+ )
88
+ // TODO: add funding account back in when implemented
89
+ // .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
90
+ .option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
91
+ .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
92
+ .option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
93
+ .option('--empty', 'Generate an empty skeleton without keys')
94
+ .option(
95
+ '--password <str>',
96
+ 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
97
+ )
98
+ .option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)')
99
+ .option('--json', 'Echo resulting JSON to stdout')
100
+ .requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
101
+ .action(async (existing: string, options) => {
102
+ const { addValidatorKeys } = await import('./add.js');
103
+ await addValidatorKeys(existing, options, log);
104
+ });
105
+
106
+ group
107
+ .command('staker')
108
+ .summary('Generate staking JSON from keystore')
109
+ .description(
110
+ 'Reads a validator keystore and outputs staking data with BLS public keys for each attester (skips mnemonics)',
111
+ )
112
+ .requiredOption('--from <keystore>', 'Path to keystore JSON file')
113
+ .option('--password <password>', 'Password for decrypting encrypted keystores (if not specified in keystore file)')
114
+ .requiredOption('--gse-address <address>', 'GSE contract address', parseEthereumAddress)
115
+ .option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated)', value => value.split(','), [
116
+ 'http://localhost:8545',
117
+ ])
118
+ .option('-c, --l1-chain-id <number>', 'L1 chain ID', value => parseInt(value), 31337)
119
+ .option('--output <file>', 'Output file path (if not specified, JSON is written to stdout)')
120
+ .action(async options => {
121
+ const { generateStakerJson } = await import('./staker.js');
122
+ await generateStakerJson(options, log);
123
+ });
124
+
125
+ // top-level convenience: aztec generate-bls-keypair
126
+ program
127
+ .command('generate-bls-keypair')
128
+ .description('Generate a BLS keypair with convenience flags')
129
+ .option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation')
130
+ .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
131
+ .option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
132
+ .option('--g2', 'Derive on G2 subgroup')
133
+ .option('--compressed', 'Output compressed public key')
134
+ .option('--json', 'Print JSON output to stdout')
135
+ .option('--out <file>', 'Write output to file')
136
+ .action(async options => {
137
+ const { generateBlsKeypair } = await import('./generate_bls_keypair.js');
138
+ await generateBlsKeypair(options, log);
139
+ });
140
+
141
+ return program;
142
+ }
@@ -0,0 +1,207 @@
1
+ import { prettyPrintJSON } from '@aztec/cli/utils';
2
+ import { createEthereumChain } from '@aztec/ethereum/chain';
3
+ import { GSEContract } from '@aztec/ethereum/contracts';
4
+ import type { EthAddress } from '@aztec/foundation/eth-address';
5
+ import type { LogFn } from '@aztec/foundation/log';
6
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
+
8
+ import { wordlist } from '@scure/bip39/wordlists/english.js';
9
+ import { writeFile } from 'fs/promises';
10
+ import { basename, dirname, join } from 'path';
11
+ import { createPublicClient, fallback, http } from 'viem';
12
+ import { generateMnemonic, mnemonicToAccount } from 'viem/accounts';
13
+
14
+ import {
15
+ buildValidatorEntries,
16
+ logValidatorSummaries,
17
+ maybePrintJson,
18
+ resolveKeystoreOutputPath,
19
+ writeBlsBn254ToFile,
20
+ writeEthJsonV3ToFile,
21
+ writeKeystoreFile,
22
+ } from './shared.js';
23
+ import { processAttesterAccounts } from './staker.js';
24
+ import {
25
+ validateBlsPathOptions,
26
+ validatePublisherOptions,
27
+ validateRemoteSignerOptions,
28
+ validateStakerOutputOptions,
29
+ } from './utils.js';
30
+
31
+ export type NewValidatorKeystoreOptions = {
32
+ dataDir?: string;
33
+ file?: string;
34
+ count?: number;
35
+ publisherCount?: number;
36
+ publishers?: string[];
37
+ mnemonic?: string;
38
+ passphrase?: string;
39
+ accountIndex?: number;
40
+ addressIndex?: number;
41
+ separatePublisher?: boolean;
42
+ ikm?: string;
43
+ blsPath?: string;
44
+ password?: string;
45
+ encryptedKeystoreDir?: string;
46
+ json?: boolean;
47
+ feeRecipient: AztecAddress;
48
+ coinbase?: EthAddress;
49
+ remoteSigner?: string;
50
+ stakerOutput?: boolean;
51
+ gseAddress?: EthAddress;
52
+ l1RpcUrls?: string[];
53
+ l1ChainId?: number;
54
+ };
55
+
56
+ export async function newValidatorKeystore(options: NewValidatorKeystoreOptions, log: LogFn) {
57
+ // validate bls-path inputs before proceeding with key generation
58
+ validateBlsPathOptions(options);
59
+ // validate staker output options before proceeding with key generation
60
+ validateStakerOutputOptions(options);
61
+ // validate publisher options
62
+ validatePublisherOptions(options);
63
+ // validate remote signer options
64
+ validateRemoteSignerOptions(options);
65
+
66
+ const {
67
+ dataDir,
68
+ file,
69
+ count,
70
+ publisherCount = 0,
71
+ publishers,
72
+ json,
73
+ coinbase,
74
+ accountIndex = 0,
75
+ addressIndex = 0,
76
+ feeRecipient,
77
+ remoteSigner,
78
+ blsPath,
79
+ ikm,
80
+ mnemonic: _mnemonic,
81
+ password,
82
+ encryptedKeystoreDir,
83
+ stakerOutput,
84
+ gseAddress,
85
+ l1RpcUrls,
86
+ l1ChainId,
87
+ } = options;
88
+
89
+ const mnemonic = _mnemonic ?? generateMnemonic(wordlist);
90
+
91
+ if (!_mnemonic && !json) {
92
+ log('No mnemonic provided, generating new one...');
93
+ log(`Using new mnemonic:`);
94
+ log('');
95
+ log(mnemonic);
96
+ log('');
97
+ }
98
+
99
+ const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
100
+ const { outputPath } = await resolveKeystoreOutputPath(dataDir, file);
101
+ const keystoreOutDir = dirname(outputPath);
102
+
103
+ const { validators, summaries } = await buildValidatorEntries({
104
+ validatorCount,
105
+ publisherCount,
106
+ publishers,
107
+ accountIndex,
108
+ baseAddressIndex: addressIndex,
109
+ mnemonic,
110
+ ikm,
111
+ blsPath,
112
+ feeRecipient,
113
+ coinbase,
114
+ remoteSigner,
115
+ });
116
+
117
+ // If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
118
+ if (password !== undefined) {
119
+ const encryptedKeystoreOutDir =
120
+ encryptedKeystoreDir && encryptedKeystoreDir.length > 0 ? encryptedKeystoreDir : keystoreOutDir;
121
+ await writeEthJsonV3ToFile(validators, { outDir: encryptedKeystoreOutDir, password });
122
+ await writeBlsBn254ToFile(validators, { outDir: encryptedKeystoreOutDir, password });
123
+ }
124
+
125
+ const keystore = {
126
+ schemaVersion: 1,
127
+ validators,
128
+ };
129
+
130
+ await writeKeystoreFile(outputPath, keystore);
131
+
132
+ // Generate staker outputs if requested
133
+ const allStakerOutputs: any[] = [];
134
+ if (stakerOutput && gseAddress && l1RpcUrls && l1ChainId !== undefined) {
135
+ const chain = createEthereumChain(l1RpcUrls, l1ChainId);
136
+ const publicClient = createPublicClient({
137
+ chain: chain.chainInfo,
138
+ transport: fallback(l1RpcUrls.map(url => http(url, { batch: false }))),
139
+ });
140
+ const gse = new GSEContract(publicClient, gseAddress);
141
+
142
+ // Extract keystore base name without extension for unique staker output filenames
143
+ const keystoreBaseName = basename(outputPath, '.json');
144
+
145
+ // Process each validator
146
+ for (let i = 0; i < validators.length; i++) {
147
+ const validator = validators[i];
148
+ const outputs = await processAttesterAccounts(validator.attester, gse, password);
149
+
150
+ // Collect all staker outputs
151
+ for (let j = 0; j < outputs.length; j++) {
152
+ allStakerOutputs.push(outputs[j]);
153
+ }
154
+ }
155
+
156
+ // Write a single JSON file with all staker outputs
157
+ if (allStakerOutputs.length > 0) {
158
+ const stakerOutputPath = join(keystoreOutDir, `${keystoreBaseName}_staker_output.json`);
159
+ await writeFile(stakerOutputPath, prettyPrintJSON(allStakerOutputs), 'utf-8');
160
+ }
161
+ }
162
+
163
+ const outputData = !_mnemonic ? { ...keystore, generatedMnemonic: mnemonic } : keystore;
164
+
165
+ // Handle JSON output
166
+ if (json) {
167
+ if (stakerOutput && allStakerOutputs.length > 0) {
168
+ const combinedOutput = {
169
+ keystore: outputData,
170
+ staker: allStakerOutputs,
171
+ };
172
+ maybePrintJson(log, json, combinedOutput as unknown as Record<string, any>);
173
+ } else {
174
+ maybePrintJson(log, json, outputData as unknown as Record<string, any>);
175
+ }
176
+ } else {
177
+ log(`Wrote validator keystore to ${outputPath}`);
178
+ if (stakerOutput && allStakerOutputs.length > 0) {
179
+ const keystoreBaseName = basename(outputPath, '.json');
180
+ const stakerOutputPath = join(keystoreOutDir, `${keystoreBaseName}_staker_output.json`);
181
+ log(`Wrote staker output for ${allStakerOutputs.length} validator(s) to ${stakerOutputPath}`);
182
+ log('');
183
+ }
184
+ }
185
+
186
+ // print a concise summary of public keys (addresses and BLS pubkeys) if no --json options was selected
187
+ if (!json) {
188
+ logValidatorSummaries(log, summaries);
189
+ }
190
+
191
+ if (mnemonic && remoteSigner && !json) {
192
+ for (let i = 0; i < validatorCount; i++) {
193
+ const addrIdx = addressIndex + i;
194
+ const acct = mnemonicToAccount(mnemonic, {
195
+ accountIndex,
196
+ addressIndex: addrIdx,
197
+ });
198
+ log(`attester address: ${acct.address} remoteSignerUrl: ${remoteSigner}`);
199
+ }
200
+ }
201
+
202
+ // Log staker outputs if not in JSON mode
203
+ if (!json && stakerOutput && allStakerOutputs.length > 0) {
204
+ log('\nStaker outputs:');
205
+ log(prettyPrintJSON(allStakerOutputs));
206
+ }
207
+ }
@@ -0,0 +1,326 @@
1
+ import { prettyPrintJSON } from '@aztec/cli/utils';
2
+ import { deriveBlsPrivateKey } from '@aztec/foundation/crypto/bls';
3
+ import { createBn254Keystore } from '@aztec/foundation/crypto/bls/bn254_keystore';
4
+ import { computeBn254G1PublicKeyCompressed } from '@aztec/foundation/crypto/bn254';
5
+ import type { EthAddress } from '@aztec/foundation/eth-address';
6
+ import type { LogFn } from '@aztec/foundation/log';
7
+ import type { EthAccount, EthPrivateKey, ValidatorKeyStore } from '@aztec/node-keystore/types';
8
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
9
+
10
+ import { Wallet } from '@ethersproject/wallet';
11
+ import { constants as fsConstants, mkdirSync } from 'fs';
12
+ import { access, writeFile } from 'fs/promises';
13
+ import { homedir } from 'os';
14
+ import { dirname, isAbsolute, join } from 'path';
15
+ import { mnemonicToAccount } from 'viem/accounts';
16
+
17
+ import { defaultBlsPath } from './utils.js';
18
+
19
+ export type ValidatorSummary = { attesterEth?: string; attesterBls?: string; publisherEth?: string[] };
20
+
21
+ export type BuildValidatorsInput = {
22
+ validatorCount: number;
23
+ publisherCount?: number;
24
+ publishers?: string[];
25
+ accountIndex: number;
26
+ baseAddressIndex: number;
27
+ mnemonic: string;
28
+ ikm?: string;
29
+ blsPath?: string;
30
+ feeRecipient: AztecAddress;
31
+ coinbase?: EthAddress;
32
+ remoteSigner?: string;
33
+ };
34
+
35
+ export function withValidatorIndex(path: string, accountIndex: number = 0, addressIndex: number = 0) {
36
+ // NOTE: The legacy BLS CLI is to allow users who generated keys in 2.1.4 to be able to use the same command
37
+ // to re-generate their keys. In 2.1.5 we switched how we append addresses to the path so this is to maintain backwards compatibility.
38
+ const useLegacyBlsCli = ['true', '1', 'yes', 'y'].includes(process.env.LEGACY_BLS_CLI ?? '');
39
+
40
+ const defaultBlsPathParts = defaultBlsPath.split('/');
41
+
42
+ const parts = path.split('/');
43
+ if (parts.length == defaultBlsPathParts.length && parts.every((part, index) => part === defaultBlsPathParts[index])) {
44
+ if (useLegacyBlsCli) {
45
+ // In 2.1.4, we were using address-index in parts[3] and did NOT use account-index, check lines 32 & 84
46
+ // https://github.com/AztecProtocol/aztec-packages/blob/v2.1.4/yarn-project/cli/src/cmds/validator_keys/shared.ts
47
+
48
+ parts[3] = String(addressIndex);
49
+ } else {
50
+ parts[3] = String(accountIndex);
51
+ parts[5] = String(addressIndex);
52
+ }
53
+ return parts.join('/');
54
+ }
55
+ return path;
56
+ }
57
+
58
+ /**
59
+ * Compute a compressed BN254 G1 public key from a private key.
60
+ * @param privateKeyHex - Private key as 0x-prefixed hex string
61
+ * @returns Compressed G1 point (32 bytes with sign bit in MSB)
62
+ */
63
+ export async function computeBlsPublicKeyCompressed(privateKeyHex: string): Promise<string> {
64
+ return await computeBn254G1PublicKeyCompressed(privateKeyHex);
65
+ }
66
+
67
+ export function deriveEthAttester(
68
+ mnemonic: string,
69
+ baseAccountIndex: number,
70
+ addressIndex: number,
71
+ remoteSigner?: string,
72
+ ): EthAccount | EthPrivateKey {
73
+ const acct = mnemonicToAccount(mnemonic, { accountIndex: baseAccountIndex, addressIndex });
74
+ return remoteSigner
75
+ ? ({ address: acct.address as unknown as EthAddress, remoteSignerUrl: remoteSigner } as EthAccount)
76
+ : (('0x' + Buffer.from(acct.getHdKey().privateKey!).toString('hex')) as EthPrivateKey);
77
+ }
78
+
79
+ export async function buildValidatorEntries(input: BuildValidatorsInput) {
80
+ const {
81
+ validatorCount,
82
+ publisherCount = 0,
83
+ publishers,
84
+ accountIndex,
85
+ baseAddressIndex,
86
+ mnemonic,
87
+ ikm,
88
+ blsPath,
89
+ feeRecipient,
90
+ coinbase,
91
+ remoteSigner,
92
+ } = input;
93
+
94
+ const summaries: ValidatorSummary[] = [];
95
+
96
+ const validators = await Promise.all(
97
+ Array.from({ length: validatorCount }, async (_unused, i) => {
98
+ const addressIndex = baseAddressIndex + i;
99
+ const basePath = blsPath ?? defaultBlsPath;
100
+ const perValidatorPath = withValidatorIndex(basePath, accountIndex, addressIndex);
101
+
102
+ const blsPrivKey = ikm || mnemonic ? deriveBlsPrivateKey(mnemonic, ikm, perValidatorPath) : undefined;
103
+ const blsPubCompressed = blsPrivKey ? await computeBlsPublicKeyCompressed(blsPrivKey) : undefined;
104
+
105
+ const ethAttester = deriveEthAttester(mnemonic, accountIndex, addressIndex, remoteSigner);
106
+ const attester = blsPrivKey ? { eth: ethAttester, bls: blsPrivKey } : ethAttester;
107
+
108
+ let publisherField: EthAccount | EthPrivateKey | (EthAccount | EthPrivateKey)[] | undefined;
109
+ const publisherAddresses: string[] = [];
110
+ if (publishers && publishers.length > 0) {
111
+ publisherAddresses.push(...publishers);
112
+ publisherField = publishers.length === 1 ? (publishers[0] as EthPrivateKey) : (publishers as EthPrivateKey[]);
113
+ } else if (publisherCount > 0) {
114
+ const publishersBaseIndex = baseAddressIndex + validatorCount + i * publisherCount;
115
+ const publisherAccounts = Array.from({ length: publisherCount }, (_unused2, j) => {
116
+ const publisherAddressIndex = publishersBaseIndex + j;
117
+ const pubAcct = mnemonicToAccount(mnemonic, {
118
+ accountIndex,
119
+ addressIndex: publisherAddressIndex,
120
+ });
121
+ publisherAddresses.push(pubAcct.address as unknown as string);
122
+ return remoteSigner
123
+ ? ({ address: pubAcct.address as unknown as EthAddress, remoteSignerUrl: remoteSigner } as EthAccount)
124
+ : (('0x' + Buffer.from(pubAcct.getHdKey().privateKey!).toString('hex')) as EthPrivateKey);
125
+ });
126
+ publisherField = publisherCount === 1 ? publisherAccounts[0] : publisherAccounts;
127
+ }
128
+
129
+ const acct = mnemonicToAccount(mnemonic, {
130
+ accountIndex,
131
+ addressIndex,
132
+ });
133
+ const attesterEthAddress = acct.address as unknown as string;
134
+ summaries.push({
135
+ attesterEth: attesterEthAddress,
136
+ attesterBls: blsPubCompressed,
137
+ publisherEth: publisherAddresses.length > 0 ? publisherAddresses : undefined,
138
+ });
139
+
140
+ return {
141
+ attester,
142
+ ...(publisherField !== undefined ? { publisher: publisherField } : {}),
143
+ feeRecipient,
144
+ coinbase: coinbase ?? attesterEthAddress,
145
+ } as ValidatorKeyStore;
146
+ }),
147
+ );
148
+
149
+ return { validators, summaries };
150
+ }
151
+
152
+ export async function resolveKeystoreOutputPath(dataDir?: string, file?: string) {
153
+ const defaultDataDir = join(homedir(), '.aztec', 'keystore');
154
+ const resolvedDir = dataDir && dataDir.length > 0 ? dataDir : defaultDataDir;
155
+ let outputPath: string;
156
+ if (file && file.length > 0) {
157
+ outputPath = isAbsolute(file) ? file : join(resolvedDir, file);
158
+ } else {
159
+ let index = 1;
160
+ while (true) {
161
+ const candidate = join(resolvedDir, `key${index}.json`);
162
+ try {
163
+ await access(candidate, fsConstants.F_OK);
164
+ index += 1;
165
+ } catch {
166
+ outputPath = candidate;
167
+ break;
168
+ }
169
+ }
170
+ }
171
+ return { resolvedDir, outputPath: outputPath! };
172
+ }
173
+
174
+ export async function writeKeystoreFile(path: string, keystore: unknown) {
175
+ mkdirSync(dirname(path), { recursive: true });
176
+ await writeFile(path, JSON.stringify(keystore, null, 2), { encoding: 'utf-8' });
177
+ }
178
+
179
+ export function logValidatorSummaries(log: LogFn, summaries: ValidatorSummary[]) {
180
+ const lines: string[] = [];
181
+ for (let i = 0; i < summaries.length; i++) {
182
+ const v = summaries[i];
183
+ lines.push(`acc${i + 1}:`);
184
+ lines.push(` attester:`);
185
+ if (v.attesterEth) {
186
+ lines.push(` eth: ${v.attesterEth}`);
187
+ }
188
+ if (v.attesterBls) {
189
+ lines.push(` bls: ${v.attesterBls}`);
190
+ }
191
+ if (v.publisherEth && v.publisherEth.length > 0) {
192
+ lines.push(` publisher:`);
193
+ for (const addr of v.publisherEth) {
194
+ lines.push(` - ${addr}`);
195
+ }
196
+ }
197
+ }
198
+ if (lines.length > 0) {
199
+ log(lines.join('\n'));
200
+ }
201
+ }
202
+
203
+ export function maybePrintJson(log: LogFn, jsonFlag: boolean | undefined, obj: unknown) {
204
+ if (jsonFlag) {
205
+ log(prettyPrintJSON(obj as Record<string, any>));
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Writes a BN254 keystore file for a BN254 BLS private key.
211
+ * Returns the absolute path to the written file.
212
+ *
213
+ * @param outDir - Directory to write the keystore file to
214
+ * @param fileNameBase - Base name for the keystore file (will be sanitized)
215
+ * @param password - Password for encrypting the private key
216
+ * @param privateKeyHex - Private key as 0x-prefixed hex string (32 bytes)
217
+ * @param pubkeyHex - Public key as hex string
218
+ * @param derivationPath - BIP-44 style derivation path
219
+ * @returns Absolute path to the written keystore file
220
+ */
221
+ export async function writeBn254BlsKeystore(
222
+ outDir: string,
223
+ fileNameBase: string,
224
+ password: string,
225
+ privateKeyHex: string,
226
+ pubkeyHex: string,
227
+ derivationPath: string,
228
+ ): Promise<string> {
229
+ mkdirSync(outDir, { recursive: true });
230
+
231
+ const keystore = createBn254Keystore(password, privateKeyHex, pubkeyHex, derivationPath);
232
+
233
+ const safeBase = fileNameBase.replace(/[^a-zA-Z0-9_-]/g, '_');
234
+ const outPath = join(outDir, `keystore-${safeBase}.json`);
235
+ await writeFile(outPath, JSON.stringify(keystore, null, 2), { encoding: 'utf-8' });
236
+ return outPath;
237
+ }
238
+
239
+ /** Replace plaintext BLS keys in validators with { path, password } pointing to BN254 keystore files. */
240
+ export async function writeBlsBn254ToFile(
241
+ validators: ValidatorKeyStore[],
242
+ options: { outDir: string; password: string; blsPath?: string },
243
+ ): Promise<void> {
244
+ for (let i = 0; i < validators.length; i++) {
245
+ const v = validators[i];
246
+ if (!v || typeof v !== 'object' || !('attester' in v)) {
247
+ continue;
248
+ }
249
+ const att = (v as any).attester;
250
+
251
+ // Shapes: { bls: <hex> } or { eth: <ethAccount>, bls?: <hex> } or plain EthAccount
252
+ const blsKey: string | undefined = typeof att === 'object' && 'bls' in att ? (att as any).bls : undefined;
253
+ if (!blsKey || typeof blsKey !== 'string') {
254
+ continue;
255
+ }
256
+
257
+ const pub = await computeBlsPublicKeyCompressed(blsKey);
258
+ const path = options.blsPath ?? defaultBlsPath;
259
+ const fileBase = `${String(i + 1)}_${pub.slice(2, 18)}`;
260
+ const keystorePath = await writeBn254BlsKeystore(options.outDir, fileBase, options.password, blsKey, pub, path);
261
+
262
+ if (typeof att === 'object') {
263
+ (att as any).bls = { path: keystorePath, password: options.password };
264
+ }
265
+ }
266
+ }
267
+
268
+ /** Writes an Ethereum JSON V3 keystore using ethers, returns absolute path */
269
+ export async function writeEthJsonV3Keystore(
270
+ outDir: string,
271
+ fileNameBase: string,
272
+ password: string,
273
+ privateKeyHex: string,
274
+ ): Promise<string> {
275
+ const safeBase = fileNameBase.replace(/[^a-zA-Z0-9_-]/g, '_');
276
+ mkdirSync(outDir, { recursive: true });
277
+ const wallet = new Wallet(privateKeyHex);
278
+ const json = await wallet.encrypt(password);
279
+ const outPath = join(outDir, `keystore-eth-${safeBase}.json`);
280
+ await writeFile(outPath, json, { encoding: 'utf-8' });
281
+ return outPath;
282
+ }
283
+
284
+ /** Replace plaintext ETH keys in validators with { path, password } pointing to JSON V3 files. */
285
+ export async function writeEthJsonV3ToFile(
286
+ validators: ValidatorKeyStore[],
287
+ options: { outDir: string; password: string },
288
+ ): Promise<void> {
289
+ const maybeEncryptEth = async (account: any, label: string) => {
290
+ if (typeof account === 'string' && account.startsWith('0x') && account.length === 66) {
291
+ const fileBase = `${label}_${account.slice(2, 10)}`;
292
+ const p = await writeEthJsonV3Keystore(options.outDir, fileBase, options.password, account);
293
+ return { path: p, password: options.password };
294
+ }
295
+ return account;
296
+ };
297
+
298
+ for (let i = 0; i < validators.length; i++) {
299
+ const v = validators[i];
300
+ if (!v || typeof v !== 'object') {
301
+ continue;
302
+ }
303
+
304
+ // attester may be string (eth), object with eth, or remote signer
305
+ const att = (v as any).attester;
306
+ if (typeof att === 'string') {
307
+ (v as any).attester = await maybeEncryptEth(att, `attester_${i + 1}`);
308
+ } else if (att && typeof att === 'object' && 'eth' in att) {
309
+ (att as any).eth = await maybeEncryptEth((att as any).eth, `attester_${i + 1}`);
310
+ }
311
+
312
+ // publisher can be single or array
313
+ if ('publisher' in v) {
314
+ const pub = (v as any).publisher;
315
+ if (Array.isArray(pub)) {
316
+ const out: any[] = [];
317
+ for (let j = 0; j < pub.length; j++) {
318
+ out.push(await maybeEncryptEth(pub[j], `publisher_${i + 1}_${j + 1}`));
319
+ }
320
+ (v as any).publisher = out;
321
+ } else if (pub !== undefined) {
322
+ (v as any).publisher = await maybeEncryptEth(pub, `publisher_${i + 1}`);
323
+ }
324
+ }
325
+ }
326
+ }