diff --git a/docs/docs/developers/contracts/references/portals/data_structures.md b/docs/docs/developers/contracts/references/portals/data_structures.md index ba97bfd52723..4b639c24fb59 100644 --- a/docs/docs/developers/contracts/references/portals/data_structures.md +++ b/docs/docs/developers/contracts/references/portals/data_structures.md @@ -40,7 +40,7 @@ A message that is sent from L1 to L2. | `sender` | `L1Actor` | The actor on L1 that is sending the message. | | `recipient` | `L2Actor` | The actor on L2 that is to receive the message. | | `content` | `field (~254 bits)` | The field element containing the content to be sent to L2. | -| `secretHash` | `field (~254 bits)` | The hash of a secret pre-image that must be known to consume the message on L2. Use the [`computeMessageSecretHash`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec.js/src/utils/secrets.ts) to compute it from a secret. | +| `secretHash` | `field (~254 bits)` | The hash of a secret pre-image that must be known to consume the message on L2. Use the [`computeSecretHash`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec.js/src/utils/secrets.ts) to compute it from a secret. | ## `L2ToL1Message` diff --git a/docs/docs/developers/contracts/references/portals/inbox.md b/docs/docs/developers/contracts/references/portals/inbox.md index 73b18fc88888..4f0eae50aeda 100644 --- a/docs/docs/developers/contracts/references/portals/inbox.md +++ b/docs/docs/developers/contracts/references/portals/inbox.md @@ -17,7 +17,7 @@ Sends a message from L1 to L2. | -------------- | ------- | ----------- | | Recipient | `L2Actor` | The recipient of the message. This **MUST** match the rollup version and an Aztec contract that is **attached** to the contract making this call. If the recipient is not attached to the caller, the message cannot be consumed by it. | | Content | `field` (~254 bits) | The content of the message. This is the data that will be passed to the recipient. The content is limited to be a single field for rollup purposes. If the content is small enough it can just be passed along, otherwise it should be hashed and the hash passed along (you can use our [`Hash`](https://github.com/AztecProtocol/aztec-packages/blob/master/l1-contracts/src/core/libraries/Hash.sol) utilities with `sha256ToField` functions) | -| Secret Hash | `field` (~254 bits) | A hash of a secret that is used when consuming the message on L2. Keep this preimage a secret to make the consumption private. To consume the message the caller must know the pre-image (the value that was hashed) - so make sure your app keeps track of the pre-images! Use the [`computeMessageSecretHash`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec.js/src/utils/secrets.ts) to compute it from a secret. | +| Secret Hash | `field` (~254 bits) | A hash of a secret that is used when consuming the message on L2. Keep this preimage a secret to make the consumption private. To consume the message the caller must know the pre-image (the value that was hashed) - so make sure your app keeps track of the pre-images! Use the [`computeSecretHash`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec.js/src/utils/secrets.ts) to compute it from a secret. | | ReturnValue | `bytes32` | The message hash, used as an identifier | #### Edge cases diff --git a/docs/docs/developers/contracts/writing_contracts/portals/communicate_with_portal.md b/docs/docs/developers/contracts/writing_contracts/portals/communicate_with_portal.md index 8d559abe6f0f..427020830dde 100644 --- a/docs/docs/developers/contracts/writing_contracts/portals/communicate_with_portal.md +++ b/docs/docs/developers/contracts/writing_contracts/portals/communicate_with_portal.md @@ -17,7 +17,7 @@ When sending messages, we need to specify quite a bit of information beyond just | Name | Type | Description | | ----------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Recipient | `L2Actor` | The message recipient. This **MUST** match the rollup version and an Aztec contract that is **attached** to the contract making this call. If the recipient is not attached to the caller, the message cannot be consumed by it. | -| Secret Hash | `field` (~254 bits) | A hash of a secret that is used when consuming the message on L2. Keep this preimage a secret to make the consumption private. To consume the message the caller must know the pre-image (the value that was hashed) - so make sure your app keeps track of the pre-images! Use the [`computeMessageSecretHash`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec.js/src/utils/secrets.ts) to compute it from a secret. | +| Secret Hash | `field` (~254 bits) | A hash of a secret that is used when consuming the message on L2. Keep this preimage a secret to make the consumption private. To consume the message the caller must know the pre-image (the value that was hashed) - so make sure your app keeps track of the pre-images! Use the [`computeSecretHash`](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec.js/src/utils/secrets.ts) to compute it from a secret. | | Content | `field` (~254 bits) | The content of the message. This is the data that will be passed to the recipient. The content is limited to be a single field. If the content is small enough it can just be passed along, otherwise it should be hashed and the hash passed along (you can use our [`Hash`](https://github.com/AztecProtocol/aztec-packages/blob/master/l1-contracts/src/core/libraries/Hash.sol) utilities with `sha256ToField` functions) With all that information at hand, we can call the `sendL2Message` function on the Inbox. The function will return a `field` (inside `bytes32`) that is the hash of the message. This hash can be used as an identifier to spot when your message has been included in a rollup block. @@ -56,7 +56,7 @@ In Solidity, you can use our `Hash.sha256ToField()` method: #include_code deposit_public l1-contracts/test/portals/TokenPortal.sol solidity -The `secret_hash` uses the pederson hash which fits in a field element. You can use the utility method `computeMessageSecretHash()`in `@aztec/aztec.js` npm package to generate a secret and its corresponding hash. +The `secret_hash` uses the pederson hash which fits in a field element. You can use the utility method `computeSecretHash()`in `@aztec/aztec.js` npm package to generate a secret and its corresponding hash. After the transaction has been mined, the message is consumed, a nullifier is emitted and the tokens have been minted on Aztec and are ready for claiming. diff --git a/docs/docs/developers/tutorials/writing_dapp/testing.md b/docs/docs/developers/tutorials/writing_dapp/testing.md index 8aea22e1de0e..3917c0596251 100644 --- a/docs/docs/developers/tutorials/writing_dapp/testing.md +++ b/docs/docs/developers/tutorials/writing_dapp/testing.md @@ -26,7 +26,7 @@ import { ExtendedNote, Fr, Note, - computeMessageSecretHash, + computeSecretHash, createPXEClient, waitForPXE, } from "@aztec/aztec.js"; diff --git a/noir-projects/aztec-nr/aztec/src/context/avm_context.nr b/noir-projects/aztec-nr/aztec/src/context/avm_context.nr index 83139c09d4ba..16d7de0223b3 100644 --- a/noir-projects/aztec-nr/aztec/src/context/avm_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/avm_context.nr @@ -1,4 +1,4 @@ -use crate::hash::{compute_message_secret_hash, compute_message_hash, compute_message_nullifier}; +use crate::hash::{compute_secret_hash, compute_message_hash, compute_message_nullifier}; use dep::protocol_types::{ address::{AztecAddress, EthAddress}, constants::{L1_TO_L2_MESSAGE_LENGTH, NESTED_CALL_L2_GAS_BUFFER}, header::Header @@ -96,7 +96,7 @@ impl PublicContextInterface for AvmContext { } fn consume_l1_to_l2_message(&mut self, content: Field, secret: Field, sender: EthAddress, leaf_index: Field) { - let secret_hash = compute_message_secret_hash(secret); + let secret_hash = compute_secret_hash(secret); let message_hash = compute_message_hash( sender, self.chain_id(), diff --git a/noir-projects/aztec-nr/aztec/src/hash.nr b/noir-projects/aztec-nr/aztec/src/hash.nr index bfeb3ff53928..435df049fa2e 100644 --- a/noir-projects/aztec-nr/aztec/src/hash.nr +++ b/noir-projects/aztec-nr/aztec/src/hash.nr @@ -1,14 +1,14 @@ use dep::protocol_types::{ address::{AztecAddress, EthAddress}, constants::{ - GENERATOR_INDEX__L1_TO_L2_MESSAGE_SECRET, GENERATOR_INDEX__MESSAGE_NULLIFIER, ARGS_HASH_CHUNK_COUNT, + GENERATOR_INDEX__SECRET_HASH, GENERATOR_INDEX__MESSAGE_NULLIFIER, ARGS_HASH_CHUNK_COUNT, GENERATOR_INDEX__FUNCTION_ARGS, ARGS_HASH_CHUNK_LENGTH }, traits::Hash, hash::{pedersen_hash, poseidon2_hash, silo_nullifier, sha256_to_field} }; -pub fn compute_message_secret_hash(secret: Field) -> Field { - pedersen_hash([secret], GENERATOR_INDEX__L1_TO_L2_MESSAGE_SECRET) +pub fn compute_secret_hash(secret: Field) -> Field { + pedersen_hash([secret], GENERATOR_INDEX__SECRET_HASH) } pub fn compute_message_hash( diff --git a/noir-projects/aztec-nr/aztec/src/messaging.nr b/noir-projects/aztec-nr/aztec/src/messaging.nr index c4b197060eb5..77087758f824 100644 --- a/noir-projects/aztec-nr/aztec/src/messaging.nr +++ b/noir-projects/aztec-nr/aztec/src/messaging.nr @@ -1,5 +1,5 @@ use crate::{ - hash::{compute_message_secret_hash, compute_message_hash, compute_message_nullifier}, + hash::{compute_secret_hash, compute_message_hash, compute_message_nullifier}, oracle::get_l1_to_l2_membership_witness::get_l1_to_l2_membership_witness }; @@ -15,7 +15,7 @@ pub fn process_l1_to_l2_message( content: Field, secret: Field ) -> Field { - let secret_hash = compute_message_secret_hash(secret); + let secret_hash = compute_secret_hash(secret); let message_hash = compute_message_hash( portal_contract_address, chain_id, diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index d5d232aa5357..4fc172d63fc4 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -11,16 +11,13 @@ mod types; contract TokenBlacklist { // Libs use dep::aztec::{ - hash::poseidon2_hash, + hash::compute_secret_hash, prelude::{AztecAddress, FunctionSelector, Map, NoteGetterOptions, PrivateSet, PublicMutable, SharedMutable} }; use dep::authwit::{auth::{assert_current_call_valid_authwit, assert_current_call_valid_authwit_public}}; - use crate::types::{ - transparent_note::{TransparentNote, GENERATOR_INDEX__TRANSPARENT_NOTE}, token_note::TokenNote, - balances_map::BalancesMap, roles::UserFlags - }; + use crate::types::{transparent_note::TransparentNote, token_note::TokenNote, balances_map::BalancesMap, roles::UserFlags}; // Changing an address' roles has a certain block delay before it goes into effect. global CHANGE_ROLES_DELAY_BLOCKS = 5; @@ -152,7 +149,7 @@ contract TokenBlacklist { assert(!to_roles.is_blacklisted, "Blacklisted: Recipient"); let pending_shields = storage.pending_shields; - let secret_hash = poseidon2_hash([secret, GENERATOR_INDEX__TRANSPARENT_NOTE]); + let secret_hash = compute_secret_hash(secret); // Get 1 note (set_limit(1)) which has amount stored in field with index 0 (select(0, amount)) and secret_hash // stored in field with index 1 (select(1, secret_hash)). let mut options = NoteGetterOptions::new(); diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr index 6f06d084a514..d5cf7197cef6 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr @@ -6,8 +6,6 @@ use dep::aztec::{ }; global TRANSPARENT_NOTE_LEN: Field = 2; -// Defined here as it's not a protocol constant. Copied over to private execution test. -global GENERATOR_INDEX__TRANSPARENT_NOTE = 92543; // Transparent note represents a note that is created in the clear (public execution), but can only be spent by those // that know the preimage of the "secret_hash" (the secret). This is typically used when shielding a token balance. diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index 7c4087a69863..e488c5f4f431 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -15,7 +15,7 @@ contract Token { use dep::compressed_string::FieldCompressedString; use dep::aztec::{ - hash::poseidon2_hash, + hash::compute_secret_hash, prelude::{NoteGetterOptions, Map, PublicMutable, SharedImmutable, PrivateSet, AztecAddress} }; @@ -23,10 +23,7 @@ contract Token { use dep::authwit::{auth::{assert_current_call_valid_authwit, assert_current_call_valid_authwit_public}}; // docs:end:import_authwit - use crate::types::{ - transparent_note::{TransparentNote, GENERATOR_INDEX__TRANSPARENT_NOTE}, - token_note::{TokenNote, TOKEN_NOTE_LEN}, balances_map::BalancesMap - }; + use crate::types::{transparent_note::TransparentNote, token_note::{TokenNote, TOKEN_NOTE_LEN}, balances_map::BalancesMap}; // docs:end::imports // docs:start:storage_struct @@ -244,7 +241,7 @@ contract Token { #[aztec(private)] fn redeem_shield(to: AztecAddress, amount: Field, secret: Field) { let pending_shields = storage.pending_shields; - let secret_hash = poseidon2_hash([secret, GENERATOR_INDEX__TRANSPARENT_NOTE]); + let secret_hash = compute_secret_hash(secret); // Get 1 note (set_limit(1)) which has amount stored in field with index 0 (select(0, amount)) and secret_hash // stored in field with index 1 (select(1, secret_hash)). let mut options = NoteGetterOptions::new(); diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr index 19b5025eacde..d5cf7197cef6 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/transparent_note.nr @@ -6,8 +6,6 @@ use dep::aztec::{ }; global TRANSPARENT_NOTE_LEN: Field = 2; -// Defined here as it's not a protocol constant. Copied over to private execution test and test contract. -global GENERATOR_INDEX__TRANSPARENT_NOTE = 92543; // Transparent note represents a note that is created in the clear (public execution), but can only be spent by those // that know the preimage of the "secret_hash" (the secret). This is typically used when shielding a token balance. diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 5dc288e472e5..ba07e8518b1a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -214,7 +214,7 @@ global GENERATOR_INDEX__CONTRACT_LEAF = 16; global GENERATOR_INDEX__CALL_CONTEXT = 17; global GENERATOR_INDEX__CALL_STACK_ITEM = 18; global GENERATOR_INDEX__CALL_STACK_ITEM_2 = 19; -global GENERATOR_INDEX__L1_TO_L2_MESSAGE_SECRET = 20; +global GENERATOR_INDEX__SECRET_HASH = 20; global GENERATOR_INDEX__L2_TO_L1_MSG = 21; global GENERATOR_INDEX__TX_CONTEXT = 22; global GENERATOR_INDEX__PUBLIC_LEAF_INDEX = 23; diff --git a/yarn-project/aztec.js/src/fee/private_fee_payment_method.ts b/yarn-project/aztec.js/src/fee/private_fee_payment_method.ts index e6abb694172f..f3298ed09ef8 100644 --- a/yarn-project/aztec.js/src/fee/private_fee_payment_method.ts +++ b/yarn-project/aztec.js/src/fee/private_fee_payment_method.ts @@ -1,6 +1,6 @@ import { type FunctionCall } from '@aztec/circuit-types'; import { FunctionData, type GasSettings } from '@aztec/circuits.js'; -import { computeMessageSecretHash } from '@aztec/circuits.js/hash'; +import { computeSecretHash } from '@aztec/circuits.js/hash'; import { FunctionSelector } from '@aztec/foundation/abi'; import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; @@ -71,7 +71,7 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod { ); await this.wallet.createAuthWit(messageHash); - const secretHashForRebate = computeMessageSecretHash(this.rebateSecret); + const secretHashForRebate = computeSecretHash(this.rebateSecret); return [ { diff --git a/yarn-project/aztec.js/src/index.ts b/yarn-project/aztec.js/src/index.ts index fc91aa829b5b..cb9179a84a74 100644 --- a/yarn-project/aztec.js/src/index.ts +++ b/yarn-project/aztec.js/src/index.ts @@ -75,7 +75,7 @@ export { INITIAL_L2_BLOCK_NUM, } from '@aztec/circuits.js'; -export { computeMessageSecretHash } from '@aztec/circuits.js/hash'; +export { computeSecretHash } from '@aztec/circuits.js/hash'; export { computeAppNullifierSecretKey, diff --git a/yarn-project/aztec/src/examples/token.ts b/yarn-project/aztec/src/examples/token.ts index 01702d9d5d17..323d32310add 100644 --- a/yarn-project/aztec/src/examples/token.ts +++ b/yarn-project/aztec/src/examples/token.ts @@ -1,5 +1,5 @@ import { getSingleKeyAccount } from '@aztec/accounts/single_key'; -import { type AccountWallet, Fr, Note, computeMessageSecretHash, createPXEClient } from '@aztec/aztec.js'; +import { type AccountWallet, Fr, Note, computeSecretHash, createPXEClient } from '@aztec/aztec.js'; import { ExtendedNote } from '@aztec/circuit-types'; import { createDebugLogger } from '@aztec/foundation/log'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; @@ -45,7 +45,7 @@ async function main() { // Create a secret and a corresponding hash that will be used to mint funds privately const aliceSecret = Fr.random(); - const aliceSecretHash = computeMessageSecretHash(aliceSecret); + const aliceSecretHash = computeSecretHash(aliceSecret); const receipt = await tokenAlice.methods.mint_private(ALICE_MINT_BALANCE, aliceSecretHash).send().wait(); // Add the newly created "pending shield" note to PXE diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index aa18be81a9cc..c40cdec3ec51 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -178,7 +178,7 @@ export enum GeneratorIndex { CALL_CONTEXT = 17, CALL_STACK_ITEM = 18, CALL_STACK_ITEM_2 = 19, - L1_TO_L2_MESSAGE_SECRET = 20, + SECRET_HASH = 20, L2_TO_L1_MSG = 21, TX_CONTEXT = 22, PUBLIC_LEAF_INDEX = 23, diff --git a/yarn-project/circuits.js/src/hash/hash.test.ts b/yarn-project/circuits.js/src/hash/hash.test.ts index ce91f4c10d72..cb1cd8626619 100644 --- a/yarn-project/circuits.js/src/hash/hash.test.ts +++ b/yarn-project/circuits.js/src/hash/hash.test.ts @@ -6,10 +6,10 @@ import { makeAztecAddress, makeVerificationKey } from '../tests/factories.js'; import { computeCommitmentNonce, computeCommitmentsHash, - computeMessageSecretHash, computeNullifierHash, computePublicDataTreeLeafSlot, computePublicDataTreeValue, + computeSecretHash, computeUniqueCommitment, computeVarArgsHash, hashVK, @@ -85,7 +85,7 @@ describe('hash', () => { it('compute secret message hash', () => { const value = new Fr(8n); - const hash = computeMessageSecretHash(value); + const hash = computeSecretHash(value); expect(hash).toMatchSnapshot(); }); diff --git a/yarn-project/circuits.js/src/hash/hash.ts b/yarn-project/circuits.js/src/hash/hash.ts index a011300861e6..94998bf7ee3c 100644 --- a/yarn-project/circuits.js/src/hash/hash.ts +++ b/yarn-project/circuits.js/src/hash/hash.ts @@ -157,12 +157,13 @@ export function computeNullifierHash(input: SideEffectLinkedToNoteHash) { } /** - * Computes a hash of a secret as is done in the L1 to L2 message flow. + * Computes a hash of a secret. + * @dev This function is used to generate secrets for the L1 to L2 message flow and for the TransparentNote. * @param secret - The secret to hash (could be generated however you want e.g. `Fr.random()`) * @returns The hash */ -export function computeMessageSecretHash(secret: Fr) { - return pedersenHash([secret], GeneratorIndex.L1_TO_L2_MESSAGE_SECRET); +export function computeSecretHash(secret: Fr) { + return pedersenHash([secret], GeneratorIndex.SECRET_HASH); } export function computeL1ToL2MessageNullifier( diff --git a/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts b/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts index 15bb02259a3e..8eafef594ed1 100644 --- a/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts +++ b/yarn-project/end-to-end/src/composed/e2e_persistence.test.ts @@ -5,7 +5,7 @@ import { ExtendedNote, Note, type TxHash, - computeMessageSecretHash, + computeSecretHash, waitForAccountSynch, } from '@aztec/aztec.js'; import { type Salt } from '@aztec/aztec.js/account'; @@ -72,13 +72,13 @@ describe('Aztec persistence', () => { const secret = Fr.random(); - const mintTxReceipt = await contract.methods.mint_private(1000n, computeMessageSecretHash(secret)).send().wait(); + const mintTxReceipt = await contract.methods.mint_private(1000n, computeSecretHash(secret)).send().wait(); await addPendingShieldNoteToPXE( ownerWallet, contractAddress, 1000n, - computeMessageSecretHash(secret), + computeSecretHash(secret), mintTxReceipt.txHash, ); @@ -130,12 +130,12 @@ describe('Aztec persistence', () => { const balance = await contract.methods.balance_of_private(ownerWallet.getAddress()).simulate(); const secret = Fr.random(); - const mintTxReceipt = await contract.methods.mint_private(1000n, computeMessageSecretHash(secret)).send().wait(); + const mintTxReceipt = await contract.methods.mint_private(1000n, computeSecretHash(secret)).send().wait(); await addPendingShieldNoteToPXE( ownerWallet, contractAddress, 1000n, - computeMessageSecretHash(secret), + computeSecretHash(secret), mintTxReceipt.txHash, ); @@ -270,7 +270,7 @@ describe('Aztec persistence', () => { secret = Fr.random(); mintAmount = 1000n; const mintTxReceipt = await contract.methods - .mint_private(mintAmount, computeMessageSecretHash(secret)) + .mint_private(mintAmount, computeSecretHash(secret)) .send() .wait(); mintTxHash = mintTxReceipt.txHash; @@ -311,7 +311,7 @@ describe('Aztec persistence', () => { ownerWallet, contractAddress, mintAmount, - computeMessageSecretHash(secret), + computeSecretHash(secret), mintTxHash, ); diff --git a/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts b/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts index bbc794b80960..1ae3c9362f6e 100644 --- a/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts +++ b/yarn-project/end-to-end/src/composed/e2e_sandbox_example.test.ts @@ -7,7 +7,7 @@ import { GrumpkinScalar, Note, type PXE, - computeMessageSecretHash, + computeSecretHash, createDebugLogger, createPXEClient, waitForPXE, @@ -69,7 +69,7 @@ describe('e2e_sandbox_example', () => { // Create a secret and a corresponding hash that will be used to mint funds privately const aliceSecret = Fr.random(); - const aliceSecretHash = computeMessageSecretHash(aliceSecret); + const aliceSecretHash = computeSecretHash(aliceSecret); logger.info(`Minting tokens to Alice...`); // Mint the initial supply privately "to secret hash" @@ -144,7 +144,7 @@ describe('e2e_sandbox_example', () => { await tokenContractAlice.methods.set_minter(bob, true).send().wait(); const bobSecret = Fr.random(); - const bobSecretHash = computeMessageSecretHash(bobSecret); + const bobSecretHash = computeSecretHash(bobSecret); // Bob now has a secret 🥷 const mintQuantity = 10_000n; diff --git a/yarn-project/end-to-end/src/e2e_account_init_fees.test.ts b/yarn-project/end-to-end/src/e2e_account_init_fees.test.ts index d8acec1c0d5c..75c225f4d52d 100644 --- a/yarn-project/end-to-end/src/e2e_account_init_fees.test.ts +++ b/yarn-project/end-to-end/src/e2e_account_init_fees.test.ts @@ -12,7 +12,7 @@ import { type TxHash, TxStatus, type Wallet, - computeMessageSecretHash, + computeSecretHash, deriveKeys, } from '@aztec/aztec.js'; import { type AztecAddress, CompleteAddress, Fq, GasSettings } from '@aztec/circuits.js'; @@ -173,7 +173,7 @@ describe('e2e_fees_account_init', () => { await bobsAccountManager.register(); const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const mintTx = await bananaCoin.methods.mint_private(mintedPrivateBananas, secretHash).send().wait(); await addTransparentNoteToPxe(sequencersAddress, mintedPrivateBananas, secretHash, mintTx.txHash); @@ -219,7 +219,7 @@ describe('e2e_fees_account_init', () => { // the new account should have received a refund await expect( // this rejects if note can't be added - addTransparentNoteToPxe(bobsAddress, maxFee - actualFee, computeMessageSecretHash(rebateSecret), tx.txHash), + addTransparentNoteToPxe(bobsAddress, maxFee - actualFee, computeSecretHash(rebateSecret), tx.txHash), ).resolves.toBeUndefined(); // and it can redeem the refund diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts index 8f1d8735bc6a..3fcd61156ab3 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract.test.ts @@ -9,7 +9,7 @@ import { type TxHash, type Wallet, computeAuthWitMessageHash, - computeMessageSecretHash, + computeSecretHash, } from '@aztec/aztec.js'; import { TokenBlacklistContract, type TokenContract } from '@aztec/noir-contracts.js'; @@ -265,7 +265,7 @@ describe('e2e_blacklist_token_contract', () => { let txHash: TxHash; beforeAll(() => { - secretHash = computeMessageSecretHash(secret); + secretHash = computeSecretHash(secret); }); describe('Mint flow', () => { @@ -660,7 +660,7 @@ describe('e2e_blacklist_token_contract', () => { let secretHash: Fr; beforeAll(() => { - secretHash = computeMessageSecretHash(secret); + secretHash = computeSecretHash(secret); }); it('on behalf of self', async () => { diff --git a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts index 01127055f91e..4fd2e8d6d6f9 100644 --- a/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts +++ b/yarn-project/end-to-end/src/e2e_cheat_codes.test.ts @@ -7,7 +7,7 @@ import { Note, type PXE, type Wallet, - computeMessageSecretHash, + computeSecretHash, } from '@aztec/aztec.js'; import { RollupAbi } from '@aztec/l1-artifacts'; import { TestContract, TokenContract } from '@aztec/noir-contracts.js'; @@ -218,7 +218,7 @@ describe('e2e_cheat_codes', () => { // docs:start:load_private_cheatcode const mintAmount = 100n; const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const receipt = await token.methods.mint_private(mintAmount, secretHash).send().wait(); // docs:start:pxe_add_note diff --git a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts index f697a02251f8..ca9f711bf2d8 100644 --- a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts +++ b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts @@ -8,7 +8,7 @@ import { Note, type PXE, type TxHash, - computeMessageSecretHash, + computeSecretHash, deriveKeys, } from '@aztec/aztec.js'; import { computePartialAddress } from '@aztec/circuits.js'; @@ -134,7 +134,7 @@ describe('e2e_crowdfunding_and_claim', () => { const mintDNTToDonors = async () => { const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const [txReceipt1, txReceipt2] = await Promise.all([ donationToken.withWallet(operatorWallet).methods.mint_private(1234n, secretHash).send().wait(), diff --git a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts b/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts index de4f2f48152a..12017b84bb89 100644 --- a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts @@ -7,7 +7,7 @@ import { Fr, Note, type PXE, - computeMessageSecretHash, + computeSecretHash, deriveKeys, } from '@aztec/aztec.js'; import { computePartialAddress } from '@aztec/circuits.js'; @@ -58,7 +58,7 @@ describe('e2e_escrow_contract', () => { const mintAmount = 100n; const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const receipt = await token.methods.mint_private(mintAmount, secretHash).send().wait(); @@ -110,7 +110,7 @@ describe('e2e_escrow_contract', () => { logger.info(`Minting funds in token contract to ${owner}`); const mintAmount = 50n; const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const receipt = await token.methods.mint_private(mintAmount, secretHash).send().wait(); diff --git a/yarn-project/end-to-end/src/e2e_fees.test.ts b/yarn-project/end-to-end/src/e2e_fees.test.ts index 1d4ecce5e3da..795fa7719cfd 100644 --- a/yarn-project/end-to-end/src/e2e_fees.test.ts +++ b/yarn-project/end-to-end/src/e2e_fees.test.ts @@ -14,7 +14,7 @@ import { TxStatus, type Wallet, computeAuthWitMessageHash, - computeMessageSecretHash, + computeSecretHash, } from '@aztec/aztec.js'; import { FunctionData, GasSettings } from '@aztec/circuits.js'; import { type ContractArtifact, decodeFunctionSignature } from '@aztec/foundation/abi'; @@ -298,7 +298,7 @@ describe('e2e_fees', () => { await expect( // this rejects if note can't be added - addPendingShieldNoteToPXE(0, RefundAmount, computeMessageSecretHash(RefundSecret), tx.txHash), + addPendingShieldNoteToPXE(0, RefundAmount, computeSecretHash(RefundSecret), tx.txHash), ).resolves.toBeUndefined(); }); @@ -361,7 +361,7 @@ describe('e2e_fees', () => { await expect( // this rejects if note can't be added - addPendingShieldNoteToPXE(0, RefundAmount, computeMessageSecretHash(RefundSecret), tx.txHash), + addPendingShieldNoteToPXE(0, RefundAmount, computeSecretHash(RefundSecret), tx.txHash), ).resolves.toBeUndefined(); }); @@ -393,7 +393,7 @@ describe('e2e_fees', () => { */ const shieldedBananas = 1n; const shieldSecret = Fr.random(); - const shieldSecretHash = computeMessageSecretHash(shieldSecret); + const shieldSecretHash = computeSecretHash(shieldSecret); const tx = await bananaCoin.methods .shield(aliceAddress, shieldedBananas, shieldSecretHash, 0n) .send({ @@ -428,7 +428,7 @@ describe('e2e_fees', () => { await expect(addPendingShieldNoteToPXE(0, shieldedBananas, shieldSecretHash, tx.txHash)).resolves.toBeUndefined(); await expect( - addPendingShieldNoteToPXE(0, RefundAmount, computeMessageSecretHash(RefundSecret), tx.txHash), + addPendingShieldNoteToPXE(0, RefundAmount, computeSecretHash(RefundSecret), tx.txHash), ).resolves.toBeUndefined(); }); @@ -436,7 +436,7 @@ describe('e2e_fees', () => { const privateTransfer = 1n; const shieldedBananas = 1n; const shieldSecret = Fr.random(); - const shieldSecretHash = computeMessageSecretHash(shieldSecret); + const shieldSecretHash = computeSecretHash(shieldSecret); /** * PRIVATE SETUP @@ -505,7 +505,7 @@ describe('e2e_fees', () => { await expect(addPendingShieldNoteToPXE(0, shieldedBananas, shieldSecretHash, tx.txHash)).resolves.toBeUndefined(); await expect( - addPendingShieldNoteToPXE(0, RefundAmount, computeMessageSecretHash(RefundSecret), tx.txHash), + addPendingShieldNoteToPXE(0, RefundAmount, computeSecretHash(RefundSecret), tx.txHash), ).resolves.toBeUndefined(); }); @@ -646,7 +646,7 @@ describe('e2e_fees', () => { const mintPrivate = async (amount: bigint, address: AztecAddress) => { // Mint bananas privately const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); logger.debug(`Minting ${amount} bananas privately for ${address} with secret ${secretHash.toString()}`); const receipt = await bananaCoin.methods.mint_private(amount, secretHash).send().wait(); diff --git a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts index 738887cdd42b..2dd4614f80ed 100644 --- a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts @@ -6,7 +6,7 @@ import { Fr, Note, computeAuthWitMessageHash, - computeMessageSecretHash, + computeSecretHash, } from '@aztec/aztec.js'; import { LendingContract, PriceFeedContract, TokenContract } from '@aztec/noir-contracts.js'; @@ -96,7 +96,7 @@ describe('e2e_lending_contract', () => { const mintAmount = 10000n; for (const asset of assets) { const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const a = asset.methods.mint_public(lendingAccount.address, mintAmount).send(); const b = asset.methods.mint_private(mintAmount, secretHash).send(); diff --git a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts index 599a69d8956c..cf239abd44f5 100644 --- a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts +++ b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts @@ -10,7 +10,7 @@ import { Note, type PXE, type Wallet, - computeMessageSecretHash, + computeSecretHash, deriveKeys, } from '@aztec/aztec.js'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; @@ -59,7 +59,7 @@ describe('e2e_multiple_accounts_1_enc_key', () => { logger.info(`Token deployed at ${tokenAddress}`); const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const receipt = await token.methods.mint_private(initialBalance, secretHash).send().wait(); diff --git a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts index e8aa0bacee3c..6108e156ed30 100644 --- a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts @@ -13,7 +13,7 @@ import { L2Actor, type PXE, computeAuthWitMessageHash, - computeMessageSecretHash, + computeSecretHash, } from '@aztec/aztec.js'; import { sha256ToField } from '@aztec/foundation/crypto'; import { InboxAbi, OutboxAbi } from '@aztec/l1-artifacts'; @@ -341,7 +341,7 @@ describe('e2e_public_cross_chain_messaging', () => { new L1Actor(crossChainTestHarness.ethAccount, crossChainTestHarness.publicClient.chain.id), new L2Actor(testContract.address, 1), Fr.random(), // content - computeMessageSecretHash(secret), // secretHash + computeSecretHash(secret), // secretHash ); await sendL2Message(message); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts index 2fa48998dcb3..7a833d6a1573 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts @@ -1,4 +1,4 @@ -import { Fr, type TxHash, computeMessageSecretHash } from '@aztec/aztec.js'; +import { Fr, type TxHash, computeSecretHash } from '@aztec/aztec.js'; import { BITSIZE_TOO_BIG_ERROR, U128_OVERFLOW_ERROR } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; @@ -71,7 +71,7 @@ describe('e2e_token_contract minting', () => { let txHash: TxHash; beforeAll(() => { - secretHash = computeMessageSecretHash(secret); + secretHash = computeSecretHash(secret); }); describe('Mint flow', () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts index 99fcd3c1336d..b0cee961f353 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts @@ -1,4 +1,4 @@ -import { Fr, computeMessageSecretHash } from '@aztec/aztec.js'; +import { Fr, computeSecretHash } from '@aztec/aztec.js'; import { U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; import { TokenContractTest } from './token_contract_test.js'; @@ -15,7 +15,7 @@ describe('e2e_token_contract shield + redeem shield', () => { await t.setup(); // Have to destructure again to ensure we have latest refs. ({ asset, accounts, tokenSim, wallets } = t); - secretHash = computeMessageSecretHash(secret); + secretHash = computeSecretHash(secret); }); afterAll(async () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts b/yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts index 9e6fb3f110c6..6325ead8df74 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/token_contract_test.ts @@ -7,7 +7,7 @@ import { Fr, Note, type TxHash, - computeMessageSecretHash, + computeSecretHash, createDebugLogger, } from '@aztec/aztec.js'; import { DocsExampleContract, TokenContract } from '@aztec/noir-contracts.js'; @@ -141,7 +141,7 @@ export class TokenContractTest { this.logger.verbose(`Minting ${amount} privately...`); const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const receipt = await asset.methods.mint_private(amount, secretHash).send().wait(); await this.addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); diff --git a/yarn-project/end-to-end/src/flakey_e2e_2_pxes.test.ts b/yarn-project/end-to-end/src/flakey_e2e_2_pxes.test.ts index ce6e676d3ad8..ea0b055b11ae 100644 --- a/yarn-project/end-to-end/src/flakey_e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/flakey_e2e_2_pxes.test.ts @@ -8,7 +8,7 @@ import { Note, type PXE, type Wallet, - computeMessageSecretHash, + computeSecretHash, retryUntil, } from '@aztec/aztec.js'; import { ChildContract, TokenContract } from '@aztec/noir-contracts.js'; @@ -93,7 +93,7 @@ describe('e2e_2_pxes', () => { const mintTokens = async (contract: TokenContract, recipient: AztecAddress, balance: bigint, pxe: PXE) => { const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const receipt = await contract.methods.mint_private(balance, secretHash).send().wait(); diff --git a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts index 8cde4b58e962..78267af530fe 100644 --- a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts +++ b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts @@ -7,7 +7,7 @@ import { Note, type PXE, TxStatus, - computeMessageSecretHash, + computeSecretHash, createPXEClient, waitForPXE, } from '@aztec/aztec.js'; @@ -47,7 +47,7 @@ describe('guides/dapp/testing', () => { const mintAmount = 20n; const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const receipt = await token.methods.mint_private(mintAmount, secretHash).send().wait(); const note = new Note([new Fr(mintAmount), secretHash]); @@ -88,7 +88,7 @@ describe('guides/dapp/testing', () => { const recipientAddress = recipient.getAddress(); const mintAmount = 20n; const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const receipt = await token.methods.mint_private(mintAmount, secretHash).send().wait(); const note = new Note([new Fr(mintAmount), secretHash]); @@ -150,7 +150,7 @@ describe('guides/dapp/testing', () => { const ownerAddress = owner.getAddress(); const mintAmount = 100n; const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const receipt = await token.methods.mint_private(100n, secretHash).send().wait(); const note = new Note([new Fr(mintAmount), secretHash]); diff --git a/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts b/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts index d708dc1fc695..2072a7ddda54 100644 --- a/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts +++ b/yarn-project/end-to-end/src/guides/writing_an_account_contract.test.ts @@ -10,7 +10,7 @@ import { GrumpkinScalar, Note, Schnorr, - computeMessageSecretHash, + computeSecretHash, } from '@aztec/aztec.js'; import { SchnorrHardcodedAccountContractArtifact } from '@aztec/noir-contracts.js/SchnorrHardcodedAccount'; import { TokenContract } from '@aztec/noir-contracts.js/Token'; @@ -68,7 +68,7 @@ describe('guides/writing_an_account_contract', () => { logger.info(`Deployed token contract at ${token.address}`); const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const mintAmount = 50n; const receipt = await token.methods.mint_private(mintAmount, secretHash).send().wait(); diff --git a/yarn-project/end-to-end/src/sample-dapp/index.mjs b/yarn-project/end-to-end/src/sample-dapp/index.mjs index 861c6f2cc03e..6f421f61f3a6 100644 --- a/yarn-project/end-to-end/src/sample-dapp/index.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/index.mjs @@ -1,5 +1,5 @@ import { getInitialTestAccountsWallets } from '@aztec/accounts/testing'; -import { ExtendedNote, Fr, Note, computeMessageSecretHash, createPXEClient } from '@aztec/aztec.js'; +import { ExtendedNote, Fr, Note, computeSecretHash, createPXEClient } from '@aztec/aztec.js'; import { fileURLToPath } from '@aztec/foundation/url'; import { getToken } from './contracts.mjs'; @@ -34,7 +34,7 @@ async function mintPrivateFunds(pxe) { const mintAmount = 20n; const secret = Fr.random(); - const secretHash = await computeMessageSecretHash(secret); + const secretHash = await computeSecretHash(secret); const receipt = await token.methods.mint_private(mintAmount, secretHash).send().wait(); const storageSlot = new Fr(5); diff --git a/yarn-project/end-to-end/src/sample-dapp/index.test.mjs b/yarn-project/end-to-end/src/sample-dapp/index.test.mjs index 837c5386c974..c9e18f6ed6e2 100644 --- a/yarn-project/end-to-end/src/sample-dapp/index.test.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/index.test.mjs @@ -4,7 +4,7 @@ import { ExtendedNote, Fr, Note, - computeMessageSecretHash, + computeSecretHash, createPXEClient, waitForPXE, } from '@aztec/aztec.js'; @@ -27,7 +27,7 @@ describe('token', () => { const initialBalance = 20n; const secret = Fr.random(); - const secretHash = await computeMessageSecretHash(secret); + const secretHash = await computeSecretHash(secret); const receipt = await token.methods.mint_private(initialBalance, secretHash).send().wait(); const storageSlot = new Fr(5); diff --git a/yarn-project/end-to-end/src/shared/browser.ts b/yarn-project/end-to-end/src/shared/browser.ts index 516bd3aa87e0..370a76983374 100644 --- a/yarn-project/end-to-end/src/shared/browser.ts +++ b/yarn-project/end-to-end/src/shared/browser.ts @@ -221,7 +221,7 @@ export const browserTestSuite = ( Fr, ExtendedNote, Note, - computeMessageSecretHash, + computeSecretHash, getDeployedTestAccountsWallets, INITIAL_TEST_SECRET_KEYS, INITIAL_TEST_SIGNING_KEYS, @@ -261,7 +261,7 @@ export const browserTestSuite = ( console.log(`Contract Deployed: ${token.address}`); const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); const mintPrivateReceipt = await token.methods.mint_private(initialBalance, secretHash).send().wait(); const storageSlot = new Fr(5); diff --git a/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts b/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts index 5da650d74d4c..994d41e7d21f 100644 --- a/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts +++ b/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts @@ -13,7 +13,7 @@ import { type TxHash, type TxReceipt, type Wallet, - computeMessageSecretHash, + computeSecretHash, deployL1Contract, retryUntil, } from '@aztec/aztec.js'; @@ -223,10 +223,15 @@ export class CrossChainTestHarness { public ownerAddress: AztecAddress, ) {} + /** + * Used to generate a claim secret using pedersen's hash function. + * @dev Used for both L1 to L2 messages and transparent note (pending shields) secrets. + * @returns A tuple of the secret and its hash. + */ generateClaimSecret(): [Fr, Fr] { this.logger.debug("Generating a claim secret using pedersen's hash function"); const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); this.logger.info('Generated claim secret: ' + secretHash.toString()); return [secret, secretHash]; } diff --git a/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts b/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts index ff3a4dc43893..dee68998224f 100644 --- a/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts +++ b/yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts @@ -6,7 +6,7 @@ import { Fr, type PXE, type Wallet, - computeMessageSecretHash, + computeSecretHash, } from '@aztec/aztec.js'; import { GasPortalAbi, OutboxAbi, PortalERC20Abi } from '@aztec/l1-artifacts'; import { GasTokenContract } from '@aztec/noir-contracts.js'; @@ -153,7 +153,7 @@ class GasBridgingTestHarness implements IGasBridgingTestHarness { generateClaimSecret(): [Fr, Fr] { this.logger.debug("Generating a claim secret using pedersen's hash function"); const secret = Fr.random(); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); this.logger.info('Generated claim secret: ' + secretHash.toString()); return [secret, secretHash]; } diff --git a/yarn-project/simulator/src/test/utils.ts b/yarn-project/simulator/src/test/utils.ts index 56231284d8ef..69769b28c7b3 100644 --- a/yarn-project/simulator/src/test/utils.ts +++ b/yarn-project/simulator/src/test/utils.ts @@ -1,6 +1,6 @@ import { L1Actor, L1ToL2Message, L2Actor } from '@aztec/circuit-types'; import { type AztecAddress, EthAddress, type Fr } from '@aztec/circuits.js'; -import { computeMessageSecretHash } from '@aztec/circuits.js/hash'; +import { computeSecretHash } from '@aztec/circuits.js/hash'; import { sha256ToField } from '@aztec/foundation/crypto'; /** @@ -21,7 +21,7 @@ export const buildL1ToL2Message = ( const selectorBuf = Buffer.from(selector, 'hex'); const content = sha256ToField([selectorBuf, ...contentPreimage]); - const secretHash = computeMessageSecretHash(secret); + const secretHash = computeSecretHash(secret); return new L1ToL2Message(new L1Actor(EthAddress.random(), 1), new L2Actor(targetContract, 1), content, secretHash); };