@@ -295,22 +295,19 @@ export class SimulatorOracle implements DBOracle {
295295 recipient : AztecAddress ,
296296 ) : Promise < IndexedTaggingSecret [ ] > {
297297 const recipientCompleteAddress = await this . getCompleteAddress ( recipient ) ;
298- const completeAddresses = await this . db . getCompleteAddresses ( ) ;
299- // Filter out the addresses corresponding to accounts
300- const accounts = await this . keyStore . getAccounts ( ) ;
301- const senders = completeAddresses . filter (
302- completeAddress => ! accounts . find ( account => account . equals ( completeAddress . address ) ) ,
303- ) ;
304298 const recipientIvsk = await this . keyStore . getMasterIncomingViewingSecretKey ( recipient ) ;
305- const secrets = senders . map ( ( { address : sender } ) => {
306- const sharedSecret = computeTaggingSecret ( recipientCompleteAddress , recipientIvsk , sender ) ;
299+
300+ // We implicitly add the recipient as a contact, this helps us decrypt tags on notes that we send to ourselves (recipient = us, sender = us)
301+ const contacts = [ ...await this . db . getContactAddresses ( ) , recipient ] ;
302+ const appTaggingSecrets = contacts . map ( ( contact ) => {
303+ const sharedSecret = computeTaggingSecret ( recipientCompleteAddress , recipientIvsk , contact ) ;
307304 return poseidon2Hash ( [ sharedSecret . x , sharedSecret . y , contractAddress ] ) ;
308305 } ) ;
309306 // Ensure the directionality (sender -> recipient)
310- const directionalSecrets = secrets . map ( secret => new TaggingSecret ( secret , recipient ) ) ;
307+ const directionalSecrets = appTaggingSecrets . map ( secret => new TaggingSecret ( secret , recipient ) ) ;
311308 const indexes = await this . db . getTaggingSecretsIndexes ( directionalSecrets ) ;
312309 return directionalSecrets . map (
313- ( { secret , recipient } , i ) => new IndexedTaggingSecret ( secret , recipient , indexes [ i ] ) ,
310+ ( directionalSecret , i ) => IndexedTaggingSecret . fromTaggingSecret ( directionalSecret , indexes [ i ] ) ,
314311 ) ;
315312 }
316313
0 commit comments