@aztec/cli 2.1.0-rc.9 → 2.1.2-rc.1

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 (40) hide show
  1. package/dest/cmds/l1/deploy_new_rollup.d.ts +1 -1
  2. package/dest/cmds/l1/deploy_new_rollup.d.ts.map +1 -1
  3. package/dest/cmds/l1/deploy_new_rollup.js +2 -2
  4. package/dest/cmds/l1/index.d.ts.map +1 -1
  5. package/dest/cmds/l1/index.js +2 -2
  6. package/dest/cmds/validator_keys/add.d.ts +5 -0
  7. package/dest/cmds/validator_keys/add.d.ts.map +1 -0
  8. package/dest/cmds/validator_keys/add.js +70 -0
  9. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +12 -0
  10. package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -0
  11. package/dest/cmds/validator_keys/generate_bls_keypair.js +26 -0
  12. package/dest/cmds/validator_keys/index.d.ts +4 -0
  13. package/dest/cmds/validator_keys/index.d.ts.map +1 -0
  14. package/dest/cmds/validator_keys/index.js +20 -0
  15. package/dest/cmds/validator_keys/new.d.ts +26 -0
  16. package/dest/cmds/validator_keys/new.d.ts.map +1 -0
  17. package/dest/cmds/validator_keys/new.js +60 -0
  18. package/dest/cmds/validator_keys/shared.d.ts +68 -0
  19. package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
  20. package/dest/cmds/validator_keys/shared.js +271 -0
  21. package/dest/config/chain_l2_config.d.ts +6 -4
  22. package/dest/config/chain_l2_config.d.ts.map +1 -1
  23. package/dest/config/chain_l2_config.js +82 -65
  24. package/dest/utils/aztec.d.ts +1 -1
  25. package/dest/utils/aztec.d.ts.map +1 -1
  26. package/dest/utils/aztec.js +2 -2
  27. package/dest/utils/commands.d.ts +10 -1
  28. package/dest/utils/commands.d.ts.map +1 -1
  29. package/dest/utils/commands.js +30 -3
  30. package/package.json +28 -24
  31. package/src/cmds/l1/deploy_new_rollup.ts +2 -0
  32. package/src/cmds/l1/index.ts +2 -0
  33. package/src/cmds/validator_keys/add.ts +113 -0
  34. package/src/cmds/validator_keys/generate_bls_keypair.ts +33 -0
  35. package/src/cmds/validator_keys/index.ts +96 -0
  36. package/src/cmds/validator_keys/new.ts +120 -0
  37. package/src/cmds/validator_keys/shared.ts +321 -0
  38. package/src/config/chain_l2_config.ts +110 -84
  39. package/src/utils/aztec.ts +2 -0
  40. package/src/utils/commands.ts +41 -3
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/utils/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,KAAK,OAAO,EAAwC,MAAM,EAAE,MAAM,WAAW,CAAC;AAIvF;;;GAGG;AACH,eAAO,MAAM,YAAY,uBAGI,CAAC;AAE9B,eAAO,MAAM,SAAS,QAAuB,CAAC;AAC9C,eAAO,MAAQ,cAAc,UAA+B,WAAW,sBAAE,QAAQ,sBAAE,OAAO,sBAAE,WAAW,oBAAgB,CAAC;AAExH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAG7D;AAED,eAAO,MAAM,aAAa,GAAI,WAAW,OAAO,WAKb,CAAC;AAEpC,eAAO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74
74
  }
75
75
  return from;
76
76
  }
77
+ /**
78
+ * Parses and validates a hex string. Removes leading 0x if present, checks for hex validity,
79
+ * and enforces an optional minimum length.
80
+ * @param hex - The hex string to validate.
81
+ * @param minLen - Optional minimum length (in hex characters, after stripping '0x').
82
+ * @returns The normalized hex string (without leading 0x).
83
+ * @throws InvalidArgumentError if the string is not valid hex or does not meet the minimum length.
84
+ */ // minLen is now interpreted as the minimum number of bytes (2 hex characters per byte)
85
+ export function parseHex(hex, minLen) {
86
+ const normalized = hex.startsWith('0x') ? hex.slice(2) : hex;
87
+ if (!/^[0-9a-fA-F]*$/.test(normalized)) {
88
+ throw new InvalidArgumentError('Invalid hex string');
89
+ }
90
+ if (minLen !== undefined) {
91
+ const minHexLen = minLen * 2;
92
+ if (normalized.length < minHexLen) {
93
+ throw new InvalidArgumentError(`Hex string is too short (length ${normalized.length}), minimum byte length is ${minLen} (hex chars: ${minHexLen})`);
94
+ }
95
+ }
96
+ return `0x${normalized}`;
97
+ }
77
98
  /**
78
99
  * Removes the leading 0x from a hex string. If no leading 0x is found the string is returned unchanged.
79
100
  * @param hex - A hex string
@@ -118,7 +139,7 @@ export function parseBigint(bigint) {
118
139
  try {
119
140
  return AztecAddress.fromString(address);
120
141
  } catch {
121
- throw new InvalidArgumentError(`Invalid address: ${address}`);
142
+ throw new InvalidArgumentError(`Invalid Aztec address: ${address}`);
122
143
  }
123
144
  }
124
145
  /**
@@ -130,7 +151,7 @@ export function parseBigint(bigint) {
130
151
  try {
131
152
  return EthAddress.fromString(address);
132
153
  } catch {
133
- throw new InvalidArgumentError(`Invalid address: ${address}`);
154
+ throw new InvalidArgumentError(`Invalid Ethereumaddress: ${address}`);
134
155
  }
135
156
  }
136
157
  /**
@@ -176,7 +197,7 @@ export function parseBigint(bigint) {
176
197
  * @param value - The string to parse into an integer.
177
198
  * @returns The parsed integer, or undefined if the input string is falsy.
178
199
  * @throws If the input is not a valid integer.
179
- */ export function parseOptionalInteger(value) {
200
+ */ export function parseOptionalInteger(value, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
180
201
  if (!value) {
181
202
  return undefined;
182
203
  }
@@ -184,6 +205,12 @@ export function parseBigint(bigint) {
184
205
  if (!Number.isInteger(parsed)) {
185
206
  throw new InvalidArgumentError('Invalid integer.');
186
207
  }
208
+ if (parsed < min) {
209
+ throw new InvalidArgumentError(`Value must be greater than ${min}.`);
210
+ }
211
+ if (parsed > max) {
212
+ throw new InvalidArgumentError(`Value must be less than ${max}.`);
213
+ }
187
214
  return parsed;
188
215
  }
189
216
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli",
3
- "version": "2.1.0-rc.9",
3
+ "version": "2.1.2-rc.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./contracts": "./dest/cmds/contracts/index.js",
@@ -10,6 +10,7 @@
10
10
  "./pxe": "./dest/cmds/pxe/index.js",
11
11
  "./cli-utils": "./dest/utils/index.js",
12
12
  "./misc": "./dest/cmds/misc/index.js",
13
+ "./validator_keys": "./dest/cmds/validator_keys/index.js",
13
14
  "./setup-contracts": "./dest/cmds/misc/setup_contracts.js",
14
15
  "./utils": "./dest/utils/index.js",
15
16
  "./inspect": "./dest/utils/inspect.js",
@@ -70,30 +71,33 @@
70
71
  ]
71
72
  },
72
73
  "dependencies": {
73
- "@aztec/archiver": "2.1.0-rc.9",
74
- "@aztec/aztec.js": "2.1.0-rc.9",
75
- "@aztec/constants": "2.1.0-rc.9",
76
- "@aztec/entrypoints": "2.1.0-rc.9",
77
- "@aztec/ethereum": "2.1.0-rc.9",
78
- "@aztec/foundation": "2.1.0-rc.9",
79
- "@aztec/l1-artifacts": "2.1.0-rc.9",
80
- "@aztec/node-lib": "2.1.0-rc.9",
81
- "@aztec/p2p": "2.1.0-rc.9",
82
- "@aztec/stdlib": "2.1.0-rc.9",
83
- "@aztec/world-state": "2.1.0-rc.9",
74
+ "@aztec/archiver": "2.1.2-rc.1",
75
+ "@aztec/aztec.js": "2.1.2-rc.1",
76
+ "@aztec/constants": "2.1.2-rc.1",
77
+ "@aztec/entrypoints": "2.1.2-rc.1",
78
+ "@aztec/ethereum": "2.1.2-rc.1",
79
+ "@aztec/foundation": "2.1.2-rc.1",
80
+ "@aztec/l1-artifacts": "2.1.2-rc.1",
81
+ "@aztec/node-keystore": "2.1.2-rc.1",
82
+ "@aztec/node-lib": "2.1.2-rc.1",
83
+ "@aztec/p2p": "2.1.2-rc.1",
84
+ "@aztec/stdlib": "2.1.2-rc.1",
85
+ "@aztec/world-state": "2.1.2-rc.1",
86
+ "@ethersproject/wallet": "^5.8.0",
84
87
  "@iarna/toml": "^2.2.5",
85
88
  "@libp2p/peer-id-factory": "^3.0.4",
89
+ "@scure/bip39": "^2.0.1",
86
90
  "commander": "^12.1.0",
87
91
  "lodash.chunk": "^4.2.0",
88
92
  "lodash.groupby": "^4.6.0",
89
93
  "semver": "^7.5.4",
90
94
  "source-map-support": "^0.5.21",
91
95
  "tslib": "^2.4.0",
92
- "viem": "2.23.7"
96
+ "viem": "npm:@spalladino/viem@2.38.2-eip7594.0"
93
97
  },
94
98
  "devDependencies": {
95
- "@aztec/accounts": "2.1.0-rc.9",
96
- "@aztec/protocol-contracts": "2.1.0-rc.9",
99
+ "@aztec/accounts": "2.1.2-rc.1",
100
+ "@aztec/protocol-contracts": "2.1.2-rc.1",
97
101
  "@jest/globals": "^30.0.0",
98
102
  "@types/jest": "^30.0.0",
99
103
  "@types/lodash.chunk": "^4.2.9",
@@ -109,15 +113,15 @@
109
113
  "typescript": "^5.3.3"
110
114
  },
111
115
  "peerDependencies": {
112
- "@aztec/accounts": "2.1.0-rc.9",
113
- "@aztec/bb-prover": "2.1.0-rc.9",
114
- "@aztec/ethereum": "2.1.0-rc.9",
115
- "@aztec/l1-artifacts": "2.1.0-rc.9",
116
- "@aztec/noir-contracts.js": "2.1.0-rc.9",
117
- "@aztec/noir-protocol-circuits-types": "2.1.0-rc.9",
118
- "@aztec/noir-test-contracts.js": "2.1.0-rc.9",
119
- "@aztec/protocol-contracts": "2.1.0-rc.9",
120
- "@aztec/stdlib": "2.1.0-rc.9"
116
+ "@aztec/accounts": "2.1.2-rc.1",
117
+ "@aztec/bb-prover": "2.1.2-rc.1",
118
+ "@aztec/ethereum": "2.1.2-rc.1",
119
+ "@aztec/l1-artifacts": "2.1.2-rc.1",
120
+ "@aztec/noir-contracts.js": "2.1.2-rc.1",
121
+ "@aztec/noir-protocol-circuits-types": "2.1.2-rc.1",
122
+ "@aztec/noir-test-contracts.js": "2.1.2-rc.1",
123
+ "@aztec/protocol-contracts": "2.1.2-rc.1",
124
+ "@aztec/stdlib": "2.1.2-rc.1"
121
125
  },
122
126
  "files": [
123
127
  "dest",
@@ -20,6 +20,7 @@ export async function deployNewRollup(
20
20
  json: boolean,
21
21
  initialValidators: Operator[],
22
22
  realVerifier: boolean,
23
+ createVerificationJson: string | false,
23
24
  log: LogFn,
24
25
  debugLogger: Logger,
25
26
  ) {
@@ -43,6 +44,7 @@ export async function deployNewRollup(
43
44
  fundingNeeded,
44
45
  config,
45
46
  realVerifier,
47
+ createVerificationJson,
46
48
  debugLogger,
47
49
  );
48
50
 
@@ -94,6 +94,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
94
94
  .option('--test-accounts', 'Populate genesis state with initial fee juice for test accounts')
95
95
  .option('--sponsored-fpc', 'Populate genesis state with a testing sponsored FPC contract')
96
96
  .option('--real-verifier', 'Deploy the real verifier', false)
97
+ .option('--create-verification-json [path]', 'Create JSON file for etherscan contract verification', false)
97
98
  .action(async options => {
98
99
  const { deployNewRollup } = await import('./deploy_new_rollup.js');
99
100
 
@@ -112,6 +113,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: Logger
112
113
  options.json,
113
114
  initialValidators,
114
115
  options.realVerifier,
116
+ options.createVerificationJson,
115
117
  log,
116
118
  debugLogger,
117
119
  );
@@ -0,0 +1,113 @@
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
+
20
+ export type AddValidatorKeysOptions = NewValidatorKeystoreOptions;
21
+
22
+ export async function addValidatorKeys(existing: string, options: AddValidatorKeysOptions, log: LogFn) {
23
+ const {
24
+ dataDir,
25
+ file,
26
+ count,
27
+ publisherCount = 0,
28
+ mnemonic,
29
+ accountIndex = 0,
30
+ addressIndex,
31
+ ikm,
32
+ blsPath,
33
+ blsOnly,
34
+ json,
35
+ feeRecipient: feeRecipientOpt,
36
+ coinbase: coinbaseOpt,
37
+ fundingAccount: fundingAccountOpt,
38
+ remoteSigner: remoteSignerOpt,
39
+ password,
40
+ outDir,
41
+ } = options;
42
+
43
+ const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
44
+ const baseAddressIndex = addressIndex ?? 0;
45
+
46
+ const keystore: KeyStore = loadKeystoreFile(existing);
47
+
48
+ if (!keystore.validators || !Array.isArray(keystore.validators)) {
49
+ throw new Error('Invalid keystore: missing validators array');
50
+ }
51
+
52
+ const first = keystore.validators[0] ?? {};
53
+ const feeRecipient = feeRecipientOpt ?? first.feeRecipient;
54
+ if (!feeRecipient) {
55
+ throw new Error('feeRecipient is required (either present in existing file or via --fee-recipient)');
56
+ }
57
+ const coinbase = (coinbaseOpt as EthAddress | undefined) ?? (first.coinbase as EthAddress | undefined);
58
+ const fundingAccount =
59
+ (fundingAccountOpt as EthAddress | undefined) ?? (first.fundingAccount as EthAddress | undefined);
60
+ const derivedRemoteSigner = (first.attester as any)?.remoteSignerUrl || (first.attester as any)?.eth?.remoteSignerUrl;
61
+ const remoteSigner = remoteSignerOpt ?? derivedRemoteSigner;
62
+
63
+ // Ensure we always have a mnemonic for key derivation if none was provided
64
+ const mnemonicToUse = mnemonic ?? generateMnemonic(wordlist);
65
+
66
+ // If user explicitly provided --address-index, use it as-is. Otherwise, append after existing validators.
67
+ const effectiveBaseAddressIndex =
68
+ addressIndex === undefined ? baseAddressIndex + keystore.validators.length : baseAddressIndex;
69
+
70
+ const { validators, summaries } = await buildValidatorEntries({
71
+ validatorCount,
72
+ publisherCount,
73
+ accountIndex,
74
+ baseAddressIndex: effectiveBaseAddressIndex,
75
+ mnemonic: mnemonicToUse,
76
+ ikm,
77
+ blsPath,
78
+ blsOnly,
79
+ feeRecipient,
80
+ coinbase,
81
+ remoteSigner,
82
+ fundingAccount,
83
+ });
84
+
85
+ keystore.validators.push(...validators);
86
+
87
+ // If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
88
+ if (password !== undefined) {
89
+ const targetDir =
90
+ outDir && outDir.length > 0 ? outDir : dataDir && dataDir.length > 0 ? dataDir : dirname(existing);
91
+ await writeEthJsonV3ToFile(keystore.validators, { outDir: targetDir, password });
92
+ await writeBlsBn254ToFile(keystore.validators, { outDir: targetDir, password });
93
+ }
94
+
95
+ let outputPath = existing;
96
+ if (file && file.length > 0) {
97
+ if (isAbsolute(file)) {
98
+ outputPath = file;
99
+ } else if (dataDir && dataDir.length > 0) {
100
+ outputPath = join(dataDir, file);
101
+ } else {
102
+ outputPath = join(dirname(existing), file);
103
+ }
104
+ }
105
+
106
+ await writeKeystoreFile(outputPath, keystore);
107
+
108
+ if (!json) {
109
+ log(`Updated keystore ${outputPath} with ${validators.length} new validator(s)`);
110
+ logValidatorSummaries(log, summaries);
111
+ }
112
+ maybePrintJson(log, !!json, keystore as unknown as Record<string, any>);
113
+ }
@@ -0,0 +1,33 @@
1
+ import { deriveBlsPrivateKey } from '@aztec/foundation/crypto';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+
4
+ import { writeFile } from 'fs/promises';
5
+
6
+ import { computeBlsPublicKeyCompressed, withValidatorIndex } from './shared.js';
7
+
8
+ export type GenerateBlsKeypairOptions = {
9
+ mnemonic?: string;
10
+ ikm?: string;
11
+ blsPath?: string;
12
+ g2?: boolean;
13
+ compressed?: boolean;
14
+ json?: boolean;
15
+ out?: string;
16
+ };
17
+
18
+ export async function generateBlsKeypair(options: GenerateBlsKeypairOptions, log: LogFn) {
19
+ const { mnemonic, ikm, blsPath, compressed = true, json, out } = options;
20
+ const path = withValidatorIndex(blsPath ?? 'm/12381/3600/0/0/0', 0);
21
+ const priv = deriveBlsPrivateKey(mnemonic, ikm, path);
22
+ const pub = await computeBlsPublicKeyCompressed(priv);
23
+ const result = { path, privateKey: priv, publicKey: pub, format: compressed ? 'compressed' : 'uncompressed' };
24
+ if (out) {
25
+ await writeFile(out, JSON.stringify(result, null, 2), { encoding: 'utf-8' });
26
+ if (!json) {
27
+ log(`Wrote BLS keypair to ${out}`);
28
+ }
29
+ }
30
+ if (json || !out) {
31
+ log(JSON.stringify(result, null, 2));
32
+ }
33
+ }
@@ -0,0 +1,96 @@
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
+
7
+ export function injectCommands(program: Command, log: LogFn) {
8
+ const group = program
9
+ .command('validator-keys')
10
+ .aliases(['valKeys'])
11
+ .description('Manage validator keystores for node operators');
12
+
13
+ group
14
+ .command('new')
15
+ .summary('Generate a new validator keystore JSON')
16
+ .description('Generates a new validator keystore with ETH secp256k1 accounts and optional BLS accounts')
17
+ .option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore')
18
+ .option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)')
19
+ .option('--count <N>', 'Number of validators to generate', parseOptionalInteger)
20
+ .option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', value =>
21
+ parseOptionalInteger(value, 0),
22
+ )
23
+ .option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
24
+ .option('--passphrase <str>', 'Optional passphrase for mnemonic')
25
+ .option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger)
26
+ .option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger)
27
+ .option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress)
28
+ .option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress)
29
+ .option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
30
+ .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
31
+ .option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)')
32
+ .option('--bls-only', 'Generate only BLS keys')
33
+ .option(
34
+ '--password <str>',
35
+ 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
36
+ )
37
+ .option('--out-dir <dir>', 'Output directory for generated keystore file(s)')
38
+ .option('--json', 'Echo resulting JSON to stdout')
39
+ .requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
40
+ .action(async options => {
41
+ const { newValidatorKeystore } = await import('./new.js');
42
+ await newValidatorKeystore(options, log);
43
+ });
44
+
45
+ group
46
+ .command('add')
47
+ .summary('Augment an existing validator keystore JSON')
48
+ .description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new')
49
+ .argument('<existing>', 'Path to existing keystore JSON')
50
+ .option('--data-dir <path>', 'Directory where keystore(s) live')
51
+ .option('--file <name>', 'Override output file name')
52
+ .option('--count <N>', 'Number of validators to add', parseOptionalInteger)
53
+ .option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', value =>
54
+ parseOptionalInteger(value, 0),
55
+ )
56
+ .option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation')
57
+ .option('--passphrase <str>', 'Optional passphrase for mnemonic')
58
+ .option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger)
59
+ .option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger)
60
+ .option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress)
61
+ .option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress)
62
+ .option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
63
+ .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
64
+ .option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)')
65
+ .option('--bls-only', 'Generate only BLS keys')
66
+ .option('--empty', 'Generate an empty skeleton without keys')
67
+ .option(
68
+ '--password <str>',
69
+ 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed',
70
+ )
71
+ .option('--out-dir <dir>', 'Output directory for generated keystore file(s)')
72
+ .option('--json', 'Echo resulting JSON to stdout')
73
+ .requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress)
74
+ .action(async (existing: string, options) => {
75
+ const { addValidatorKeys } = await import('./add.js');
76
+ await addValidatorKeys(existing, options, log);
77
+ });
78
+
79
+ // top-level convenience: aztec generate-bls-keypair
80
+ program
81
+ .command('generate-bls-keypair')
82
+ .description('Generate a BLS keypair with convenience flags')
83
+ .option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation')
84
+ .option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
85
+ .option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)')
86
+ .option('--g2', 'Derive on G2 subgroup')
87
+ .option('--compressed', 'Output compressed public key')
88
+ .option('--json', 'Print JSON output to stdout')
89
+ .option('--out <file>', 'Write output to file')
90
+ .action(async options => {
91
+ const { generateBlsKeypair } = await import('./generate_bls_keypair.js');
92
+ await generateBlsKeypair(options, log);
93
+ });
94
+
95
+ return program;
96
+ }
@@ -0,0 +1,120 @@
1
+ import type { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+
5
+ import { wordlist } from '@scure/bip39/wordlists/english.js';
6
+ import { dirname } from 'path';
7
+ import { generateMnemonic, mnemonicToAccount } from 'viem/accounts';
8
+
9
+ import {
10
+ buildValidatorEntries,
11
+ logValidatorSummaries,
12
+ maybePrintJson,
13
+ resolveKeystoreOutputPath,
14
+ writeBlsBn254ToFile,
15
+ writeEthJsonV3ToFile,
16
+ writeKeystoreFile,
17
+ } from './shared.js';
18
+
19
+ export type NewValidatorKeystoreOptions = {
20
+ dataDir?: string;
21
+ file?: string;
22
+ count?: number;
23
+ publisherCount?: number;
24
+ mnemonic?: string;
25
+ passphrase?: string;
26
+ accountIndex?: number;
27
+ addressIndex?: number;
28
+ separatePublisher?: boolean;
29
+ ikm?: string;
30
+ blsPath?: string;
31
+ blsOnly?: boolean;
32
+ password?: string;
33
+ outDir?: string;
34
+ json?: boolean;
35
+ feeRecipient: AztecAddress;
36
+ coinbase?: EthAddress;
37
+ remoteSigner?: string;
38
+ fundingAccount?: EthAddress;
39
+ };
40
+
41
+ export async function newValidatorKeystore(options: NewValidatorKeystoreOptions, log: LogFn) {
42
+ const {
43
+ dataDir,
44
+ file,
45
+ count,
46
+ publisherCount = 0,
47
+ json,
48
+ coinbase,
49
+ accountIndex = 0,
50
+ addressIndex = 0,
51
+ feeRecipient,
52
+ remoteSigner,
53
+ fundingAccount,
54
+ blsOnly,
55
+ blsPath,
56
+ ikm,
57
+ mnemonic: _mnemonic,
58
+ password,
59
+ outDir,
60
+ } = options;
61
+
62
+ if (remoteSigner && !_mnemonic) {
63
+ throw new Error(
64
+ 'Using --remote-signer requires a deterministic key source. Provide --mnemonic to derive keys, or omit --remote-signer to write new private keys to keystore.',
65
+ );
66
+ }
67
+
68
+ const mnemonic = _mnemonic ?? generateMnemonic(wordlist);
69
+
70
+ const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
71
+ const { outputPath } = await resolveKeystoreOutputPath(dataDir, file);
72
+
73
+ const { validators, summaries } = await buildValidatorEntries({
74
+ validatorCount,
75
+ publisherCount,
76
+ accountIndex,
77
+ baseAddressIndex: addressIndex,
78
+ mnemonic,
79
+ ikm,
80
+ blsPath,
81
+ blsOnly,
82
+ feeRecipient,
83
+ coinbase,
84
+ remoteSigner,
85
+ fundingAccount,
86
+ });
87
+
88
+ // If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
89
+ if (password !== undefined) {
90
+ const keystoreOutDir = outDir && outDir.length > 0 ? outDir : dirname(outputPath);
91
+ await writeEthJsonV3ToFile(validators, { outDir: keystoreOutDir, password });
92
+ await writeBlsBn254ToFile(validators, { outDir: keystoreOutDir, password });
93
+ }
94
+
95
+ const keystore = {
96
+ schemaVersion: 1,
97
+ validators,
98
+ };
99
+
100
+ await writeKeystoreFile(outputPath, keystore);
101
+
102
+ maybePrintJson(log, json, keystore as unknown as Record<string, any>);
103
+ if (!json) {
104
+ log(`Wrote validator keystore to ${outputPath}`);
105
+ }
106
+
107
+ // Always print a concise summary of public keys (addresses and BLS pubkeys)
108
+ logValidatorSummaries(log, summaries);
109
+
110
+ if (!blsOnly && mnemonic && remoteSigner) {
111
+ for (let i = 0; i < validatorCount; i++) {
112
+ const addrIdx = addressIndex + i;
113
+ const acct = mnemonicToAccount(mnemonic, {
114
+ accountIndex,
115
+ addressIndex: addrIdx,
116
+ });
117
+ log(`attester address: ${acct.address} remoteSignerUrl: ${remoteSigner}`);
118
+ }
119
+ }
120
+ }