Skip to content

Commit

Permalink
don't pass secret as default val
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-kothari committed Jun 8, 2023
1 parent 969067d commit 7e92302
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions yarn-project/aztec.js/src/utils/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { CircuitsWasm, Fr } from '@aztec/circuits.js';
import { computeSecretMessageHash } from '@aztec/circuits.js/abis';

/**
* Given a secret, it computes its pederson hash - used to send l1 to l2 messages
* @param secret - the secret to hash (defaults to a random field element)
* Given a secret, it computes its pedersen hash - used to send l1 to l2 messages
* @param secret - the secret to hash - secret could be generated however you want e.g. `Fr.random()`
* @returns the hash
*/
export async function computeMessageSecretHash(secret = Fr.random()): Promise<Fr> {
export async function computeMessageSecretHash(secret: Fr): Promise<Fr> {
const wasm = await CircuitsWasm.get();
return computeSecretMessageHash(wasm, secret);
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ describe('archiver integration with l1 to l2 messages', () => {

// Generate a claim secret using pedersen
logger("Generating a claim secret using pedersen's hash function");
const secretHash = await computeMessageSecretHash();
const secret = Fr.random();
const secretHash = await computeMessageSecretHash(secret);
const secretString = `0x${secretHash.toBuffer().toString('hex')}` as `0x${string}`;
logger('Generated claim secret: ', secretString);

Expand Down

0 comments on commit 7e92302

Please sign in to comment.