Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Oct 28, 2024
1 parent 264c8b7 commit 9a004e3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions yarn-project/pxe/src/database/incoming_note_dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class IncomingNoteDao implements NoteData {
/** The location of the relevant note in the note hash tree. */
public index: bigint,
/** The public key with which the note was encrypted. */
public ivpkM: PublicKey,
public addressPoint: PublicKey,
) {}

static fromPayloadAndNoteInfo(
Expand Down Expand Up @@ -73,7 +73,7 @@ export class IncomingNoteDao implements NoteData {
this.noteHash,
this.siloedNullifier,
this.index,
this.ivpkM,
this.addressPoint,
]);
}
static fromBuffer(buffer: Buffer | BufferReader) {
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/pxe/src/database/kv_pxe_database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import {
AztecAddress,
CompleteAddress,
computePoint,
type ContractInstanceWithAddress,
Header,
SerializableContractInstance,
Expand Down Expand Up @@ -263,7 +264,7 @@ export class KVPxeDatabase implements PxeDatabase {

getIncomingNotes(filter: IncomingNotesFilter): Promise<IncomingNoteDao[]> {
const publicKey: PublicKey | undefined = filter.owner
? this.#getCompleteAddress(filter.owner)?.publicKeys.masterIncomingViewingPublicKey
? computePoint(filter.owner)
: undefined;

filter.status = filter.status ?? NoteStatus.ACTIVE;
Expand Down
22 changes: 11 additions & 11 deletions yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
computeAddressSecret,
computeContractAddressFromInstance,
computeContractClassId,
computePoint,
getContractClassFromArtifact,
} from '@aztec/circuits.js';
import { computeNoteHashNonce, siloNullifier } from '@aztec/circuits.js/hash';
Expand Down Expand Up @@ -124,14 +125,13 @@ export class PXEService implements PXE {

private async restoreNoteProcessors() {
const accounts = await this.keyStore.getAccounts();
const publicKeys = accounts.map(async account => await this.keyStore.getMasterIncomingViewingPublicKey(account));
const publicKeysSet = new Set(publicKeys.map(k => k.toString()));
const accountsSet = new Set(accounts.map(k => k.toString()));

const registeredAddresses = await this.db.getCompleteAddresses();

let count = 0;
for (const address of registeredAddresses) {
if (!publicKeysSet.has(address.publicKeys.masterIncomingViewingPublicKey.toString())) {
if (!accountsSet.has(address.address.toString())) {
continue;
}

Expand Down Expand Up @@ -307,10 +307,10 @@ export class PXEService implements PXE {
let owner = filter.owner;
if (owner === undefined) {
const completeAddresses = (await this.db.getCompleteAddresses()).find(address =>
address.publicKeys.masterIncomingViewingPublicKey.equals(dao.ivpkM),
computePoint(address.address).equals(dao.addressPoint),
);
if (completeAddresses === undefined) {
throw new Error(`Cannot find complete address for IvpkM ${dao.ivpkM.toString()}`);
throw new Error(`Cannot find complete address for addressPoint ${dao.addressPoint.toString()}`);
}
owner = completeAddresses.address;
}
Expand Down Expand Up @@ -405,18 +405,18 @@ export class PXEService implements PXE {
noteHash,
siloedNullifier,
index,
owner.publicKeys.masterIncomingViewingPublicKey,
computePoint(owner.address),
),
scope,
);
}
}

public async addNullifiedNote(note: ExtendedNote) {
const owner = await this.db.getCompleteAddress(note.owner);
if (!owner) {
throw new Error(`Unknown account: ${note.owner.toString()}`);
}
// const owner = await this.db.getCompleteAddress(note.owner);
// if (!owner) {
// throw new Error(`Unknown account: ${note.owner.toString()}`);
// }

const nonces = await this.#getNoteNonces(note);
if (nonces.length === 0) {
Expand Down Expand Up @@ -453,7 +453,7 @@ export class PXEService implements PXE {
noteHash,
Fr.ZERO, // We are not able to derive
index,
owner.publicKeys.masterIncomingViewingPublicKey,
computePoint(note.owner),
),
);
}
Expand Down

0 comments on commit 9a004e3

Please sign in to comment.