@aztec/pxe 0.61.0 → 0.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dest/database/deferred_note_dao.d.ts +2 -2
  2. package/dest/database/deferred_note_dao.d.ts.map +1 -1
  3. package/dest/database/deferred_note_dao.js +2 -2
  4. package/dest/database/incoming_note_dao.d.ts +3 -3
  5. package/dest/database/incoming_note_dao.d.ts.map +1 -1
  6. package/dest/database/incoming_note_dao.js +6 -6
  7. package/dest/database/kv_pxe_database.d.ts +8 -5
  8. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  9. package/dest/database/kv_pxe_database.js +63 -44
  10. package/dest/database/outgoing_note_dao.d.ts +1 -1
  11. package/dest/database/outgoing_note_dao.js +2 -2
  12. package/dest/database/pxe_database.d.ts +33 -3
  13. package/dest/database/pxe_database.d.ts.map +1 -1
  14. package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
  15. package/dest/database/pxe_database_test_suite.js +11 -11
  16. package/dest/index.d.ts +1 -1
  17. package/dest/index.d.ts.map +1 -1
  18. package/dest/index.js +1 -1
  19. package/dest/note_processor/note_processor.d.ts.map +1 -1
  20. package/dest/note_processor/note_processor.js +9 -8
  21. package/dest/note_processor/utils/produce_note_daos.d.ts +2 -2
  22. package/dest/note_processor/utils/produce_note_daos.d.ts.map +1 -1
  23. package/dest/note_processor/utils/produce_note_daos.js +7 -7
  24. package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
  25. package/dest/pxe_http/pxe_http_server.js +23 -21
  26. package/dest/pxe_service/pxe_service.d.ts +15 -7
  27. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  28. package/dest/pxe_service/pxe_service.js +42 -39
  29. package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
  30. package/dest/pxe_service/test/pxe_test_suite.js +2 -32
  31. package/dest/simulator_oracle/index.d.ts +24 -1
  32. package/dest/simulator_oracle/index.d.ts.map +1 -1
  33. package/dest/simulator_oracle/index.js +81 -18
  34. package/dest/synchronizer/synchronizer.js +6 -6
  35. package/package.json +16 -14
  36. package/src/database/deferred_note_dao.ts +1 -1
  37. package/src/database/incoming_note_dao.ts +4 -4
  38. package/src/database/kv_pxe_database.ts +72 -46
  39. package/src/database/outgoing_note_dao.ts +2 -2
  40. package/src/database/pxe_database.ts +36 -2
  41. package/src/database/pxe_database_test_suite.ts +12 -20
  42. package/src/index.ts +1 -1
  43. package/src/note_processor/note_processor.ts +12 -9
  44. package/src/note_processor/utils/produce_note_daos.ts +6 -6
  45. package/src/pxe_http/pxe_http_server.ts +22 -19
  46. package/src/pxe_service/pxe_service.ts +50 -44
  47. package/src/pxe_service/test/pxe_test_suite.ts +1 -53
  48. package/src/simulator_oracle/index.ts +93 -14
  49. package/src/synchronizer/synchronizer.ts +5 -5
@@ -1,16 +1,13 @@
1
- import {
2
- type IncomingNotesFilter,
3
- MerkleTreeId,
4
- NoteStatus,
5
- type OutgoingNotesFilter,
6
- type PublicKey,
7
- } from '@aztec/circuit-types';
1
+ import { type IncomingNotesFilter, MerkleTreeId, NoteStatus, type OutgoingNotesFilter } from '@aztec/circuit-types';
8
2
  import {
9
3
  AztecAddress,
10
4
  CompleteAddress,
11
5
  type ContractInstanceWithAddress,
12
6
  Header,
7
+ type PublicKey,
13
8
  SerializableContractInstance,
9
+ type TaggingSecret,
10
+ computePoint,
14
11
  } from '@aztec/circuits.js';
15
12
  import { type ContractArtifact } from '@aztec/foundation/abi';
16
13
  import { toBufferBE } from '@aztec/foundation/bigint-buffer';
@@ -35,8 +32,9 @@ import { type PxeDatabase } from './pxe_database.js';
35
32
  */
36
33
  export class KVPxeDatabase implements PxeDatabase {
37
34
  #synchronizedBlock: AztecSingleton<Buffer>;
38
- #addresses: AztecArray<Buffer>;
39
- #addressIndex: AztecMap<string, number>;
35
+ #completeAddresses: AztecArray<Buffer>;
36
+ #completeAddressIndex: AztecMap<string, number>;
37
+ #addressBook: AztecSet<string>;
40
38
  #authWitnesses: AztecMap<string, Buffer[]>;
41
39
  #capsules: AztecArray<Buffer[]>;
42
40
  #notes: AztecMap<string, Buffer>;
@@ -46,7 +44,7 @@ export class KVPxeDatabase implements PxeDatabase {
46
44
  #nullifiedNotesByContract: AztecMultiMap<string, string>;
47
45
  #nullifiedNotesByStorageSlot: AztecMultiMap<string, string>;
48
46
  #nullifiedNotesByTxHash: AztecMultiMap<string, string>;
49
- #nullifiedNotesByIvpkM: AztecMultiMap<string, string>;
47
+ #nullifiedNotesByAddressPoint: AztecMultiMap<string, string>;
50
48
  #deferredNotes: AztecArray<Buffer | null>;
51
49
  #deferredNotesByContract: AztecMultiMap<string, number>;
52
50
  #syncedBlockPerPublicKey: AztecMap<string, number>;
@@ -64,15 +62,17 @@ export class KVPxeDatabase implements PxeDatabase {
64
62
  #notesByContractAndScope: Map<string, AztecMultiMap<string, string>>;
65
63
  #notesByStorageSlotAndScope: Map<string, AztecMultiMap<string, string>>;
66
64
  #notesByTxHashAndScope: Map<string, AztecMultiMap<string, string>>;
67
- #notesByIvpkMAndScope: Map<string, AztecMultiMap<string, string>>;
65
+ #notesByAddressPointAndScope: Map<string, AztecMultiMap<string, string>>;
68
66
 
69
67
  #taggingSecretIndexes: AztecMap<string, number>;
70
68
 
71
69
  constructor(private db: AztecKVStore) {
72
70
  this.#db = db;
73
71
 
74
- this.#addresses = db.openArray('addresses');
75
- this.#addressIndex = db.openMap('address_index');
72
+ this.#completeAddresses = db.openArray('complete_addresses');
73
+ this.#completeAddressIndex = db.openMap('complete_address_index');
74
+
75
+ this.#addressBook = db.openSet('address_book');
76
76
 
77
77
  this.#authWitnesses = db.openMap('auth_witnesses');
78
78
  this.#capsules = db.openArray('capsules');
@@ -90,7 +90,7 @@ export class KVPxeDatabase implements PxeDatabase {
90
90
  this.#nullifiedNotesByContract = db.openMultiMap('nullified_notes_by_contract');
91
91
  this.#nullifiedNotesByStorageSlot = db.openMultiMap('nullified_notes_by_storage_slot');
92
92
  this.#nullifiedNotesByTxHash = db.openMultiMap('nullified_notes_by_tx_hash');
93
- this.#nullifiedNotesByIvpkM = db.openMultiMap('nullified_notes_by_ivpk_m');
93
+ this.#nullifiedNotesByAddressPoint = db.openMultiMap('nullified_notes_by_address_point');
94
94
 
95
95
  this.#deferredNotes = db.openArray('deferred_notes');
96
96
  this.#deferredNotesByContract = db.openMultiMap('deferred_notes_by_contract');
@@ -105,13 +105,13 @@ export class KVPxeDatabase implements PxeDatabase {
105
105
  this.#notesByContractAndScope = new Map<string, AztecMultiMap<string, string>>();
106
106
  this.#notesByStorageSlotAndScope = new Map<string, AztecMultiMap<string, string>>();
107
107
  this.#notesByTxHashAndScope = new Map<string, AztecMultiMap<string, string>>();
108
- this.#notesByIvpkMAndScope = new Map<string, AztecMultiMap<string, string>>();
108
+ this.#notesByAddressPointAndScope = new Map<string, AztecMultiMap<string, string>>();
109
109
 
110
110
  for (const scope of this.#scopes.entries()) {
111
111
  this.#notesByContractAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_contract`));
112
112
  this.#notesByStorageSlotAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_storage_slot`));
113
113
  this.#notesByTxHashAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_tx_hash`));
114
- this.#notesByIvpkMAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_ivpk_m`));
114
+ this.#notesByAddressPointAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_address_point`));
115
115
  }
116
116
 
117
117
  this.#taggingSecretIndexes = db.openMap('tagging_secret_indices');
@@ -201,7 +201,7 @@ export class KVPxeDatabase implements PxeDatabase {
201
201
  void this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex);
202
202
  void this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex);
203
203
  void this.#notesByTxHashAndScope.get(scope.toString())!.set(dao.txHash.toString(), noteIndex);
204
- void this.#notesByIvpkMAndScope.get(scope.toString())!.set(dao.ivpkM.toString(), noteIndex);
204
+ void this.#notesByAddressPointAndScope.get(scope.toString())!.set(dao.addressPoint.toString(), noteIndex);
205
205
  }
206
206
 
207
207
  for (const dao of outgoingNotes) {
@@ -266,9 +266,7 @@ export class KVPxeDatabase implements PxeDatabase {
266
266
  }
267
267
 
268
268
  getIncomingNotes(filter: IncomingNotesFilter): Promise<IncomingNoteDao[]> {
269
- const publicKey: PublicKey | undefined = filter.owner
270
- ? this.#getCompleteAddress(filter.owner)?.publicKeys.masterIncomingViewingPublicKey
271
- : undefined;
269
+ const publicKey: PublicKey | undefined = filter.owner ? computePoint(filter.owner) : undefined;
272
270
 
273
271
  filter.status = filter.status ?? NoteStatus.ACTIVE;
274
272
 
@@ -286,14 +284,14 @@ export class KVPxeDatabase implements PxeDatabase {
286
284
 
287
285
  activeNoteIdsPerScope.push(
288
286
  publicKey
289
- ? this.#notesByIvpkMAndScope.get(formattedScopeString)!.getValues(publicKey.toString())
287
+ ? this.#notesByAddressPointAndScope.get(formattedScopeString)!.getValues(publicKey.toString())
290
288
  : filter.txHash
291
289
  ? this.#notesByTxHashAndScope.get(formattedScopeString)!.getValues(filter.txHash.toString())
292
290
  : filter.contractAddress
293
291
  ? this.#notesByContractAndScope.get(formattedScopeString)!.getValues(filter.contractAddress.toString())
294
292
  : filter.storageSlot
295
293
  ? this.#notesByStorageSlotAndScope.get(formattedScopeString)!.getValues(filter.storageSlot.toString())
296
- : this.#notesByIvpkMAndScope.get(formattedScopeString)!.values(),
294
+ : this.#notesByAddressPointAndScope.get(formattedScopeString)!.values(),
297
295
  );
298
296
  }
299
297
 
@@ -305,7 +303,7 @@ export class KVPxeDatabase implements PxeDatabase {
305
303
  if (filter.status == NoteStatus.ACTIVE_OR_NULLIFIED) {
306
304
  candidateNoteSources.push({
307
305
  ids: publicKey
308
- ? this.#nullifiedNotesByIvpkM.getValues(publicKey.toString())
306
+ ? this.#nullifiedNotesByAddressPoint.getValues(publicKey.toString())
309
307
  : filter.txHash
310
308
  ? this.#nullifiedNotesByTxHash.getValues(filter.txHash.toString())
311
309
  : filter.contractAddress
@@ -338,7 +336,7 @@ export class KVPxeDatabase implements PxeDatabase {
338
336
  continue;
339
337
  }
340
338
 
341
- if (publicKey && !note.ivpkM.equals(publicKey)) {
339
+ if (publicKey && !note.addressPoint.equals(publicKey)) {
342
340
  continue;
343
341
  }
344
342
 
@@ -403,7 +401,7 @@ export class KVPxeDatabase implements PxeDatabase {
403
401
  return Promise.resolve(notes);
404
402
  }
405
403
 
406
- removeNullifiedNotes(nullifiers: Fr[], accountIvpkM: PublicKey): Promise<IncomingNoteDao[]> {
404
+ removeNullifiedNotes(nullifiers: Fr[], accountAddressPoint: PublicKey): Promise<IncomingNoteDao[]> {
407
405
  if (nullifiers.length === 0) {
408
406
  return Promise.resolve([]);
409
407
  }
@@ -425,7 +423,7 @@ export class KVPxeDatabase implements PxeDatabase {
425
423
  }
426
424
 
427
425
  const note = IncomingNoteDao.fromBuffer(noteBuffer);
428
- if (!note.ivpkM.equals(accountIvpkM)) {
426
+ if (!note.addressPoint.equals(accountAddressPoint)) {
429
427
  // tried to nullify someone else's note
430
428
  continue;
431
429
  }
@@ -435,7 +433,7 @@ export class KVPxeDatabase implements PxeDatabase {
435
433
  void this.#notes.delete(noteIndex);
436
434
 
437
435
  for (const scope in this.#scopes.entries()) {
438
- void this.#notesByIvpkMAndScope.get(scope)!.deleteValue(accountIvpkM.toString(), noteIndex);
436
+ void this.#notesByAddressPointAndScope.get(scope)!.deleteValue(accountAddressPoint.toString(), noteIndex);
439
437
  void this.#notesByTxHashAndScope.get(scope)!.deleteValue(note.txHash.toString(), noteIndex);
440
438
  void this.#notesByContractAndScope.get(scope)!.deleteValue(note.contractAddress.toString(), noteIndex);
441
439
  void this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(note.storageSlot.toString(), noteIndex);
@@ -445,7 +443,7 @@ export class KVPxeDatabase implements PxeDatabase {
445
443
  void this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
446
444
  void this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
447
445
  void this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex);
448
- void this.#nullifiedNotesByIvpkM.set(note.ivpkM.toString(), noteIndex);
446
+ void this.#nullifiedNotesByAddressPoint.set(note.addressPoint.toString(), noteIndex);
449
447
 
450
448
  void this.#nullifierToNoteId.delete(nullifier.toString());
451
449
  }
@@ -461,7 +459,7 @@ export class KVPxeDatabase implements PxeDatabase {
461
459
  await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
462
460
  await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
463
461
  await this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex);
464
- await this.#nullifiedNotesByIvpkM.set(note.ivpkM.toString(), noteIndex);
462
+ await this.#nullifiedNotesByAddressPoint.set(note.addressPoint.toString(), noteIndex);
465
463
 
466
464
  return Promise.resolve();
467
465
  }
@@ -499,7 +497,7 @@ export class KVPxeDatabase implements PxeDatabase {
499
497
  this.#notesByContractAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_contract`));
500
498
  this.#notesByStorageSlotAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_storage_slot`));
501
499
  this.#notesByTxHashAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_tx_hash`));
502
- this.#notesByIvpkMAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_ivpk_m`));
500
+ this.#notesByAddressPointAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_address_point`));
503
501
 
504
502
  return true;
505
503
  }
@@ -510,15 +508,15 @@ export class KVPxeDatabase implements PxeDatabase {
510
508
  return this.#db.transaction(() => {
511
509
  const addressString = completeAddress.address.toString();
512
510
  const buffer = completeAddress.toBuffer();
513
- const existing = this.#addressIndex.get(addressString);
511
+ const existing = this.#completeAddressIndex.get(addressString);
514
512
  if (typeof existing === 'undefined') {
515
- const index = this.#addresses.length;
516
- void this.#addresses.push(buffer);
517
- void this.#addressIndex.set(addressString, index);
513
+ const index = this.#completeAddresses.length;
514
+ void this.#completeAddresses.push(buffer);
515
+ void this.#completeAddressIndex.set(addressString, index);
518
516
 
519
517
  return true;
520
518
  } else {
521
- const existingBuffer = this.#addresses.at(existing);
519
+ const existingBuffer = this.#completeAddresses.at(existing);
522
520
 
523
521
  if (existingBuffer?.equals(buffer)) {
524
522
  return false;
@@ -532,12 +530,12 @@ export class KVPxeDatabase implements PxeDatabase {
532
530
  }
533
531
 
534
532
  #getCompleteAddress(address: AztecAddress): CompleteAddress | undefined {
535
- const index = this.#addressIndex.get(address.toString());
533
+ const index = this.#completeAddressIndex.get(address.toString());
536
534
  if (typeof index === 'undefined') {
537
535
  return undefined;
538
536
  }
539
537
 
540
- const value = this.#addresses.at(index);
538
+ const value = this.#completeAddresses.at(index);
541
539
  return value ? CompleteAddress.fromBuffer(value) : undefined;
542
540
  }
543
541
 
@@ -546,7 +544,31 @@ export class KVPxeDatabase implements PxeDatabase {
546
544
  }
547
545
 
548
546
  getCompleteAddresses(): Promise<CompleteAddress[]> {
549
- return Promise.resolve(Array.from(this.#addresses).map(v => CompleteAddress.fromBuffer(v)));
547
+ return Promise.resolve(Array.from(this.#completeAddresses).map(v => CompleteAddress.fromBuffer(v)));
548
+ }
549
+
550
+ async addContactAddress(address: AztecAddress): Promise<boolean> {
551
+ if (this.#addressBook.has(address.toString())) {
552
+ return false;
553
+ }
554
+
555
+ await this.#addressBook.add(address.toString());
556
+
557
+ return true;
558
+ }
559
+
560
+ getContactAddresses(): AztecAddress[] {
561
+ return [...this.#addressBook.entries()].map(AztecAddress.fromString);
562
+ }
563
+
564
+ async removeContactAddress(address: AztecAddress): Promise<boolean> {
565
+ if (!this.#addressBook.has(address.toString())) {
566
+ return false;
567
+ }
568
+
569
+ await this.#addressBook.delete(address.toString());
570
+
571
+ return true;
550
572
  }
551
573
 
552
574
  getSynchedBlockNumberForAccount(account: AztecAddress): number | undefined {
@@ -571,25 +593,29 @@ export class KVPxeDatabase implements PxeDatabase {
571
593
  (sum, value) => sum + value.length * Fr.SIZE_IN_BYTES,
572
594
  0,
573
595
  );
574
- const addressesSize = this.#addresses.length * CompleteAddress.SIZE_IN_BYTES;
596
+ const addressesSize = this.#completeAddresses.length * CompleteAddress.SIZE_IN_BYTES;
575
597
  const treeRootsSize = Object.keys(MerkleTreeId).length * Fr.SIZE_IN_BYTES;
576
598
 
577
599
  return incomingNotesSize + outgoingNotesSize + treeRootsSize + authWitsSize + addressesSize;
578
600
  }
579
601
 
580
- async incrementTaggingSecretsIndexes(appTaggingSecrets: Fr[]): Promise<void> {
581
- const indexes = await this.getTaggingSecretsIndexes(appTaggingSecrets);
602
+ async incrementTaggingSecretsIndexes(appTaggingSecretsWithRecipient: TaggingSecret[]): Promise<void> {
603
+ const indexes = await this.getTaggingSecretsIndexes(appTaggingSecretsWithRecipient);
582
604
  await this.db.transaction(() => {
583
- indexes.forEach(index => {
584
- const nextIndex = index ? index + 1 : 1;
585
- void this.#taggingSecretIndexes.set(appTaggingSecrets.toString(), nextIndex);
605
+ indexes.forEach((taggingSecretIndex, listIndex) => {
606
+ const nextIndex = taggingSecretIndex + 1;
607
+ const { secret, recipient } = appTaggingSecretsWithRecipient[listIndex];
608
+ const key = `${secret.toString()}-${recipient.toString()}`;
609
+ void this.#taggingSecretIndexes.set(key, nextIndex);
586
610
  });
587
611
  });
588
612
  }
589
613
 
590
- getTaggingSecretsIndexes(appTaggingSecrets: Fr[]): Promise<number[]> {
614
+ getTaggingSecretsIndexes(appTaggingSecretsWithRecipient: TaggingSecret[]): Promise<number[]> {
591
615
  return this.db.transaction(() =>
592
- appTaggingSecrets.map(secret => this.#taggingSecretIndexes.get(secret.toString()) ?? 0),
616
+ appTaggingSecretsWithRecipient.map(
617
+ ({ secret, recipient }) => this.#taggingSecretIndexes.get(`${secret.toString()}-${recipient.toString()}`) ?? 0,
618
+ ),
593
619
  );
594
620
  }
595
621
  }
@@ -39,7 +39,7 @@ export class OutgoingNoteDao {
39
39
  payload: L1NotePayload,
40
40
  noteInfo: NoteInfo,
41
41
  dataStartIndexForTx: number,
42
- ivpkM: PublicKey,
42
+ ovpkM: PublicKey,
43
43
  ) {
44
44
  const noteHashIndexInTheWholeTree = BigInt(dataStartIndexForTx + noteInfo.noteHashIndex);
45
45
  return new OutgoingNoteDao(
@@ -51,7 +51,7 @@ export class OutgoingNoteDao {
51
51
  noteInfo.nonce,
52
52
  noteInfo.noteHash,
53
53
  noteHashIndexInTheWholeTree,
54
- ivpkM,
54
+ ovpkM,
55
55
  );
56
56
  }
57
57
 
@@ -4,6 +4,7 @@ import {
4
4
  type ContractInstanceWithAddress,
5
5
  type Header,
6
6
  type PublicKey,
7
+ type TaggingSecret,
7
8
  } from '@aztec/circuits.js';
8
9
  import { type ContractArtifact } from '@aztec/foundation/abi';
9
10
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
@@ -145,6 +146,26 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
145
146
  */
146
147
  setHeader(header: Header): Promise<void>;
147
148
 
149
+ /**
150
+ * Adds contact address to the database.
151
+ * @param address - The address to add to the address book.
152
+ * @returns A promise resolving to true if the address was added, false if it already exists.
153
+ */
154
+ addContactAddress(address: AztecAddress): Promise<boolean>;
155
+
156
+ /**
157
+ * Retrieves the list of contact addresses in the address book.
158
+ * @returns An array of Aztec addresses.
159
+ */
160
+ getContactAddresses(): AztecAddress[];
161
+
162
+ /**
163
+ * Removes a contact address from the database.
164
+ * @param address - The address to remove from the address book.
165
+ * @returns A promise resolving to true if the address was removed, false if it does not exist.
166
+ */
167
+ removeContactAddress(address: AztecAddress): Promise<boolean>;
168
+
148
169
  /**
149
170
  * Adds complete address to the database.
150
171
  * @param address - The complete address to add.
@@ -186,7 +207,20 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
186
207
  */
187
208
  estimateSize(): Promise<number>;
188
209
 
189
- getTaggingSecretsIndexes(appTaggingSecrets: Fr[]): Promise<number[]>;
210
+ /**
211
+ * Returns the last seen indexes for the provided app siloed tagging secrets or 0 if they've never been seen.
212
+ * The recipient must also be provided to convey "directionality" of the secret and index pair, or in other words
213
+ * whether the index was used to tag a sent or received note.
214
+ * @param appTaggingSecrets - The app siloed tagging secrets.
215
+ * @returns The indexes for the provided secrets, 0 if they've never been seen.
216
+ */
217
+ getTaggingSecretsIndexes(appTaggingSecretsWithRecipient: TaggingSecret[]): Promise<number[]>;
190
218
 
191
- incrementTaggingSecretsIndexes(appTaggingSecrets: Fr[]): Promise<void>;
219
+ /**
220
+ * Increments the index for the provided app siloed tagging secrets.
221
+ * The recipient must also be provided to convey "directionality" of the secret and index pair, or in other words
222
+ * whether the index was used to tag a sent or received note.
223
+ * @param appTaggingSecrets - The app siloed tagging secrets.
224
+ */
225
+ incrementTaggingSecretsIndexes(appTaggingSecretsWithRecipient: TaggingSecret[]): Promise<void>;
192
226
  }
@@ -5,6 +5,7 @@ import {
5
5
  INITIAL_L2_BLOCK_NUM,
6
6
  PublicKeys,
7
7
  SerializableContractInstance,
8
+ computePoint,
8
9
  } from '@aztec/circuits.js';
9
10
  import { makeHeader } from '@aztec/circuits.js/testing';
10
11
  import { randomInt } from '@aztec/foundation/crypto';
@@ -101,7 +102,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
101
102
 
102
103
  [
103
104
  () => ({ owner: owners[0].address }),
104
- () => notes.filter(note => note.ivpkM.equals(owners[0].publicKeys.masterIncomingViewingPublicKey)),
105
+ () => notes.filter(note => note.addressPoint.equals(computePoint(owners[0].address))),
105
106
  ],
106
107
 
107
108
  [
@@ -123,7 +124,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
123
124
  randomIncomingNoteDao({
124
125
  contractAddress: contractAddresses[i % contractAddresses.length],
125
126
  storageSlot: storageSlots[i % storageSlots.length],
126
- ivpkM: owners[i % owners.length].publicKeys.masterIncomingViewingPublicKey,
127
+ addressPoint: computePoint(owners[i % owners.length].address),
127
128
  index: BigInt(i),
128
129
  }),
129
130
  );
@@ -155,13 +156,11 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
155
156
 
156
157
  // Nullify all notes and use the same filter as other test cases
157
158
  for (const owner of owners) {
158
- const notesToNullify = notes.filter(note =>
159
- note.ivpkM.equals(owner.publicKeys.masterIncomingViewingPublicKey),
160
- );
159
+ const notesToNullify = notes.filter(note => note.addressPoint.equals(computePoint(owner.address)));
161
160
  const nullifiers = notesToNullify.map(note => note.siloedNullifier);
162
- await expect(
163
- database.removeNullifiedNotes(nullifiers, owner.publicKeys.masterIncomingViewingPublicKey),
164
- ).resolves.toEqual(notesToNullify);
161
+ await expect(database.removeNullifiedNotes(nullifiers, computePoint(owner.address))).resolves.toEqual(
162
+ notesToNullify,
163
+ );
165
164
  }
166
165
 
167
166
  await expect(
@@ -172,11 +171,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
172
171
  it('skips nullified notes by default or when requesting active', async () => {
173
172
  await database.addNotes(notes, []);
174
173
 
175
- const notesToNullify = notes.filter(note =>
176
- note.ivpkM.equals(owners[0].publicKeys.masterIncomingViewingPublicKey),
177
- );
174
+ const notesToNullify = notes.filter(note => note.addressPoint.equals(computePoint(owners[0].address)));
178
175
  const nullifiers = notesToNullify.map(note => note.siloedNullifier);
179
- await expect(database.removeNullifiedNotes(nullifiers, notesToNullify[0].ivpkM)).resolves.toEqual(
176
+ await expect(database.removeNullifiedNotes(nullifiers, notesToNullify[0].addressPoint)).resolves.toEqual(
180
177
  notesToNullify,
181
178
  );
182
179
 
@@ -190,11 +187,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
190
187
  it('returns active and nullified notes when requesting either', async () => {
191
188
  await database.addNotes(notes, []);
192
189
 
193
- const notesToNullify = notes.filter(note =>
194
- note.ivpkM.equals(owners[0].publicKeys.masterIncomingViewingPublicKey),
195
- );
190
+ const notesToNullify = notes.filter(note => note.addressPoint.equals(computePoint(owners[0].address)));
196
191
  const nullifiers = notesToNullify.map(note => note.siloedNullifier);
197
- await expect(database.removeNullifiedNotes(nullifiers, notesToNullify[0].ivpkM)).resolves.toEqual(
192
+ await expect(database.removeNullifiedNotes(nullifiers, notesToNullify[0].addressPoint)).resolves.toEqual(
198
193
  notesToNullify,
199
194
  );
200
195
 
@@ -251,10 +246,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
251
246
  ).resolves.toEqual([notes[0]]);
252
247
 
253
248
  await expect(
254
- database.removeNullifiedNotes(
255
- [notes[0].siloedNullifier],
256
- owners[0].publicKeys.masterIncomingViewingPublicKey,
257
- ),
249
+ database.removeNullifiedNotes([notes[0].siloedNullifier], computePoint(owners[0].address)),
258
250
  ).resolves.toEqual([notes[0]]);
259
251
 
260
252
  await expect(
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ export * from './config/index.js';
4
4
 
5
5
  export { Tx, TxHash } from '@aztec/circuit-types';
6
6
 
7
- export { TxRequest, PartialAddress } from '@aztec/circuits.js';
7
+ export { TxRequest } from '@aztec/circuits.js';
8
8
  export * from '@aztec/foundation/fields';
9
9
  export * from '@aztec/foundation/eth-address';
10
10
  export * from '@aztec/foundation/aztec-address';
@@ -5,6 +5,7 @@ import {
5
5
  INITIAL_L2_BLOCK_NUM,
6
6
  MAX_NOTE_HASHES_PER_TX,
7
7
  computeAddressSecret,
8
+ computePoint,
8
9
  } from '@aztec/circuits.js';
9
10
  import { type Fr } from '@aztec/foundation/fields';
10
11
  import { type Logger, createDebugLogger } from '@aztec/foundation/log';
@@ -146,11 +147,16 @@ export class NoteProcessor {
146
147
  // We iterate over both encrypted and unencrypted logs to decrypt the notes since partial notes are passed
147
148
  // via the unencrypted logs stream.
148
149
  for (const txFunctionLogs of [encryptedTxFunctionLogs, unencryptedTxFunctionLogs]) {
150
+ const isFromPublic = txFunctionLogs === unencryptedTxFunctionLogs;
149
151
  for (const functionLogs of txFunctionLogs) {
150
152
  for (const unprocessedLog of functionLogs.logs) {
151
153
  this.stats.seen++;
152
- const incomingNotePayload = L1NotePayload.decryptAsIncoming(unprocessedLog.data, addressSecret);
153
- const outgoingNotePayload = L1NotePayload.decryptAsOutgoing(unprocessedLog.data, ovskM);
154
+ const incomingNotePayload = L1NotePayload.decryptAsIncoming(
155
+ unprocessedLog.data,
156
+ addressSecret,
157
+ isFromPublic,
158
+ );
159
+ const outgoingNotePayload = L1NotePayload.decryptAsOutgoing(unprocessedLog.data, ovskM, isFromPublic);
154
160
 
155
161
  if (incomingNotePayload || outgoingNotePayload) {
156
162
  if (incomingNotePayload && outgoingNotePayload && !incomingNotePayload.equals(outgoingNotePayload)) {
@@ -168,7 +174,7 @@ export class NoteProcessor {
168
174
  await produceNoteDaos(
169
175
  this.simulator,
170
176
  this.db,
171
- incomingNotePayload ? this.account.publicKeys.masterIncomingViewingPublicKey : undefined,
177
+ incomingNotePayload ? computePoint(this.account.address) : undefined,
172
178
  outgoingNotePayload ? this.account.publicKeys.masterOutgoingViewingPublicKey : undefined,
173
179
  payload!,
174
180
  txEffect.txHash,
@@ -250,10 +256,7 @@ export class NoteProcessor {
250
256
  const nullifiers: Fr[] = blocksAndNotes.flatMap(b =>
251
257
  b.block.body.txEffects.flatMap(txEffect => txEffect.nullifiers),
252
258
  );
253
- const removedNotes = await this.db.removeNullifiedNotes(
254
- nullifiers,
255
- this.account.publicKeys.masterIncomingViewingPublicKey,
256
- );
259
+ const removedNotes = await this.db.removeNullifiedNotes(nullifiers, computePoint(this.account.address));
257
260
  removedNotes.forEach(noteDao => {
258
261
  this.log.verbose(
259
262
  `Removed note for contract ${noteDao.contractAddress} at slot ${
@@ -312,7 +315,7 @@ export class NoteProcessor {
312
315
  for (const deferredNote of deferredNoteDaos) {
313
316
  const { publicKey, payload, txHash, noteHashes, dataStartIndexForTx, unencryptedLogs } = deferredNote;
314
317
 
315
- const isIncoming = publicKey.equals(this.account.publicKeys.masterIncomingViewingPublicKey);
318
+ const isIncoming = publicKey.equals(computePoint(this.account.address));
316
319
  const isOutgoing = publicKey.equals(this.account.publicKeys.masterOutgoingViewingPublicKey);
317
320
 
318
321
  if (!isIncoming && !isOutgoing) {
@@ -323,7 +326,7 @@ export class NoteProcessor {
323
326
  const { incomingNote, outgoingNote } = await produceNoteDaos(
324
327
  this.simulator,
325
328
  this.db,
326
- isIncoming ? this.account.publicKeys.masterIncomingViewingPublicKey : undefined,
329
+ isIncoming ? computePoint(this.account.address) : undefined,
327
330
  isOutgoing ? this.account.publicKeys.masterOutgoingViewingPublicKey : undefined,
328
331
  payload,
329
332
  txHash,
@@ -17,7 +17,7 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
17
17
  *
18
18
  * @param simulator - An instance of AcirSimulator.
19
19
  * @param db - An instance of PxeDatabase.
20
- * @param ivpkM - The public counterpart to the secret key to be used in the decryption of incoming note logs.
20
+ * @param addressPoint - The public counterpart to the address secret, which is used in the decryption of incoming note logs.
21
21
  * @param ovpkM - The public counterpart to the secret key to be used in the decryption of outgoing note logs.
22
22
  * @param payload - An instance of l1NotePayload.
23
23
  * @param txHash - The hash of the transaction that created the note. Equivalent to the first nullifier of the transaction.
@@ -31,7 +31,7 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
31
31
  export async function produceNoteDaos(
32
32
  simulator: AcirSimulator,
33
33
  db: PxeDatabase,
34
- ivpkM: PublicKey | undefined,
34
+ addressPoint: PublicKey | undefined,
35
35
  ovpkM: PublicKey | undefined,
36
36
  payload: L1NotePayload,
37
37
  txHash: TxHash,
@@ -46,8 +46,8 @@ export async function produceNoteDaos(
46
46
  incomingDeferredNote: DeferredNoteDao | undefined;
47
47
  outgoingDeferredNote: DeferredNoteDao | undefined;
48
48
  }> {
49
- if (!ivpkM && !ovpkM) {
50
- throw new Error('Both ivpkM and ovpkM are undefined. Cannot create note.');
49
+ if (!addressPoint && !ovpkM) {
50
+ throw new Error('Both addressPoint and ovpkM are undefined. Cannot create note.');
51
51
  }
52
52
 
53
53
  let incomingNote: IncomingNoteDao | undefined;
@@ -55,11 +55,11 @@ export async function produceNoteDaos(
55
55
  let incomingDeferredNote: DeferredNoteDao | undefined;
56
56
  let outgoingDeferredNote: DeferredNoteDao | undefined;
57
57
 
58
- if (ivpkM) {
58
+ if (addressPoint) {
59
59
  [incomingNote, incomingDeferredNote] = await produceNoteDaosForKey(
60
60
  simulator,
61
61
  db,
62
- ivpkM,
62
+ addressPoint,
63
63
  payload,
64
64
  txHash,
65
65
  noteHashes,
@@ -6,6 +6,7 @@ import {
6
6
  EncryptedL2Log,
7
7
  EncryptedL2NoteLog,
8
8
  EncryptedNoteL2BlockL2Logs,
9
+ EventMetadata,
9
10
  ExtendedNote,
10
11
  ExtendedUnencryptedL2Log,
11
12
  L2Block,
@@ -27,7 +28,7 @@ import {
27
28
  UniqueNote,
28
29
  } from '@aztec/circuit-types';
29
30
  import { FunctionSelector, PrivateCircuitPublicInputs, PublicKeys } from '@aztec/circuits.js';
30
- import { NoteSelector } from '@aztec/foundation/abi';
31
+ import { EventSelector, NoteSelector } from '@aztec/foundation/abi';
31
32
  import { AztecAddress } from '@aztec/foundation/aztec-address';
32
33
  import { Buffer32 } from '@aztec/foundation/buffer';
33
34
  import { EthAddress } from '@aztec/foundation/eth-address';
@@ -44,43 +45,45 @@ export function createPXERpcServer(pxeService: PXE): JsonRpcServer {
44
45
  return new JsonRpcServer(
45
46
  pxeService,
46
47
  {
47
- CompleteAddress,
48
+ AuthWitness,
48
49
  AztecAddress,
49
- TxExecutionRequest,
50
- ExtendedUnencryptedL2Log,
51
- FunctionSelector,
52
- TxHash,
53
50
  Buffer32,
51
+ CompleteAddress,
54
52
  EthAddress,
55
- Point,
53
+ EventSelector,
54
+ ExtendedNote,
55
+ ExtendedUnencryptedL2Log,
56
56
  Fr,
57
+ FunctionSelector,
57
58
  GrumpkinScalar,
59
+ L2Block,
60
+ LogId,
58
61
  Note,
59
- ExtendedNote,
62
+ Point,
60
63
  PublicKeys,
61
- UniqueNote,
62
64
  SiblingPath,
63
- AuthWitness,
64
- L2Block,
65
65
  TxEffect,
66
- LogId,
66
+ TxExecutionRequest,
67
+ TxHash,
68
+ UniqueNote,
67
69
  },
68
70
  {
69
- EncryptedNoteL2BlockL2Logs,
70
- EncryptedL2NoteLog,
71
+ CountedPublicExecutionRequest,
72
+ CountedNoteLog,
71
73
  EncryptedL2Log,
72
- UnencryptedL2Log,
74
+ EncryptedL2NoteLog,
75
+ EncryptedNoteL2BlockL2Logs,
76
+ EventMetadata,
73
77
  NoteSelector,
74
78
  NullifierMembershipWitness,
75
- TxSimulationResult,
76
- TxProvingResult,
77
79
  PrivateCircuitPublicInputs,
78
80
  PrivateExecutionResult,
79
- CountedPublicExecutionRequest,
80
- CountedNoteLog,
81
+ TxSimulationResult,
82
+ TxProvingResult,
81
83
  Tx,
82
84
  TxReceipt,
83
85
  UnencryptedL2BlockL2Logs,
86
+ UnencryptedL2Log,
84
87
  },
85
88
  ['start', 'stop'],
86
89
  );