From e5fe49e7d9a9f7c51580b7635a4b01113c53b5a9 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Fri, 9 Aug 2024 23:04:34 +0000 Subject: [PATCH] fix: call cmd secret key --- aztec-up/bin/aztec | 2 +- docker-compose.yml | 2 +- yarn-project/cli/README.md | 2 +- .../cli/src/cmds/misc/generate_private_key.ts | 11 ----------- .../cli/src/cmds/misc/generate_secret_key.ts | 5 +++++ yarn-project/cli/src/cmds/misc/index.ts | 15 +++++++++++---- yarn-project/cli/src/cmds/pxe/index.ts | 2 +- yarn-project/cli/src/inspect.ts | 2 +- 8 files changed, 21 insertions(+), 20 deletions(-) delete mode 100644 yarn-project/cli/src/cmds/misc/generate_private_key.ts create mode 100644 yarn-project/cli/src/cmds/misc/generate_secret_key.ts diff --git a/aztec-up/bin/aztec b/aztec-up/bin/aztec index eff925be279..0989bb64469 100755 --- a/aztec-up/bin/aztec +++ b/aztec-up/bin/aztec @@ -68,5 +68,5 @@ elif [ "${1:-}" == "start" ]; then export ENV_VARS_TO_INJECT="${ENV_VARS_TO_INJECT[*]}" ENV_VARS_TO_INJECT="${ENV_VARS_TO_INJECT[*]}" INHERIT_USER=0 $(dirname $0)/.aztec-run aztecprotocol/aztec "$@" else - SKIP_PORT_ASSIGNMENT=1 $(dirname $0)/.aztec-run aztecprotocol/aztec "$@" + ENV_VARS_TO_INJECT="SECRET_KEY" SKIP_PORT_ASSIGNMENT=1 $(dirname $0)/.aztec-run aztecprotocol/aztec "$@" fi diff --git a/docker-compose.yml b/docker-compose.yml index 82a33648b5a..44b53fbdb29 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -107,7 +107,7 @@ services: environment: PXE_URL: http://pxe:8080 NODE_NO_WARNINGS: 1 - PRIVATE_KEY: + SECRET_KEY: ETHEREUM_HOST: profiles: - cli diff --git a/yarn-project/cli/README.md b/yarn-project/cli/README.md index 0ed38b95305..cb164a202a4 100644 --- a/yarn-project/cli/README.md +++ b/yarn-project/cli/README.md @@ -35,7 +35,7 @@ Replace `` with the actual command you want to execute and `[options]` Some options can be set globally as environment variables to avoid having to re-enter them every time you call `aztec-cli.` These options are: -- `PRIVATE_KEY` -> `-k, --private-key` for all commands that require a private key. +- `SECRET_KEY` -> `-sk, --secret-key` for all commands that require an Aztec secret key. - `PUBLIC_KEY` -> `-k, --public-key` for all commands that require a public key. - `PXE_URL` -> `-u, --rpc-url` for commands that require a PXE - `ETHEREUM_RPC_HOST` -> `-u, --rpc-url` for `deploy-l1-contracts`. diff --git a/yarn-project/cli/src/cmds/misc/generate_private_key.ts b/yarn-project/cli/src/cmds/misc/generate_private_key.ts deleted file mode 100644 index 5744658b383..00000000000 --- a/yarn-project/cli/src/cmds/misc/generate_private_key.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Fr } from '@aztec/aztec.js'; -import { deriveSigningKey } from '@aztec/circuits.js'; - -export function generateKeys() { - const privateKey = Fr.random(); - const signingKey = deriveSigningKey(privateKey); - return { - privateEncryptionKey: privateKey, - privateSigningKey: signingKey, - }; -} diff --git a/yarn-project/cli/src/cmds/misc/generate_secret_key.ts b/yarn-project/cli/src/cmds/misc/generate_secret_key.ts new file mode 100644 index 00000000000..ad7498f670e --- /dev/null +++ b/yarn-project/cli/src/cmds/misc/generate_secret_key.ts @@ -0,0 +1,5 @@ +import { Fr } from '@aztec/aztec.js'; + +export function generateSecretKey() { + return { secretKey: Fr.random() }; +} diff --git a/yarn-project/cli/src/cmds/misc/index.ts b/yarn-project/cli/src/cmds/misc/index.ts index 1a759417fc7..474ab0e24bf 100644 --- a/yarn-project/cli/src/cmds/misc/index.ts +++ b/yarn-project/cli/src/cmds/misc/index.ts @@ -2,6 +2,8 @@ import { type LogFn } from '@aztec/foundation/log'; import { type Command } from 'commander'; +import { prettyPrintJSON } from '../../utils/commands.js'; + export * from './deploy_contracts.js'; export function injectCommands(program: Command, log: LogFn) { @@ -9,10 +11,15 @@ export function injectCommands(program: Command, log: LogFn) { .command('generate-keys') .summary('Generates encryption and signing private keys.') .description('Generates and encryption and signing private key pair.') - .action(async _options => { - const { generateKeys } = await import('./generate_private_key.js'); - const { privateEncryptionKey, privateSigningKey } = generateKeys(); - log(`Encryption Private Key: ${privateEncryptionKey}\nSigning Private key: ${privateSigningKey}\n`); + .option('--json', 'Output the keys in JSON format') + .action(async ({ json }) => { + const { generateSecretKey } = await import('./generate_secret_key.js'); + const { secretKey } = generateSecretKey(); + if (json) { + log(prettyPrintJSON({ secretKey: secretKey.toString() })); + } else { + log(`Secret Key: ${secretKey}`); + } }); program diff --git a/yarn-project/cli/src/cmds/pxe/index.ts b/yarn-project/cli/src/cmds/pxe/index.ts index d6cbaeb1b0a..f8c602eb2ed 100644 --- a/yarn-project/cli/src/cmds/pxe/index.ts +++ b/yarn-project/cli/src/cmds/pxe/index.ts @@ -179,7 +179,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL options.args, options.contractArtifact, options.contractAddress, - options.privateKey, + options.secretKey, options.rpcUrl, debugLogger, log, diff --git a/yarn-project/cli/src/inspect.ts b/yarn-project/cli/src/inspect.ts index 98b55051015..7978a12ac0c 100644 --- a/yarn-project/cli/src/inspect.ts +++ b/yarn-project/cli/src/inspect.ts @@ -46,7 +46,7 @@ export async function inspectTx( ]); // Base tx data log(`Tx ${txHash.toString()}`); - log(` Status: ${receipt.status} ${effects ? `(${effects.revertCode.getDescription()}})` : ''})`); + log(` Status: ${receipt.status} ${effects ? `(${effects.revertCode.getDescription()})` : ''}`); if (receipt.error) { log(` Error: ${receipt.error}`); }