Commit 5a7f73b sklppy88
committed
1 parent 72781e1 commit 5a7f73b Copy full SHA for 5a7f73b
File tree 7 files changed +40
-0
lines changed
noir-projects/aztec-nr/aztec/src/oracle
7 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,18 @@ unconstrained fn get_app_tagging_secret_oracle(
221
221
_recipient : AztecAddress ,
222
222
) -> [Field ; INDEXED_TAGGING_SECRET_LENGTH ] {}
223
223
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
+
224
236
/// Returns the tagging secrets for a given recipient and all the senders in PXE's address book,
225
237
// siloed for the current contract address.
226
238
/// Includes the last known index used for tagging with this secret.
Original file line number Diff line number Diff line change @@ -6,4 +6,8 @@ export class IndexedTaggingSecret {
6
6
toFields ( ) : Fr [ ] {
7
7
return [ this . secret , new Fr ( this . index ) ] ;
8
8
}
9
+
10
+ static fromFields ( fields : Fr [ ] ) : IndexedTaggingSecret {
11
+ return new this ( fields [ 0 ] , fields [ 1 ] . toNumber ( ) )
12
+ }
9
13
}
Original file line number Diff line number Diff line change @@ -252,6 +252,12 @@ export class SimulatorOracle implements DBOracle {
252
252
return new IndexedTaggingSecret ( secret , index ) ;
253
253
}
254
254
255
+ public async incrementAppTaggingSecret (
256
+ indexedSecret : IndexedTaggingSecret ,
257
+ ) : Promise < void > {
258
+ await this . db . incrementTaggingSecretsIndexes ( [ indexedSecret . secret ] ) ;
259
+ }
260
+
255
261
/**
256
262
* Returns the siloed tagging secrets for a given recipient and all the senders in the address book
257
263
* @param contractAddress - The contract address to silo the secret for
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { type ACVMField } from '../acvm_types.js';
7
7
import { frToBoolean , frToNumber , fromACVMField } from '../deserialize.js' ;
8
8
import { toACVMField } from '../serialize.js' ;
9
9
import { type TypedOracle } from './typed_oracle.js' ;
10
+ import { IndexedTaggingSecret } from '@aztec/circuits.js' ;
10
11
11
12
/**
12
13
* A data source that has all the apis required by Aztec.nr.
@@ -417,6 +418,10 @@ export class Oracle {
417
418
return taggingSecret . toFields ( ) . map ( toACVMField ) ;
418
419
}
419
420
421
+ async incrementAppTaggingSecret ( indexedTaggingSecret : ACVMField [ ] ) {
422
+ await this . typedOracle . incrementAppTaggingSecret ( IndexedTaggingSecret . fromFields ( indexedTaggingSecret . map ( fromACVMField ) ) ) ;
423
+ }
424
+
420
425
async getAppTaggingSecretsForSenders ( [ recipient ] : ACVMField [ ] ) : Promise < ACVMField [ ] > {
421
426
const taggingSecrets = await this . typedOracle . getAppTaggingSecretsForSenders ( AztecAddress . fromString ( recipient ) ) ;
422
427
return taggingSecrets . flatMap ( taggingSecret => taggingSecret . toFields ( ) . map ( toACVMField ) ) ;
Original file line number Diff line number Diff line change @@ -258,6 +258,10 @@ export abstract class TypedOracle {
258
258
throw new OracleMethodNotAvailableError ( 'getAppTaggingSecret' ) ;
259
259
}
260
260
261
+ incrementAppTaggingSecret ( _indexedTaggingSecret : IndexedTaggingSecret ) : Promise < void > {
262
+ throw new OracleMethodNotAvailableError ( 'incrementAppTaggingSecret' ) ;
263
+ }
264
+
261
265
getAppTaggingSecretsForSenders ( _recipient : AztecAddress ) : Promise < IndexedTaggingSecret [ ] > {
262
266
throw new OracleMethodNotAvailableError ( 'getAppTaggingSecretsForSenders' ) ;
263
267
}
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
17
17
CallContext ,
18
18
FunctionSelector ,
19
19
type Header ,
20
+ IndexedTaggingSecret ,
20
21
PRIVATE_CONTEXT_INPUTS_LENGTH ,
21
22
PUBLIC_DISPATCH_SELECTOR ,
22
23
PrivateContextInputs ,
@@ -609,4 +610,8 @@ export class ClientExecutionContext extends ViewDataOracle {
609
610
public getDebugFunctionName ( ) {
610
611
return this . db . getDebugFunctionName ( this . contractAddress , this . callContext . functionSelector ) ;
611
612
}
613
+
614
+ public async incrementAppTaggingSecret ( indexedTaggingSecret : IndexedTaggingSecret ) {
615
+ await this . db . incrementTaggingSecret ( indexedTaggingSecret ) ;
616
+ }
612
617
}
Original file line number Diff line number Diff line change @@ -209,6 +209,10 @@ export interface DBOracle extends CommitmentsDB {
209
209
recipient : AztecAddress ,
210
210
) : Promise < IndexedTaggingSecret > ;
211
211
212
+ incrementAppTaggingSecret (
213
+ indexedSecret : IndexedTaggingSecret ,
214
+ ) : Promise < void > ;
215
+
212
216
/**
213
217
* Returns the siloed tagging secrets for a given recipient and all the senders in the address book
214
218
* @param contractAddress - The contract address to silo the secret for
You can’t perform that action at this time.
0 commit comments