@aztec/pxe 0.70.0 → 0.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dest/config/index.d.ts.map +1 -1
  2. package/dest/config/index.js +3 -3
  3. package/dest/database/kv_pxe_database.d.ts +4 -2
  4. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  5. package/dest/database/kv_pxe_database.js +32 -10
  6. package/dest/database/note_dao.d.ts +1 -3
  7. package/dest/database/note_dao.d.ts.map +1 -1
  8. package/dest/database/note_dao.js +1 -5
  9. package/dest/database/outgoing_note_dao.d.ts +1 -3
  10. package/dest/database/outgoing_note_dao.d.ts.map +1 -1
  11. package/dest/database/outgoing_note_dao.js +1 -5
  12. package/dest/database/pxe_database.d.ts +29 -12
  13. package/dest/database/pxe_database.d.ts.map +1 -1
  14. package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
  15. package/dest/database/pxe_database_test_suite.js +93 -20
  16. package/dest/note_decryption_utils/add_public_values_to_payload.js +2 -2
  17. package/dest/simulator_oracle/index.d.ts +12 -20
  18. package/dest/simulator_oracle/index.d.ts.map +1 -1
  19. package/dest/simulator_oracle/index.js +99 -59
  20. package/package.json +14 -14
  21. package/src/config/index.ts +2 -1
  22. package/src/database/kv_pxe_database.ts +40 -8
  23. package/src/database/note_dao.ts +1 -29
  24. package/src/database/outgoing_note_dao.ts +1 -28
  25. package/src/database/pxe_database.ts +31 -12
  26. package/src/database/pxe_database_test_suite.ts +118 -19
  27. package/src/note_decryption_utils/add_public_values_to_payload.ts +1 -1
  28. package/src/simulator_oracle/index.ts +198 -77
  29. package/dest/note_decryption_utils/brute_force_note_info.d.ts +0 -31
  30. package/dest/note_decryption_utils/brute_force_note_info.d.ts.map +0 -1
  31. package/dest/note_decryption_utils/brute_force_note_info.js +0 -54
  32. package/dest/note_decryption_utils/index.d.ts +0 -3
  33. package/dest/note_decryption_utils/index.d.ts.map +0 -1
  34. package/dest/note_decryption_utils/index.js +0 -2
  35. package/dest/note_decryption_utils/produce_note_daos.d.ts +0 -28
  36. package/dest/note_decryption_utils/produce_note_daos.d.ts.map +0 -1
  37. package/dest/note_decryption_utils/produce_note_daos.js +0 -33
  38. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts +0 -8
  39. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts.map +0 -1
  40. package/dest/note_decryption_utils/produce_note_daos_for_key.js +0 -17
  41. package/src/note_decryption_utils/brute_force_note_info.ts +0 -90
  42. package/src/note_decryption_utils/index.ts +0 -2
  43. package/src/note_decryption_utils/produce_note_daos.ts +0 -69
  44. package/src/note_decryption_utils/produce_note_daos_for_key.ts +0 -59
@@ -1,28 +0,0 @@
1
- import { type L1NotePayload, type PublicKey, type TxHash } from '@aztec/circuit-types';
2
- import { type Fr } from '@aztec/foundation/fields';
3
- import { type Logger } from '@aztec/foundation/log';
4
- import { type AcirSimulator } from '@aztec/simulator/client';
5
- import { NoteDao } from '../database/note_dao.js';
6
- import { type PxeDatabase } from '../database/pxe_database.js';
7
- /**
8
- * Decodes a note from a transaction that we know was intended for us.
9
- * Throws if we do not yet have the contract corresponding to the note in our database.
10
- * Accepts a set of excluded indices, which are indices that have been assigned a note in the same tx.
11
- * Inserts the index of the note into the excludedIndices set if the note is successfully decoded.
12
- *
13
- * @param simulator - An instance of AcirSimulator.
14
- * @param db - An instance of PxeDatabase.
15
- * @param addressPoint - The public counterpart to the address secret, which is used in the decryption of incoming note logs.
16
- * @param payload - An instance of l1NotePayload.
17
- * @param txHash - The hash of the transaction that created the note. Equivalent to the first nullifier of the transaction.
18
- * @param noteHashes - New note hashes in this transaction, one of which belongs to this note.
19
- * @param dataStartIndexForTx - The next available leaf index for the note hash tree for this transaction.
20
- * @param excludedIndices - Indices that have been assigned a note in the same tx. Notes in a tx can have the same l1NotePayload, we need to find a different index for each replicate.
21
- * @param logger - An instance of Logger.
22
- * @param unencryptedLogs - Unencrypted logs for the transaction (used to complete partial notes).
23
- * @returns An object containing the incoming notes.
24
- */
25
- export declare function produceNoteDaos(simulator: AcirSimulator, db: PxeDatabase, addressPoint: PublicKey | undefined, payload: L1NotePayload, txHash: TxHash, firstNullifier: Fr, l2BlockNumber: number, l2BlockHash: string, noteHashes: Fr[], dataStartIndexForTx: number, excludedIndices: Set<number>, logger: Logger): Promise<{
26
- note: NoteDao | undefined;
27
- }>;
28
- //# sourceMappingURL=produce_note_daos.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"produce_note_daos.d.ts","sourceRoot":"","sources":["../../src/note_decryption_utils/produce_note_daos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,aAAa,EACxB,EAAE,EAAE,WAAW,EACf,YAAY,EAAE,SAAS,GAAG,SAAS,EACnC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,EAAE,EAClB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,EAAE,EAAE,EAChB,mBAAmB,EAAE,MAAM,EAC3B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,EAC5B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,CAAC,CA4BxC"}
@@ -1,33 +0,0 @@
1
- import { NoteDao } from '../database/note_dao.js';
2
- import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
3
- /**
4
- * Decodes a note from a transaction that we know was intended for us.
5
- * Throws if we do not yet have the contract corresponding to the note in our database.
6
- * Accepts a set of excluded indices, which are indices that have been assigned a note in the same tx.
7
- * Inserts the index of the note into the excludedIndices set if the note is successfully decoded.
8
- *
9
- * @param simulator - An instance of AcirSimulator.
10
- * @param db - An instance of PxeDatabase.
11
- * @param addressPoint - The public counterpart to the address secret, which is used in the decryption of incoming note logs.
12
- * @param payload - An instance of l1NotePayload.
13
- * @param txHash - The hash of the transaction that created the note. Equivalent to the first nullifier of the transaction.
14
- * @param noteHashes - New note hashes in this transaction, one of which belongs to this note.
15
- * @param dataStartIndexForTx - The next available leaf index for the note hash tree for this transaction.
16
- * @param excludedIndices - Indices that have been assigned a note in the same tx. Notes in a tx can have the same l1NotePayload, we need to find a different index for each replicate.
17
- * @param logger - An instance of Logger.
18
- * @param unencryptedLogs - Unencrypted logs for the transaction (used to complete partial notes).
19
- * @returns An object containing the incoming notes.
20
- */
21
- export async function produceNoteDaos(simulator, db, addressPoint, payload, txHash, firstNullifier, l2BlockNumber, l2BlockHash, noteHashes, dataStartIndexForTx, excludedIndices, logger) {
22
- if (!addressPoint) {
23
- throw new Error('addressPoint is undefined. Cannot create note.');
24
- }
25
- let note;
26
- if (addressPoint) {
27
- note = await produceNoteDaosForKey(simulator, db, addressPoint, payload, txHash, firstNullifier, l2BlockNumber, l2BlockHash, noteHashes, dataStartIndexForTx, excludedIndices, logger, NoteDao.fromPayloadAndNoteInfo);
28
- }
29
- return {
30
- note,
31
- };
32
- }
33
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZHVjZV9ub3RlX2Rhb3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbm90ZV9kZWNyeXB0aW9uX3V0aWxzL3Byb2R1Y2Vfbm90ZV9kYW9zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUVsRCxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUV2RTs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FpQkc7QUFDSCxNQUFNLENBQUMsS0FBSyxVQUFVLGVBQWUsQ0FDbkMsU0FBd0IsRUFDeEIsRUFBZSxFQUNmLFlBQW1DLEVBQ25DLE9BQXNCLEVBQ3RCLE1BQWMsRUFDZCxjQUFrQixFQUNsQixhQUFxQixFQUNyQixXQUFtQixFQUNuQixVQUFnQixFQUNoQixtQkFBMkIsRUFDM0IsZUFBNEIsRUFDNUIsTUFBYztJQUVkLElBQUksQ0FBQyxZQUFZLEVBQUUsQ0FBQztRQUNsQixNQUFNLElBQUksS0FBSyxDQUFDLGdEQUFnRCxDQUFDLENBQUM7SUFDcEUsQ0FBQztJQUVELElBQUksSUFBeUIsQ0FBQztJQUU5QixJQUFJLFlBQVksRUFBRSxDQUFDO1FBQ2pCLElBQUksR0FBRyxNQUFNLHFCQUFxQixDQUNoQyxTQUFTLEVBQ1QsRUFBRSxFQUNGLFlBQVksRUFDWixPQUFPLEVBQ1AsTUFBTSxFQUNOLGNBQWMsRUFDZCxhQUFhLEVBQ2IsV0FBVyxFQUNYLFVBQVUsRUFDVixtQkFBbUIsRUFDbkIsZUFBZSxFQUNmLE1BQU0sRUFDTixPQUFPLENBQUMsc0JBQXNCLENBQy9CLENBQUM7SUFDSixDQUFDO0lBRUQsT0FBTztRQUNMLElBQUk7S0FDTCxDQUFDO0FBQ0osQ0FBQyJ9
@@ -1,8 +0,0 @@
1
- import { type L1NotePayload, type Note, type TxHash } from '@aztec/circuit-types';
2
- import { type Fr, type PublicKey } from '@aztec/circuits.js';
3
- import { type Logger } from '@aztec/foundation/log';
4
- import { type AcirSimulator } from '@aztec/simulator/client';
5
- import { type PxeDatabase } from '../database/pxe_database.js';
6
- import { type NoteInfo } from './brute_force_note_info.js';
7
- export declare function produceNoteDaosForKey<T>(simulator: AcirSimulator, db: PxeDatabase, pkM: PublicKey, payload: L1NotePayload, txHash: TxHash, firstNullifier: Fr, l2BlockNumber: number, l2BlockHash: string, noteHashes: Fr[], dataStartIndexForTx: number, excludedIndices: Set<number>, logger: Logger, daoConstructor: (note: Note, payload: L1NotePayload, noteInfo: NoteInfo, l2BlockNumber: number, l2BlockHash: string, dataStartIndexForTx: number, pkM: PublicKey) => T): Promise<T | undefined>;
8
- //# sourceMappingURL=produce_note_daos_for_key.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"produce_note_daos_for_key.d.ts","sourceRoot":"","sources":["../../src/note_decryption_utils/produce_note_daos_for_key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,KAAK,QAAQ,EAAsB,MAAM,4BAA4B,CAAC;AAE/E,wBAAsB,qBAAqB,CAAC,CAAC,EAC3C,SAAS,EAAE,aAAa,EACxB,EAAE,EAAE,WAAW,EACf,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,EAAE,EAClB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,EAAE,EAAE,EAChB,mBAAmB,EAAE,MAAM,EAC3B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,EAC5B,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,CACd,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,MAAM,EAC3B,GAAG,EAAE,SAAS,KACX,CAAC,GACL,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CA2BxB"}
@@ -1,17 +0,0 @@
1
- import { getOrderedNoteItems } from './add_public_values_to_payload.js';
2
- import { bruteForceNoteInfo } from './brute_force_note_info.js';
3
- export async function produceNoteDaosForKey(simulator, db, pkM, payload, txHash, firstNullifier, l2BlockNumber, l2BlockHash, noteHashes, dataStartIndexForTx, excludedIndices, logger, daoConstructor) {
4
- let noteDao;
5
- try {
6
- // We get the note by merging publicly and privately delivered note values.
7
- const note = await getOrderedNoteItems(db, payload);
8
- const noteInfo = await bruteForceNoteInfo(simulator, noteHashes, txHash, firstNullifier, payload.contractAddress, payload.storageSlot, payload.noteTypeId, note, excludedIndices, true);
9
- excludedIndices?.add(noteInfo.noteHashIndex);
10
- noteDao = daoConstructor(note, payload, noteInfo, l2BlockNumber, l2BlockHash, dataStartIndexForTx, pkM);
11
- }
12
- catch (e) {
13
- logger.error(`Could not process note because of "${e}". Discarding note...`);
14
- }
15
- return noteDao;
16
- }
17
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZHVjZV9ub3RlX2Rhb3NfZm9yX2tleS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ub3RlX2RlY3J5cHRpb25fdXRpbHMvcHJvZHVjZV9ub3RlX2Rhb3NfZm9yX2tleS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUN4RSxPQUFPLEVBQWlCLGtCQUFrQixFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFFL0UsTUFBTSxDQUFDLEtBQUssVUFBVSxxQkFBcUIsQ0FDekMsU0FBd0IsRUFDeEIsRUFBZSxFQUNmLEdBQWMsRUFDZCxPQUFzQixFQUN0QixNQUFjLEVBQ2QsY0FBa0IsRUFDbEIsYUFBcUIsRUFDckIsV0FBbUIsRUFDbkIsVUFBZ0IsRUFDaEIsbUJBQTJCLEVBQzNCLGVBQTRCLEVBQzVCLE1BQWMsRUFDZCxjQVFNO0lBRU4sSUFBSSxPQUFzQixDQUFDO0lBRTNCLElBQUksQ0FBQztRQUNILDJFQUEyRTtRQUMzRSxNQUFNLElBQUksR0FBRyxNQUFNLG1CQUFtQixDQUFDLEVBQUUsRUFBRSxPQUFPLENBQUMsQ0FBQztRQUVwRCxNQUFNLFFBQVEsR0FBRyxNQUFNLGtCQUFrQixDQUN2QyxTQUFTLEVBQ1QsVUFBVSxFQUNWLE1BQU0sRUFDTixjQUFjLEVBQ2QsT0FBTyxDQUFDLGVBQWUsRUFDdkIsT0FBTyxDQUFDLFdBQVcsRUFDbkIsT0FBTyxDQUFDLFVBQVUsRUFDbEIsSUFBSSxFQUNKLGVBQWUsRUFDZixJQUFJLENBQ0wsQ0FBQztRQUNGLGVBQWUsRUFBRSxHQUFHLENBQUMsUUFBUSxDQUFDLGFBQWEsQ0FBQyxDQUFDO1FBRTdDLE9BQU8sR0FBRyxjQUFjLENBQUMsSUFBSSxFQUFFLE9BQU8sRUFBRSxRQUFRLEVBQUUsYUFBYSxFQUFFLFdBQVcsRUFBRSxtQkFBbUIsRUFBRSxHQUFHLENBQUMsQ0FBQztJQUMxRyxDQUFDO0lBQUMsT0FBTyxDQUFDLEVBQUUsQ0FBQztRQUNYLE1BQU0sQ0FBQyxLQUFLLENBQUMsc0NBQXNDLENBQUMsdUJBQXVCLENBQUMsQ0FBQztJQUMvRSxDQUFDO0lBRUQsT0FBTyxPQUFPLENBQUM7QUFDakIsQ0FBQyJ9
@@ -1,90 +0,0 @@
1
- import { type Note, type TxHash } from '@aztec/circuit-types';
2
- import { type AztecAddress } from '@aztec/circuits.js';
3
- import { computeNoteHashNonce, siloNullifier } from '@aztec/circuits.js/hash';
4
- import { type NoteSelector } from '@aztec/foundation/abi';
5
- import { Fr } from '@aztec/foundation/fields';
6
- import { type AcirSimulator } from '@aztec/simulator/client';
7
-
8
- export interface NoteInfo {
9
- noteHashIndex: number;
10
- nonce: Fr;
11
- noteHash: Fr;
12
- siloedNullifier: Fr;
13
- txHash: TxHash;
14
- }
15
-
16
- /**
17
- * Finds nonce, index, inner hash and siloed nullifier for a given note.
18
- * @dev Finds the index in the note hash tree by computing the note hash with different nonce and see which hash for
19
- * the current tx matches this value.
20
- * @remarks This method assists in identifying spent notes in the note hash tree.
21
- * @param uniqueNoteHashes - Note hashes in the tx. One of them should correspond to the note we are looking for
22
- * @param txHash - Hash of a tx the note was emitted in.
23
- * @param contractAddress - Address of the contract the note was emitted in.
24
- * @param storageSlot - Storage slot of the note.
25
- * @param noteTypeId - Type of the note.
26
- * @param note - Note items.
27
- * @param excludedIndices - Indices that have been assigned a note in the same tx. Notes in a tx can have the same
28
- * l1NotePayload. We need to find a different index for each replicate.
29
- * @param computeNullifier - A flag indicating whether to compute the nullifier or just return 0.
30
- * @returns Nonce, index, inner hash and siloed nullifier for a given note.
31
- * @throws If cannot find the nonce for the note.
32
- */
33
- export async function bruteForceNoteInfo(
34
- simulator: AcirSimulator,
35
- uniqueNoteHashes: Fr[],
36
- txHash: TxHash,
37
- firstNullifier: Fr,
38
- contractAddress: AztecAddress,
39
- storageSlot: Fr,
40
- noteTypeId: NoteSelector,
41
- note: Note,
42
- excludedIndices: Set<number>,
43
- computeNullifier: boolean,
44
- ): Promise<NoteInfo> {
45
- let noteHashIndex = 0;
46
- let nonce: Fr | undefined;
47
- let noteHash: Fr | undefined;
48
- let uniqueNoteHash: Fr | undefined;
49
- let innerNullifier: Fr | undefined;
50
-
51
- for (; noteHashIndex < uniqueNoteHashes.length; ++noteHashIndex) {
52
- if (excludedIndices.has(noteHashIndex)) {
53
- continue;
54
- }
55
-
56
- const uniqueNoteHashFromTxEffect = uniqueNoteHashes[noteHashIndex];
57
- if (uniqueNoteHashFromTxEffect.equals(Fr.ZERO)) {
58
- break;
59
- }
60
-
61
- const expectedNonce = computeNoteHashNonce(firstNullifier, noteHashIndex);
62
- ({ noteHash, uniqueNoteHash, innerNullifier } = await simulator.computeNoteHashAndOptionallyANullifier(
63
- contractAddress,
64
- expectedNonce,
65
- storageSlot,
66
- noteTypeId,
67
- computeNullifier,
68
- note,
69
- ));
70
-
71
- if (uniqueNoteHashFromTxEffect.equals(uniqueNoteHash)) {
72
- nonce = expectedNonce;
73
- break;
74
- }
75
- }
76
-
77
- if (!nonce) {
78
- // NB: this used to warn the user that a decrypted log didn't match any notes.
79
- // This was previously fine as we didn't chop transient note logs, but now we do (#1641 complete).
80
- throw new Error('Cannot find a matching note hash for the note.');
81
- }
82
-
83
- return {
84
- noteHashIndex,
85
- nonce,
86
- noteHash: noteHash!,
87
- siloedNullifier: siloNullifier(contractAddress, innerNullifier!),
88
- txHash,
89
- };
90
- }
@@ -1,2 +0,0 @@
1
- export { produceNoteDaos } from './produce_note_daos.js';
2
- export { NoteInfo } from './brute_force_note_info.js';
@@ -1,69 +0,0 @@
1
- import { type L1NotePayload, type PublicKey, type TxHash } from '@aztec/circuit-types';
2
- import { type Fr } from '@aztec/foundation/fields';
3
- import { type Logger } from '@aztec/foundation/log';
4
- import { type AcirSimulator } from '@aztec/simulator/client';
5
-
6
- import { NoteDao } from '../database/note_dao.js';
7
- import { type PxeDatabase } from '../database/pxe_database.js';
8
- import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
9
-
10
- /**
11
- * Decodes a note from a transaction that we know was intended for us.
12
- * Throws if we do not yet have the contract corresponding to the note in our database.
13
- * Accepts a set of excluded indices, which are indices that have been assigned a note in the same tx.
14
- * Inserts the index of the note into the excludedIndices set if the note is successfully decoded.
15
- *
16
- * @param simulator - An instance of AcirSimulator.
17
- * @param db - An instance of PxeDatabase.
18
- * @param addressPoint - The public counterpart to the address secret, which is used in the decryption of incoming note logs.
19
- * @param payload - An instance of l1NotePayload.
20
- * @param txHash - The hash of the transaction that created the note. Equivalent to the first nullifier of the transaction.
21
- * @param noteHashes - New note hashes in this transaction, one of which belongs to this note.
22
- * @param dataStartIndexForTx - The next available leaf index for the note hash tree for this transaction.
23
- * @param excludedIndices - Indices that have been assigned a note in the same tx. Notes in a tx can have the same l1NotePayload, we need to find a different index for each replicate.
24
- * @param logger - An instance of Logger.
25
- * @param unencryptedLogs - Unencrypted logs for the transaction (used to complete partial notes).
26
- * @returns An object containing the incoming notes.
27
- */
28
- export async function produceNoteDaos(
29
- simulator: AcirSimulator,
30
- db: PxeDatabase,
31
- addressPoint: PublicKey | undefined,
32
- payload: L1NotePayload,
33
- txHash: TxHash,
34
- firstNullifier: Fr,
35
- l2BlockNumber: number,
36
- l2BlockHash: string,
37
- noteHashes: Fr[],
38
- dataStartIndexForTx: number,
39
- excludedIndices: Set<number>,
40
- logger: Logger,
41
- ): Promise<{ note: NoteDao | undefined }> {
42
- if (!addressPoint) {
43
- throw new Error('addressPoint is undefined. Cannot create note.');
44
- }
45
-
46
- let note: NoteDao | undefined;
47
-
48
- if (addressPoint) {
49
- note = await produceNoteDaosForKey(
50
- simulator,
51
- db,
52
- addressPoint,
53
- payload,
54
- txHash,
55
- firstNullifier,
56
- l2BlockNumber,
57
- l2BlockHash,
58
- noteHashes,
59
- dataStartIndexForTx,
60
- excludedIndices,
61
- logger,
62
- NoteDao.fromPayloadAndNoteInfo,
63
- );
64
- }
65
-
66
- return {
67
- note,
68
- };
69
- }
@@ -1,59 +0,0 @@
1
- import { type L1NotePayload, type Note, type TxHash } from '@aztec/circuit-types';
2
- import { type Fr, type PublicKey } from '@aztec/circuits.js';
3
- import { type Logger } from '@aztec/foundation/log';
4
- import { type AcirSimulator } from '@aztec/simulator/client';
5
-
6
- import { type PxeDatabase } from '../database/pxe_database.js';
7
- import { getOrderedNoteItems } from './add_public_values_to_payload.js';
8
- import { type NoteInfo, bruteForceNoteInfo } from './brute_force_note_info.js';
9
-
10
- export async function produceNoteDaosForKey<T>(
11
- simulator: AcirSimulator,
12
- db: PxeDatabase,
13
- pkM: PublicKey,
14
- payload: L1NotePayload,
15
- txHash: TxHash,
16
- firstNullifier: Fr,
17
- l2BlockNumber: number,
18
- l2BlockHash: string,
19
- noteHashes: Fr[],
20
- dataStartIndexForTx: number,
21
- excludedIndices: Set<number>,
22
- logger: Logger,
23
- daoConstructor: (
24
- note: Note,
25
- payload: L1NotePayload,
26
- noteInfo: NoteInfo,
27
- l2BlockNumber: number,
28
- l2BlockHash: string,
29
- dataStartIndexForTx: number,
30
- pkM: PublicKey,
31
- ) => T,
32
- ): Promise<T | undefined> {
33
- let noteDao: T | undefined;
34
-
35
- try {
36
- // We get the note by merging publicly and privately delivered note values.
37
- const note = await getOrderedNoteItems(db, payload);
38
-
39
- const noteInfo = await bruteForceNoteInfo(
40
- simulator,
41
- noteHashes,
42
- txHash,
43
- firstNullifier,
44
- payload.contractAddress,
45
- payload.storageSlot,
46
- payload.noteTypeId,
47
- note,
48
- excludedIndices,
49
- true, // For incoming we compute a nullifier (recipient of incoming is the party that nullifies).
50
- );
51
- excludedIndices?.add(noteInfo.noteHashIndex);
52
-
53
- noteDao = daoConstructor(note, payload, noteInfo, l2BlockNumber, l2BlockHash, dataStartIndexForTx, pkM);
54
- } catch (e) {
55
- logger.error(`Could not process note because of "${e}". Discarding note...`);
56
- }
57
-
58
- return noteDao;
59
- }