Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Oct 31, 2024
1 parent e636349 commit f6e4e0f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions yarn-project/pxe/src/simulator_oracle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,22 +297,19 @@ export class SimulatorOracle implements DBOracle {
recipient: AztecAddress,
): Promise<IndexedTaggingSecret[]> {
const recipientCompleteAddress = await this.getCompleteAddress(recipient);
const completeAddresses = await this.db.getCompleteAddresses();
// Filter out the addresses corresponding to accounts
const accounts = await this.keyStore.getAccounts();
const senders = completeAddresses.filter(
completeAddress => !accounts.find(account => account.equals(completeAddress.address)),
);
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
const secrets = senders.map(({ address: sender }) => {
const sharedSecret = computeTaggingSecret(recipientCompleteAddress, recipientIvsk, sender);

// We implicitly add the recipient as a contact, this helps us decrypt tags on notes that we send to ourselves (recipient = us, sender = us)
const contacts = [...(await this.db.getContactAddresses()), recipient];
const appTaggingSecrets = contacts.map((contact) => {
const sharedSecret = computeTaggingSecret(recipientCompleteAddress, recipientIvsk, contact);
return poseidon2Hash([sharedSecret.x, sharedSecret.y, contractAddress]);
});
// Ensure the directionality (sender -> recipient)
const directionalSecrets = secrets.map(secret => new TaggingSecret(secret, recipient));
const directionalSecrets = appTaggingSecrets.map(secret => new TaggingSecret(secret, recipient));
const indexes = await this.db.getTaggingSecretsIndexes(directionalSecrets);
return directionalSecrets.map(
({ secret, recipient }, i) => new IndexedTaggingSecret(secret, recipient, indexes[i]),
(directionalSecret, i) => IndexedTaggingSecret.fromTaggingSecret(directionalSecret, indexes[i]),
);
}

Expand Down

0 comments on commit f6e4e0f

Please sign in to comment.