@aztec/stdlib 0.80.0 → 0.82.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 (201) hide show
  1. package/dest/abi/abi.d.ts +5 -1
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +2 -1
  4. package/dest/abi/contract_artifact.d.ts.map +1 -1
  5. package/dest/abi/contract_artifact.js +11 -0
  6. package/dest/auth_witness/auth_witness.d.ts +21 -0
  7. package/dest/auth_witness/auth_witness.d.ts.map +1 -1
  8. package/dest/auth_witness/auth_witness.js +29 -0
  9. package/dest/avm/avm.d.ts +173 -405
  10. package/dest/avm/avm.d.ts.map +1 -1
  11. package/dest/avm/avm.js +34 -27
  12. package/dest/avm/avm_proving_request.d.ts +84 -186
  13. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  14. package/dest/avm/public_data_write.d.ts +1 -0
  15. package/dest/avm/public_data_write.d.ts.map +1 -1
  16. package/dest/avm/public_data_write.js +3 -0
  17. package/dest/block/body.d.ts +1 -0
  18. package/dest/block/body.d.ts.map +1 -1
  19. package/dest/block/body.js +3 -0
  20. package/dest/block/index.d.ts +1 -1
  21. package/dest/block/index.d.ts.map +1 -1
  22. package/dest/block/index.js +1 -1
  23. package/dest/block/l2_block.d.ts +2 -1
  24. package/dest/block/l2_block.d.ts.map +1 -1
  25. package/dest/block/l2_block.js +3 -0
  26. package/dest/block/l2_block_downloader/l2_block_stream.d.ts +3 -3
  27. package/dest/block/l2_block_downloader/l2_block_stream.d.ts.map +1 -1
  28. package/dest/block/l2_block_downloader/l2_block_stream.js +2 -4
  29. package/dest/block/l2_block_source.d.ts +9 -0
  30. package/dest/block/l2_block_source.d.ts.map +1 -1
  31. package/dest/block/published_l2_block.d.ts +89 -0
  32. package/dest/block/published_l2_block.d.ts.map +1 -0
  33. package/dest/block/published_l2_block.js +32 -0
  34. package/dest/contract/interfaces/contract_data_source.d.ts +3 -14
  35. package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
  36. package/dest/database-version/version_manager.d.ts +5 -0
  37. package/dest/database-version/version_manager.d.ts.map +1 -1
  38. package/dest/database-version/version_manager.js +8 -1
  39. package/dest/interfaces/archiver.d.ts +1 -2
  40. package/dest/interfaces/archiver.d.ts.map +1 -1
  41. package/dest/interfaces/archiver.js +5 -6
  42. package/dest/interfaces/aztec-node-admin.d.ts +20 -0
  43. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -0
  44. package/dest/interfaces/aztec-node-admin.js +16 -0
  45. package/dest/interfaces/aztec-node.d.ts +9 -39
  46. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  47. package/dest/interfaces/aztec-node.js +6 -12
  48. package/dest/interfaces/client.d.ts +1 -0
  49. package/dest/interfaces/client.d.ts.map +1 -1
  50. package/dest/interfaces/client.js +1 -0
  51. package/dest/interfaces/private_kernel_prover.d.ts +2 -3
  52. package/dest/interfaces/private_kernel_prover.d.ts.map +1 -1
  53. package/dest/interfaces/prover-node.d.ts +1 -2
  54. package/dest/interfaces/prover-node.d.ts.map +1 -1
  55. package/dest/interfaces/prover-node.js +5 -4
  56. package/dest/interfaces/proving-job.d.ts +106 -208
  57. package/dest/interfaces/proving-job.d.ts.map +1 -1
  58. package/dest/interfaces/pxe.d.ts +21 -39
  59. package/dest/interfaces/pxe.d.ts.map +1 -1
  60. package/dest/interfaces/pxe.js +10 -9
  61. package/dest/kernel/index.d.ts +1 -1
  62. package/dest/kernel/index.d.ts.map +1 -1
  63. package/dest/kernel/index.js +1 -1
  64. package/dest/kernel/private_kernel_prover_output.d.ts +49 -0
  65. package/dest/kernel/private_kernel_prover_output.d.ts.map +1 -0
  66. package/dest/kernel/private_kernel_prover_output.js +8 -0
  67. package/dest/kernel/private_kernel_simulated_output.d.ts +3 -7
  68. package/dest/kernel/private_kernel_simulated_output.d.ts.map +1 -1
  69. package/dest/logs/contract_class_log.d.ts +1 -0
  70. package/dest/logs/contract_class_log.d.ts.map +1 -1
  71. package/dest/logs/contract_class_log.js +3 -0
  72. package/dest/logs/l1_payload/index.d.ts +1 -1
  73. package/dest/logs/l1_payload/index.d.ts.map +1 -1
  74. package/dest/logs/l1_payload/index.js +1 -1
  75. package/dest/logs/log_with_tx_data.js +2 -2
  76. package/dest/logs/private_log.d.ts +2 -1
  77. package/dest/logs/private_log.d.ts.map +1 -1
  78. package/dest/logs/private_log.js +14 -3
  79. package/dest/logs/public_log.d.ts.map +1 -1
  80. package/dest/logs/public_log.js +4 -1
  81. package/dest/logs/tx_scoped_l2_log.d.ts +16 -28
  82. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  83. package/dest/logs/tx_scoped_l2_log.js +28 -19
  84. package/dest/noir/index.d.ts +5 -1
  85. package/dest/noir/index.d.ts.map +1 -1
  86. package/dest/note/extended_note.d.ts +10 -21
  87. package/dest/note/extended_note.d.ts.map +1 -1
  88. package/dest/note/extended_note.js +19 -28
  89. package/dest/note/notes_filter.d.ts +2 -2
  90. package/dest/note/notes_filter.d.ts.map +1 -1
  91. package/dest/note/notes_filter.js +1 -1
  92. package/dest/p2p/consensus_payload.d.ts +3 -1
  93. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  94. package/dest/p2p/consensus_payload.js +3 -0
  95. package/dest/proofs/client_ivc_proof.d.ts +1 -2
  96. package/dest/proofs/client_ivc_proof.d.ts.map +1 -1
  97. package/dest/proofs/client_ivc_proof.js +6 -9
  98. package/dest/proofs/proof.d.ts +0 -1
  99. package/dest/proofs/proof.d.ts.map +1 -1
  100. package/dest/proofs/proof.js +2 -7
  101. package/dest/rollup/block_root_rollup.d.ts +1 -1
  102. package/dest/rollup/tube_inputs.d.ts +7 -2
  103. package/dest/rollup/tube_inputs.d.ts.map +1 -1
  104. package/dest/rollup/tube_inputs.js +10 -4
  105. package/dest/tests/factories.d.ts +3 -2
  106. package/dest/tests/factories.d.ts.map +1 -1
  107. package/dest/tests/factories.js +14 -8
  108. package/dest/tests/mocks.d.ts +2 -2
  109. package/dest/tests/mocks.d.ts.map +1 -1
  110. package/dest/tests/mocks.js +4 -5
  111. package/dest/trees/nullifier_membership_witness.d.ts +11 -7
  112. package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
  113. package/dest/trees/nullifier_membership_witness.js +10 -0
  114. package/dest/trees/public_data_witness.d.ts +12 -12
  115. package/dest/trees/public_data_witness.d.ts.map +1 -1
  116. package/dest/trees/public_data_witness.js +13 -0
  117. package/dest/tx/capsule.d.ts +2 -0
  118. package/dest/tx/capsule.d.ts.map +1 -1
  119. package/dest/tx/capsule.js +2 -0
  120. package/dest/tx/index.d.ts +2 -0
  121. package/dest/tx/index.d.ts.map +1 -1
  122. package/dest/tx/index.js +2 -0
  123. package/dest/tx/private_execution_result.d.ts +4 -0
  124. package/dest/tx/private_execution_result.d.ts.map +1 -1
  125. package/dest/tx/private_execution_result.js +5 -0
  126. package/dest/tx/profiled_tx.d.ts +9 -0
  127. package/dest/tx/profiled_tx.d.ts.map +1 -0
  128. package/dest/tx/profiled_tx.js +27 -0
  129. package/dest/tx/proven_tx.d.ts +33 -0
  130. package/dest/tx/proven_tx.d.ts.map +1 -0
  131. package/dest/tx/proven_tx.js +35 -0
  132. package/dest/tx/simulated_tx.d.ts +8 -44
  133. package/dest/tx/simulated_tx.d.ts.map +1 -1
  134. package/dest/tx/simulated_tx.js +17 -40
  135. package/dest/tx/tx_effect.d.ts +1 -0
  136. package/dest/tx/tx_effect.d.ts.map +1 -1
  137. package/dest/tx/tx_effect.js +4 -1
  138. package/dest/tx/tx_receipt.d.ts +1 -30
  139. package/dest/tx/tx_receipt.d.ts.map +1 -1
  140. package/dest/tx/tx_receipt.js +3 -13
  141. package/package.json +6 -7
  142. package/src/abi/abi.ts +7 -2
  143. package/src/abi/contract_artifact.ts +11 -0
  144. package/src/auth_witness/auth_witness.ts +29 -0
  145. package/src/avm/avm.ts +42 -39
  146. package/src/avm/public_data_write.ts +4 -0
  147. package/src/block/body.ts +6 -0
  148. package/src/block/index.ts +1 -1
  149. package/src/block/l2_block.ts +4 -0
  150. package/src/block/l2_block_downloader/l2_block_stream.ts +5 -7
  151. package/src/block/l2_block_source.ts +11 -0
  152. package/src/block/published_l2_block.ts +45 -0
  153. package/src/contract/interfaces/contract_data_source.ts +3 -16
  154. package/src/database-version/version_manager.ts +11 -1
  155. package/src/interfaces/archiver.ts +11 -14
  156. package/src/interfaces/aztec-node-admin.ts +39 -0
  157. package/src/interfaces/aztec-node.ts +13 -72
  158. package/src/interfaces/client.ts +1 -0
  159. package/src/interfaces/private_kernel_prover.ts +2 -3
  160. package/src/interfaces/prover-node.ts +2 -4
  161. package/src/interfaces/pxe.ts +34 -56
  162. package/src/kernel/index.ts +1 -1
  163. package/src/kernel/private_kernel_prover_output.ts +44 -0
  164. package/src/kernel/private_kernel_simulated_output.ts +4 -13
  165. package/src/logs/contract_class_log.ts +8 -0
  166. package/src/logs/l1_payload/index.ts +1 -1
  167. package/src/logs/log_with_tx_data.ts +2 -2
  168. package/src/logs/private_log.ts +13 -3
  169. package/src/logs/public_log.ts +11 -1
  170. package/src/logs/tx_scoped_l2_log.ts +28 -25
  171. package/src/noir/index.ts +6 -1
  172. package/src/note/extended_note.ts +17 -36
  173. package/src/note/notes_filter.ts +3 -3
  174. package/src/p2p/consensus_payload.ts +9 -0
  175. package/src/proofs/client_ivc_proof.ts +5 -15
  176. package/src/proofs/proof.ts +2 -8
  177. package/src/rollup/tube_inputs.ts +8 -4
  178. package/src/tests/factories.ts +15 -14
  179. package/src/tests/mocks.ts +4 -9
  180. package/src/trees/nullifier_membership_witness.ts +12 -0
  181. package/src/trees/public_data_witness.ts +15 -0
  182. package/src/tx/capsule.ts +2 -0
  183. package/src/tx/index.ts +2 -0
  184. package/src/tx/private_execution_result.ts +7 -0
  185. package/src/tx/profiled_tx.ts +27 -0
  186. package/src/tx/proven_tx.ts +58 -0
  187. package/src/tx/simulated_tx.ts +11 -63
  188. package/src/tx/tx_effect.ts +23 -1
  189. package/src/tx/tx_receipt.ts +0 -36
  190. package/dest/block/nullifier_with_block_source.d.ts +0 -6
  191. package/dest/block/nullifier_with_block_source.d.ts.map +0 -1
  192. package/dest/block/nullifier_with_block_source.js +0 -1
  193. package/dest/kernel/private_kernel_prover_profile_result.d.ts +0 -25
  194. package/dest/kernel/private_kernel_prover_profile_result.d.ts.map +0 -1
  195. package/dest/kernel/private_kernel_prover_profile_result.js +0 -7
  196. package/dest/logs/l1_payload/l1_note_payload.d.ts +0 -82
  197. package/dest/logs/l1_payload/l1_note_payload.d.ts.map +0 -1
  198. package/dest/logs/l1_payload/l1_note_payload.js +0 -129
  199. package/src/block/nullifier_with_block_source.ts +0 -7
  200. package/src/kernel/private_kernel_prover_profile_result.ts +0 -7
  201. package/src/logs/l1_payload/l1_note_payload.ts +0 -182
@@ -1 +0,0 @@
1
- {"version":3,"file":"nullifier_with_block_source.d.ts","sourceRoot":"","sources":["../../src/block/nullifier_with_block_source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,WAAW,wBAAwB;IACvC,8BAA8B,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;CACjH"}
@@ -1 +0,0 @@
1
- export { };
@@ -1,25 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const PrivateKernelProverProfileResultSchema: z.ZodObject<{
3
- gateCounts: z.ZodArray<z.ZodObject<{
4
- circuitName: z.ZodString;
5
- gateCount: z.ZodNumber;
6
- }, "strip", z.ZodTypeAny, {
7
- circuitName: string;
8
- gateCount: number;
9
- }, {
10
- circuitName: string;
11
- gateCount: number;
12
- }>, "many">;
13
- }, "strip", z.ZodTypeAny, {
14
- gateCounts: {
15
- circuitName: string;
16
- gateCount: number;
17
- }[];
18
- }, {
19
- gateCounts: {
20
- circuitName: string;
21
- gateCount: number;
22
- }[];
23
- }>;
24
- export type PrivateKernelProverProfileResult = z.infer<typeof PrivateKernelProverProfileResultSchema>;
25
- //# sourceMappingURL=private_kernel_prover_profile_result.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"private_kernel_prover_profile_result.d.ts","sourceRoot":"","sources":["../../src/kernel/private_kernel_prover_profile_result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;EAEjD,CAAC;AAEH,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sCAAsC,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { z } from 'zod';
2
- export const PrivateKernelProverProfileResultSchema = z.object({
3
- gateCounts: z.array(z.object({
4
- circuitName: z.string(),
5
- gateCount: z.number()
6
- }))
7
- });
@@ -1,82 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { type Fq, Fr } from '@aztec/foundation/fields';
4
- import { BufferReader } from '@aztec/foundation/serialize';
5
- import { NoteSelector } from '../../abi/note_selector.js';
6
- import { AztecAddress } from '../../aztec-address/index.js';
7
- import type { PrivateLog } from '../private_log.js';
8
- import { PublicLog } from '../public_log.js';
9
- /**
10
- * A class which wraps note data which is pushed on L1.
11
- * @remarks This data is required to compute a nullifier/to spend a note. Along with that this class contains
12
- * the necessary functionality to encrypt and decrypt the data.
13
- */
14
- export declare class L1NotePayload {
15
- /**
16
- * Address of the contract this tx is interacting with.
17
- */
18
- contractAddress: AztecAddress;
19
- /**
20
- * Storage slot of the underlying note.
21
- */
22
- storageSlot: Fr;
23
- /**
24
- * Type identifier for the underlying note, required to determine how to compute its hash and nullifier.
25
- */
26
- noteTypeId: NoteSelector;
27
- /**
28
- * Note values delivered encrypted.
29
- * @dev Note that to recreate the correct note we need to merge privateNoteValues and publicNoteValues. To do that
30
- * we need access to the contract ABI (that is done in the NoteProcessor).
31
- */
32
- privateNoteValues: Fr[];
33
- /**
34
- * Note values delivered in plaintext.
35
- * @dev Note that to recreate the correct note we need to merge privateNoteValues and publicNoteValues. To do that
36
- * we need access to the contract ABI (that is done in the NoteProcessor).
37
- */
38
- publicNoteValues: Fr[];
39
- constructor(
40
- /**
41
- * Address of the contract this tx is interacting with.
42
- */
43
- contractAddress: AztecAddress,
44
- /**
45
- * Storage slot of the underlying note.
46
- */
47
- storageSlot: Fr,
48
- /**
49
- * Type identifier for the underlying note, required to determine how to compute its hash and nullifier.
50
- */
51
- noteTypeId: NoteSelector,
52
- /**
53
- * Note values delivered encrypted.
54
- * @dev Note that to recreate the correct note we need to merge privateNoteValues and publicNoteValues. To do that
55
- * we need access to the contract ABI (that is done in the NoteProcessor).
56
- */
57
- privateNoteValues: Fr[],
58
- /**
59
- * Note values delivered in plaintext.
60
- * @dev Note that to recreate the correct note we need to merge privateNoteValues and publicNoteValues. To do that
61
- * we need access to the contract ABI (that is done in the NoteProcessor).
62
- */
63
- publicNoteValues: Fr[]);
64
- static fromIncomingBodyPlaintextContractAndPublicValues(plaintext: Buffer, contractAddress: AztecAddress, publicNoteValues: Fr[]): L1NotePayload | undefined;
65
- static decryptAsIncoming(log: PrivateLog, sk: Fq): Promise<L1NotePayload | undefined>;
66
- static decryptAsIncomingFromPublic(log: PublicLog, sk: Fq): Promise<L1NotePayload | undefined>;
67
- /**
68
- * Serializes the L1NotePayload object into a Buffer.
69
- * @returns Buffer representation of the L1NotePayload object.
70
- */
71
- toIncomingBodyPlaintext(): Buffer;
72
- /**
73
- * Create a random L1NotePayload object (useful for testing purposes).
74
- * @param contract - The address of a contract the note was emitted from.
75
- * @returns A random L1NotePayload object.
76
- */
77
- static random(contract?: AztecAddress): Promise<L1NotePayload>;
78
- equals(other: L1NotePayload): boolean;
79
- toBuffer(): Buffer;
80
- static fromBuffer(buffer: Buffer | BufferReader): L1NotePayload;
81
- }
82
- //# sourceMappingURL=l1_note_payload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"l1_note_payload.d.ts","sourceRoot":"","sources":["../../../src/logs/l1_payload/l1_note_payload.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C;;;;GAIG;AACH,qBAAa,aAAa;IAEtB;;OAEG;IACI,eAAe,EAAE,YAAY;IACpC;;OAEG;IACI,WAAW,EAAE,EAAE;IACtB;;OAEG;IACI,UAAU,EAAE,YAAY;IAC/B;;;;OAIG;IACI,iBAAiB,EAAE,EAAE,EAAE;IAC9B;;;;OAIG;IACI,gBAAgB,EAAE,EAAE,EAAE;;IAvB7B;;OAEG;IACI,eAAe,EAAE,YAAY;IACpC;;OAEG;IACI,WAAW,EAAE,EAAE;IACtB;;OAEG;IACI,UAAU,EAAE,YAAY;IAC/B;;;;OAIG;IACI,iBAAiB,EAAE,EAAE,EAAE;IAC9B;;;;OAIG;IACI,gBAAgB,EAAE,EAAE,EAAE;IAG/B,MAAM,CAAC,gDAAgD,CACrD,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,YAAY,EAC7B,gBAAgB,EAAE,EAAE,EAAE,GACrB,aAAa,GAAG,SAAS;WAgBf,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;WAa9E,2BAA2B,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAkBpG;;;OAGG;IACH,uBAAuB;IAKvB;;;;OAIG;WACU,MAAM,CAAC,QAAQ,CAAC,EAAE,YAAY;IAgBpC,MAAM,CAAC,KAAK,EAAE,aAAa;IAUlC,QAAQ;IAUR,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;CAUhD"}
@@ -1,129 +0,0 @@
1
- import { randomInt } from '@aztec/foundation/crypto';
2
- import { Fr } from '@aztec/foundation/fields';
3
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
- import { NoteSelector } from '../../abi/note_selector.js';
5
- import { AztecAddress } from '../../aztec-address/index.js';
6
- import { Vector } from '../../types/index.js';
7
- import { EncryptedLogPayload } from './encrypted_log_payload.js';
8
- /**
9
- * A class which wraps note data which is pushed on L1.
10
- * @remarks This data is required to compute a nullifier/to spend a note. Along with that this class contains
11
- * the necessary functionality to encrypt and decrypt the data.
12
- */ export class L1NotePayload {
13
- contractAddress;
14
- storageSlot;
15
- noteTypeId;
16
- privateNoteValues;
17
- publicNoteValues;
18
- constructor(/**
19
- * Address of the contract this tx is interacting with.
20
- */ contractAddress, /**
21
- * Storage slot of the underlying note.
22
- */ storageSlot, /**
23
- * Type identifier for the underlying note, required to determine how to compute its hash and nullifier.
24
- */ noteTypeId, /**
25
- * Note values delivered encrypted.
26
- * @dev Note that to recreate the correct note we need to merge privateNoteValues and publicNoteValues. To do that
27
- * we need access to the contract ABI (that is done in the NoteProcessor).
28
- */ privateNoteValues, /**
29
- * Note values delivered in plaintext.
30
- * @dev Note that to recreate the correct note we need to merge privateNoteValues and publicNoteValues. To do that
31
- * we need access to the contract ABI (that is done in the NoteProcessor).
32
- */ publicNoteValues){
33
- this.contractAddress = contractAddress;
34
- this.storageSlot = storageSlot;
35
- this.noteTypeId = noteTypeId;
36
- this.privateNoteValues = privateNoteValues;
37
- this.publicNoteValues = publicNoteValues;
38
- }
39
- static fromIncomingBodyPlaintextContractAndPublicValues(plaintext, contractAddress, publicNoteValues) {
40
- try {
41
- const reader = BufferReader.asReader(plaintext);
42
- const fields = reader.readArray(plaintext.length / Fr.SIZE_IN_BYTES, Fr);
43
- const storageSlot = fields[0];
44
- const noteTypeId = NoteSelector.fromField(fields[1]);
45
- const privateNoteValues = fields.slice(2);
46
- return new L1NotePayload(contractAddress, storageSlot, noteTypeId, privateNoteValues, publicNoteValues);
47
- } catch (e) {
48
- return undefined;
49
- }
50
- }
51
- static async decryptAsIncoming(log, sk) {
52
- const decryptedLog = await EncryptedLogPayload.decryptAsIncoming(log.fields, sk);
53
- if (!decryptedLog) {
54
- return undefined;
55
- }
56
- return this.fromIncomingBodyPlaintextContractAndPublicValues(decryptedLog.incomingBodyPlaintext, decryptedLog.contractAddress, /* publicValues */ []);
57
- }
58
- static async decryptAsIncomingFromPublic(log, sk) {
59
- const { privateValues, publicValues } = parseLogFromPublic(log);
60
- if (!privateValues) {
61
- return undefined;
62
- }
63
- const decryptedLog = await EncryptedLogPayload.decryptAsIncoming(privateValues, sk);
64
- if (!decryptedLog) {
65
- return undefined;
66
- }
67
- return this.fromIncomingBodyPlaintextContractAndPublicValues(decryptedLog.incomingBodyPlaintext, decryptedLog.contractAddress, publicValues);
68
- }
69
- /**
70
- * Serializes the L1NotePayload object into a Buffer.
71
- * @returns Buffer representation of the L1NotePayload object.
72
- */ toIncomingBodyPlaintext() {
73
- const fields = [
74
- this.storageSlot,
75
- this.noteTypeId.toField(),
76
- ...this.privateNoteValues
77
- ];
78
- return serializeToBuffer(fields);
79
- }
80
- /**
81
- * Create a random L1NotePayload object (useful for testing purposes).
82
- * @param contract - The address of a contract the note was emitted from.
83
- * @returns A random L1NotePayload object.
84
- */ static async random(contract) {
85
- const numPrivateNoteValues = randomInt(2) + 1;
86
- const privateNoteValues = Array.from({
87
- length: numPrivateNoteValues
88
- }, ()=>Fr.random());
89
- const numPublicNoteValues = randomInt(2) + 1;
90
- const publicNoteValues = Array.from({
91
- length: numPublicNoteValues
92
- }, ()=>Fr.random());
93
- return new L1NotePayload(contract ?? await AztecAddress.random(), Fr.random(), NoteSelector.random(), privateNoteValues, publicNoteValues);
94
- }
95
- equals(other) {
96
- return this.contractAddress.equals(other.contractAddress) && this.storageSlot.equals(other.storageSlot) && this.noteTypeId.equals(other.noteTypeId) && this.privateNoteValues.every((value, index)=>value.equals(other.privateNoteValues[index])) && this.publicNoteValues.every((value, index)=>value.equals(other.publicNoteValues[index]));
97
- }
98
- toBuffer() {
99
- return serializeToBuffer(this.contractAddress, this.storageSlot, this.noteTypeId, new Vector(this.privateNoteValues), new Vector(this.publicNoteValues));
100
- }
101
- static fromBuffer(buffer) {
102
- const reader = BufferReader.asReader(buffer);
103
- return new L1NotePayload(reader.readObject(AztecAddress), reader.readObject(Fr), reader.readObject(NoteSelector), reader.readVector(Fr), reader.readVector(Fr));
104
- }
105
- }
106
- /**
107
- * Parse the given log into an array of public values and an encrypted log.
108
- *
109
- * @param log - Log to be parsed.
110
- * @returns An object containing the public values, encrypted log, and ciphertext length.
111
- */ function parseLogFromPublic(log) {
112
- // Extract lengths from the log
113
- // See aztec_nr/aztec/src/macros/note/mod.nr to see how the "finalization_log" is encoded.
114
- // Each length is stored in 2 bytes with a 0 separator byte between them:
115
- // [ publicLen[0], publicLen[1], 0, privateLen[0], privateLen[1] ]
116
- // Search the codebase for "disgusting encoding" to see other hardcoded instances of this encoding, that you might need to change if you ever find yourself here.
117
- const lengths = log.log[0].toBuffer().subarray(-5);
118
- const publicValuesLength = lengths.readUint16BE();
119
- const privateValuesLength = lengths.readUint16BE(3);
120
- // Now we get the fields corresponding to the values generated from private.
121
- // Note: +1 for the length values in position 0
122
- const privateValues = log.log.slice(1, 1 + privateValuesLength);
123
- // At last we load the public values
124
- const publicValues = log.log.slice(1 + privateValuesLength, 1 + privateValuesLength + publicValuesLength);
125
- return {
126
- publicValues,
127
- privateValues
128
- };
129
- }
@@ -1,7 +0,0 @@
1
- import type { Fr } from '@aztec/foundation/fields';
2
-
3
- import type { InBlock } from './in_block.js';
4
-
5
- export interface NullifierWithBlockSource {
6
- findNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): Promise<(InBlock<bigint> | undefined)[]>;
7
- }
@@ -1,7 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- export const PrivateKernelProverProfileResultSchema = z.object({
4
- gateCounts: z.array(z.object({ circuitName: z.string(), gateCount: z.number() })),
5
- });
6
-
7
- export type PrivateKernelProverProfileResult = z.infer<typeof PrivateKernelProverProfileResultSchema>;
@@ -1,182 +0,0 @@
1
- import { randomInt } from '@aztec/foundation/crypto';
2
- import { type Fq, Fr } from '@aztec/foundation/fields';
3
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
-
5
- import { NoteSelector } from '../../abi/note_selector.js';
6
- import { AztecAddress } from '../../aztec-address/index.js';
7
- import { Vector } from '../../types/index.js';
8
- import type { PrivateLog } from '../private_log.js';
9
- import { PublicLog } from '../public_log.js';
10
- import { EncryptedLogPayload } from './encrypted_log_payload.js';
11
-
12
- /**
13
- * A class which wraps note data which is pushed on L1.
14
- * @remarks This data is required to compute a nullifier/to spend a note. Along with that this class contains
15
- * the necessary functionality to encrypt and decrypt the data.
16
- */
17
- export class L1NotePayload {
18
- constructor(
19
- /**
20
- * Address of the contract this tx is interacting with.
21
- */
22
- public contractAddress: AztecAddress,
23
- /**
24
- * Storage slot of the underlying note.
25
- */
26
- public storageSlot: Fr,
27
- /**
28
- * Type identifier for the underlying note, required to determine how to compute its hash and nullifier.
29
- */
30
- public noteTypeId: NoteSelector,
31
- /**
32
- * Note values delivered encrypted.
33
- * @dev Note that to recreate the correct note we need to merge privateNoteValues and publicNoteValues. To do that
34
- * we need access to the contract ABI (that is done in the NoteProcessor).
35
- */
36
- public privateNoteValues: Fr[],
37
- /**
38
- * Note values delivered in plaintext.
39
- * @dev Note that to recreate the correct note we need to merge privateNoteValues and publicNoteValues. To do that
40
- * we need access to the contract ABI (that is done in the NoteProcessor).
41
- */
42
- public publicNoteValues: Fr[],
43
- ) {}
44
-
45
- static fromIncomingBodyPlaintextContractAndPublicValues(
46
- plaintext: Buffer,
47
- contractAddress: AztecAddress,
48
- publicNoteValues: Fr[],
49
- ): L1NotePayload | undefined {
50
- try {
51
- const reader = BufferReader.asReader(plaintext);
52
- const fields = reader.readArray(plaintext.length / Fr.SIZE_IN_BYTES, Fr);
53
-
54
- const storageSlot = fields[0];
55
- const noteTypeId = NoteSelector.fromField(fields[1]);
56
-
57
- const privateNoteValues = fields.slice(2);
58
-
59
- return new L1NotePayload(contractAddress, storageSlot, noteTypeId, privateNoteValues, publicNoteValues);
60
- } catch (e) {
61
- return undefined;
62
- }
63
- }
64
-
65
- static async decryptAsIncoming(log: PrivateLog, sk: Fq): Promise<L1NotePayload | undefined> {
66
- const decryptedLog = await EncryptedLogPayload.decryptAsIncoming(log.fields, sk);
67
- if (!decryptedLog) {
68
- return undefined;
69
- }
70
-
71
- return this.fromIncomingBodyPlaintextContractAndPublicValues(
72
- decryptedLog.incomingBodyPlaintext,
73
- decryptedLog.contractAddress,
74
- /* publicValues */ [],
75
- );
76
- }
77
-
78
- static async decryptAsIncomingFromPublic(log: PublicLog, sk: Fq): Promise<L1NotePayload | undefined> {
79
- const { privateValues, publicValues } = parseLogFromPublic(log);
80
- if (!privateValues) {
81
- return undefined;
82
- }
83
-
84
- const decryptedLog = await EncryptedLogPayload.decryptAsIncoming(privateValues, sk);
85
- if (!decryptedLog) {
86
- return undefined;
87
- }
88
-
89
- return this.fromIncomingBodyPlaintextContractAndPublicValues(
90
- decryptedLog.incomingBodyPlaintext,
91
- decryptedLog.contractAddress,
92
- publicValues,
93
- );
94
- }
95
-
96
- /**
97
- * Serializes the L1NotePayload object into a Buffer.
98
- * @returns Buffer representation of the L1NotePayload object.
99
- */
100
- toIncomingBodyPlaintext() {
101
- const fields = [this.storageSlot, this.noteTypeId.toField(), ...this.privateNoteValues];
102
- return serializeToBuffer(fields);
103
- }
104
-
105
- /**
106
- * Create a random L1NotePayload object (useful for testing purposes).
107
- * @param contract - The address of a contract the note was emitted from.
108
- * @returns A random L1NotePayload object.
109
- */
110
- static async random(contract?: AztecAddress) {
111
- const numPrivateNoteValues = randomInt(2) + 1;
112
- const privateNoteValues = Array.from({ length: numPrivateNoteValues }, () => Fr.random());
113
-
114
- const numPublicNoteValues = randomInt(2) + 1;
115
- const publicNoteValues = Array.from({ length: numPublicNoteValues }, () => Fr.random());
116
-
117
- return new L1NotePayload(
118
- contract ?? (await AztecAddress.random()),
119
- Fr.random(),
120
- NoteSelector.random(),
121
- privateNoteValues,
122
- publicNoteValues,
123
- );
124
- }
125
-
126
- public equals(other: L1NotePayload) {
127
- return (
128
- this.contractAddress.equals(other.contractAddress) &&
129
- this.storageSlot.equals(other.storageSlot) &&
130
- this.noteTypeId.equals(other.noteTypeId) &&
131
- this.privateNoteValues.every((value, index) => value.equals(other.privateNoteValues[index])) &&
132
- this.publicNoteValues.every((value, index) => value.equals(other.publicNoteValues[index]))
133
- );
134
- }
135
-
136
- toBuffer() {
137
- return serializeToBuffer(
138
- this.contractAddress,
139
- this.storageSlot,
140
- this.noteTypeId,
141
- new Vector(this.privateNoteValues),
142
- new Vector(this.publicNoteValues),
143
- );
144
- }
145
-
146
- static fromBuffer(buffer: Buffer | BufferReader) {
147
- const reader = BufferReader.asReader(buffer);
148
- return new L1NotePayload(
149
- reader.readObject(AztecAddress),
150
- reader.readObject(Fr),
151
- reader.readObject(NoteSelector),
152
- reader.readVector(Fr),
153
- reader.readVector(Fr),
154
- );
155
- }
156
- }
157
-
158
- /**
159
- * Parse the given log into an array of public values and an encrypted log.
160
- *
161
- * @param log - Log to be parsed.
162
- * @returns An object containing the public values, encrypted log, and ciphertext length.
163
- */
164
- function parseLogFromPublic(log: PublicLog) {
165
- // Extract lengths from the log
166
- // See aztec_nr/aztec/src/macros/note/mod.nr to see how the "finalization_log" is encoded.
167
- // Each length is stored in 2 bytes with a 0 separator byte between them:
168
- // [ publicLen[0], publicLen[1], 0, privateLen[0], privateLen[1] ]
169
- // Search the codebase for "disgusting encoding" to see other hardcoded instances of this encoding, that you might need to change if you ever find yourself here.
170
- const lengths = log.log[0].toBuffer().subarray(-5);
171
- const publicValuesLength = lengths.readUint16BE();
172
- const privateValuesLength = lengths.readUint16BE(3);
173
-
174
- // Now we get the fields corresponding to the values generated from private.
175
- // Note: +1 for the length values in position 0
176
- const privateValues = log.log.slice(1, 1 + privateValuesLength);
177
-
178
- // At last we load the public values
179
- const publicValues = log.log.slice(1 + privateValuesLength, 1 + privateValuesLength + publicValuesLength);
180
-
181
- return { publicValues, privateValues };
182
- }