diff --git a/yarn-project/cli/src/cmds/misc/generate_secret_and_hash.ts b/yarn-project/cli/src/cmds/misc/generate_secret_and_hash.ts new file mode 100644 index 00000000000..fddea589c33 --- /dev/null +++ b/yarn-project/cli/src/cmds/misc/generate_secret_and_hash.ts @@ -0,0 +1,15 @@ +import { computeSecretHash } from '@aztec/aztec.js'; +import { Fr } from '@aztec/foundation/fields'; +import { type LogFn } from '@aztec/foundation/log'; + +export function generateSecretAndHash(log: LogFn) { + const secret = Fr.random(); + + // We hash this the same way that aztec nr hash does. + const secretHash = computeSecretHash(secret); + + log(` + Secret: ${secret} + Secret hash: ${secretHash} + `); +} diff --git a/yarn-project/cli/src/cmds/misc/index.ts b/yarn-project/cli/src/cmds/misc/index.ts index 474ab0e24bf..75d30d59e04 100644 --- a/yarn-project/cli/src/cmds/misc/index.ts +++ b/yarn-project/cli/src/cmds/misc/index.ts @@ -48,6 +48,14 @@ export function injectCommands(program: Command, log: LogFn) { computeSelector(functionSignature, log); }); + program + .command('generate-secret-and-hash') + .description('Generates an arbitrary secret (Fr), and its hash (using aztec-nr defaults)') + .action(async () => { + const { generateSecretAndHash } = await import('./generate_secret_and_hash.js'); + generateSecretAndHash(log); + }); + program .command('update') .description('Updates Nodejs and Noir dependencies')