Skip to content

Commit 5a7f73b

Browse files
author
sklppy88
committed
init
1 parent 72781e1 commit 5a7f73b

File tree

7 files changed

+40
-0
lines changed

7 files changed

+40
-0
lines changed

noir-projects/aztec-nr/aztec/src/oracle/notes.nr

+12
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,18 @@ unconstrained fn get_app_tagging_secret_oracle(
221221
_recipient: AztecAddress,
222222
) -> [Field; INDEXED_TAGGING_SECRET_LENGTH] {}
223223

224+
225+
pub unconstrained fn increment_app_tagging_secret(
226+
to_increment: IndexedTaggingSecret,
227+
) {
228+
increment_app_tagging_secret_oracle(to_increment);
229+
}
230+
231+
#[oracle(incrementAppTaggingSecret)]
232+
unconstrained fn increment_app_tagging_secret_oracle(
233+
to_increment: IndexedTaggingSecret,
234+
) {}
235+
224236
/// Returns the tagging secrets for a given recipient and all the senders in PXE's address book,
225237
// siloed for the current contract address.
226238
/// Includes the last known index used for tagging with this secret.

yarn-project/circuits.js/src/structs/indexed_tagging_secret.ts

+4
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ export class IndexedTaggingSecret {
66
toFields(): Fr[] {
77
return [this.secret, new Fr(this.index)];
88
}
9+
10+
static fromFields(fields: Fr[]): IndexedTaggingSecret {
11+
return new this(fields[0], fields[1].toNumber())
12+
}
913
}

yarn-project/pxe/src/simulator_oracle/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ export class SimulatorOracle implements DBOracle {
252252
return new IndexedTaggingSecret(secret, index);
253253
}
254254

255+
public async incrementAppTaggingSecret(
256+
indexedSecret: IndexedTaggingSecret,
257+
): Promise<void> {
258+
await this.db.incrementTaggingSecretsIndexes([indexedSecret.secret]);
259+
}
260+
255261
/**
256262
* Returns the siloed tagging secrets for a given recipient and all the senders in the address book
257263
* @param contractAddress - The contract address to silo the secret for

yarn-project/simulator/src/acvm/oracle/oracle.ts

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { type ACVMField } from '../acvm_types.js';
77
import { frToBoolean, frToNumber, fromACVMField } from '../deserialize.js';
88
import { toACVMField } from '../serialize.js';
99
import { type TypedOracle } from './typed_oracle.js';
10+
import { IndexedTaggingSecret } from '@aztec/circuits.js';
1011

1112
/**
1213
* A data source that has all the apis required by Aztec.nr.
@@ -417,6 +418,10 @@ export class Oracle {
417418
return taggingSecret.toFields().map(toACVMField);
418419
}
419420

421+
async incrementAppTaggingSecret(indexedTaggingSecret: ACVMField[]) {
422+
await this.typedOracle.incrementAppTaggingSecret(IndexedTaggingSecret.fromFields(indexedTaggingSecret.map(fromACVMField)));
423+
}
424+
420425
async getAppTaggingSecretsForSenders([recipient]: ACVMField[]): Promise<ACVMField[]> {
421426
const taggingSecrets = await this.typedOracle.getAppTaggingSecretsForSenders(AztecAddress.fromString(recipient));
422427
return taggingSecrets.flatMap(taggingSecret => taggingSecret.toFields().map(toACVMField));

yarn-project/simulator/src/acvm/oracle/typed_oracle.ts

+4
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ export abstract class TypedOracle {
258258
throw new OracleMethodNotAvailableError('getAppTaggingSecret');
259259
}
260260

261+
incrementAppTaggingSecret(_indexedTaggingSecret: IndexedTaggingSecret): Promise<void> {
262+
throw new OracleMethodNotAvailableError('incrementAppTaggingSecret');
263+
}
264+
261265
getAppTaggingSecretsForSenders(_recipient: AztecAddress): Promise<IndexedTaggingSecret[]> {
262266
throw new OracleMethodNotAvailableError('getAppTaggingSecretsForSenders');
263267
}

yarn-project/simulator/src/client/client_execution_context.ts

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
CallContext,
1818
FunctionSelector,
1919
type Header,
20+
IndexedTaggingSecret,
2021
PRIVATE_CONTEXT_INPUTS_LENGTH,
2122
PUBLIC_DISPATCH_SELECTOR,
2223
PrivateContextInputs,
@@ -609,4 +610,8 @@ export class ClientExecutionContext extends ViewDataOracle {
609610
public getDebugFunctionName() {
610611
return this.db.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
611612
}
613+
614+
public async incrementAppTaggingSecret(indexedTaggingSecret: IndexedTaggingSecret) {
615+
await this.db.incrementTaggingSecret(indexedTaggingSecret);
616+
}
612617
}

yarn-project/simulator/src/client/db_oracle.ts

+4
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ export interface DBOracle extends CommitmentsDB {
209209
recipient: AztecAddress,
210210
): Promise<IndexedTaggingSecret>;
211211

212+
incrementAppTaggingSecret(
213+
indexedSecret: IndexedTaggingSecret,
214+
): Promise<void>;
215+
212216
/**
213217
* Returns the siloed tagging secrets for a given recipient and all the senders in the address book
214218
* @param contractAddress - The contract address to silo the secret for

0 commit comments

Comments
 (0)