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 72781e1 commit 5a7f73b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 0 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())
}
}
6 changes: 6 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,12 @@ 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
5 changes: 5 additions & 0 deletions yarn-project/simulator/src/acvm/oracle/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { type ACVMField } from '../acvm_types.js';
import { frToBoolean, frToNumber, fromACVMField } from '../deserialize.js';
import { toACVMField } from '../serialize.js';
import { type TypedOracle } from './typed_oracle.js';
import { IndexedTaggingSecret } from '@aztec/circuits.js';

/**
* A data source that has all the apis required by Aztec.nr.
Expand Down Expand Up @@ -417,6 +418,10 @@ 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 async incrementAppTaggingSecret(indexedTaggingSecret: IndexedTaggingSecret) {
await this.db.incrementTaggingSecret(indexedTaggingSecret);
}
}
4 changes: 4 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,10 @@ 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

0 comments on commit 5a7f73b

Please sign in to comment.