From 1fad06a5f6b6ccfeeca456a1a2eed2543be549d9 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Wed, 30 Oct 2024 11:27:16 +0000 Subject: [PATCH] init --- noir-projects/aztec-nr/aztec/src/oracle/notes.nr | 12 ++++++++++++ .../src/structs/indexed_tagging_secret.ts | 4 ++++ .../protocol-contracts/src/protocol_contract_data.ts | 8 ++++---- yarn-project/pxe/src/simulator_oracle/index.ts | 4 ++++ yarn-project/simulator/src/acvm/oracle/oracle.ts | 7 +++++++ .../simulator/src/acvm/oracle/typed_oracle.ts | 4 ++++ .../simulator/src/client/client_execution_context.ts | 5 +++++ yarn-project/simulator/src/client/db_oracle.ts | 2 ++ yarn-project/txe/src/oracle/txe_oracle.ts | 4 ++++ 9 files changed, 46 insertions(+), 4 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr index 00bb2f14ab1b..7c56f41a881b 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr @@ -221,6 +221,18 @@ unconstrained fn get_app_tagging_secret_oracle( _recipient: AztecAddress, ) -> [Field; INDEXED_TAGGING_SECRET_LENGTH] {} + +pub unconstrained fn increment_app_tagging_secret( + to_increment: IndexedTaggingSecret, +) { + increment_app_tagging_secret_oracle(to_increment); +} + +#[oracle(incrementAppTaggingSecret)] +unconstrained fn increment_app_tagging_secret_oracle( + to_increment: IndexedTaggingSecret, +) {} + /// Returns the tagging secrets for a given recipient and all the senders in PXE's address book, // siloed for the current contract address. /// Includes the last known index used for tagging with this secret. diff --git a/yarn-project/circuits.js/src/structs/indexed_tagging_secret.ts b/yarn-project/circuits.js/src/structs/indexed_tagging_secret.ts index ab218b5b7ee7..47dd25c4fcd2 100644 --- a/yarn-project/circuits.js/src/structs/indexed_tagging_secret.ts +++ b/yarn-project/circuits.js/src/structs/indexed_tagging_secret.ts @@ -6,4 +6,8 @@ export class IndexedTaggingSecret { toFields(): Fr[] { return [this.secret, new Fr(this.index)]; } + + static fromFields(fields: Fr[]): IndexedTaggingSecret { + return new this(fields[0], fields[1].toNumber()); + } } diff --git a/yarn-project/protocol-contracts/src/protocol_contract_data.ts b/yarn-project/protocol-contracts/src/protocol_contract_data.ts index 8b1c4f4c09ab..f6746242d93e 100644 --- a/yarn-project/protocol-contracts/src/protocol_contract_data.ts +++ b/yarn-project/protocol-contracts/src/protocol_contract_data.ts @@ -50,14 +50,14 @@ export const ProtocolContractAddress: Record }; export const ProtocolContractLeaf = { - AuthRegistry: Fr.fromString('0x13794ed6c957a68bc852fe4c2a161019a53011b08331d8eb0287483a7845d334'), + AuthRegistry: Fr.fromString('0x16f00633c07cb18f29a819d16a8b5140dea24787ca2a030dc54379a8e6896e3e'), ContractInstanceDeployer: Fr.fromString('0x04a661c9d4d295fc485a7e0f3de40c09b35366343bce8ad229106a8ef4076fe5'), ContractClassRegisterer: Fr.fromString('0x147ba3294403576dbad10f86d3ffd4eb83fb230ffbcd5c8b153dd02942d0611f'), MultiCallEntrypoint: Fr.fromString('0x154b701b41d6cf6da7204fef36b2ee9578b449d21b3792a9287bf45eba48fd26'), - FeeJuice: Fr.fromString('0x0191fe64a9d9efca55572a5190479698b8a3b296295f0f2d917b91fcb5486251'), - Router: Fr.fromString('0x19e9ec99aedfe3ea69ba91b862b815df7d1796fa802985a154159cd739fe4817'), + FeeJuice: Fr.fromString('0x2e41a1cdc1e39153819779ed2750ab57f40683971d3cca12d159e0227b74ff89'), + Router: Fr.fromString('0x1cedd0ce59239cb4d55408257d8942bdbd1ac6f0ddab9980157255391dbaa596'), }; export const protocolContractTreeRoot = Fr.fromString( - '0x158c0b725f29c56278203f9d49c503c14bcf22888684ee73a4826e2edf2a56a8', + '0x2cf0d0f80097e52d5a605e7a0d4246d1cad56f6c506963b53556606651e86e8e', ); diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 50570db1ae5b..30aa3236451b 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -252,6 +252,10 @@ export class SimulatorOracle implements DBOracle { return new IndexedTaggingSecret(secret, index); } + public async incrementAppTaggingSecret(indexedSecret: IndexedTaggingSecret): Promise { + await this.db.incrementTaggingSecretsIndexes([indexedSecret.secret]); + } + /** * Returns the siloed tagging secrets for a given recipient and all the senders in the address book * @param contractAddress - The contract address to silo the secret for diff --git a/yarn-project/simulator/src/acvm/oracle/oracle.ts b/yarn-project/simulator/src/acvm/oracle/oracle.ts index c8fdb5a18b2f..f6f483281545 100644 --- a/yarn-project/simulator/src/acvm/oracle/oracle.ts +++ b/yarn-project/simulator/src/acvm/oracle/oracle.ts @@ -1,4 +1,5 @@ import { MerkleTreeId, UnencryptedL2Log } from '@aztec/circuit-types'; +import { IndexedTaggingSecret } from '@aztec/circuits.js'; import { FunctionSelector, NoteSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; @@ -417,6 +418,12 @@ export class Oracle { return taggingSecret.toFields().map(toACVMField); } + async incrementAppTaggingSecret(indexedTaggingSecret: ACVMField[]) { + await this.typedOracle.incrementAppTaggingSecret( + IndexedTaggingSecret.fromFields(indexedTaggingSecret.map(fromACVMField)), + ); + } + async getAppTaggingSecretsForSenders([recipient]: ACVMField[]): Promise { const taggingSecrets = await this.typedOracle.getAppTaggingSecretsForSenders(AztecAddress.fromString(recipient)); return taggingSecrets.flatMap(taggingSecret => taggingSecret.toFields().map(toACVMField)); diff --git a/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts b/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts index 284b08f5e0f5..3e12797896fc 100644 --- a/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts +++ b/yarn-project/simulator/src/acvm/oracle/typed_oracle.ts @@ -258,6 +258,10 @@ export abstract class TypedOracle { throw new OracleMethodNotAvailableError('getAppTaggingSecret'); } + incrementAppTaggingSecret(_indexedTaggingSecret: IndexedTaggingSecret): Promise { + throw new OracleMethodNotAvailableError('incrementAppTaggingSecret'); + } + getAppTaggingSecretsForSenders(_recipient: AztecAddress): Promise { throw new OracleMethodNotAvailableError('getAppTaggingSecretsForSenders'); } diff --git a/yarn-project/simulator/src/client/client_execution_context.ts b/yarn-project/simulator/src/client/client_execution_context.ts index 06c51c9b0bf4..7dd6f960e56a 100644 --- a/yarn-project/simulator/src/client/client_execution_context.ts +++ b/yarn-project/simulator/src/client/client_execution_context.ts @@ -17,6 +17,7 @@ import { CallContext, FunctionSelector, type Header, + IndexedTaggingSecret, PRIVATE_CONTEXT_INPUTS_LENGTH, PUBLIC_DISPATCH_SELECTOR, PrivateContextInputs, @@ -609,4 +610,8 @@ export class ClientExecutionContext extends ViewDataOracle { public getDebugFunctionName() { return this.db.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector); } + + public override async incrementAppTaggingSecret(indexedTaggingSecret: IndexedTaggingSecret) { + await this.db.incrementAppTaggingSecret(indexedTaggingSecret); + } } diff --git a/yarn-project/simulator/src/client/db_oracle.ts b/yarn-project/simulator/src/client/db_oracle.ts index c19a0b1636ac..a1e73e52130e 100644 --- a/yarn-project/simulator/src/client/db_oracle.ts +++ b/yarn-project/simulator/src/client/db_oracle.ts @@ -209,6 +209,8 @@ export interface DBOracle extends CommitmentsDB { recipient: AztecAddress, ): Promise; + incrementAppTaggingSecret(indexedSecret: IndexedTaggingSecret): Promise; + /** * Returns the siloed tagging secrets for a given recipient and all the senders in the address book * @param contractAddress - The contract address to silo the secret for diff --git a/yarn-project/txe/src/oracle/txe_oracle.ts b/yarn-project/txe/src/oracle/txe_oracle.ts index 1078e6e329eb..46f4582c615e 100644 --- a/yarn-project/txe/src/oracle/txe_oracle.ts +++ b/yarn-project/txe/src/oracle/txe_oracle.ts @@ -752,6 +752,10 @@ export class TXE implements TypedOracle { return; } + async incrementAppTaggingSecret(indexedSecret: IndexedTaggingSecret): Promise { + await this.txeDatabase.incrementTaggingSecretsIndexes([indexedSecret.secret]); + } + async getAppTaggingSecret(sender: AztecAddress, recipient: AztecAddress): Promise { const senderCompleteAddress = await this.getCompleteAddress(sender); const senderIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(sender);