Skip to content

Commit

Permalink
feat: add generate-secret-and-hash to cli (#7977)
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 authored Aug 14, 2024
1 parent f4fa797 commit cdf62a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
15 changes: 15 additions & 0 deletions yarn-project/cli/src/cmds/misc/generate_secret_and_hash.ts
Original file line number Diff line number Diff line change
@@ -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}
`);
}
8 changes: 8 additions & 0 deletions yarn-project/cli/src/cmds/misc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit cdf62a0

Please sign in to comment.