@aztec/cli 0.0.0-test.1 → 0.0.1-commit.0b941701

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 (285) 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 +14 -15
  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 +13 -15
  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 +8 -10
  31. package/dest/cmds/infrastructure/sequencers.d.ts +5 -6
  32. package/dest/cmds/infrastructure/sequencers.d.ts.map +1 -1
  33. package/dest/cmds/infrastructure/sequencers.js +38 -18
  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 +11 -24
  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 +8 -6
  40. package/dest/cmds/l1/assume_proven_through.d.ts +3 -2
  41. package/dest/cmds/l1/assume_proven_through.d.ts.map +1 -1
  42. package/dest/cmds/l1/assume_proven_through.js +10 -10
  43. package/dest/cmds/l1/bridge_erc20.d.ts +3 -3
  44. package/dest/cmds/l1/bridge_erc20.d.ts.map +1 -1
  45. package/dest/cmds/l1/bridge_erc20.js +6 -5
  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_cmd.js +81 -0
  50. package/dest/cmds/l1/deploy_new_rollup.d.ts +4 -3
  51. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
  52. package/dest/cmds/l1/deploy_new_rollup.js +18 -9
  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 +19 -17
  61. package/dest/cmds/l1/index.d.ts +1 -1
  62. package/dest/cmds/l1/index.d.ts.map +1 -1
  63. package/dest/cmds/l1/index.js +37 -44
  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 +6 -0
  68. package/dest/cmds/l1/trigger_seed_snapshot.d.ts.map +1 -0
  69. package/dest/cmds/l1/trigger_seed_snapshot.js +20 -0
  70. package/dest/cmds/l1/update_l1_validators.d.ts +21 -6
  71. package/dest/cmds/l1/update_l1_validators.d.ts.map +1 -1
  72. package/dest/cmds/l1/update_l1_validators.js +198 -103
  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 +2 -2
  76. package/dest/cmds/misc/generate_bootnode_enr.d.ts.map +1 -1
  77. package/dest/cmds/misc/generate_bootnode_enr.js +2 -2
  78. package/dest/cmds/misc/generate_p2p_private_key.d.ts +1 -1
  79. package/dest/cmds/misc/generate_secret_and_hash.d.ts +2 -2
  80. package/dest/cmds/misc/generate_secret_and_hash.d.ts.map +1 -1
  81. package/dest/cmds/misc/generate_secret_and_hash.js +4 -4
  82. package/dest/cmds/misc/generate_secret_key.d.ts +2 -2
  83. package/dest/cmds/misc/generate_secret_key.d.ts.map +1 -1
  84. package/dest/cmds/misc/generate_secret_key.js +1 -1
  85. package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts +3 -0
  86. package/dest/cmds/misc/get_canonical_sponsored_fpc_address.d.ts.map +1 -0
  87. package/dest/cmds/misc/get_canonical_sponsored_fpc_address.js +4 -0
  88. package/dest/cmds/misc/index.d.ts +1 -1
  89. package/dest/cmds/misc/index.d.ts.map +1 -1
  90. package/dest/cmds/misc/index.js +8 -4
  91. package/dest/cmds/misc/update/common.d.ts +1 -1
  92. package/dest/cmds/misc/update/github.d.ts +1 -2
  93. package/dest/cmds/misc/update/github.d.ts.map +1 -1
  94. package/dest/cmds/misc/update/github.js +0 -1
  95. package/dest/cmds/misc/update/noir.d.ts +1 -1
  96. package/dest/cmds/misc/update/npm.d.ts +1 -1
  97. package/dest/cmds/misc/update/npm.js +1 -1
  98. package/dest/cmds/misc/update/utils.d.ts +1 -1
  99. package/dest/cmds/misc/update.d.ts +1 -1
  100. package/dest/cmds/misc/update.d.ts.map +1 -1
  101. package/dest/cmds/misc/update.js +2 -3
  102. package/dest/cmds/validator_keys/add.d.ts +5 -0
  103. package/dest/cmds/validator_keys/add.d.ts.map +1 -0
  104. package/dest/cmds/validator_keys/add.js +83 -0
  105. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +12 -0
  106. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -0
  107. package/dest/cmds/validator_keys/generate_bls_keypair.js +27 -0
  108. package/dest/cmds/validator_keys/index.d.ts +4 -0
  109. package/dest/cmds/validator_keys/index.d.ts.map +1 -0
  110. package/dest/cmds/validator_keys/index.js +32 -0
  111. package/dest/cmds/validator_keys/new.d.ts +29 -0
  112. package/dest/cmds/validator_keys/new.d.ts.map +1 -0
  113. package/dest/cmds/validator_keys/new.js +134 -0
  114. package/dest/cmds/validator_keys/shared.d.ts +68 -0
  115. package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
  116. package/dest/cmds/validator_keys/shared.js +274 -0
  117. package/dest/cmds/validator_keys/staker.d.ts +38 -0
  118. package/dest/cmds/validator_keys/staker.d.ts.map +1 -0
  119. package/dest/cmds/validator_keys/staker.js +210 -0
  120. package/dest/cmds/validator_keys/utils.d.ts +25 -0
  121. package/dest/cmds/validator_keys/utils.d.ts.map +1 -0
  122. package/dest/cmds/validator_keys/utils.js +52 -0
  123. package/dest/config/cached_fetch.d.ts +18 -0
  124. package/dest/config/cached_fetch.d.ts.map +1 -0
  125. package/dest/config/cached_fetch.js +54 -0
  126. package/dest/config/chain_l2_config.d.ts +14 -0
  127. package/dest/config/chain_l2_config.d.ts.map +1 -0
  128. package/dest/config/chain_l2_config.js +45 -0
  129. package/dest/config/enrich_env.d.ts +4 -0
  130. package/dest/config/enrich_env.d.ts.map +1 -0
  131. package/dest/config/enrich_env.js +12 -0
  132. package/dest/config/generated/networks.d.ts +205 -0
  133. package/dest/config/generated/networks.d.ts.map +1 -0
  134. package/dest/config/generated/networks.js +206 -0
  135. package/dest/config/get_l1_config.d.ts +9 -0
  136. package/dest/config/get_l1_config.d.ts.map +1 -0
  137. package/dest/config/get_l1_config.js +24 -0
  138. package/dest/config/index.d.ts +5 -0
  139. package/dest/config/index.d.ts.map +1 -0
  140. package/dest/config/index.js +4 -0
  141. package/dest/config/network_config.d.ts +22 -0
  142. package/dest/config/network_config.d.ts.map +1 -0
  143. package/dest/config/network_config.js +115 -0
  144. package/dest/utils/aztec.d.ts +15 -26
  145. package/dest/utils/aztec.d.ts.map +1 -1
  146. package/dest/utils/aztec.js +56 -72
  147. package/dest/utils/commands.d.ts +22 -13
  148. package/dest/utils/commands.d.ts.map +1 -1
  149. package/dest/utils/commands.js +43 -16
  150. package/dest/utils/encoding.d.ts +1 -1
  151. package/dest/utils/encoding.js +2 -2
  152. package/dest/utils/github.d.ts +1 -2
  153. package/dest/utils/github.d.ts.map +1 -1
  154. package/dest/utils/github.js +0 -1
  155. package/dest/utils/index.d.ts +2 -1
  156. package/dest/utils/index.d.ts.map +1 -1
  157. package/dest/utils/index.js +1 -0
  158. package/dest/utils/inspect.d.ts +5 -11
  159. package/dest/utils/inspect.d.ts.map +1 -1
  160. package/dest/utils/inspect.js +23 -110
  161. package/dest/utils/setup_contracts.d.ts +3 -0
  162. package/dest/utils/setup_contracts.d.ts.map +1 -0
  163. package/dest/utils/setup_contracts.js +16 -0
  164. package/package.json +61 -37
  165. package/public_include_metric_prefixes.json +1 -0
  166. package/src/cmds/aztec_node/block_number.ts +9 -0
  167. package/src/cmds/aztec_node/get_block.ts +11 -0
  168. package/src/cmds/aztec_node/get_current_min_fee.ts +9 -0
  169. package/src/cmds/aztec_node/get_l1_to_l2_message_witness.ts +27 -0
  170. package/src/cmds/{pxe → aztec_node}/get_logs.ts +11 -9
  171. package/src/cmds/{pxe → aztec_node}/get_node_info.ts +15 -23
  172. package/src/cmds/aztec_node/index.ts +87 -0
  173. package/src/cmds/contracts/inspect_contract.ts +20 -17
  174. package/src/cmds/infrastructure/index.ts +8 -11
  175. package/src/cmds/infrastructure/sequencers.ts +41 -22
  176. package/src/cmds/infrastructure/setup_l2_contract.ts +13 -25
  177. package/src/cmds/l1/advance_epoch.ts +7 -5
  178. package/src/cmds/l1/assume_proven_through.ts +11 -10
  179. package/src/cmds/l1/bridge_erc20.ts +8 -4
  180. package/src/cmds/l1/deploy_l1_contracts_cmd.ts +107 -0
  181. package/src/cmds/l1/deploy_new_rollup.ts +24 -15
  182. package/src/cmds/l1/get_l1_addresses.ts +5 -3
  183. package/src/cmds/l1/get_l1_balance.ts +2 -2
  184. package/src/cmds/l1/governance_utils.ts +20 -24
  185. package/src/cmds/l1/index.ts +77 -113
  186. package/src/cmds/l1/prover_stats.ts +42 -31
  187. package/src/cmds/l1/trigger_seed_snapshot.ts +32 -0
  188. package/src/cmds/l1/update_l1_validators.ts +218 -97
  189. package/src/cmds/misc/generate_bootnode_enr.ts +3 -2
  190. package/src/cmds/misc/generate_secret_and_hash.ts +4 -4
  191. package/src/cmds/misc/generate_secret_key.ts +1 -1
  192. package/src/cmds/misc/get_canonical_sponsored_fpc_address.ts +7 -0
  193. package/src/cmds/misc/index.ts +14 -5
  194. package/src/cmds/misc/update/github.ts +0 -1
  195. package/src/cmds/misc/update/npm.ts +1 -1
  196. package/src/cmds/misc/update.ts +1 -7
  197. package/src/cmds/validator_keys/add.ts +123 -0
  198. package/src/cmds/validator_keys/generate_bls_keypair.ts +34 -0
  199. package/src/cmds/validator_keys/index.ts +142 -0
  200. package/src/cmds/validator_keys/new.ts +207 -0
  201. package/src/cmds/validator_keys/shared.ts +326 -0
  202. package/src/cmds/validator_keys/staker.ts +301 -0
  203. package/src/cmds/validator_keys/utils.ts +81 -0
  204. package/src/config/cached_fetch.ts +67 -0
  205. package/src/config/chain_l2_config.ts +57 -0
  206. package/src/config/enrich_env.ts +15 -0
  207. package/src/config/generated/networks.ts +210 -0
  208. package/src/config/get_l1_config.ts +31 -0
  209. package/src/config/index.ts +4 -0
  210. package/src/config/network_config.ts +147 -0
  211. package/src/utils/aztec.ts +74 -120
  212. package/src/utils/commands.ts +57 -20
  213. package/src/utils/encoding.ts +2 -2
  214. package/src/utils/github.ts +0 -1
  215. package/src/utils/index.ts +1 -0
  216. package/src/utils/inspect.ts +28 -124
  217. package/src/utils/setup_contracts.ts +19 -0
  218. package/dest/cmds/devnet/bootstrap_network.d.ts +0 -3
  219. package/dest/cmds/devnet/bootstrap_network.d.ts.map +0 -1
  220. package/dest/cmds/devnet/bootstrap_network.js +0 -196
  221. package/dest/cmds/devnet/faucet.d.ts +0 -4
  222. package/dest/cmds/devnet/faucet.d.ts.map +0 -1
  223. package/dest/cmds/devnet/faucet.js +0 -26
  224. package/dest/cmds/devnet/index.d.ts +0 -4
  225. package/dest/cmds/devnet/index.d.ts.map +0 -1
  226. package/dest/cmds/devnet/index.js +0 -14
  227. package/dest/cmds/l1/deploy_l1_contracts.d.ts +0 -4
  228. package/dest/cmds/l1/deploy_l1_contracts.d.ts.map +0 -1
  229. package/dest/cmds/l1/deploy_l1_contracts.js +0 -29
  230. package/dest/cmds/l1/deploy_l1_verifier.d.ts +0 -5
  231. package/dest/cmds/l1/deploy_l1_verifier.d.ts.map +0 -1
  232. package/dest/cmds/l1/deploy_l1_verifier.js +0 -54
  233. package/dest/cmds/misc/setup_contracts.d.ts +0 -7
  234. package/dest/cmds/misc/setup_contracts.d.ts.map +0 -1
  235. package/dest/cmds/misc/setup_contracts.js +0 -27
  236. package/dest/cmds/pxe/add_contract.d.ts +0 -5
  237. package/dest/cmds/pxe/add_contract.d.ts.map +0 -1
  238. package/dest/cmds/pxe/add_contract.js +0 -29
  239. package/dest/cmds/pxe/block_number.d.ts +0 -3
  240. package/dest/cmds/pxe/block_number.d.ts.map +0 -1
  241. package/dest/cmds/pxe/block_number.js +0 -10
  242. package/dest/cmds/pxe/get_account.d.ts +0 -4
  243. package/dest/cmds/pxe/get_account.d.ts.map +0 -1
  244. package/dest/cmds/pxe/get_account.js +0 -10
  245. package/dest/cmds/pxe/get_accounts.d.ts +0 -3
  246. package/dest/cmds/pxe/get_accounts.d.ts.map +0 -1
  247. package/dest/cmds/pxe/get_accounts.js +0 -25
  248. package/dest/cmds/pxe/get_block.d.ts +0 -3
  249. package/dest/cmds/pxe/get_block.d.ts.map +0 -1
  250. package/dest/cmds/pxe/get_block.js +0 -9
  251. package/dest/cmds/pxe/get_contract_data.d.ts +0 -4
  252. package/dest/cmds/pxe/get_contract_data.d.ts.map +0 -1
  253. package/dest/cmds/pxe/get_contract_data.js +0 -31
  254. package/dest/cmds/pxe/get_current_base_fee.d.ts +0 -3
  255. package/dest/cmds/pxe/get_current_base_fee.d.ts.map +0 -1
  256. package/dest/cmds/pxe/get_current_base_fee.js +0 -7
  257. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts +0 -4
  258. package/dest/cmds/pxe/get_l1_to_l2_message_witness.d.ts.map +0 -1
  259. package/dest/cmds/pxe/get_l1_to_l2_message_witness.js +0 -11
  260. package/dest/cmds/pxe/get_logs.d.ts +0 -4
  261. package/dest/cmds/pxe/get_logs.d.ts.map +0 -1
  262. package/dest/cmds/pxe/get_node_info.d.ts +0 -3
  263. package/dest/cmds/pxe/get_node_info.d.ts.map +0 -1
  264. package/dest/cmds/pxe/get_pxe_info.d.ts +0 -3
  265. package/dest/cmds/pxe/get_pxe_info.d.ts.map +0 -1
  266. package/dest/cmds/pxe/get_pxe_info.js +0 -11
  267. package/dest/cmds/pxe/index.d.ts +0 -4
  268. package/dest/cmds/pxe/index.d.ts.map +0 -1
  269. package/dest/cmds/pxe/index.js +0 -55
  270. package/src/cmds/devnet/bootstrap_network.ts +0 -318
  271. package/src/cmds/devnet/faucet.ts +0 -33
  272. package/src/cmds/devnet/index.ts +0 -60
  273. package/src/cmds/l1/deploy_l1_contracts.ts +0 -65
  274. package/src/cmds/l1/deploy_l1_verifier.ts +0 -105
  275. package/src/cmds/misc/setup_contracts.ts +0 -40
  276. package/src/cmds/pxe/add_contract.ts +0 -41
  277. package/src/cmds/pxe/block_number.ts +0 -9
  278. package/src/cmds/pxe/get_account.ts +0 -16
  279. package/src/cmds/pxe/get_accounts.ts +0 -35
  280. package/src/cmds/pxe/get_block.ts +0 -10
  281. package/src/cmds/pxe/get_contract_data.ts +0 -51
  282. package/src/cmds/pxe/get_current_base_fee.ts +0 -9
  283. package/src/cmds/pxe/get_l1_to_l2_message_witness.ts +0 -25
  284. package/src/cmds/pxe/get_pxe_info.ts +0 -13
  285. package/src/cmds/pxe/index.ts +0 -170
@@ -0,0 +1,123 @@
1
+ import type { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ import { loadKeystoreFile } from '@aztec/node-keystore/loader';
4
+ import type { KeyStore } from '@aztec/node-keystore/types';
5
+
6
+ import { wordlist } from '@scure/bip39/wordlists/english.js';
7
+ import { dirname, isAbsolute, join } from 'path';
8
+ import { generateMnemonic } from 'viem/accounts';
9
+
10
+ import type { NewValidatorKeystoreOptions } from './new.js';
11
+ import {
12
+ buildValidatorEntries,
13
+ logValidatorSummaries,
14
+ maybePrintJson,
15
+ writeBlsBn254ToFile,
16
+ writeEthJsonV3ToFile,
17
+ writeKeystoreFile,
18
+ } from './shared.js';
19
+ import { validateBlsPathOptions, validatePublisherOptions, validateRemoteSignerOptions } from './utils.js';
20
+
21
+ export type AddValidatorKeysOptions = NewValidatorKeystoreOptions;
22
+
23
+ export async function addValidatorKeys(existing: string, options: AddValidatorKeysOptions, log: LogFn) {
24
+ // validate bls-path inputs before proceeding with key generation
25
+ validateBlsPathOptions(options);
26
+ // validate publisher options
27
+ validatePublisherOptions(options);
28
+ // validate remote signer options
29
+ validateRemoteSignerOptions(options);
30
+
31
+ const {
32
+ dataDir,
33
+ file,
34
+ count,
35
+ publisherCount = 0,
36
+ publishers,
37
+ mnemonic,
38
+ accountIndex = 0,
39
+ addressIndex,
40
+ ikm,
41
+ blsPath,
42
+ json,
43
+ feeRecipient: feeRecipientOpt,
44
+ coinbase: coinbaseOpt,
45
+ remoteSigner: remoteSignerOpt,
46
+ password,
47
+ encryptedKeystoreDir,
48
+ } = options;
49
+
50
+ const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
51
+ const baseAddressIndex = addressIndex ?? 0;
52
+
53
+ const keystore: KeyStore = loadKeystoreFile(existing);
54
+
55
+ if (!keystore.validators || !Array.isArray(keystore.validators)) {
56
+ throw new Error('Invalid keystore: missing validators array');
57
+ }
58
+
59
+ const first = keystore.validators[0] ?? {};
60
+ const feeRecipient = feeRecipientOpt ?? first.feeRecipient;
61
+ if (!feeRecipient) {
62
+ throw new Error('feeRecipient is required (either present in existing file or via --fee-recipient)');
63
+ }
64
+ const coinbase = (coinbaseOpt as EthAddress | undefined) ?? (first.coinbase as EthAddress | undefined);
65
+ const derivedRemoteSigner = (first.attester as any)?.remoteSignerUrl || (first.attester as any)?.eth?.remoteSignerUrl;
66
+ const remoteSigner = remoteSignerOpt ?? derivedRemoteSigner;
67
+
68
+ // Ensure we always have a mnemonic for key derivation if none was provided
69
+ const mnemonicToUse = mnemonic ?? generateMnemonic(wordlist);
70
+
71
+ // If user explicitly provided --address-index, use it as-is. Otherwise, append after existing validators.
72
+ const effectiveBaseAddressIndex =
73
+ addressIndex === undefined ? baseAddressIndex + keystore.validators.length : baseAddressIndex;
74
+
75
+ const { validators, summaries } = await buildValidatorEntries({
76
+ validatorCount,
77
+ publisherCount,
78
+ publishers,
79
+ accountIndex,
80
+ baseAddressIndex: effectiveBaseAddressIndex,
81
+ mnemonic: mnemonicToUse,
82
+ ikm,
83
+ blsPath,
84
+ feeRecipient,
85
+ coinbase,
86
+ remoteSigner,
87
+ });
88
+
89
+ keystore.validators.push(...validators);
90
+
91
+ // If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
92
+ if (password !== undefined) {
93
+ let targetDir: string;
94
+ if (encryptedKeystoreDir && encryptedKeystoreDir.length > 0) {
95
+ targetDir = encryptedKeystoreDir;
96
+ } else if (dataDir && dataDir.length > 0) {
97
+ targetDir = dataDir;
98
+ } else {
99
+ targetDir = dirname(existing);
100
+ }
101
+ await writeEthJsonV3ToFile(keystore.validators, { outDir: targetDir, password });
102
+ await writeBlsBn254ToFile(keystore.validators, { outDir: targetDir, password, blsPath });
103
+ }
104
+
105
+ let outputPath = existing;
106
+ if (file && file.length > 0) {
107
+ if (isAbsolute(file)) {
108
+ outputPath = file;
109
+ } else if (dataDir && dataDir.length > 0) {
110
+ outputPath = join(dataDir, file);
111
+ } else {
112
+ outputPath = join(dirname(existing), file);
113
+ }
114
+ }
115
+
116
+ await writeKeystoreFile(outputPath, keystore);
117
+
118
+ if (!json) {
119
+ log(`Updated keystore ${outputPath} with ${validators.length} new validator(s)`);
120
+ logValidatorSummaries(log, summaries);
121
+ }
122
+ maybePrintJson(log, !!json, keystore as unknown as Record<string, any>);
123
+ }
@@ -0,0 +1,34 @@
1
+ import { deriveBlsPrivateKey } from '@aztec/foundation/crypto/bls';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+
4
+ import { writeFile } from 'fs/promises';
5
+
6
+ import { computeBlsPublicKeyCompressed, withValidatorIndex } from './shared.js';
7
+ import { defaultBlsPath } from './utils.js';
8
+
9
+ export type GenerateBlsKeypairOptions = {
10
+ mnemonic?: string;
11
+ ikm?: string;
12
+ blsPath?: string;
13
+ g2?: boolean;
14
+ compressed?: boolean;
15
+ json?: boolean;
16
+ out?: string;
17
+ };
18
+
19
+ export async function generateBlsKeypair(options: GenerateBlsKeypairOptions, log: LogFn) {
20
+ const { mnemonic, ikm, blsPath, compressed = true, json, out } = options;
21
+ const path = withValidatorIndex(blsPath ?? defaultBlsPath, 0);
22
+ const priv = deriveBlsPrivateKey(mnemonic, ikm, path);
23
+ const pub = await computeBlsPublicKeyCompressed(priv);
24
+ const result = { path, privateKey: priv, publicKey: pub, format: compressed ? 'compressed' : 'uncompressed' };
25
+ if (out) {
26
+ await writeFile(out, JSON.stringify(result, null, 2), { encoding: 'utf-8' });
27
+ if (!json) {
28
+ log(`Wrote BLS keypair to ${out}`);
29
+ }
30
+ }
31
+ if (json || !out) {
32
+ log(JSON.stringify(result, null, 2));
33
+ }
34
+ }
@@ -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
+ }