From 623d1b20d4f092532d6e282d0b006c641a01874c Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Mon, 28 Oct 2024 00:13:54 +0000 Subject: [PATCH] init --- .../l1_payload/encrypted_log_payload.test.ts | 6 +- .../logs/l1_payload/encrypted_log_payload.ts | 38 ++++----- .../end-to-end/scripts/e2e_test_config.yml | 80 +++++++++---------- .../pxe/src/database/deferred_note_dao.ts | 2 +- .../src/database/incoming_note_dao.test.ts | 4 +- .../pxe/src/database/incoming_note_dao.ts | 8 +- .../pxe/src/database/kv_pxe_database.ts | 37 +++++---- .../pxe/src/database/outgoing_note_dao.ts | 4 +- .../src/database/pxe_database_test_suite.ts | 32 +++----- .../src/note_processor/note_processor.test.ts | 48 ++++++----- .../pxe/src/note_processor/note_processor.ts | 12 ++- .../note_processor/utils/produce_note_daos.ts | 12 +-- .../pxe/src/pxe_service/pxe_service.ts | 25 +++--- .../pxe/src/synchronizer/synchronizer.ts | 4 +- 14 files changed, 143 insertions(+), 169 deletions(-) diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts index f53a8bf3071..1885b0ec749 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.test.ts @@ -44,7 +44,7 @@ describe('EncryptedLogPayload', () => { const ephSk = GrumpkinScalar.random(); - encrypted = original.encrypt(ephSk, completeAddress.address, computePoint(completeAddress.address), ovKeys); + encrypted = original.encrypt(ephSk, completeAddress.address, ovKeys); }); it('decrypt a log as incoming', () => { @@ -122,9 +122,7 @@ describe('EncryptedLogPayload', () => { '0x25afb798ea6d0b8c1618e50fdeafa463059415013d3b7c75d46abf5e242be70c138af8799f2fba962549802469e12e3b7ba4c5f9c999c6421e05c73f45ec68481970dd8ce0250b677759dfc040f6edaf77c5827a7bcd425e66bcdec3fa7e59bc18dd22d6a4032eefe3a7a55703f583396596235f7c186e450c92981186ee74042e49e00996565114016a1a478309842ecbaf930fb716c3f498e7e10370631d7507f696b8b233de2c1935e43c793399586f532da5ff7c0356636a75acb862e964156e8a3e42bfca3663936ba98c7fd26386a14657c23b5f5146f1a94b6c4651542685ea16f17c580a7cc7c8ff2688dce9bde8bf1f50475f4c3281e1c33404ee0025f50db0733f719462b22eff03cec746bb9e3829ae3636c84fbccd2754b5a5a92087a5f41ccf94a03a2671cd341ba3264c45147e75d4ea96e3b1a58498550b89', ); - const encrypted = log - .encrypt(ephSk, recipientCompleteAddress.address, computePoint(recipientCompleteAddress.address), ovKeys) - .toString('hex'); + const encrypted = log.encrypt(ephSk, recipientCompleteAddress.address, ovKeys).toString('hex'); expect(encrypted).toMatchInlineSnapshot( `"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008d460c0e434d846ec1ea286e4090eb56376ff27bddc1aacae1d856549f701fa70577790aeabcc2d81ec8d0c99e7f5d2bf2f1452025dc777a178404f851d93de818923f85187871d99bdf95d695eff0a9e09ba15153fc9b4d224b6e1e71dfbdcaab06c09d5b3c749bfebe1c0407eccd04f51bbb59142680c8a091b97fc6cbcf61f6c2af9b8ebc8f78537ab23fd0c5e818e4d42d459d265adb77c2ef829bf68f87f2c47b478bb57ae7e41a07643f65c353083d557b94e31da4a2a13127498d2eb3f0346da5eed2e9bc245aaf022a954ed0b09132b498f537702899b44e3666776238ebf633b3562d7f124dbba82918e871958a94218fd796bc6983feecc7ce382c82861d63fe45999244ea9494b226ddb694b2640dce005b473acf1ae3be158f558ad1ca228e9f793d09390230a2597e0e53ad28f7aa9a700ccc302607ad6c26ea1410735b6a8c793f6317f7009409a3912b15ee2f28ccf17cf6c94b720301e5c5826de39e85bc7db3dc33aa79afcaf325670d1b359d08b10bd07840d394c9f038"`, ); diff --git a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts index e9231ce876e..02afcf98d37 100644 --- a/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts +++ b/yarn-project/circuit-types/src/logs/l1_payload/encrypted_log_payload.ts @@ -7,6 +7,7 @@ import { Point, type PublicKey, computeOvskApp, + computePoint, derivePublicKeyFromSecretKey, } from '@aztec/circuits.js'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; @@ -45,18 +46,11 @@ export class EncryptedLogPayload { public readonly incomingBodyPlaintext: Buffer, ) {} - public encrypt( - ephSk: GrumpkinScalar, - recipient: AztecAddress, - ivpk: PublicKey, - ovKeys: KeyValidationRequest, - ): Buffer { - if (ivpk.isZero()) { - throw new Error(`Attempting to encrypt an event log with a zero ivpk.`); - } + public encrypt(ephSk: GrumpkinScalar, recipient: AztecAddress, ovKeys: KeyValidationRequest): Buffer { + const addressPoint = computePoint(recipient); const ephPk = derivePublicKeyFromSecretKey(ephSk); - const incomingHeaderCiphertext = encrypt(this.contractAddress.toBuffer(), ephSk, ivpk); + const incomingHeaderCiphertext = encrypt(this.contractAddress.toBuffer(), ephSk, addressPoint); const outgoingHeaderCiphertext = encrypt(this.contractAddress.toBuffer(), ephSk, ovKeys.pkM); if (incomingHeaderCiphertext.length !== HEADER_SIZE) { @@ -66,9 +60,9 @@ export class EncryptedLogPayload { throw new Error(`Invalid outgoing header size: ${outgoingHeaderCiphertext.length}`); } - const incomingBodyCiphertext = encrypt(this.incomingBodyPlaintext, ephSk, ivpk); + const incomingBodyCiphertext = encrypt(this.incomingBodyPlaintext, ephSk, addressPoint); // The serialization of Fq is [high, low] check `outgoing_body.nr` - const outgoingBodyPlaintext = serializeToBuffer(ephSk.hi, ephSk.lo, recipient, ivpk.toCompressedBuffer()); + const outgoingBodyPlaintext = serializeToBuffer(ephSk.hi, ephSk.lo, recipient, addressPoint.toCompressedBuffer()); const outgoingBodyCiphertext = encrypt( outgoingBodyPlaintext, ovKeys.skAppAsGrumpkinScalar, @@ -94,18 +88,18 @@ export class EncryptedLogPayload { /** * Decrypts a ciphertext as an incoming log. * - * This is executable by the recipient of the note, and uses the ivsk to decrypt the payload. + * This is executable by the recipient of the note, and uses the addressSecret to decrypt the payload. * The outgoing parts of the log are ignored entirely. * * Produces the same output as `decryptAsOutgoing`. * * @param ciphertext - The ciphertext for the log - * @param ivsk - The incoming viewing secret key, used to decrypt the logs + * @param addressSecret - The incoming viewing secret key, used to decrypt the logs * @returns The decrypted log payload */ public static decryptAsIncoming( ciphertext: Buffer | BufferReader, - ivsk: GrumpkinScalar, + addressSecret: GrumpkinScalar, ): EncryptedLogPayload | undefined { const reader = BufferReader.asReader(ciphertext); @@ -115,14 +109,14 @@ export class EncryptedLogPayload { const ephPk = Point.fromCompressedBuffer(reader.readBytes(Point.COMPRESSED_SIZE_IN_BYTES)); - const incomingHeader = decrypt(reader.readBytes(HEADER_SIZE), ivsk, ephPk); + const incomingHeader = decrypt(reader.readBytes(HEADER_SIZE), addressSecret, ephPk); // Skipping the outgoing header and body reader.readBytes(HEADER_SIZE); reader.readBytes(OUTGOING_BODY_SIZE); // The incoming can be of variable size, so we read until the end - const incomingBodyPlaintext = decrypt(reader.readToEnd(), ivsk, ephPk); + const incomingBodyPlaintext = decrypt(reader.readToEnd(), addressSecret, ephPk); return new EncryptedLogPayload( incomingTag, @@ -180,19 +174,19 @@ export class EncryptedLogPayload { const ovskApp = computeOvskApp(ovsk, contractAddress); let ephSk: GrumpkinScalar; - let recipientIvpk: PublicKey; + let recipientAddressPoint: PublicKey; { const outgoingBody = decrypt(reader.readBytes(OUTGOING_BODY_SIZE), ovskApp, ephPk, derivePoseidonAESSecret); const obReader = BufferReader.asReader(outgoingBody); - // From outgoing body we extract ephSk, recipient and recipientIvpk + // From outgoing body we extract ephSk, recipient and recipientAddressPoint ephSk = GrumpkinScalar.fromHighLow(obReader.readObject(Fr), obReader.readObject(Fr)); const _recipient = obReader.readObject(AztecAddress); - recipientIvpk = Point.fromCompressedBuffer(obReader.readBytes(Point.COMPRESSED_SIZE_IN_BYTES)); + recipientAddressPoint = Point.fromCompressedBuffer(obReader.readBytes(Point.COMPRESSED_SIZE_IN_BYTES)); } - // Now we decrypt the incoming body using the ephSk and recipientIvpk - const incomingBody = decrypt(reader.readToEnd(), ephSk, recipientIvpk); + // Now we decrypt the incoming body using the ephSk and recipientAddressPoint + const incomingBody = decrypt(reader.readToEnd(), ephSk, recipientAddressPoint); return new EncryptedLogPayload(incomingTag, outgoingTag, contractAddress, incomingBody); } catch (e: any) { diff --git a/yarn-project/end-to-end/scripts/e2e_test_config.yml b/yarn-project/end-to-end/scripts/e2e_test_config.yml index 2f7c718c14c..55939e7e8ac 100644 --- a/yarn-project/end-to-end/scripts/e2e_test_config.yml +++ b/yarn-project/end-to-end/scripts/e2e_test_config.yml @@ -2,22 +2,22 @@ tests: base: {} bench_prover: env: - HARDWARE_CONCURRENCY: "32" - COMPOSE_FILE: "scripts/docker-compose-no-sandbox.yml" - DEBUG: "aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees" - command: "./scripts/e2e_compose_test.sh bench_prover" + HARDWARE_CONCURRENCY: '32' + COMPOSE_FILE: 'scripts/docker-compose-no-sandbox.yml' + DEBUG: 'aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees' + command: './scripts/e2e_compose_test.sh bench_prover' bench_publish_rollup: env: - HARDWARE_CONCURRENCY: "32" - COMPOSE_FILE: "scripts/docker-compose-no-sandbox.yml" - DEBUG: "aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees" - command: "./scripts/e2e_compose_test.sh bench_publish_rollup" + HARDWARE_CONCURRENCY: '32' + COMPOSE_FILE: 'scripts/docker-compose-no-sandbox.yml' + DEBUG: 'aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees' + command: './scripts/e2e_compose_test.sh bench_publish_rollup' bench_tx_size: env: - HARDWARE_CONCURRENCY: "32" - COMPOSE_FILE: "scripts/docker-compose-no-sandbox.yml" - DEBUG: "aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees" - command: "./scripts/e2e_compose_test.sh bench_tx_size" + HARDWARE_CONCURRENCY: '32' + COMPOSE_FILE: 'scripts/docker-compose-no-sandbox.yml' + DEBUG: 'aztec:benchmarks:*,aztec:sequencer,aztec:sequencer:*,aztec:world_state,aztec:merkle_trees' + command: './scripts/e2e_compose_test.sh bench_tx_size' e2e_2_pxes: {} e2e_account_contracts: {} e2e_authwit: {} @@ -37,20 +37,20 @@ tests: use_compose: true e2e_escrow_contract: {} e2e_fees_account_init: - test_path: "e2e_fees/account_init.test.ts" + test_path: 'e2e_fees/account_init.test.ts' # TODO(https://github.com/AztecProtocol/aztec-packages/issues/9488): reenable # e2e_fees_dapp_subscription: # test_path: "e2e_fees/dapp_subscription.test.ts" e2e_fees_failures: - test_path: "e2e_fees/failures.test.ts" + test_path: 'e2e_fees/failures.test.ts' e2e_fees_fee_juice_payments: - test_path: "e2e_fees/fee_juice_payments.test.ts" + test_path: 'e2e_fees/fee_juice_payments.test.ts' e2e_fees_gas_estimation: - test_path: "e2e_fees/gas_estimation.test.ts" + test_path: 'e2e_fees/gas_estimation.test.ts' e2e_fees_private_payments: - test_path: "e2e_fees/private_payments.test.ts" + test_path: 'e2e_fees/private_payments.test.ts' e2e_fees_private_refunds: - test_path: "e2e_fees/private_refunds.test.ts" + test_path: 'e2e_fees/private_refunds.test.ts' e2e_keys: {} e2e_l1_with_wall_time: {} e2e_lending_contract: {} @@ -67,13 +67,13 @@ tests: e2e_private_voting_contract: {} e2e_prover_coordination: {} e2e_prover_fake_proofs: - test_path: "e2e_prover/full.test.ts" + test_path: 'e2e_prover/full.test.ts' env: - FAKE_PROOFS: "1" + FAKE_PROOFS: '1' e2e_prover_full: - test_path: "e2e_prover/full.test.ts" + test_path: 'e2e_prover/full.test.ts' env: - HARDWARE_CONCURRENCY: "32" + HARDWARE_CONCURRENCY: '32' e2e_public_testnet: {} e2e_sandbox_example: use_compose: true @@ -82,44 +82,44 @@ tests: e2e_synching: {} e2e_token_contract: {} flakey_e2e_tests: - test_path: "./src/flakey" + test_path: './src/flakey' ignore_failures: true guides_dapp_testing: use_compose: true - test_path: "guides/dapp_testing.test.ts" + test_path: 'guides/dapp_testing.test.ts' guides_sample_dapp: use_compose: true - test_path: "sample-dapp/index.test.mjs" + test_path: 'sample-dapp/index.test.mjs' guides_sample_dapp_ci: use_compose: true - test_path: "sample-dapp/ci/index.test.mjs" + test_path: 'sample-dapp/ci/index.test.mjs' guides_up_quick_start: use_compose: true - test_path: "guides/up_quick_start.test.ts" + test_path: 'guides/up_quick_start.test.ts' guides_writing_an_account_contract: use_compose: true - test_path: "guides/writing_an_account_contract.test.ts" + test_path: 'guides/writing_an_account_contract.test.ts' integration_l1_publisher: use_compose: true kind_network_4epochs: env: - NAMESPACE: "smoke" - FRESH_INSTALL: "true" - VALUES_FILE: "$-default.yaml" - command: "./scripts/network_test.sh ./src/spartan/4epochs.test.ts" + NAMESPACE: 'smoke' + FRESH_INSTALL: 'true' + VALUES_FILE: '$-default.yaml' + command: './scripts/network_test.sh ./src/spartan/4epochs.test.ts' ignore_failures: true kind_network_smoke: env: - NAMESPACE: "smoke" - FRESH_INSTALL: "true" - VALUES_FILE: "$-default.yaml" - command: "./scripts/network_test.sh ./src/spartan/smoke.test.ts" + NAMESPACE: 'smoke' + FRESH_INSTALL: 'true' + VALUES_FILE: '$-default.yaml' + command: './scripts/network_test.sh ./src/spartan/smoke.test.ts' kind_network_transfer: env: - NAMESPACE: "transfer" - FRESH_INSTALL: "true" - VALUES_FILE: "$-default.yaml" - command: "./scripts/network_test.sh ./src/spartan/smoke.test.ts" + NAMESPACE: 'transfer' + FRESH_INSTALL: 'true' + VALUES_FILE: '$-default.yaml' + command: './scripts/network_test.sh ./src/spartan/smoke.test.ts' pxe: use_compose: true uniswap_trade_on_l1_from_l2: 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..77bb577213d 100644 --- a/yarn-project/pxe/src/database/kv_pxe_database.ts +++ b/yarn-project/pxe/src/database/kv_pxe_database.ts @@ -11,6 +11,7 @@ import { type ContractInstanceWithAddress, Header, SerializableContractInstance, + computePoint, } from '@aztec/circuits.js'; import { type ContractArtifact } from '@aztec/foundation/abi'; import { toBufferBE } from '@aztec/foundation/bigint-buffer'; @@ -46,7 +47,7 @@ export class KVPxeDatabase implements PxeDatabase { #nullifiedNotesByContract: AztecMultiMap; #nullifiedNotesByStorageSlot: AztecMultiMap; #nullifiedNotesByTxHash: AztecMultiMap; - #nullifiedNotesByIvpkM: AztecMultiMap; + #nullifiedNotesByAddressPoint: AztecMultiMap; #deferredNotes: AztecArray; #deferredNotesByContract: AztecMultiMap; #syncedBlockPerPublicKey: AztecMap; @@ -64,7 +65,7 @@ export class KVPxeDatabase implements PxeDatabase { #notesByContractAndScope: Map>; #notesByStorageSlotAndScope: Map>; #notesByTxHashAndScope: Map>; - #notesByIvpkMAndScope: Map>; + #notesByAddressPointAndScope: Map>; constructor(private db: AztecKVStore) { this.#db = db; @@ -88,7 +89,7 @@ export class KVPxeDatabase implements PxeDatabase { this.#nullifiedNotesByContract = db.openMultiMap('nullified_notes_by_contract'); this.#nullifiedNotesByStorageSlot = db.openMultiMap('nullified_notes_by_storage_slot'); this.#nullifiedNotesByTxHash = db.openMultiMap('nullified_notes_by_tx_hash'); - this.#nullifiedNotesByIvpkM = db.openMultiMap('nullified_notes_by_ivpk_m'); + this.#nullifiedNotesByAddressPoint = db.openMultiMap('nullified_notes_by_address_point'); this.#deferredNotes = db.openArray('deferred_notes'); this.#deferredNotesByContract = db.openMultiMap('deferred_notes_by_contract'); @@ -103,13 +104,13 @@ export class KVPxeDatabase implements PxeDatabase { this.#notesByContractAndScope = new Map>(); this.#notesByStorageSlotAndScope = new Map>(); this.#notesByTxHashAndScope = new Map>(); - this.#notesByIvpkMAndScope = new Map>(); + this.#notesByAddressPointAndScope = new Map>(); for (const scope of this.#scopes.entries()) { this.#notesByContractAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_contract`)); this.#notesByStorageSlotAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_storage_slot`)); this.#notesByTxHashAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_tx_hash`)); - this.#notesByIvpkMAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_ivpk_m`)); + this.#notesByAddressPointAndScope.set(scope, db.openMultiMap(`${scope}:notes_by_address_point`)); } } @@ -197,7 +198,7 @@ export class KVPxeDatabase implements PxeDatabase { void this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex); void this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex); void this.#notesByTxHashAndScope.get(scope.toString())!.set(dao.txHash.toString(), noteIndex); - void this.#notesByIvpkMAndScope.get(scope.toString())!.set(dao.ivpkM.toString(), noteIndex); + void this.#notesByAddressPointAndScope.get(scope.toString())!.set(dao.addressPoint.toString(), noteIndex); } for (const dao of outgoingNotes) { @@ -262,9 +263,7 @@ export class KVPxeDatabase implements PxeDatabase { } getIncomingNotes(filter: IncomingNotesFilter): Promise { - const publicKey: PublicKey | undefined = filter.owner - ? this.#getCompleteAddress(filter.owner)?.publicKeys.masterIncomingViewingPublicKey - : undefined; + const publicKey: PublicKey | undefined = filter.owner ? computePoint(filter.owner) : undefined; filter.status = filter.status ?? NoteStatus.ACTIVE; @@ -282,14 +281,14 @@ export class KVPxeDatabase implements PxeDatabase { activeNoteIdsPerScope.push( publicKey - ? this.#notesByIvpkMAndScope.get(formattedScopeString)!.getValues(publicKey.toString()) + ? this.#notesByAddressPointAndScope.get(formattedScopeString)!.getValues(publicKey.toString()) : filter.txHash ? this.#notesByTxHashAndScope.get(formattedScopeString)!.getValues(filter.txHash.toString()) : filter.contractAddress ? this.#notesByContractAndScope.get(formattedScopeString)!.getValues(filter.contractAddress.toString()) : filter.storageSlot ? this.#notesByStorageSlotAndScope.get(formattedScopeString)!.getValues(filter.storageSlot.toString()) - : this.#notesByIvpkMAndScope.get(formattedScopeString)!.values(), + : this.#notesByAddressPointAndScope.get(formattedScopeString)!.values(), ); } @@ -301,7 +300,7 @@ export class KVPxeDatabase implements PxeDatabase { if (filter.status == NoteStatus.ACTIVE_OR_NULLIFIED) { candidateNoteSources.push({ ids: publicKey - ? this.#nullifiedNotesByIvpkM.getValues(publicKey.toString()) + ? this.#nullifiedNotesByAddressPoint.getValues(publicKey.toString()) : filter.txHash ? this.#nullifiedNotesByTxHash.getValues(filter.txHash.toString()) : filter.contractAddress @@ -334,7 +333,7 @@ export class KVPxeDatabase implements PxeDatabase { continue; } - if (publicKey && !note.ivpkM.equals(publicKey)) { + if (publicKey && !note.addressPoint.equals(publicKey)) { continue; } @@ -399,7 +398,7 @@ export class KVPxeDatabase implements PxeDatabase { return Promise.resolve(notes); } - removeNullifiedNotes(nullifiers: Fr[], accountIvpkM: PublicKey): Promise { + removeNullifiedNotes(nullifiers: Fr[], accountAddressPoint: PublicKey): Promise { if (nullifiers.length === 0) { return Promise.resolve([]); } @@ -421,7 +420,7 @@ export class KVPxeDatabase implements PxeDatabase { } const note = IncomingNoteDao.fromBuffer(noteBuffer); - if (!note.ivpkM.equals(accountIvpkM)) { + if (!note.addressPoint.equals(accountAddressPoint)) { // tried to nullify someone else's note continue; } @@ -431,7 +430,7 @@ export class KVPxeDatabase implements PxeDatabase { void this.#notes.delete(noteIndex); for (const scope in this.#scopes.entries()) { - void this.#notesByIvpkMAndScope.get(scope)!.deleteValue(accountIvpkM.toString(), noteIndex); + void this.#notesByAddressPointAndScope.get(scope)!.deleteValue(accountAddressPoint.toString(), noteIndex); void this.#notesByTxHashAndScope.get(scope)!.deleteValue(note.txHash.toString(), noteIndex); void this.#notesByContractAndScope.get(scope)!.deleteValue(note.contractAddress.toString(), noteIndex); void this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(note.storageSlot.toString(), noteIndex); @@ -441,7 +440,7 @@ export class KVPxeDatabase implements PxeDatabase { void this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex); void this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex); void this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex); - void this.#nullifiedNotesByIvpkM.set(note.ivpkM.toString(), noteIndex); + void this.#nullifiedNotesByAddressPoint.set(note.addressPoint.toString(), noteIndex); void this.#nullifierToNoteId.delete(nullifier.toString()); } @@ -457,7 +456,7 @@ export class KVPxeDatabase implements PxeDatabase { await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex); await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex); await this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex); - await this.#nullifiedNotesByIvpkM.set(note.ivpkM.toString(), noteIndex); + await this.#nullifiedNotesByAddressPoint.set(note.addressPoint.toString(), noteIndex); return Promise.resolve(); } @@ -495,7 +494,7 @@ export class KVPxeDatabase implements PxeDatabase { this.#notesByContractAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_contract`)); this.#notesByStorageSlotAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_storage_slot`)); this.#notesByTxHashAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_tx_hash`)); - this.#notesByIvpkMAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_ivpk_m`)); + this.#notesByAddressPointAndScope.set(scopeString, this.#db.openMultiMap(`${scopeString}:notes_by_address_point`)); return true; } 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..1fefa614bad 100644 --- a/yarn-project/pxe/src/database/pxe_database_test_suite.ts +++ b/yarn-project/pxe/src/database/pxe_database_test_suite.ts @@ -5,6 +5,7 @@ import { INITIAL_L2_BLOCK_NUM, PublicKeys, SerializableContractInstance, + computePoint, } from '@aztec/circuits.js'; import { makeHeader } from '@aztec/circuits.js/testing'; import { randomInt } from '@aztec/foundation/crypto'; @@ -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(computePoint(owners[0].address))), ], [ @@ -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: computePoint(owners[i % owners.length].address), index: BigInt(i), }), ); @@ -155,13 +156,11 @@ 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), - ); + const notesToNullify = notes.filter(note => note.addressPoint.equals(computePoint(owner.address))); const nullifiers = notesToNullify.map(note => note.siloedNullifier); - await expect( - database.removeNullifiedNotes(nullifiers, owner.publicKeys.masterIncomingViewingPublicKey), - ).resolves.toEqual(notesToNullify); + await expect(database.removeNullifiedNotes(nullifiers, computePoint(owner.address))).resolves.toEqual( + notesToNullify, + ); } await expect( @@ -172,11 +171,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { it('skips nullified notes by default or when requesting active', async () => { await database.addNotes(notes, []); - const notesToNullify = notes.filter(note => - note.ivpkM.equals(owners[0].publicKeys.masterIncomingViewingPublicKey), - ); + const notesToNullify = notes.filter(note => 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, ); @@ -190,11 +187,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { it('returns active and nullified notes when requesting either', async () => { await database.addNotes(notes, []); - const notesToNullify = notes.filter(note => - note.ivpkM.equals(owners[0].publicKeys.masterIncomingViewingPublicKey), - ); + const notesToNullify = notes.filter(note => 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, ); @@ -251,10 +246,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) { ).resolves.toEqual([notes[0]]); await expect( - database.removeNullifiedNotes( - [notes[0].siloedNullifier], - owners[0].publicKeys.masterIncomingViewingPublicKey, - ), + database.removeNullifiedNotes([notes[0].siloedNullifier], computePoint(owners[0].address)), ).resolves.toEqual([notes[0]]); await expect( diff --git a/yarn-project/pxe/src/note_processor/note_processor.test.ts b/yarn-project/pxe/src/note_processor/note_processor.test.ts index db2d55caff7..901691aebfa 100644 --- a/yarn-project/pxe/src/note_processor/note_processor.test.ts +++ b/yarn-project/pxe/src/note_processor/note_processor.test.ts @@ -14,12 +14,13 @@ import { KeyValidationRequest, MAX_NOTE_HASHES_PER_TX, type PublicKey, + computeAddressSecret, computeOvskApp, computePoint, deriveKeys, } from '@aztec/circuits.js'; import { pedersenHash } from '@aztec/foundation/crypto'; -import { GrumpkinScalar, Point } from '@aztec/foundation/fields'; +import { GrumpkinScalar } from '@aztec/foundation/fields'; import { type KeyStore } from '@aztec/key-store'; import { openTmpStore } from '@aztec/kv-store/utils'; import { type AcirSimulator } from '@aztec/simulator'; @@ -47,8 +48,8 @@ class MockNoteRequest { public readonly txIndex: number, /** Index of a note hash within a list of note hashes for 1 tx. */ public readonly noteHashIndex: number, - /** ivpk we use when encrypting a note. */ - public readonly ivpk: PublicKey, + /** Address point we use when encrypting a note. */ + public readonly recipient: AztecAddress, /** ovKeys we use when encrypting a note. */ public readonly ovKeys: KeyValidationRequest, ) { @@ -65,8 +66,7 @@ class MockNoteRequest { encrypt(): EncryptedL2NoteLog { const ephSk = GrumpkinScalar.random(); - const recipient = AztecAddress.random(); - const logWithoutNumPublicValues = this.logPayload.encrypt(ephSk, recipient, this.ivpk, this.ovKeys); + const logWithoutNumPublicValues = this.logPayload.encrypt(ephSk, this.recipient, this.ovKeys); // We prefix the log with an empty byte indicating there are 0 public values. const log = Buffer.concat([Buffer.alloc(1), logWithoutNumPublicValues]); return new EncryptedL2NoteLog(log); @@ -104,7 +104,6 @@ describe('Note Processor', () => { const app = AztecAddress.random(); let ownerIvskM: GrumpkinScalar; - let ownerIvpkM: PublicKey; let ownerOvskM: GrumpkinScalar; let ownerOvKeys: KeyValidationRequest; let account: CompleteAddress; @@ -148,7 +147,6 @@ describe('Note Processor', () => { const partialAddress = Fr.random(); account = CompleteAddress.fromSecretKeyAndPartialAddress(ownerSk, partialAddress); - ownerIvpkM = account.publicKeys.masterIncomingViewingPublicKey; ({ masterIncomingViewingSecretKey: ownerIvskM, masterOutgoingViewingSecretKey: ownerOvskM } = deriveKeys(ownerSk)); @@ -167,7 +165,7 @@ describe('Note Processor', () => { simulator = mock(); keyStore.getMasterSecretKey.mockImplementation((pkM: PublicKey) => { - if (pkM.equals(ownerIvpkM)) { + if (pkM.equals(account.publicKeys.masterOutgoingViewingPublicKey)) { return Promise.resolve(ownerIvskM); } if (pkM.equals(ownerOvKeys.pkM)) { @@ -201,7 +199,7 @@ describe('Note Processor', () => { 4, 0, 2, - computePoint(account.address), + account.address, KeyValidationRequest.random(), ); @@ -222,7 +220,7 @@ describe('Note Processor', () => { }, 25_000); it('should store an outgoing note that belongs to us', async () => { - const request = new MockNoteRequest(getRandomNoteLogPayload(app), 4, 0, 2, Point.random(), ownerOvKeys); + const request = new MockNoteRequest(getRandomNoteLogPayload(app), 4, 0, 2, CompleteAddress.random().address, ownerOvKeys); const blocks = mockBlocks([request]); await noteProcessor.process(blocks); @@ -234,18 +232,18 @@ describe('Note Processor', () => { it('should store multiple notes that belong to us', async () => { const requests = [ - new MockNoteRequest(getRandomNoteLogPayload(app), 1, 1, 1, computePoint(account.address), ownerOvKeys), - new MockNoteRequest(getRandomNoteLogPayload(app), 2, 3, 0, Point.random(), ownerOvKeys), + new MockNoteRequest(getRandomNoteLogPayload(app), 1, 1, 1, account.address, ownerOvKeys), + new MockNoteRequest(getRandomNoteLogPayload(app), 2, 3, 0, CompleteAddress.random().address, ownerOvKeys), new MockNoteRequest( getRandomNoteLogPayload(app), 6, 3, 2, - computePoint(account.address), + account.address, KeyValidationRequest.random(), ), - new MockNoteRequest(getRandomNoteLogPayload(app), 9, 3, 2, Point.random(), KeyValidationRequest.random()), - new MockNoteRequest(getRandomNoteLogPayload(app), 12, 3, 2, computePoint(account.address), ownerOvKeys), + new MockNoteRequest(getRandomNoteLogPayload(app), 9, 3, 2, CompleteAddress.random().address, KeyValidationRequest.random()), + new MockNoteRequest(getRandomNoteLogPayload(app), 12, 3, 2, account.address, ownerOvKeys), ]; const blocks = mockBlocks(requests); @@ -253,7 +251,7 @@ describe('Note Processor', () => { expect(addNotesSpy).toHaveBeenCalledTimes(1); expect(addNotesSpy).toHaveBeenCalledWith( - // Incoming should contain notes from requests 0, 2, 4 because in those requests we set owner ivpk. + // Incoming should contain notes from requests 0, 2, 4 because in those requests we set owner address point. [ expect.objectContaining({ ...requests[0].snippetOfNoteDao, @@ -281,8 +279,8 @@ describe('Note Processor', () => { it('should not store notes that do not belong to us', async () => { // Both notes should be ignored because the encryption keys do not belong to owner (they are random). const blocks = mockBlocks([ - new MockNoteRequest(getRandomNoteLogPayload(), 2, 1, 1, Point.random(), KeyValidationRequest.random()), - new MockNoteRequest(getRandomNoteLogPayload(), 2, 3, 0, Point.random(), KeyValidationRequest.random()), + new MockNoteRequest(getRandomNoteLogPayload(), 2, 1, 1, CompleteAddress.random().address, KeyValidationRequest.random()), + new MockNoteRequest(getRandomNoteLogPayload(), 2, 3, 0, CompleteAddress.random().address, KeyValidationRequest.random()), ]); await noteProcessor.process(blocks); @@ -294,11 +292,11 @@ describe('Note Processor', () => { const note2 = getRandomNoteLogPayload(app); // All note payloads except one have the same contract address, storage slot, and the actual note. const requests = [ - new MockNoteRequest(note, 3, 0, 0, computePoint(account.address), ownerOvKeys), - new MockNoteRequest(note, 4, 0, 2, computePoint(account.address), ownerOvKeys), - new MockNoteRequest(note, 4, 2, 0, computePoint(account.address), ownerOvKeys), - new MockNoteRequest(note2, 5, 2, 1, computePoint(account.address), ownerOvKeys), - new MockNoteRequest(note, 6, 2, 3, computePoint(account.address), ownerOvKeys), + new MockNoteRequest(note, 3, 0, 0, account.address, ownerOvKeys), + new MockNoteRequest(note, 4, 0, 2, account.address, ownerOvKeys), + new MockNoteRequest(note, 4, 2, 0, account.address, ownerOvKeys), + new MockNoteRequest(note2, 5, 2, 1, account.address, ownerOvKeys), + new MockNoteRequest(note, 6, 2, 3, account.address, ownerOvKeys), ]; const blocks = mockBlocks(requests); @@ -337,7 +335,7 @@ describe('Note Processor', () => { }); it('advances the block number', async () => { - const request = new MockNoteRequest(getRandomNoteLogPayload(), 6, 0, 2, ownerIvpkM, ownerOvKeys); + const request = new MockNoteRequest(getRandomNoteLogPayload(), 6, 0, 2, account.address, ownerOvKeys); const blocks = mockBlocks([request]); await noteProcessor.process(blocks); @@ -351,7 +349,7 @@ describe('Note Processor', () => { 6, 0, 2, - Point.random(), + CompleteAddress.random().address, KeyValidationRequest.random(), ); diff --git a/yarn-project/pxe/src/note_processor/note_processor.ts b/yarn-project/pxe/src/note_processor/note_processor.ts index 2200bbab86c..3540cc9e596 100644 --- a/yarn-project/pxe/src/note_processor/note_processor.ts +++ b/yarn-project/pxe/src/note_processor/note_processor.ts @@ -5,6 +5,7 @@ import { INITIAL_L2_BLOCK_NUM, MAX_NOTE_HASHES_PER_TX, computeAddressSecret, + computePoint, } from '@aztec/circuits.js'; import { type Fr } from '@aztec/foundation/fields'; import { type Logger, createDebugLogger } from '@aztec/foundation/log'; @@ -168,7 +169,7 @@ export class NoteProcessor { await produceNoteDaos( this.simulator, this.db, - incomingNotePayload ? this.account.publicKeys.masterIncomingViewingPublicKey : undefined, + incomingNotePayload ? computePoint(this.account.address) : undefined, outgoingNotePayload ? this.account.publicKeys.masterOutgoingViewingPublicKey : undefined, payload!, txEffect.txHash, @@ -250,10 +251,7 @@ export class NoteProcessor { const nullifiers: Fr[] = blocksAndNotes.flatMap(b => b.block.body.txEffects.flatMap(txEffect => txEffect.nullifiers), ); - const removedNotes = await this.db.removeNullifiedNotes( - nullifiers, - this.account.publicKeys.masterIncomingViewingPublicKey, - ); + const removedNotes = await this.db.removeNullifiedNotes(nullifiers, computePoint(this.account.address)); removedNotes.forEach(noteDao => { this.log.verbose( `Removed note for contract ${noteDao.contractAddress} at slot ${ @@ -312,7 +310,7 @@ export class NoteProcessor { for (const deferredNote of deferredNoteDaos) { const { publicKey, payload, txHash, noteHashes, dataStartIndexForTx, unencryptedLogs } = deferredNote; - const isIncoming = publicKey.equals(this.account.publicKeys.masterIncomingViewingPublicKey); + const isIncoming = publicKey.equals(computePoint(this.account.address)); const isOutgoing = publicKey.equals(this.account.publicKeys.masterOutgoingViewingPublicKey); if (!isIncoming && !isOutgoing) { @@ -323,7 +321,7 @@ export class NoteProcessor { const { incomingNote, outgoingNote } = await produceNoteDaos( this.simulator, this.db, - isIncoming ? this.account.publicKeys.masterIncomingViewingPublicKey : undefined, + isIncoming ? computePoint(this.account.address) : undefined, isOutgoing ? this.account.publicKeys.masterOutgoingViewingPublicKey : undefined, payload, txHash, 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 c2bea391e5d..31b82f878b3 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,19 +125,18 @@ 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())) { + for (const completeAddress of registeredAddresses) { + if (!accountsSet.has(completeAddress.address.toString())) { continue; } count++; - this.synchronizer.addAccount(address, this.keyStore, this.config.l2StartingBlock); + this.synchronizer.addAccount(completeAddress, this.keyStore, this.config.l2StartingBlock); } if (count > 0) { @@ -306,11 +306,11 @@ export class PXEService implements PXE { const extendedNotes = noteDaos.map(async dao => { let owner = filter.owner; if (owner === undefined) { - const completeAddresses = (await this.db.getCompleteAddresses()).find(address => - address.publicKeys.masterIncomingViewingPublicKey.equals(dao.ivpkM), + const completeAddresses = (await this.db.getCompleteAddresses()).find(completeAddress => + computePoint(completeAddress.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,11 +413,6 @@ 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 nonces = await this.#getNoteNonces(note); if (nonces.length === 0) { throw new Error(`Cannot find the note in tx: ${note.txHash}.`); @@ -453,7 +448,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 8c9bcd14e42..b2cfd71928e 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