diff --git a/yarn-project/pxe/src/database/deferred_note_dao.ts b/yarn-project/pxe/src/database/deferred_note_dao.ts index d5cafe85f89..16044d7441e 100644 --- a/yarn-project/pxe/src/database/deferred_note_dao.ts +++ b/yarn-project/pxe/src/database/deferred_note_dao.ts @@ -9,7 +9,7 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; */ export class DeferredNoteDao { constructor( - /** IvpkM or OvpkM (depending on if incoming or outgoing) the note was encrypted with. */ + /** Address Point or OvpkM (depending on if incoming or outgoing) the note was encrypted with. */ public publicKey: PublicKey, /** The note payload delivered via L1. */ public payload: L1NotePayload, diff --git a/yarn-project/pxe/src/database/incoming_note_dao.test.ts b/yarn-project/pxe/src/database/incoming_note_dao.test.ts index 398263165d6..a3cb0d5345c 100644 --- a/yarn-project/pxe/src/database/incoming_note_dao.test.ts +++ b/yarn-project/pxe/src/database/incoming_note_dao.test.ts @@ -14,7 +14,7 @@ export const randomIncomingNoteDao = ({ noteHash = Fr.random(), siloedNullifier = Fr.random(), index = Fr.random().toBigInt(), - ivpkM = Point.random(), + addressPoint = Point.random(), }: Partial = {}) => { return new IncomingNoteDao( note, @@ -26,7 +26,7 @@ export const randomIncomingNoteDao = ({ noteHash, siloedNullifier, index, - ivpkM, + addressPoint, ); }; diff --git a/yarn-project/pxe/src/database/incoming_note_dao.ts b/yarn-project/pxe/src/database/incoming_note_dao.ts index 0bd0c6a992c..8a07c9d39a5 100644 --- a/yarn-project/pxe/src/database/incoming_note_dao.ts +++ b/yarn-project/pxe/src/database/incoming_note_dao.ts @@ -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( @@ -45,7 +45,7 @@ export class IncomingNoteDao implements NoteData { payload: L1NotePayload, noteInfo: NoteInfo, dataStartIndexForTx: number, - ivpkM: PublicKey, + addressPoint: PublicKey, ) { const noteHashIndexInTheWholeTree = BigInt(dataStartIndexForTx + noteInfo.noteHashIndex); return new IncomingNoteDao( @@ -58,7 +58,7 @@ export class IncomingNoteDao implements NoteData { noteInfo.noteHash, noteInfo.siloedNullifier, noteHashIndexInTheWholeTree, - ivpkM, + addressPoint, ); } @@ -73,7 +73,7 @@ export class IncomingNoteDao implements NoteData { this.noteHash, this.siloedNullifier, this.index, - this.ivpkM, + this.addressPoint, ]); } static fromBuffer(buffer: Buffer | BufferReader) { diff --git a/yarn-project/pxe/src/database/kv_pxe_database.ts b/yarn-project/pxe/src/database/kv_pxe_database.ts index b0061e587ce..c79c0f27778 100644 --- a/yarn-project/pxe/src/database/kv_pxe_database.ts +++ b/yarn-project/pxe/src/database/kv_pxe_database.ts @@ -8,6 +8,7 @@ import { import { AztecAddress, CompleteAddress, + computePoint, type ContractInstanceWithAddress, Header, SerializableContractInstance, @@ -263,7 +264,7 @@ export class KVPxeDatabase implements PxeDatabase { getIncomingNotes(filter: IncomingNotesFilter): Promise { const publicKey: PublicKey | undefined = filter.owner - ? this.#getCompleteAddress(filter.owner)?.publicKeys.masterIncomingViewingPublicKey + ? computePoint(filter.owner) : undefined; filter.status = filter.status ?? NoteStatus.ACTIVE; diff --git a/yarn-project/pxe/src/database/outgoing_note_dao.ts b/yarn-project/pxe/src/database/outgoing_note_dao.ts index 048bef1ad3b..30385bb684e 100644 --- a/yarn-project/pxe/src/database/outgoing_note_dao.ts +++ b/yarn-project/pxe/src/database/outgoing_note_dao.ts @@ -39,7 +39,7 @@ export class OutgoingNoteDao { payload: L1NotePayload, noteInfo: NoteInfo, dataStartIndexForTx: number, - ivpkM: PublicKey, + ovpkM: PublicKey, ) { const noteHashIndexInTheWholeTree = BigInt(dataStartIndexForTx + noteInfo.noteHashIndex); return new OutgoingNoteDao( @@ -51,7 +51,7 @@ export class OutgoingNoteDao { noteInfo.nonce, noteInfo.noteHash, noteHashIndexInTheWholeTree, - ivpkM, + ovpkM, ); } diff --git a/yarn-project/pxe/src/database/pxe_database_test_suite.ts b/yarn-project/pxe/src/database/pxe_database_test_suite.ts index 8981df245fb..253fe974200 100644 --- a/yarn-project/pxe/src/database/pxe_database_test_suite.ts +++ b/yarn-project/pxe/src/database/pxe_database_test_suite.ts @@ -2,6 +2,7 @@ import { type IncomingNotesFilter, NoteStatus, type OutgoingNotesFilter, randomT import { AztecAddress, CompleteAddress, + computePoint, INITIAL_L2_BLOCK_NUM, PublicKeys, SerializableContractInstance, @@ -101,7 +102,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { [ () => ({ owner: owners[0].address }), - () => notes.filter(note => note.ivpkM.equals(owners[0].publicKeys.masterIncomingViewingPublicKey)), + () => notes.filter(note => note.addressPoint.equals(owners[0].publicKeys.masterIncomingViewingPublicKey)), ], [ @@ -123,7 +124,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { randomIncomingNoteDao({ contractAddress: contractAddresses[i % contractAddresses.length], storageSlot: storageSlots[i % storageSlots.length], - ivpkM: owners[i % owners.length].publicKeys.masterIncomingViewingPublicKey, + addressPoint: owners[i % owners.length].publicKeys.masterIncomingViewingPublicKey, index: BigInt(i), }), ); @@ -156,7 +157,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { // Nullify all notes and use the same filter as other test cases for (const owner of owners) { const notesToNullify = notes.filter(note => - note.ivpkM.equals(owner.publicKeys.masterIncomingViewingPublicKey), + note.addressPoint.equals(computePoint(owner.address)), ); const nullifiers = notesToNullify.map(note => note.siloedNullifier); await expect( @@ -173,10 +174,10 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { await database.addNotes(notes, []); const notesToNullify = notes.filter(note => - note.ivpkM.equals(owners[0].publicKeys.masterIncomingViewingPublicKey), + note.addressPoint.equals(computePoint(owners[0].address)), ); const nullifiers = notesToNullify.map(note => note.siloedNullifier); - await expect(database.removeNullifiedNotes(nullifiers, notesToNullify[0].ivpkM)).resolves.toEqual( + await expect(database.removeNullifiedNotes(nullifiers, notesToNullify[0].addressPoint)).resolves.toEqual( notesToNullify, ); @@ -191,10 +192,10 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { await database.addNotes(notes, []); const notesToNullify = notes.filter(note => - note.ivpkM.equals(owners[0].publicKeys.masterIncomingViewingPublicKey), + note.addressPoint.equals(computePoint(owners[0].address)), ); const nullifiers = notesToNullify.map(note => note.siloedNullifier); - await expect(database.removeNullifiedNotes(nullifiers, notesToNullify[0].ivpkM)).resolves.toEqual( + await expect(database.removeNullifiedNotes(nullifiers, notesToNullify[0].addressPoint)).resolves.toEqual( notesToNullify, ); diff --git a/yarn-project/pxe/src/note_processor/utils/produce_note_daos.ts b/yarn-project/pxe/src/note_processor/utils/produce_note_daos.ts index 15127d36cd9..1b86279eaf8 100644 --- a/yarn-project/pxe/src/note_processor/utils/produce_note_daos.ts +++ b/yarn-project/pxe/src/note_processor/utils/produce_note_daos.ts @@ -17,7 +17,7 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js'; * * @param simulator - An instance of AcirSimulator. * @param db - An instance of PxeDatabase. - * @param ivpkM - The public counterpart to the secret key to be used in the decryption of incoming note logs. + * @param addressPoint - The public counterpart to the secret key to be used in the decryption of incoming note logs. * @param ovpkM - The public counterpart to the secret key to be used in the decryption of outgoing note logs. * @param payload - An instance of l1NotePayload. * @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'; export async function produceNoteDaos( simulator: AcirSimulator, db: PxeDatabase, - ivpkM: PublicKey | undefined, + addressPoint: PublicKey | undefined, ovpkM: PublicKey | undefined, payload: L1NotePayload, txHash: TxHash, @@ -46,8 +46,8 @@ export async function produceNoteDaos( incomingDeferredNote: DeferredNoteDao | undefined; outgoingDeferredNote: DeferredNoteDao | undefined; }> { - if (!ivpkM && !ovpkM) { - throw new Error('Both ivpkM and ovpkM are undefined. Cannot create note.'); + if (!addressPoint && !ovpkM) { + throw new Error('Both addressPoint and ovpkM are undefined. Cannot create note.'); } let incomingNote: IncomingNoteDao | undefined; @@ -55,11 +55,11 @@ export async function produceNoteDaos( let incomingDeferredNote: DeferredNoteDao | undefined; let outgoingDeferredNote: DeferredNoteDao | undefined; - if (ivpkM) { + if (addressPoint) { [incomingNote, incomingDeferredNote] = await produceNoteDaosForKey( simulator, db, - ivpkM, + addressPoint, payload, txHash, noteHashes, diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index 3fdc1843ae8..83d113a6cfb 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -44,6 +44,7 @@ import { computeAddressSecret, computeContractAddressFromInstance, computeContractClassId, + computePoint, getContractClassFromArtifact, } from '@aztec/circuits.js'; import { computeNoteHashNonce, siloNullifier } from '@aztec/circuits.js/hash'; @@ -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; } @@ -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; } @@ -405,7 +405,7 @@ export class PXEService implements PXE { noteHash, siloedNullifier, index, - owner.publicKeys.masterIncomingViewingPublicKey, + computePoint(owner.address), ), scope, ); @@ -413,10 +413,10 @@ export class PXEService implements PXE { } 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) { @@ -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), ), ); } diff --git a/yarn-project/pxe/src/synchronizer/synchronizer.ts b/yarn-project/pxe/src/synchronizer/synchronizer.ts index 5bef1301e85..42f3445d0a1 100644 --- a/yarn-project/pxe/src/synchronizer/synchronizer.ts +++ b/yarn-project/pxe/src/synchronizer/synchronizer.ts @@ -373,9 +373,9 @@ export class Synchronizer { // now group the decoded incoming notes by public key const publicKeyToIncomingNotes: Map = new Map(); for (const noteDao of notes) { - const notesForPublicKey = publicKeyToIncomingNotes.get(noteDao.ivpkM) ?? []; + const notesForPublicKey = publicKeyToIncomingNotes.get(noteDao.addressPoint) ?? []; notesForPublicKey.push(noteDao); - publicKeyToIncomingNotes.set(noteDao.ivpkM, notesForPublicKey); + publicKeyToIncomingNotes.set(noteDao.addressPoint, notesForPublicKey); } // now for each group, look for the nullifiers in the nullifier tree