diff --git a/noir-projects/aztec-nr/aztec/src/messages/encryption/aes128.nr b/noir-projects/aztec-nr/aztec/src/messages/encryption/aes128.nr index 66d75084c472..b2fe60c7cfe8 100644 --- a/noir-projects/aztec-nr/aztec/src/messages/encryption/aes128.nr +++ b/noir-projects/aztec-nr/aztec/src/messages/encryption/aes128.nr @@ -393,11 +393,7 @@ mod test { test::helpers::test_environment::TestEnvironment, }; use super::AES128; - use protocol_types::{ - address::AztecAddress, - indexed_tagging_secret::IndexedTaggingSecret, - traits::{Deserialize, FromField}, - }; + use protocol_types::{address::AztecAddress, traits::FromField}; use std::{embedded_curve_ops::EmbeddedCurveScalar, test::OracleMock}; #[test] @@ -419,10 +415,7 @@ mod test { let randomness = 0x0101010101010101010101010101010101010101010101010101010101010101; let _ = OracleMock::mock("utilityGetRandomField").returns(randomness).times(1000000); - let _ = OracleMock::mock("utilityGetIndexedTaggingSecretAsSender").returns( - IndexedTaggingSecret::deserialize([69420, 1337]), - ); - let _ = OracleMock::mock("privateIncrementAppTaggingSecretIndexAsSender").returns(()); + let _ = OracleMock::mock("privateGetNextAppTagAsSender").returns(42); // Encrypt the message let encrypted_message = BoundedVec::from_array(AES128::encrypt(plaintext, recipient)); diff --git a/noir-projects/aztec-nr/aztec/src/messages/logs/utils.nr b/noir-projects/aztec-nr/aztec/src/messages/logs/utils.nr index c1a05e452f5c..e059b09363e7 100644 --- a/noir-projects/aztec-nr/aztec/src/messages/logs/utils.nr +++ b/noir-projects/aztec-nr/aztec/src/messages/logs/utils.nr @@ -1,6 +1,4 @@ -use crate::oracle::notes::{ - get_app_tag_as_sender, get_sender_for_tags, increment_app_tagging_secret_index_as_sender, -}; +use crate::oracle::notes::{get_next_app_tag_as_sender, get_sender_for_tags}; use dep::protocol_types::address::AztecAddress; // TODO(#14565): Add constrained tagging @@ -15,8 +13,7 @@ pub(crate) fn prefix_with_tag( let sender = get_sender_for_tags().expect( f"Sender for tags is not set when emitting a private log. Set it by calling `set_sender_for_tags(...)`.", ); - increment_app_tagging_secret_index_as_sender(sender, recipient); - get_app_tag_as_sender(sender, recipient) + get_next_app_tag_as_sender(sender, recipient) }; let mut log_with_tag = [0; L + 1]; @@ -31,30 +28,18 @@ pub(crate) fn prefix_with_tag( mod test { use super::prefix_with_tag; - use protocol_types::{ - address::AztecAddress, - indexed_tagging_secret::IndexedTaggingSecret, - traits::{Deserialize, FromField}, - }; + use protocol_types::{address::AztecAddress, traits::FromField}; use std::test::OracleMock; #[test(should_fail)] unconstrained fn no_tag_sender() { let recipient = AztecAddress::from_field(2); - let app_tagging_secret = 42; - let index = 5; - - // I am using the deserialize trait instead of directly instantiating the IndexedTaggingSecret struct because - // direct instantiation functionality is not exposed. - let indexed_tagging_secret = IndexedTaggingSecret::deserialize([app_tagging_secret, index]); + let expected_tag = 42; // Mock the tagging oracles - note privateGetSenderForTags returns none let _ = OracleMock::mock("privateGetSenderForTags").returns(Option::::none()); - let _ = OracleMock::mock("utilityGetIndexedTaggingSecretAsSender").returns( - indexed_tagging_secret, - ); - let _ = OracleMock::mock("privateIncrementAppTaggingSecretIndexAsSender").returns(()); + let _ = OracleMock::mock("privateGetNextAppTagAsSender").returns(expected_tag); let log_without_tag = [1, 2, 3]; let _ = prefix_with_tag(log_without_tag, recipient); @@ -65,24 +50,16 @@ mod test { let sender = AztecAddress::from_field(1); let recipient = AztecAddress::from_field(2); - let app_tagging_secret = 42; - let index = 5; - - // I am using the deserialize trait instead of directly instantiating the IndexedTaggingSecret struct because - // direct instantiation functionality is not exposed. - let indexed_tagging_secret = IndexedTaggingSecret::deserialize([app_tagging_secret, index]); + let expected_tag = 42; // Mock the tagging oracles let _ = OracleMock::mock("privateGetSenderForTags").returns(Option::some(sender)); - let _ = OracleMock::mock("utilityGetIndexedTaggingSecretAsSender").returns( - indexed_tagging_secret, - ); - let _ = OracleMock::mock("privateIncrementAppTaggingSecretIndexAsSender").returns(()); + let _ = OracleMock::mock("privateGetNextAppTagAsSender").returns(expected_tag); let log_without_tag = [1, 2, 3]; let log_with_tag = prefix_with_tag(log_without_tag, recipient); - let expected_result = [indexed_tagging_secret.compute_tag(recipient), 1, 2, 3]; + let expected_result = [expected_tag, 1, 2, 3]; // Check tag was prefixed correctly assert_eq(log_with_tag, expected_result, "Tag was not prefixed correctly"); diff --git a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr index 68a339a88742..419b1a0def74 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr @@ -1,8 +1,6 @@ use crate::note::{note_interface::NoteType, retrieved_note::RetrievedNote}; -use dep::protocol_types::{ - address::AztecAddress, indexed_tagging_secret::IndexedTaggingSecret, traits::Packable, -}; +use dep::protocol_types::{address::AztecAddress, traits::Packable}; /// Notifies the simulator that a note has been created, so that it can be returned in future read requests in the same /// transaction. This note should only be added to the non-volatile database if found in an actual block. @@ -191,43 +189,25 @@ unconstrained fn check_nullifier_exists_oracle(_inner_nullifier: Field) -> bool // TODO: Oracles below are generic private log oracles and are not specific to notes. Move them somewhere else. -/// Returns the derived app tagging secret ready to be included in a log for a given sender and recipient pair, -/// siloed for the current contract address. -pub unconstrained fn get_app_tag_as_sender(sender: AztecAddress, recipient: AztecAddress) -> Field { - get_indexed_tagging_secret_as_sender_oracle(sender, recipient).compute_tag(recipient) -} - -#[oracle(utilityGetIndexedTaggingSecretAsSender)] -unconstrained fn get_indexed_tagging_secret_as_sender_oracle( - _sender: AztecAddress, - _recipient: AztecAddress, -) -> IndexedTaggingSecret {} - -/// Notifies the simulator that a tag has been used in a note, and to therefore increment the associated index so that -/// future notes get a different tag and can be discovered by the recipient. +/// Returns the next app tag for a given sender and recipient pair. +/// +/// This also notifies the simulator that a tag has been used in a note, and to therefore increment the +/// associated index so that future notes get a different tag and can be discovered by the recipient. /// This change should only be persisted in a non-volatile database if the tagged log is found in an actual block - /// otherwise e.g. a reverting transaction can cause the sender to accidentally skip indices and later produce notes /// that are not found by the recipient. -pub fn increment_app_tagging_secret_index_as_sender(sender: AztecAddress, recipient: AztecAddress) { - // Safety: This oracle call returns nothing: we only call it for its side effects. It is therefore always safe - // to call. - unsafe { - increment_app_tagging_secret_index_as_sender_wrapper(sender, recipient); - } -} - -unconstrained fn increment_app_tagging_secret_index_as_sender_wrapper( +pub unconstrained fn get_next_app_tag_as_sender( sender: AztecAddress, recipient: AztecAddress, -) { - increment_app_tagging_secret_index_as_sender_oracle(sender, recipient); +) -> Field { + get_next_app_tag_as_sender_oracle(sender, recipient) } -#[oracle(privateIncrementAppTaggingSecretIndexAsSender)] -unconstrained fn increment_app_tagging_secret_index_as_sender_oracle( +#[oracle(privateGetNextAppTagAsSender)] +unconstrained fn get_next_app_tag_as_sender_oracle( _sender: AztecAddress, _recipient: AztecAddress, -) {} +) -> Field {} /// Gets the sender for tags. /// diff --git a/noir-projects/aztec-nr/aztec/src/oracle/version.nr b/noir-projects/aztec-nr/aztec/src/oracle/version.nr index f45a554b6458..99a33ac86b0a 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/version.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/version.nr @@ -4,7 +4,7 @@ /// /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called and /// if the oracle version is incompatible an error is thrown. -pub global ORACLE_VERSION: Field = 2; +pub global ORACLE_VERSION: Field = 3; /// Asserts that the version of the oracle is compatible with the version expected by the contract. pub fn assert_compatible_oracle_version() { @@ -30,7 +30,7 @@ mod test { assert_compatible_oracle_version_oracle(ORACLE_VERSION); } - #[test(should_fail_with = "Incompatible oracle version. TXE is using version '2', but got a request for '318183437'.")] + #[test(should_fail_with = "Incompatible oracle version. TXE is using version '3', but got a request for '318183437'.")] unconstrained fn incompatible_oracle_version() { let arbitrary_incorrect_version = 318183437; assert_compatible_oracle_version_oracle(arbitrary_incorrect_version); diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/indexed_tagging_secret.nr b/noir-projects/noir-protocol-circuits/crates/types/src/indexed_tagging_secret.nr deleted file mode 100644 index 99093372014f..000000000000 --- a/noir-projects/noir-protocol-circuits/crates/types/src/indexed_tagging_secret.nr +++ /dev/null @@ -1,19 +0,0 @@ -use crate::traits::{Deserialize, Serialize, ToField}; -use super::{address::aztec_address::AztecAddress, hash::poseidon2_hash}; -use std::meta::derive; - -pub global INDEXED_TAGGING_SECRET_LENGTH: u32 = 2; - -#[derive(Serialize, Deserialize)] -pub struct IndexedTaggingSecret { - app_tagging_secret: Field, - index: u32, -} - -impl IndexedTaggingSecret { - pub fn compute_tag(self, recipient: AztecAddress) -> Field { - poseidon2_hash( - [self.app_tagging_secret, recipient.to_field(), self.index as Field], - ) - } -} diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/lib.nr b/noir-projects/noir-protocol-circuits/crates/types/src/lib.nr index 8e8ea3adfb04..ccb423e8d1b5 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/lib.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/lib.nr @@ -30,7 +30,6 @@ pub mod data; pub mod storage; pub mod validate; pub mod meta; -pub mod indexed_tagging_secret; pub mod tests; diff --git a/yarn-project/pxe/src/contract_function_simulator/execution_data_provider.ts b/yarn-project/pxe/src/contract_function_simulator/execution_data_provider.ts index 68c7abc1a898..b91b883de6a7 100644 --- a/yarn-project/pxe/src/contract_function_simulator/execution_data_provider.ts +++ b/yarn-project/pxe/src/contract_function_simulator/execution_data_provider.ts @@ -5,7 +5,6 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address'; import type { L2Block } from '@aztec/stdlib/block'; import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract'; import type { KeyValidationRequest } from '@aztec/stdlib/kernel'; -import { IndexedTaggingSecret } from '@aztec/stdlib/logs'; import type { NoteStatus } from '@aztec/stdlib/note'; import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees'; import type { BlockHeader, NodeStats } from '@aztec/stdlib/tx'; @@ -215,30 +214,13 @@ export interface ExecutionDataProvider { assertCompatibleOracleVersion(version: number): void; /** - * Returns the tagging secret for a given sender and recipient pair. For this to work, the ivsk_m of the sender must be known. - * Includes the next index to be used used for tagging with this secret. + * Returns the next app tag for a given sender and recipient pair. * @param contractAddress - The contract address to silo the secret for * @param sender - The address sending the note * @param recipient - The address receiving the note - * @returns A tagging secret that can be used to tag notes. + * @returns The computed tag. */ - getIndexedTaggingSecretAsSender( - contractAddress: AztecAddress, - sender: AztecAddress, - recipient: AztecAddress, - ): Promise; - - /** - * Increments the tagging secret for a given sender and recipient pair. For this to work, the ivsk_m of the sender must be known. - * @param contractAddress - The contract address to silo the secret for - * @param sender - The address sending the note - * @param recipient - The address receiving the note - */ - incrementAppTaggingSecretIndexAsSender( - contractAddress: AztecAddress, - sender: AztecAddress, - recipient: AztecAddress, - ): Promise; + getNextAppTagAsSender(contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress): Promise; /** * Synchronizes the private logs tagged with scoped addresses and all the senders in the address book. Stores the found diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/interfaces.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/interfaces.ts index 7dd77b7de6cc..768680b2276c 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/interfaces.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/interfaces.ts @@ -4,7 +4,7 @@ import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi'; import type { AztecAddress } from '@aztec/stdlib/aztec-address'; import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract'; import type { KeyValidationRequest } from '@aztec/stdlib/kernel'; -import type { ContractClassLog, IndexedTaggingSecret } from '@aztec/stdlib/logs'; +import type { ContractClassLog } from '@aztec/stdlib/logs'; import type { Note, NoteStatus } from '@aztec/stdlib/note'; import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees'; import type { BlockHeader } from '@aztec/stdlib/tx'; @@ -100,7 +100,6 @@ export interface IUtilityExecutionOracle { blockNumber: number, numberOfElements: number, ): Promise; - utilityGetIndexedTaggingSecretAsSender(sender: AztecAddress, recipient: AztecAddress): Promise; utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise; utilityValidateEnqueuedNotesAndEvents( contractAddress: AztecAddress, @@ -153,8 +152,8 @@ export interface IPrivateExecutionOracle { isStaticCall: boolean, ): Promise; privateNotifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise; - privateIncrementAppTaggingSecretIndexAsSender(sender: AztecAddress, recipient: AztecAddress): Promise; privateGetSenderForTags(): Promise; privateSetSenderForTags(senderForTags: AztecAddress): Promise; + privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise; utilityEmitOffchainEffect(data: Fr[]): Promise; } diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/oracle.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/oracle.ts index aac567b2a786..e26d24f5a756 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/oracle.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/oracle.ts @@ -433,23 +433,12 @@ export class Oracle { return Promise.resolve([]); } - async utilityGetIndexedTaggingSecretAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise { - const taggingSecret = await this.handlerAsUtility().utilityGetIndexedTaggingSecretAsSender( + async privateGetNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise { + const tag = await this.handlerAsPrivate().privateGetNextAppTagAsSender( AztecAddress.fromString(sender), AztecAddress.fromString(recipient), ); - return taggingSecret.toFields().map(toACVMField); - } - - async privateIncrementAppTaggingSecretIndexAsSender( - [sender]: ACVMField[], - [recipient]: ACVMField[], - ): Promise { - await this.handlerAsPrivate().privateIncrementAppTaggingSecretIndexAsSender( - AztecAddress.fromString(sender), - AztecAddress.fromString(recipient), - ); - return []; + return [toACVMField(tag)]; } async utilityFetchTaggedLogs([pendingTaggedLogArrayBaseSlot]: ACVMField[]): Promise { diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution.test.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution.test.ts index 6eb3492bf4f0..ef168d524c1f 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution.test.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution.test.ts @@ -47,7 +47,6 @@ import { } from '@aztec/stdlib/hash'; import { KeyValidationRequest } from '@aztec/stdlib/kernel'; import { computeAppNullifierSecretKey, deriveKeys } from '@aztec/stdlib/keys'; -import { IndexedTaggingSecret } from '@aztec/stdlib/logs'; import { L1Actor, L1ToL2Message, L2Actor } from '@aztec/stdlib/messaging'; import { Note } from '@aztec/stdlib/note'; import { makeHeader } from '@aztec/stdlib/testing'; @@ -302,10 +301,9 @@ describe('Private Execution test suite', () => { throw new Error(`Unknown address: ${address}. Recipient: ${recipient}, Owner: ${owner}`); }); - executionDataProvider.getIndexedTaggingSecretAsSender.mockImplementation( + executionDataProvider.getNextAppTagAsSender.mockImplementation( (_contractAddress: AztecAddress, _sender: AztecAddress, _recipient: AztecAddress) => { - const secret = Fr.random(); - return Promise.resolve(new IndexedTaggingSecret(secret, 0)); + return Promise.resolve(Fr.random()); }, ); executionDataProvider.getFunctionArtifact.mockImplementation(async (address, selector) => { diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution_oracle.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution_oracle.ts index e4db19d7f7ce..9910f06a22fb 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution_oracle.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/private_execution_oracle.ts @@ -185,6 +185,16 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP return Promise.resolve(); } + /** + * Returns the next app tag for a given sender and recipient pair. + * @param sender - The address sending the log + * @param recipient - The address receiving the log + * @returns An app tag to be used in a log. + */ + public async privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise { + return await this.executionDataProvider.getNextAppTagAsSender(this.contractAddress, sender, recipient); + } + /** * Store values in the execution cache. * @param values - Values to store. @@ -567,10 +577,6 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP return this.executionDataProvider.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector); } - public async privateIncrementAppTaggingSecretIndexAsSender(sender: AztecAddress, recipient: AztecAddress) { - await this.executionDataProvider.incrementAppTaggingSecretIndexAsSender(this.contractAddress, sender, recipient); - } - public utilityEmitOffchainEffect(data: Fr[]): Promise { this.offchainEffects.push({ data }); return Promise.resolve(); diff --git a/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts b/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts index fb2be250e493..e6e6c76da18a 100644 --- a/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts +++ b/yarn-project/pxe/src/contract_function_simulator/oracle/utility_execution_oracle.ts @@ -6,7 +6,6 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address'; import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract'; import { siloNullifier } from '@aztec/stdlib/hash'; import type { KeyValidationRequest } from '@aztec/stdlib/kernel'; -import { IndexedTaggingSecret } from '@aztec/stdlib/logs'; import type { NoteStatus } from '@aztec/stdlib/note'; import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees'; import type { BlockHeader, Capsule } from '@aztec/stdlib/tx'; @@ -264,21 +263,6 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra this.log[levelName](`${applyStringFormatting(message, fields)}`, { module: `${this.log.module}:debug_log` }); } - /** - * Returns the tagging secret for a given sender and recipient pair, siloed to the current contract address. - * Includes the next index to be used used for tagging with this secret. - * For this to work, the ivsk_m of the sender must be known. - * @param sender - The address sending the note - * @param recipient - The address receiving the note - * @returns A tagging secret that can be used to tag notes. - */ - public async utilityGetIndexedTaggingSecretAsSender( - sender: AztecAddress, - recipient: AztecAddress, - ): Promise { - return await this.executionDataProvider.getIndexedTaggingSecretAsSender(this.contractAddress, sender, recipient); - } - public async utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) { await this.executionDataProvider.syncTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes); diff --git a/yarn-project/pxe/src/contract_function_simulator/pxe_oracle_interface.ts b/yarn-project/pxe/src/contract_function_simulator/pxe_oracle_interface.ts index 7139317b27fc..e1238058f602 100644 --- a/yarn-project/pxe/src/contract_function_simulator/pxe_oracle_interface.ts +++ b/yarn-project/pxe/src/contract_function_simulator/pxe_oracle_interface.ts @@ -263,52 +263,40 @@ export class PXEOracleInterface implements ExecutionDataProvider { } /** - * Returns the tagging secret for a given sender and recipient pair. For this to work, the ivsk_m of the sender must be known. - * Includes the next index to be used used for tagging with this secret. - * @param contractAddress - The contract address to silo the secret for + * Returns the next app tag for a given sender and recipient pair. + * @param contractAddress - The contract address emitting the log. * @param sender - The address sending the note * @param recipient - The address receiving the note - * @returns An indexed tagging secret that can be used to tag notes. + * @returns The computed tag. */ - public async getIndexedTaggingSecretAsSender( + public async getNextAppTagAsSender( contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress, - ): Promise { + ): Promise { await this.syncTaggedLogsAsSender(contractAddress, sender, recipient); const appTaggingSecret = await this.#calculateAppTaggingSecret(contractAddress, sender, recipient); const [index] = await this.taggingDataProvider.getTaggingSecretsIndexesAsSender([appTaggingSecret], sender); - return new IndexedTaggingSecret(appTaggingSecret, index); - } - - /** - * Increments the tagging secret for a given sender and recipient pair. For this to work, the ivsk_m of the sender must be known. - * @param contractAddress - The contract address to silo the secret for - * @param sender - The address sending the note - * @param recipient - The address receiving the note - */ - public async incrementAppTaggingSecretIndexAsSender( - contractAddress: AztecAddress, - sender: AztecAddress, - recipient: AztecAddress, - ): Promise { - const secret = await this.#calculateAppTaggingSecret(contractAddress, sender, recipient); + // Increment the index for next time const contractName = await this.contractDataProvider.getDebugContractName(contractAddress); this.log.debug(`Incrementing app tagging secret at ${contractName}(${contractAddress})`, { - secret, + appTaggingSecret, sender, recipient, contractName, contractAddress, }); - const [index] = await this.taggingDataProvider.getTaggingSecretsIndexesAsSender([secret], sender); await this.taggingDataProvider.setTaggingSecretsIndexesAsSender( - [new IndexedTaggingSecret(secret, index + 1)], + [new IndexedTaggingSecret(appTaggingSecret, index + 1)], sender, ); + + // Compute and return the tag using the current index + const indexedTaggingSecret = new IndexedTaggingSecret(appTaggingSecret, index); + return indexedTaggingSecret.computeTag(recipient); } async #calculateAppTaggingSecret(contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress) { diff --git a/yarn-project/pxe/src/oracle_version.ts b/yarn-project/pxe/src/oracle_version.ts index 9b65da6e8b72..c2e623af1523 100644 --- a/yarn-project/pxe/src/oracle_version.ts +++ b/yarn-project/pxe/src/oracle_version.ts @@ -4,8 +4,8 @@ /// /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called /// and if the oracle version is incompatible an error is thrown. -export const ORACLE_VERSION = 2; +export const ORACLE_VERSION = 3; /// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes, /// which in turn implies that you need to update the ORACLE_VERSION constant. -export const ORACLE_INTERFACE_HASH = '6cf8e69893d8cfb3579bcffcf6740bf35a09dd63bdf5b076407841f896b0c07f'; +export const ORACLE_INTERFACE_HASH = 'f9168ceb5a2227c148c5021ebffd4e2ca0da99885b87c5be3ee5ac0d8dd3d67c'; diff --git a/yarn-project/txe/src/rpc_translator.ts b/yarn-project/txe/src/rpc_translator.ts index fc646b1e4b59..ff2ed3df7e8e 100644 --- a/yarn-project/txe/src/rpc_translator.ts +++ b/yarn-project/txe/src/rpc_translator.ts @@ -596,15 +596,6 @@ export class RPCTranslator { return toForeignCallResult(witness.toNoirRepresentation()); } - async utilityGetIndexedTaggingSecretAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) { - const sender = AztecAddress.fromField(fromSingle(foreignSender)); - const recipient = AztecAddress.fromField(fromSingle(foreignRecipient)); - - const secret = await this.handlerAsUtility().utilityGetIndexedTaggingSecretAsSender(sender, recipient); - - return toForeignCallResult(secret.toFields().map(toSingle)); - } - async utilityFetchTaggedLogs(foreignPendingTaggedLogArrayBaseSlot: ForeignCallSingle) { const pendingTaggedLogArrayBaseSlot = fromSingle(foreignPendingTaggedLogArrayBaseSlot); @@ -1006,4 +997,13 @@ export class RPCTranslator { return toForeignCallResult([]); } + + async privateGetNextAppTagAsSender(foreignSender: ForeignCallSingle, foreignRecipient: ForeignCallSingle) { + const sender = AztecAddress.fromField(fromSingle(foreignSender)); + const recipient = AztecAddress.fromField(fromSingle(foreignRecipient)); + + const nextAppTag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(sender, recipient); + + return toForeignCallResult([toSingle(nextAppTag)]); + } }