@aztec/cli 3.0.0-nightly.20251030-2 → 3.0.0-nightly.20251101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/cmds/validator_keys/add.d.ts +5 -0
- package/dest/cmds/validator_keys/add.d.ts.map +1 -0
- package/dest/cmds/validator_keys/add.js +70 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.d.ts +12 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.d.ts.map +1 -0
- package/dest/cmds/validator_keys/generate_bls_keypair.js +26 -0
- package/dest/cmds/validator_keys/index.d.ts +4 -0
- package/dest/cmds/validator_keys/index.d.ts.map +1 -0
- package/dest/cmds/validator_keys/index.js +20 -0
- package/dest/cmds/validator_keys/new.d.ts +26 -0
- package/dest/cmds/validator_keys/new.d.ts.map +1 -0
- package/dest/cmds/validator_keys/new.js +60 -0
- package/dest/cmds/validator_keys/shared.d.ts +68 -0
- package/dest/cmds/validator_keys/shared.d.ts.map +1 -0
- package/dest/cmds/validator_keys/shared.js +271 -0
- package/dest/config/chain_l2_config.d.ts.map +1 -1
- package/dest/config/chain_l2_config.js +21 -21
- package/dest/utils/commands.d.ts +10 -1
- package/dest/utils/commands.d.ts.map +1 -1
- package/dest/utils/commands.js +30 -3
- package/package.json +28 -24
- package/src/cmds/validator_keys/add.ts +113 -0
- package/src/cmds/validator_keys/generate_bls_keypair.ts +33 -0
- package/src/cmds/validator_keys/index.ts +96 -0
- package/src/cmds/validator_keys/new.ts +120 -0
- package/src/cmds/validator_keys/shared.ts +321 -0
- package/src/config/chain_l2_config.ts +28 -26
- package/src/utils/commands.ts +41 -3
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
import type { NewValidatorKeystoreOptions } from './new.js';
|
|
3
|
+
export type AddValidatorKeysOptions = NewValidatorKeystoreOptions;
|
|
4
|
+
export declare function addValidatorKeys(existing: string, options: AddValidatorKeysOptions, log: LogFn): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/add.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAU5D,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,CAAC;AAElE,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,GAAG,EAAE,KAAK,iBA2FpG"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { loadKeystoreFile } from '@aztec/node-keystore/loader';
|
|
2
|
+
import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
3
|
+
import { dirname, isAbsolute, join } from 'path';
|
|
4
|
+
import { generateMnemonic } from 'viem/accounts';
|
|
5
|
+
import { buildValidatorEntries, logValidatorSummaries, maybePrintJson, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
|
|
6
|
+
export async function addValidatorKeys(existing, options, log) {
|
|
7
|
+
const { dataDir, file, count, publisherCount = 0, mnemonic, accountIndex = 0, addressIndex, ikm, blsPath, blsOnly, json, feeRecipient: feeRecipientOpt, coinbase: coinbaseOpt, fundingAccount: fundingAccountOpt, remoteSigner: remoteSignerOpt, password, outDir } = options;
|
|
8
|
+
const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
|
|
9
|
+
const baseAddressIndex = addressIndex ?? 0;
|
|
10
|
+
const keystore = loadKeystoreFile(existing);
|
|
11
|
+
if (!keystore.validators || !Array.isArray(keystore.validators)) {
|
|
12
|
+
throw new Error('Invalid keystore: missing validators array');
|
|
13
|
+
}
|
|
14
|
+
const first = keystore.validators[0] ?? {};
|
|
15
|
+
const feeRecipient = feeRecipientOpt ?? first.feeRecipient;
|
|
16
|
+
if (!feeRecipient) {
|
|
17
|
+
throw new Error('feeRecipient is required (either present in existing file or via --fee-recipient)');
|
|
18
|
+
}
|
|
19
|
+
const coinbase = coinbaseOpt ?? first.coinbase;
|
|
20
|
+
const fundingAccount = fundingAccountOpt ?? first.fundingAccount;
|
|
21
|
+
const derivedRemoteSigner = first.attester?.remoteSignerUrl || first.attester?.eth?.remoteSignerUrl;
|
|
22
|
+
const remoteSigner = remoteSignerOpt ?? derivedRemoteSigner;
|
|
23
|
+
// Ensure we always have a mnemonic for key derivation if none was provided
|
|
24
|
+
const mnemonicToUse = mnemonic ?? generateMnemonic(wordlist);
|
|
25
|
+
// If user explicitly provided --address-index, use it as-is. Otherwise, append after existing validators.
|
|
26
|
+
const effectiveBaseAddressIndex = addressIndex === undefined ? baseAddressIndex + keystore.validators.length : baseAddressIndex;
|
|
27
|
+
const { validators, summaries } = await buildValidatorEntries({
|
|
28
|
+
validatorCount,
|
|
29
|
+
publisherCount,
|
|
30
|
+
accountIndex,
|
|
31
|
+
baseAddressIndex: effectiveBaseAddressIndex,
|
|
32
|
+
mnemonic: mnemonicToUse,
|
|
33
|
+
ikm,
|
|
34
|
+
blsPath,
|
|
35
|
+
blsOnly,
|
|
36
|
+
feeRecipient,
|
|
37
|
+
coinbase,
|
|
38
|
+
remoteSigner,
|
|
39
|
+
fundingAccount
|
|
40
|
+
});
|
|
41
|
+
keystore.validators.push(...validators);
|
|
42
|
+
// If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
|
|
43
|
+
if (password !== undefined) {
|
|
44
|
+
const targetDir = outDir && outDir.length > 0 ? outDir : dataDir && dataDir.length > 0 ? dataDir : dirname(existing);
|
|
45
|
+
await writeEthJsonV3ToFile(keystore.validators, {
|
|
46
|
+
outDir: targetDir,
|
|
47
|
+
password
|
|
48
|
+
});
|
|
49
|
+
await writeBlsBn254ToFile(keystore.validators, {
|
|
50
|
+
outDir: targetDir,
|
|
51
|
+
password
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
let outputPath = existing;
|
|
55
|
+
if (file && file.length > 0) {
|
|
56
|
+
if (isAbsolute(file)) {
|
|
57
|
+
outputPath = file;
|
|
58
|
+
} else if (dataDir && dataDir.length > 0) {
|
|
59
|
+
outputPath = join(dataDir, file);
|
|
60
|
+
} else {
|
|
61
|
+
outputPath = join(dirname(existing), file);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
await writeKeystoreFile(outputPath, keystore);
|
|
65
|
+
if (!json) {
|
|
66
|
+
log(`Updated keystore ${outputPath} with ${validators.length} new validator(s)`);
|
|
67
|
+
logValidatorSummaries(log, summaries);
|
|
68
|
+
}
|
|
69
|
+
maybePrintJson(log, !!json, keystore);
|
|
70
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
export type GenerateBlsKeypairOptions = {
|
|
3
|
+
mnemonic?: string;
|
|
4
|
+
ikm?: string;
|
|
5
|
+
blsPath?: string;
|
|
6
|
+
g2?: boolean;
|
|
7
|
+
compressed?: boolean;
|
|
8
|
+
json?: boolean;
|
|
9
|
+
out?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function generateBlsKeypair(options: GenerateBlsKeypairOptions, log: LogFn): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=generate_bls_keypair.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate_bls_keypair.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/generate_bls_keypair.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAMnD,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,EAAE,GAAG,EAAE,KAAK,iBAetF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { deriveBlsPrivateKey } from '@aztec/foundation/crypto';
|
|
2
|
+
import { writeFile } from 'fs/promises';
|
|
3
|
+
import { computeBlsPublicKeyCompressed, withValidatorIndex } from './shared.js';
|
|
4
|
+
export async function generateBlsKeypair(options, log) {
|
|
5
|
+
const { mnemonic, ikm, blsPath, compressed = true, json, out } = options;
|
|
6
|
+
const path = withValidatorIndex(blsPath ?? 'm/12381/3600/0/0/0', 0);
|
|
7
|
+
const priv = deriveBlsPrivateKey(mnemonic, ikm, path);
|
|
8
|
+
const pub = await computeBlsPublicKeyCompressed(priv);
|
|
9
|
+
const result = {
|
|
10
|
+
path,
|
|
11
|
+
privateKey: priv,
|
|
12
|
+
publicKey: pub,
|
|
13
|
+
format: compressed ? 'compressed' : 'uncompressed'
|
|
14
|
+
};
|
|
15
|
+
if (out) {
|
|
16
|
+
await writeFile(out, JSON.stringify(result, null, 2), {
|
|
17
|
+
encoding: 'utf-8'
|
|
18
|
+
});
|
|
19
|
+
if (!json) {
|
|
20
|
+
log(`Wrote BLS keypair to ${out}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (json || !out) {
|
|
24
|
+
log(JSON.stringify(result, null, 2));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,WAyF1D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseAztecAddress, parseEthereumAddress, parseHex, parseOptionalInteger } from '../../utils/commands.js';
|
|
2
|
+
export function injectCommands(program, log) {
|
|
3
|
+
const group = program.command('validator-keys').aliases([
|
|
4
|
+
'valKeys'
|
|
5
|
+
]).description('Manage validator keystores for node operators');
|
|
6
|
+
group.command('new').summary('Generate a new validator keystore JSON').description('Generates a new validator keystore with ETH secp256k1 accounts and optional BLS accounts').option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore').option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)').option('--count <N>', 'Number of validators to generate', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', (value)=>parseOptionalInteger(value, 0)).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress).option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress).option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)').option('--bls-only', 'Generate only BLS keys').option('--password <str>', 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed').option('--out-dir <dir>', 'Output directory for generated keystore file(s)').option('--json', 'Echo resulting JSON to stdout').requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (options)=>{
|
|
7
|
+
const { newValidatorKeystore } = await import('./new.js');
|
|
8
|
+
await newValidatorKeystore(options, log);
|
|
9
|
+
});
|
|
10
|
+
group.command('add').summary('Augment an existing validator keystore JSON').description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new').argument('<existing>', 'Path to existing keystore JSON').option('--data-dir <path>', 'Directory where keystore(s) live').option('--file <name>', 'Override output file name').option('--count <N>', 'Number of validators to add', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 1)', (value)=>parseOptionalInteger(value, 0)).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing', parseEthereumAddress).option('--funding-account <address>', 'ETH account to fund publishers', parseEthereumAddress).option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)').option('--bls-only', 'Generate only BLS keys').option('--empty', 'Generate an empty skeleton without keys').option('--password <str>', 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed').option('--out-dir <dir>', 'Output directory for generated keystore file(s)').option('--json', 'Echo resulting JSON to stdout').requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (existing, options)=>{
|
|
11
|
+
const { addValidatorKeys } = await import('./add.js');
|
|
12
|
+
await addValidatorKeys(existing, options, log);
|
|
13
|
+
});
|
|
14
|
+
// top-level convenience: aztec generate-bls-keypair
|
|
15
|
+
program.command('generate-bls-keypair').description('Generate a BLS keypair with convenience flags').option('--mnemonic <mnemonic>', 'Mnemonic for BLS derivation').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', 'EIP-2334 path (default m/12381/3600/0/0/0)').option('--g2', 'Derive on G2 subgroup').option('--compressed', 'Output compressed public key').option('--json', 'Print JSON output to stdout').option('--out <file>', 'Write output to file').action(async (options)=>{
|
|
16
|
+
const { generateBlsKeypair } = await import('./generate_bls_keypair.js');
|
|
17
|
+
await generateBlsKeypair(options, log);
|
|
18
|
+
});
|
|
19
|
+
return program;
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
export type NewValidatorKeystoreOptions = {
|
|
5
|
+
dataDir?: string;
|
|
6
|
+
file?: string;
|
|
7
|
+
count?: number;
|
|
8
|
+
publisherCount?: number;
|
|
9
|
+
mnemonic?: string;
|
|
10
|
+
passphrase?: string;
|
|
11
|
+
accountIndex?: number;
|
|
12
|
+
addressIndex?: number;
|
|
13
|
+
separatePublisher?: boolean;
|
|
14
|
+
ikm?: string;
|
|
15
|
+
blsPath?: string;
|
|
16
|
+
blsOnly?: boolean;
|
|
17
|
+
password?: string;
|
|
18
|
+
outDir?: string;
|
|
19
|
+
json?: boolean;
|
|
20
|
+
feeRecipient: AztecAddress;
|
|
21
|
+
coinbase?: EthAddress;
|
|
22
|
+
remoteSigner?: string;
|
|
23
|
+
fundingAccount?: EthAddress;
|
|
24
|
+
};
|
|
25
|
+
export declare function newValidatorKeystore(options: NewValidatorKeystoreOptions, log: LogFn): Promise<void>;
|
|
26
|
+
//# sourceMappingURL=new.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/new.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAgBhE,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,UAAU,CAAC;CAC7B,CAAC;AAEF,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,EAAE,GAAG,EAAE,KAAK,iBA+E1F"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
import { generateMnemonic, mnemonicToAccount } from 'viem/accounts';
|
|
4
|
+
import { buildValidatorEntries, logValidatorSummaries, maybePrintJson, resolveKeystoreOutputPath, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
|
|
5
|
+
export async function newValidatorKeystore(options, log) {
|
|
6
|
+
const { dataDir, file, count, publisherCount = 0, json, coinbase, accountIndex = 0, addressIndex = 0, feeRecipient, remoteSigner, fundingAccount, blsOnly, blsPath, ikm, mnemonic: _mnemonic, password, outDir } = options;
|
|
7
|
+
if (remoteSigner && !_mnemonic) {
|
|
8
|
+
throw new Error('Using --remote-signer requires a deterministic key source. Provide --mnemonic to derive keys, or omit --remote-signer to write new private keys to keystore.');
|
|
9
|
+
}
|
|
10
|
+
const mnemonic = _mnemonic ?? generateMnemonic(wordlist);
|
|
11
|
+
const validatorCount = typeof count === 'number' && Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
|
|
12
|
+
const { outputPath } = await resolveKeystoreOutputPath(dataDir, file);
|
|
13
|
+
const { validators, summaries } = await buildValidatorEntries({
|
|
14
|
+
validatorCount,
|
|
15
|
+
publisherCount,
|
|
16
|
+
accountIndex,
|
|
17
|
+
baseAddressIndex: addressIndex,
|
|
18
|
+
mnemonic,
|
|
19
|
+
ikm,
|
|
20
|
+
blsPath,
|
|
21
|
+
blsOnly,
|
|
22
|
+
feeRecipient,
|
|
23
|
+
coinbase,
|
|
24
|
+
remoteSigner,
|
|
25
|
+
fundingAccount
|
|
26
|
+
});
|
|
27
|
+
// If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
|
|
28
|
+
if (password !== undefined) {
|
|
29
|
+
const keystoreOutDir = outDir && outDir.length > 0 ? outDir : dirname(outputPath);
|
|
30
|
+
await writeEthJsonV3ToFile(validators, {
|
|
31
|
+
outDir: keystoreOutDir,
|
|
32
|
+
password
|
|
33
|
+
});
|
|
34
|
+
await writeBlsBn254ToFile(validators, {
|
|
35
|
+
outDir: keystoreOutDir,
|
|
36
|
+
password
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const keystore = {
|
|
40
|
+
schemaVersion: 1,
|
|
41
|
+
validators
|
|
42
|
+
};
|
|
43
|
+
await writeKeystoreFile(outputPath, keystore);
|
|
44
|
+
maybePrintJson(log, json, keystore);
|
|
45
|
+
if (!json) {
|
|
46
|
+
log(`Wrote validator keystore to ${outputPath}`);
|
|
47
|
+
}
|
|
48
|
+
// Always print a concise summary of public keys (addresses and BLS pubkeys)
|
|
49
|
+
logValidatorSummaries(log, summaries);
|
|
50
|
+
if (!blsOnly && mnemonic && remoteSigner) {
|
|
51
|
+
for(let i = 0; i < validatorCount; i++){
|
|
52
|
+
const addrIdx = addressIndex + i;
|
|
53
|
+
const acct = mnemonicToAccount(mnemonic, {
|
|
54
|
+
accountIndex,
|
|
55
|
+
addressIndex: addrIdx
|
|
56
|
+
});
|
|
57
|
+
log(`attester address: ${acct.address} remoteSignerUrl: ${remoteSigner}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
import type { EthAccount, EthPrivateKey, ValidatorKeyStore } from '@aztec/node-keystore/types';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
export type ValidatorSummary = {
|
|
6
|
+
attesterEth?: string;
|
|
7
|
+
attesterBls?: string;
|
|
8
|
+
publisherEth?: string[];
|
|
9
|
+
};
|
|
10
|
+
export type BuildValidatorsInput = {
|
|
11
|
+
validatorCount: number;
|
|
12
|
+
publisherCount?: number;
|
|
13
|
+
accountIndex: number;
|
|
14
|
+
baseAddressIndex: number;
|
|
15
|
+
mnemonic: string;
|
|
16
|
+
ikm?: string;
|
|
17
|
+
blsPath?: string;
|
|
18
|
+
blsOnly?: boolean;
|
|
19
|
+
feeRecipient: AztecAddress;
|
|
20
|
+
coinbase?: EthAddress;
|
|
21
|
+
remoteSigner?: string;
|
|
22
|
+
fundingAccount?: EthAddress;
|
|
23
|
+
};
|
|
24
|
+
export declare function withValidatorIndex(path: string, index: number): string;
|
|
25
|
+
/**
|
|
26
|
+
* Compute a compressed BN254 G1 public key from a private key.
|
|
27
|
+
* @param privateKeyHex - Private key as 0x-prefixed hex string
|
|
28
|
+
* @returns Compressed G1 point (32 bytes with sign bit in MSB)
|
|
29
|
+
*/
|
|
30
|
+
export declare function computeBlsPublicKeyCompressed(privateKeyHex: string): Promise<string>;
|
|
31
|
+
export declare function deriveEthAttester(mnemonic: string, baseAccountIndex: number, addressIndex: number, remoteSigner?: string): EthAccount | EthPrivateKey;
|
|
32
|
+
export declare function buildValidatorEntries(input: BuildValidatorsInput): Promise<{
|
|
33
|
+
validators: ValidatorKeyStore[];
|
|
34
|
+
summaries: ValidatorSummary[];
|
|
35
|
+
}>;
|
|
36
|
+
export declare function resolveKeystoreOutputPath(dataDir?: string, file?: string): Promise<{
|
|
37
|
+
resolvedDir: string;
|
|
38
|
+
outputPath: string;
|
|
39
|
+
}>;
|
|
40
|
+
export declare function writeKeystoreFile(path: string, keystore: unknown): Promise<void>;
|
|
41
|
+
export declare function logValidatorSummaries(log: LogFn, summaries: ValidatorSummary[]): void;
|
|
42
|
+
export declare function maybePrintJson(log: LogFn, jsonFlag: boolean | undefined, obj: unknown): void;
|
|
43
|
+
/**
|
|
44
|
+
* Writes a BN254 keystore file for a BN254 BLS private key.
|
|
45
|
+
* Returns the absolute path to the written file.
|
|
46
|
+
*
|
|
47
|
+
* @param outDir - Directory to write the keystore file to
|
|
48
|
+
* @param fileNameBase - Base name for the keystore file (will be sanitized)
|
|
49
|
+
* @param password - Password for encrypting the private key
|
|
50
|
+
* @param privateKeyHex - Private key as 0x-prefixed hex string (32 bytes)
|
|
51
|
+
* @param pubkeyHex - Public key as hex string
|
|
52
|
+
* @param derivationPath - BIP-44 style derivation path
|
|
53
|
+
* @returns Absolute path to the written keystore file
|
|
54
|
+
*/
|
|
55
|
+
export declare function writeBn254BlsKeystore(outDir: string, fileNameBase: string, password: string, privateKeyHex: string, pubkeyHex: string, derivationPath: string): Promise<string>;
|
|
56
|
+
/** Replace plaintext BLS keys in validators with { path, password } pointing to BN254 keystore files. */
|
|
57
|
+
export declare function writeBlsBn254ToFile(validators: ValidatorKeyStore[], options: {
|
|
58
|
+
outDir: string;
|
|
59
|
+
password: string;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
/** Writes an Ethereum JSON V3 keystore using ethers, returns absolute path */
|
|
62
|
+
export declare function writeEthJsonV3Keystore(outDir: string, fileNameBase: string, password: string, privateKeyHex: string): Promise<string>;
|
|
63
|
+
/** Replace plaintext ETH keys in validators with { path, password } pointing to JSON V3 files. */
|
|
64
|
+
export declare function writeEthJsonV3ToFile(validators: ValidatorKeyStore[], options: {
|
|
65
|
+
outDir: string;
|
|
66
|
+
password: string;
|
|
67
|
+
}): Promise<void>;
|
|
68
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/shared.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAShE,MAAM,MAAM,gBAAgB,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEvG,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ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EAAE,MAAM,CAAA;CAAE,GAC5C,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED,8EAA8E;AAC9E,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,kGAAkG;AAClG,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,iBAAiB,EAAE,EAC/B,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC5C,OAAO,CAAC,IAAI,CAAC,CA2Cf"}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
2
|
+
import { computeBn254G1PublicKeyCompressed, deriveBlsPrivateKey } from '@aztec/foundation/crypto';
|
|
3
|
+
import { createBn254Keystore } from '@aztec/foundation/crypto/bls/bn254_keystore';
|
|
4
|
+
import { Wallet } from '@ethersproject/wallet';
|
|
5
|
+
import { constants as fsConstants, mkdirSync } from 'fs';
|
|
6
|
+
import { access, writeFile } from 'fs/promises';
|
|
7
|
+
import { homedir } from 'os';
|
|
8
|
+
import { dirname, isAbsolute, join } from 'path';
|
|
9
|
+
import { mnemonicToAccount } from 'viem/accounts';
|
|
10
|
+
export function withValidatorIndex(path, index) {
|
|
11
|
+
const parts = path.split('/');
|
|
12
|
+
if (parts.length >= 4 && parts[0] === 'm' && parts[1] === '12381' && parts[2] === '3600') {
|
|
13
|
+
parts[3] = String(index);
|
|
14
|
+
return parts.join('/');
|
|
15
|
+
}
|
|
16
|
+
return path;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Compute a compressed BN254 G1 public key from a private key.
|
|
20
|
+
* @param privateKeyHex - Private key as 0x-prefixed hex string
|
|
21
|
+
* @returns Compressed G1 point (32 bytes with sign bit in MSB)
|
|
22
|
+
*/ export async function computeBlsPublicKeyCompressed(privateKeyHex) {
|
|
23
|
+
return await computeBn254G1PublicKeyCompressed(privateKeyHex);
|
|
24
|
+
}
|
|
25
|
+
export function deriveEthAttester(mnemonic, baseAccountIndex, addressIndex, remoteSigner) {
|
|
26
|
+
const acct = mnemonicToAccount(mnemonic, {
|
|
27
|
+
accountIndex: baseAccountIndex,
|
|
28
|
+
addressIndex
|
|
29
|
+
});
|
|
30
|
+
return remoteSigner ? {
|
|
31
|
+
address: acct.address,
|
|
32
|
+
remoteSignerUrl: remoteSigner
|
|
33
|
+
} : '0x' + Buffer.from(acct.getHdKey().privateKey).toString('hex');
|
|
34
|
+
}
|
|
35
|
+
export async function buildValidatorEntries(input) {
|
|
36
|
+
const { validatorCount, publisherCount = 0, accountIndex, baseAddressIndex, mnemonic, ikm, blsPath, blsOnly, feeRecipient, coinbase, remoteSigner, fundingAccount } = input;
|
|
37
|
+
const defaultBlsPath = 'm/12381/3600/0/0/0';
|
|
38
|
+
const summaries = [];
|
|
39
|
+
const validators = await Promise.all(Array.from({
|
|
40
|
+
length: validatorCount
|
|
41
|
+
}, async (_unused, i)=>{
|
|
42
|
+
const addressIndex = baseAddressIndex + i;
|
|
43
|
+
const basePath = blsPath ?? defaultBlsPath;
|
|
44
|
+
const perValidatorPath = withValidatorIndex(basePath, addressIndex);
|
|
45
|
+
const blsPrivKey = blsOnly || ikm || mnemonic ? deriveBlsPrivateKey(mnemonic, ikm, perValidatorPath) : undefined;
|
|
46
|
+
const blsPubCompressed = blsPrivKey ? await computeBlsPublicKeyCompressed(blsPrivKey) : undefined;
|
|
47
|
+
if (blsOnly) {
|
|
48
|
+
const attester = {
|
|
49
|
+
bls: blsPrivKey
|
|
50
|
+
};
|
|
51
|
+
summaries.push({
|
|
52
|
+
attesterBls: blsPubCompressed
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
attester,
|
|
56
|
+
feeRecipient
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const ethAttester = deriveEthAttester(mnemonic, accountIndex, addressIndex, remoteSigner);
|
|
60
|
+
const attester = blsPrivKey ? {
|
|
61
|
+
eth: ethAttester,
|
|
62
|
+
bls: blsPrivKey
|
|
63
|
+
} : ethAttester;
|
|
64
|
+
let publisherField;
|
|
65
|
+
const publisherAddresses = [];
|
|
66
|
+
if (publisherCount > 0) {
|
|
67
|
+
const publishersBaseIndex = baseAddressIndex + validatorCount + i * publisherCount;
|
|
68
|
+
const publisherAccounts = Array.from({
|
|
69
|
+
length: publisherCount
|
|
70
|
+
}, (_unused2, j)=>{
|
|
71
|
+
const publisherAddressIndex = publishersBaseIndex + j;
|
|
72
|
+
const pubAcct = mnemonicToAccount(mnemonic, {
|
|
73
|
+
accountIndex,
|
|
74
|
+
addressIndex: publisherAddressIndex
|
|
75
|
+
});
|
|
76
|
+
publisherAddresses.push(pubAcct.address);
|
|
77
|
+
return remoteSigner ? {
|
|
78
|
+
address: pubAcct.address,
|
|
79
|
+
remoteSignerUrl: remoteSigner
|
|
80
|
+
} : '0x' + Buffer.from(pubAcct.getHdKey().privateKey).toString('hex');
|
|
81
|
+
});
|
|
82
|
+
publisherField = publisherCount === 1 ? publisherAccounts[0] : publisherAccounts;
|
|
83
|
+
}
|
|
84
|
+
const acct = mnemonicToAccount(mnemonic, {
|
|
85
|
+
accountIndex,
|
|
86
|
+
addressIndex
|
|
87
|
+
});
|
|
88
|
+
const attesterEthAddress = acct.address;
|
|
89
|
+
summaries.push({
|
|
90
|
+
attesterEth: attesterEthAddress,
|
|
91
|
+
attesterBls: blsPubCompressed,
|
|
92
|
+
publisherEth: publisherAddresses.length > 0 ? publisherAddresses : undefined
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
attester,
|
|
96
|
+
...publisherField !== undefined ? {
|
|
97
|
+
publisher: publisherField
|
|
98
|
+
} : {},
|
|
99
|
+
feeRecipient,
|
|
100
|
+
coinbase,
|
|
101
|
+
fundingAccount
|
|
102
|
+
};
|
|
103
|
+
}));
|
|
104
|
+
return {
|
|
105
|
+
validators,
|
|
106
|
+
summaries
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export async function resolveKeystoreOutputPath(dataDir, file) {
|
|
110
|
+
const defaultDataDir = join(homedir(), '.aztec', 'keystore');
|
|
111
|
+
const resolvedDir = dataDir && dataDir.length > 0 ? dataDir : defaultDataDir;
|
|
112
|
+
let outputPath;
|
|
113
|
+
if (file && file.length > 0) {
|
|
114
|
+
outputPath = isAbsolute(file) ? file : join(resolvedDir, file);
|
|
115
|
+
} else {
|
|
116
|
+
let index = 1;
|
|
117
|
+
while(true){
|
|
118
|
+
const candidate = join(resolvedDir, `key${index}.json`);
|
|
119
|
+
try {
|
|
120
|
+
await access(candidate, fsConstants.F_OK);
|
|
121
|
+
index += 1;
|
|
122
|
+
} catch {
|
|
123
|
+
outputPath = candidate;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
resolvedDir,
|
|
130
|
+
outputPath: outputPath
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export async function writeKeystoreFile(path, keystore) {
|
|
134
|
+
mkdirSync(dirname(path), {
|
|
135
|
+
recursive: true
|
|
136
|
+
});
|
|
137
|
+
await writeFile(path, JSON.stringify(keystore, null, 2), {
|
|
138
|
+
encoding: 'utf-8'
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
export function logValidatorSummaries(log, summaries) {
|
|
142
|
+
const lines = [];
|
|
143
|
+
for(let i = 0; i < summaries.length; i++){
|
|
144
|
+
const v = summaries[i];
|
|
145
|
+
lines.push(`acc${i + 1}:`);
|
|
146
|
+
lines.push(` attester:`);
|
|
147
|
+
if (v.attesterEth) {
|
|
148
|
+
lines.push(` eth: ${v.attesterEth}`);
|
|
149
|
+
}
|
|
150
|
+
if (v.attesterBls) {
|
|
151
|
+
lines.push(` bls: ${v.attesterBls}`);
|
|
152
|
+
}
|
|
153
|
+
if (v.publisherEth && v.publisherEth.length > 0) {
|
|
154
|
+
lines.push(` publisher:`);
|
|
155
|
+
for (const addr of v.publisherEth){
|
|
156
|
+
lines.push(` - ${addr}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (lines.length > 0) {
|
|
161
|
+
log(lines.join('\n'));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export function maybePrintJson(log, jsonFlag, obj) {
|
|
165
|
+
if (jsonFlag) {
|
|
166
|
+
log(prettyPrintJSON(obj));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Writes a BN254 keystore file for a BN254 BLS private key.
|
|
171
|
+
* Returns the absolute path to the written file.
|
|
172
|
+
*
|
|
173
|
+
* @param outDir - Directory to write the keystore file to
|
|
174
|
+
* @param fileNameBase - Base name for the keystore file (will be sanitized)
|
|
175
|
+
* @param password - Password for encrypting the private key
|
|
176
|
+
* @param privateKeyHex - Private key as 0x-prefixed hex string (32 bytes)
|
|
177
|
+
* @param pubkeyHex - Public key as hex string
|
|
178
|
+
* @param derivationPath - BIP-44 style derivation path
|
|
179
|
+
* @returns Absolute path to the written keystore file
|
|
180
|
+
*/ export async function writeBn254BlsKeystore(outDir, fileNameBase, password, privateKeyHex, pubkeyHex, derivationPath) {
|
|
181
|
+
mkdirSync(outDir, {
|
|
182
|
+
recursive: true
|
|
183
|
+
});
|
|
184
|
+
const keystore = createBn254Keystore(password, privateKeyHex, pubkeyHex, derivationPath);
|
|
185
|
+
const safeBase = fileNameBase.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
186
|
+
const outPath = join(outDir, `keystore-${safeBase}.json`);
|
|
187
|
+
await writeFile(outPath, JSON.stringify(keystore, null, 2), {
|
|
188
|
+
encoding: 'utf-8'
|
|
189
|
+
});
|
|
190
|
+
return outPath;
|
|
191
|
+
}
|
|
192
|
+
/** Replace plaintext BLS keys in validators with { path, password } pointing to BN254 keystore files. */ export async function writeBlsBn254ToFile(validators, options) {
|
|
193
|
+
for(let i = 0; i < validators.length; i++){
|
|
194
|
+
const v = validators[i];
|
|
195
|
+
if (!v || typeof v !== 'object' || !('attester' in v)) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const att = v.attester;
|
|
199
|
+
// Shapes: { bls: <hex> } or { eth: <ethAccount>, bls?: <hex> } or plain EthAccount
|
|
200
|
+
const blsKey = typeof att === 'object' && 'bls' in att ? att.bls : undefined;
|
|
201
|
+
if (!blsKey || typeof blsKey !== 'string') {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const pub = await computeBlsPublicKeyCompressed(blsKey);
|
|
205
|
+
const path = 'm/12381/3600/0/0/0';
|
|
206
|
+
const fileBase = `${String(i + 1)}_${pub.slice(2, 18)}`;
|
|
207
|
+
const keystorePath = await writeBn254BlsKeystore(options.outDir, fileBase, options.password, blsKey, pub, path);
|
|
208
|
+
if (typeof att === 'object') {
|
|
209
|
+
att.bls = {
|
|
210
|
+
path: keystorePath,
|
|
211
|
+
password: options.password
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/** Writes an Ethereum JSON V3 keystore using ethers, returns absolute path */ export async function writeEthJsonV3Keystore(outDir, fileNameBase, password, privateKeyHex) {
|
|
217
|
+
const safeBase = fileNameBase.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
218
|
+
mkdirSync(outDir, {
|
|
219
|
+
recursive: true
|
|
220
|
+
});
|
|
221
|
+
const wallet = new Wallet(privateKeyHex);
|
|
222
|
+
const json = await wallet.encrypt(password);
|
|
223
|
+
const outPath = join(outDir, `keystore-eth-${safeBase}.json`);
|
|
224
|
+
await writeFile(outPath, json, {
|
|
225
|
+
encoding: 'utf-8'
|
|
226
|
+
});
|
|
227
|
+
return outPath;
|
|
228
|
+
}
|
|
229
|
+
/** Replace plaintext ETH keys in validators with { path, password } pointing to JSON V3 files. */ export async function writeEthJsonV3ToFile(validators, options) {
|
|
230
|
+
const maybeEncryptEth = async (account, label)=>{
|
|
231
|
+
if (typeof account === 'string' && account.startsWith('0x') && account.length === 66) {
|
|
232
|
+
const fileBase = `${label}_${account.slice(2, 10)}`;
|
|
233
|
+
const p = await writeEthJsonV3Keystore(options.outDir, fileBase, options.password, account);
|
|
234
|
+
return {
|
|
235
|
+
path: p,
|
|
236
|
+
password: options.password
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return account;
|
|
240
|
+
};
|
|
241
|
+
for(let i = 0; i < validators.length; i++){
|
|
242
|
+
const v = validators[i];
|
|
243
|
+
if (!v || typeof v !== 'object') {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
// attester may be string (eth), object with eth, or remote signer
|
|
247
|
+
const att = v.attester;
|
|
248
|
+
if (typeof att === 'string') {
|
|
249
|
+
v.attester = await maybeEncryptEth(att, `attester_${i + 1}`);
|
|
250
|
+
} else if (att && typeof att === 'object' && 'eth' in att) {
|
|
251
|
+
att.eth = await maybeEncryptEth(att.eth, `attester_${i + 1}`);
|
|
252
|
+
}
|
|
253
|
+
// publisher can be single or array
|
|
254
|
+
if ('publisher' in v) {
|
|
255
|
+
const pub = v.publisher;
|
|
256
|
+
if (Array.isArray(pub)) {
|
|
257
|
+
const out = [];
|
|
258
|
+
for(let j = 0; j < pub.length; j++){
|
|
259
|
+
out.push(await maybeEncryptEth(pub[j], `publisher_${i + 1}_${j + 1}`));
|
|
260
|
+
}
|
|
261
|
+
v.publisher = out;
|
|
262
|
+
} else if (pub !== undefined) {
|
|
263
|
+
v.publisher = await maybeEncryptEth(pub, `publisher_${i + 1}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Optional fundingAccount within validator
|
|
267
|
+
if ('fundingAccount' in v) {
|
|
268
|
+
v.fundingAccount = await maybeEncryptEth(v.fundingAccount, `funding_${i + 1}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
@@ -1 +1 @@
|
|
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