@aztec/pxe 0.60.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 (69) hide show
  1. package/dest/database/deferred_note_dao.d.ts +8 -21
  2. package/dest/database/deferred_note_dao.d.ts.map +1 -1
  3. package/dest/database/deferred_note_dao.js +9 -19
  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 +11 -6
  8. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  9. package/dest/database/kv_pxe_database.js +75 -42
  10. package/dest/database/outgoing_note_dao.d.ts +1 -1
  11. package/dest/database/outgoing_note_dao.d.ts.map +1 -1
  12. package/dest/database/outgoing_note_dao.js +3 -3
  13. package/dest/database/pxe_database.d.ts +37 -5
  14. package/dest/database/pxe_database.d.ts.map +1 -1
  15. package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
  16. package/dest/database/pxe_database_test_suite.js +11 -11
  17. package/dest/index.d.ts +1 -1
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +1 -1
  20. package/dest/note_processor/note_processor.d.ts +1 -5
  21. package/dest/note_processor/note_processor.d.ts.map +1 -1
  22. package/dest/note_processor/note_processor.js +57 -58
  23. package/dest/note_processor/utils/add_public_values_to_payload.d.ts +10 -0
  24. package/dest/note_processor/utils/add_public_values_to_payload.d.ts.map +1 -0
  25. package/dest/note_processor/utils/add_public_values_to_payload.js +48 -0
  26. package/dest/note_processor/utils/brute_force_note_info.d.ts +8 -3
  27. package/dest/note_processor/utils/brute_force_note_info.d.ts.map +1 -1
  28. package/dest/note_processor/utils/brute_force_note_info.js +6 -3
  29. package/dest/note_processor/utils/produce_note_daos.d.ts +2 -2
  30. package/dest/note_processor/utils/produce_note_daos.d.ts.map +1 -1
  31. package/dest/note_processor/utils/produce_note_daos.js +8 -10
  32. package/dest/note_processor/utils/produce_note_daos_for_key.d.ts +3 -3
  33. package/dest/note_processor/utils/produce_note_daos_for_key.d.ts.map +1 -1
  34. package/dest/note_processor/utils/produce_note_daos_for_key.js +7 -61
  35. package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
  36. package/dest/pxe_http/pxe_http_server.js +23 -21
  37. package/dest/pxe_service/pxe_service.d.ts +15 -7
  38. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  39. package/dest/pxe_service/pxe_service.js +59 -42
  40. package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
  41. package/dest/pxe_service/test/pxe_test_suite.js +2 -32
  42. package/dest/simulator_oracle/index.d.ts +41 -2
  43. package/dest/simulator_oracle/index.d.ts.map +1 -1
  44. package/dest/simulator_oracle/index.js +104 -2
  45. package/dest/synchronizer/synchronizer.d.ts +1 -1
  46. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  47. package/dest/synchronizer/synchronizer.js +8 -8
  48. package/package.json +16 -14
  49. package/src/database/deferred_note_dao.ts +7 -20
  50. package/src/database/incoming_note_dao.ts +6 -5
  51. package/src/database/kv_pxe_database.ts +91 -45
  52. package/src/database/outgoing_note_dao.ts +4 -3
  53. package/src/database/pxe_database.ts +42 -4
  54. package/src/database/pxe_database_test_suite.ts +12 -20
  55. package/src/index.ts +1 -1
  56. package/src/note_processor/note_processor.ts +91 -87
  57. package/src/note_processor/utils/add_public_values_to_payload.ts +63 -0
  58. package/src/note_processor/utils/brute_force_note_info.ts +11 -3
  59. package/src/note_processor/utils/produce_note_daos.ts +11 -13
  60. package/src/note_processor/utils/produce_note_daos_for_key.ts +19 -114
  61. package/src/pxe_http/pxe_http_server.ts +22 -19
  62. package/src/pxe_service/pxe_service.ts +71 -46
  63. package/src/pxe_service/test/pxe_test_suite.ts +1 -53
  64. package/src/simulator_oracle/index.ts +131 -1
  65. package/src/synchronizer/synchronizer.ts +7 -7
  66. package/dest/note_processor/utils/add_nullable_field_to_payload.d.ts +0 -12
  67. package/dest/note_processor/utils/add_nullable_field_to_payload.d.ts.map +0 -1
  68. package/dest/note_processor/utils/add_nullable_field_to_payload.js +0 -46
  69. package/src/note_processor/utils/add_nullable_field_to_payload.ts +0 -67
@@ -1,20 +1,17 @@
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';
17
- import { Fr, type Point } from '@aztec/foundation/fields';
14
+ import { Fr } from '@aztec/foundation/fields';
18
15
  import {
19
16
  type AztecArray,
20
17
  type AztecKVStore,
@@ -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,13 +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>>;
66
+
67
+ #taggingSecretIndexes: AztecMap<string, number>;
68
68
 
69
69
  constructor(private db: AztecKVStore) {
70
70
  this.#db = db;
71
71
 
72
- this.#addresses = db.openArray('addresses');
73
- 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');
74
76
 
75
77
  this.#authWitnesses = db.openMap('auth_witnesses');
76
78
  this.#capsules = db.openArray('capsules');
@@ -88,7 +90,7 @@ export class KVPxeDatabase implements PxeDatabase {
88
90
  this.#nullifiedNotesByContract = db.openMultiMap('nullified_notes_by_contract');
89
91
  this.#nullifiedNotesByStorageSlot = db.openMultiMap('nullified_notes_by_storage_slot');
90
92
  this.#nullifiedNotesByTxHash = db.openMultiMap('nullified_notes_by_tx_hash');
91
- this.#nullifiedNotesByIvpkM = db.openMultiMap('nullified_notes_by_ivpk_m');
93
+ this.#nullifiedNotesByAddressPoint = db.openMultiMap('nullified_notes_by_address_point');
92
94
 
93
95
  this.#deferredNotes = db.openArray('deferred_notes');
94
96
  this.#deferredNotesByContract = db.openMultiMap('deferred_notes_by_contract');
@@ -103,14 +105,16 @@ export class KVPxeDatabase implements PxeDatabase {
103
105
  this.#notesByContractAndScope = new Map<string, AztecMultiMap<string, string>>();
104
106
  this.#notesByStorageSlotAndScope = new Map<string, AztecMultiMap<string, string>>();
105
107
  this.#notesByTxHashAndScope = new Map<string, AztecMultiMap<string, string>>();
106
- this.#notesByIvpkMAndScope = new Map<string, AztecMultiMap<string, string>>();
108
+ this.#notesByAddressPointAndScope = new Map<string, AztecMultiMap<string, string>>();
107
109
 
108
110
  for (const scope of this.#scopes.entries()) {
109
111
  this.#notesByContractAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_contract`));
110
112
  this.#notesByStorageSlotAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_storage_slot`));
111
113
  this.#notesByTxHashAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_tx_hash`));
112
- this.#notesByIvpkMAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_ivpk_m`));
114
+ this.#notesByAddressPointAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_address_point`));
113
115
  }
116
+
117
+ this.#taggingSecretIndexes = db.openMap('tagging_secret_indices');
114
118
  }
115
119
 
116
120
  public async getContract(
@@ -197,7 +201,7 @@ export class KVPxeDatabase implements PxeDatabase {
197
201
  void this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex);
198
202
  void this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex);
199
203
  void this.#notesByTxHashAndScope.get(scope.toString())!.set(dao.txHash.toString(), noteIndex);
200
- void this.#notesByIvpkMAndScope.get(scope.toString())!.set(dao.ivpkM.toString(), noteIndex);
204
+ void this.#notesByAddressPointAndScope.get(scope.toString())!.set(dao.addressPoint.toString(), noteIndex);
201
205
  }
202
206
 
203
207
  for (const dao of outgoingNotes) {
@@ -215,7 +219,7 @@ export class KVPxeDatabase implements PxeDatabase {
215
219
  const newLength = await this.#deferredNotes.push(...deferredNotes.map(note => note.toBuffer()));
216
220
  for (const [index, note] of deferredNotes.entries()) {
217
221
  const noteId = newLength - deferredNotes.length + index;
218
- await this.#deferredNotesByContract.set(note.contractAddress.toString(), noteId);
222
+ await this.#deferredNotesByContract.set(note.payload.contractAddress.toString(), noteId);
219
223
  }
220
224
  }
221
225
 
@@ -262,9 +266,7 @@ export class KVPxeDatabase implements PxeDatabase {
262
266
  }
263
267
 
264
268
  getIncomingNotes(filter: IncomingNotesFilter): Promise<IncomingNoteDao[]> {
265
- const publicKey: PublicKey | undefined = filter.owner
266
- ? this.#getCompleteAddress(filter.owner)?.publicKeys.masterIncomingViewingPublicKey
267
- : undefined;
269
+ const publicKey: PublicKey | undefined = filter.owner ? computePoint(filter.owner) : undefined;
268
270
 
269
271
  filter.status = filter.status ?? NoteStatus.ACTIVE;
270
272
 
@@ -282,14 +284,14 @@ export class KVPxeDatabase implements PxeDatabase {
282
284
 
283
285
  activeNoteIdsPerScope.push(
284
286
  publicKey
285
- ? this.#notesByIvpkMAndScope.get(formattedScopeString)!.getValues(publicKey.toString())
287
+ ? this.#notesByAddressPointAndScope.get(formattedScopeString)!.getValues(publicKey.toString())
286
288
  : filter.txHash
287
289
  ? this.#notesByTxHashAndScope.get(formattedScopeString)!.getValues(filter.txHash.toString())
288
290
  : filter.contractAddress
289
291
  ? this.#notesByContractAndScope.get(formattedScopeString)!.getValues(filter.contractAddress.toString())
290
292
  : filter.storageSlot
291
293
  ? this.#notesByStorageSlotAndScope.get(formattedScopeString)!.getValues(filter.storageSlot.toString())
292
- : this.#notesByIvpkMAndScope.get(formattedScopeString)!.values(),
294
+ : this.#notesByAddressPointAndScope.get(formattedScopeString)!.values(),
293
295
  );
294
296
  }
295
297
 
@@ -301,7 +303,7 @@ export class KVPxeDatabase implements PxeDatabase {
301
303
  if (filter.status == NoteStatus.ACTIVE_OR_NULLIFIED) {
302
304
  candidateNoteSources.push({
303
305
  ids: publicKey
304
- ? this.#nullifiedNotesByIvpkM.getValues(publicKey.toString())
306
+ ? this.#nullifiedNotesByAddressPoint.getValues(publicKey.toString())
305
307
  : filter.txHash
306
308
  ? this.#nullifiedNotesByTxHash.getValues(filter.txHash.toString())
307
309
  : filter.contractAddress
@@ -334,7 +336,7 @@ export class KVPxeDatabase implements PxeDatabase {
334
336
  continue;
335
337
  }
336
338
 
337
- if (publicKey && !note.ivpkM.equals(publicKey)) {
339
+ if (publicKey && !note.addressPoint.equals(publicKey)) {
338
340
  continue;
339
341
  }
340
342
 
@@ -399,7 +401,7 @@ export class KVPxeDatabase implements PxeDatabase {
399
401
  return Promise.resolve(notes);
400
402
  }
401
403
 
402
- removeNullifiedNotes(nullifiers: Fr[], accountIvpkM: PublicKey): Promise<IncomingNoteDao[]> {
404
+ removeNullifiedNotes(nullifiers: Fr[], accountAddressPoint: PublicKey): Promise<IncomingNoteDao[]> {
403
405
  if (nullifiers.length === 0) {
404
406
  return Promise.resolve([]);
405
407
  }
@@ -421,7 +423,7 @@ export class KVPxeDatabase implements PxeDatabase {
421
423
  }
422
424
 
423
425
  const note = IncomingNoteDao.fromBuffer(noteBuffer);
424
- if (!note.ivpkM.equals(accountIvpkM)) {
426
+ if (!note.addressPoint.equals(accountAddressPoint)) {
425
427
  // tried to nullify someone else's note
426
428
  continue;
427
429
  }
@@ -431,7 +433,7 @@ export class KVPxeDatabase implements PxeDatabase {
431
433
  void this.#notes.delete(noteIndex);
432
434
 
433
435
  for (const scope in this.#scopes.entries()) {
434
- void this.#notesByIvpkMAndScope.get(scope)!.deleteValue(accountIvpkM.toString(), noteIndex);
436
+ void this.#notesByAddressPointAndScope.get(scope)!.deleteValue(accountAddressPoint.toString(), noteIndex);
435
437
  void this.#notesByTxHashAndScope.get(scope)!.deleteValue(note.txHash.toString(), noteIndex);
436
438
  void this.#notesByContractAndScope.get(scope)!.deleteValue(note.contractAddress.toString(), noteIndex);
437
439
  void this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(note.storageSlot.toString(), noteIndex);
@@ -441,7 +443,7 @@ export class KVPxeDatabase implements PxeDatabase {
441
443
  void this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
442
444
  void this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
443
445
  void this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex);
444
- void this.#nullifiedNotesByIvpkM.set(note.ivpkM.toString(), noteIndex);
446
+ void this.#nullifiedNotesByAddressPoint.set(note.addressPoint.toString(), noteIndex);
445
447
 
446
448
  void this.#nullifierToNoteId.delete(nullifier.toString());
447
449
  }
@@ -457,7 +459,7 @@ export class KVPxeDatabase implements PxeDatabase {
457
459
  await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
458
460
  await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
459
461
  await this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex);
460
- await this.#nullifiedNotesByIvpkM.set(note.ivpkM.toString(), noteIndex);
462
+ await this.#nullifiedNotesByAddressPoint.set(note.addressPoint.toString(), noteIndex);
461
463
 
462
464
  return Promise.resolve();
463
465
  }
@@ -495,7 +497,7 @@ export class KVPxeDatabase implements PxeDatabase {
495
497
  this.#notesByContractAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_contract`));
496
498
  this.#notesByStorageSlotAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_storage_slot`));
497
499
  this.#notesByTxHashAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_tx_hash`));
498
- 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`));
499
501
 
500
502
  return true;
501
503
  }
@@ -506,15 +508,15 @@ export class KVPxeDatabase implements PxeDatabase {
506
508
  return this.#db.transaction(() => {
507
509
  const addressString = completeAddress.address.toString();
508
510
  const buffer = completeAddress.toBuffer();
509
- const existing = this.#addressIndex.get(addressString);
511
+ const existing = this.#completeAddressIndex.get(addressString);
510
512
  if (typeof existing === 'undefined') {
511
- const index = this.#addresses.length;
512
- void this.#addresses.push(buffer);
513
- 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);
514
516
 
515
517
  return true;
516
518
  } else {
517
- const existingBuffer = this.#addresses.at(existing);
519
+ const existingBuffer = this.#completeAddresses.at(existing);
518
520
 
519
521
  if (existingBuffer?.equals(buffer)) {
520
522
  return false;
@@ -528,12 +530,12 @@ export class KVPxeDatabase implements PxeDatabase {
528
530
  }
529
531
 
530
532
  #getCompleteAddress(address: AztecAddress): CompleteAddress | undefined {
531
- const index = this.#addressIndex.get(address.toString());
533
+ const index = this.#completeAddressIndex.get(address.toString());
532
534
  if (typeof index === 'undefined') {
533
535
  return undefined;
534
536
  }
535
537
 
536
- const value = this.#addresses.at(index);
538
+ const value = this.#completeAddresses.at(index);
537
539
  return value ? CompleteAddress.fromBuffer(value) : undefined;
538
540
  }
539
541
 
@@ -542,15 +544,39 @@ export class KVPxeDatabase implements PxeDatabase {
542
544
  }
543
545
 
544
546
  getCompleteAddresses(): Promise<CompleteAddress[]> {
545
- 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;
546
572
  }
547
573
 
548
- getSynchedBlockNumberForPublicKey(publicKey: Point): number | undefined {
549
- return this.#syncedBlockPerPublicKey.get(publicKey.toString());
574
+ getSynchedBlockNumberForAccount(account: AztecAddress): number | undefined {
575
+ return this.#syncedBlockPerPublicKey.get(account.toString());
550
576
  }
551
577
 
552
- setSynchedBlockNumberForPublicKey(publicKey: Point, blockNumber: number): Promise<void> {
553
- return this.#syncedBlockPerPublicKey.set(publicKey.toString(), blockNumber);
578
+ setSynchedBlockNumberForAccount(account: AztecAddress, blockNumber: number): Promise<void> {
579
+ return this.#syncedBlockPerPublicKey.set(account.toString(), blockNumber);
554
580
  }
555
581
 
556
582
  async estimateSize(): Promise<number> {
@@ -567,9 +593,29 @@ export class KVPxeDatabase implements PxeDatabase {
567
593
  (sum, value) => sum + value.length * Fr.SIZE_IN_BYTES,
568
594
  0,
569
595
  );
570
- const addressesSize = this.#addresses.length * CompleteAddress.SIZE_IN_BYTES;
596
+ const addressesSize = this.#completeAddresses.length * CompleteAddress.SIZE_IN_BYTES;
571
597
  const treeRootsSize = Object.keys(MerkleTreeId).length * Fr.SIZE_IN_BYTES;
572
598
 
573
599
  return incomingNotesSize + outgoingNotesSize + treeRootsSize + authWitsSize + addressesSize;
574
600
  }
601
+
602
+ async incrementTaggingSecretsIndexes(appTaggingSecretsWithRecipient: TaggingSecret[]): Promise<void> {
603
+ const indexes = await this.getTaggingSecretsIndexes(appTaggingSecretsWithRecipient);
604
+ await this.db.transaction(() => {
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);
610
+ });
611
+ });
612
+ }
613
+
614
+ getTaggingSecretsIndexes(appTaggingSecretsWithRecipient: TaggingSecret[]): Promise<number[]> {
615
+ return this.db.transaction(() =>
616
+ appTaggingSecretsWithRecipient.map(
617
+ ({ secret, recipient }) => this.#taggingSecretIndexes.get(`${secret.toString()}-${recipient.toString()}`) ?? 0,
618
+ ),
619
+ );
620
+ }
575
621
  }
@@ -35,14 +35,15 @@ export class OutgoingNoteDao {
35
35
  ) {}
36
36
 
37
37
  static fromPayloadAndNoteInfo(
38
+ note: Note,
38
39
  payload: L1NotePayload,
39
40
  noteInfo: NoteInfo,
40
41
  dataStartIndexForTx: number,
41
- ivpkM: PublicKey,
42
+ ovpkM: PublicKey,
42
43
  ) {
43
44
  const noteHashIndexInTheWholeTree = BigInt(dataStartIndexForTx + noteInfo.noteHashIndex);
44
45
  return new OutgoingNoteDao(
45
- payload.note,
46
+ note,
46
47
  payload.contractAddress,
47
48
  payload.storageSlot,
48
49
  payload.noteTypeId,
@@ -50,7 +51,7 @@ export class OutgoingNoteDao {
50
51
  noteInfo.nonce,
51
52
  noteInfo.noteHash,
52
53
  noteHashIndexInTheWholeTree,
53
- ivpkM,
54
+ ovpkM,
54
55
  );
55
56
  }
56
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.
@@ -169,20 +190,37 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
169
190
 
170
191
  /**
171
192
  * Updates up to which block number we have processed notes for a given public key.
172
- * @param publicKey - The public key to set the synched block number for.
193
+ * @param account - The account to set the synched block number for.
173
194
  * @param blockNumber - The block number to set.
174
195
  */
175
- setSynchedBlockNumberForPublicKey(publicKey: PublicKey, blockNumber: number): Promise<void>;
196
+ setSynchedBlockNumberForAccount(account: AztecAddress, blockNumber: number): Promise<void>;
176
197
 
177
198
  /**
178
199
  * Get the synched block number for a given public key.
179
- * @param publicKey - The public key to get the synched block number for.
200
+ * @param account - The account to get the synched block number for.
180
201
  */
181
- getSynchedBlockNumberForPublicKey(publicKey: PublicKey): number | undefined;
202
+ getSynchedBlockNumberForAccount(account: AztecAddress): number | undefined;
182
203
 
183
204
  /**
184
205
  * Returns the estimated size in bytes of this db.
185
206
  * @returns The estimated size in bytes of this db.
186
207
  */
187
208
  estimateSize(): Promise<number>;
209
+
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[]>;
218
+
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>;
188
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';