Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Oct 30, 2024
1 parent dfcd747 commit 1fad06a
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 4 deletions.
12 changes: 12 additions & 0 deletions noir-projects/aztec-nr/aztec/src/oracle/notes.nr
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
8 changes: 4 additions & 4 deletions yarn-project/protocol-contracts/src/protocol_contract_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ export const ProtocolContractAddress: Record<ProtocolContractName, AztecAddress>
};

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',
);
4 changes: 4 additions & 0 deletions yarn-project/pxe/src/simulator_oracle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ export class SimulatorOracle implements DBOracle {
return new IndexedTaggingSecret(secret, index);
}

public async incrementAppTaggingSecret(indexedSecret: IndexedTaggingSecret): Promise<void> {
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
Expand Down
7 changes: 7 additions & 0 deletions yarn-project/simulator/src/acvm/oracle/oracle.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<ACVMField[]> {
const taggingSecrets = await this.typedOracle.getAppTaggingSecretsForSenders(AztecAddress.fromString(recipient));
return taggingSecrets.flatMap(taggingSecret => taggingSecret.toFields().map(toACVMField));
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/simulator/src/acvm/oracle/typed_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ export abstract class TypedOracle {
throw new OracleMethodNotAvailableError('getAppTaggingSecret');
}

incrementAppTaggingSecret(_indexedTaggingSecret: IndexedTaggingSecret): Promise<void> {
throw new OracleMethodNotAvailableError('incrementAppTaggingSecret');
}

getAppTaggingSecretsForSenders(_recipient: AztecAddress): Promise<IndexedTaggingSecret[]> {
throw new OracleMethodNotAvailableError('getAppTaggingSecretsForSenders');
}
Expand Down
5 changes: 5 additions & 0 deletions yarn-project/simulator/src/client/client_execution_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
CallContext,
FunctionSelector,
type Header,
IndexedTaggingSecret,
PRIVATE_CONTEXT_INPUTS_LENGTH,
PUBLIC_DISPATCH_SELECTOR,
PrivateContextInputs,
Expand Down Expand Up @@ -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);
}
}
2 changes: 2 additions & 0 deletions yarn-project/simulator/src/client/db_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ export interface DBOracle extends CommitmentsDB {
recipient: AztecAddress,
): Promise<IndexedTaggingSecret>;

incrementAppTaggingSecret(indexedSecret: IndexedTaggingSecret): Promise<void>;

/**
* 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
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/txe/src/oracle/txe_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@ export class TXE implements TypedOracle {
return;
}

async incrementAppTaggingSecret(indexedSecret: IndexedTaggingSecret): Promise<void> {
await this.txeDatabase.incrementTaggingSecretsIndexes([indexedSecret.secret]);
}

async getAppTaggingSecret(sender: AztecAddress, recipient: AztecAddress): Promise<IndexedTaggingSecret> {
const senderCompleteAddress = await this.getCompleteAddress(sender);
const senderIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(sender);
Expand Down

0 comments on commit 1fad06a

Please sign in to comment.