@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
@@ -29,15 +29,9 @@ import { type LogFilter, LogFilterSchema } from '../logs/log_filter.js';
29
29
  import { UniqueNote } from '../note/extended_note.js';
30
30
  import { type NotesFilter, NotesFilterSchema } from '../note/notes_filter.js';
31
31
  import { AbiDecodedSchema, optional, schemas } from '../schemas/schemas.js';
32
- import {
33
- PrivateExecutionResult,
34
- Tx,
35
- TxExecutionRequest,
36
- TxHash,
37
- TxProvingResult,
38
- TxReceipt,
39
- TxSimulationResult,
40
- } from '../tx/index.js';
32
+ import { PrivateExecutionResult, Tx, TxExecutionRequest, TxHash, TxReceipt, TxSimulationResult } from '../tx/index.js';
33
+ import { TxProfileResult } from '../tx/profiled_tx.js';
34
+ import { TxProvingResult } from '../tx/proven_tx.js';
41
35
  import { TxEffect } from '../tx/tx_effect.js';
42
36
  import {
43
37
  type GetContractClassLogsResponse,
@@ -61,38 +55,6 @@ export interface PXE {
61
55
  */
62
56
  isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean>;
63
57
 
64
- /**
65
- * Insert an auth witness for a given message hash. Auth witnesses are used to authorize actions on
66
- * behalf of a user. For instance, a token transfer initiated by a different address may request
67
- * authorization from the user to move their tokens. This authorization is granted by the user
68
- * account contract by verifying an auth witness requested to the execution oracle. Witnesses are
69
- * usually a signature over a hash of the action to be authorized, but their actual contents depend
70
- * on the account contract that consumes them.
71
- *
72
- * @param authWitness - The auth witness to insert. Composed of an identifier, which is the hash of
73
- * the action to be authorized, and the actual witness as an array of fields, which are to be
74
- * deserialized and processed by the account contract.
75
- */
76
- addAuthWitness(authWitness: AuthWitness): Promise<void>;
77
-
78
- /**
79
- * Fetches the serialized auth witness for a given message hash or returns undefined if not found.
80
- * @param messageHash - The hash of the message for which to get the auth witness.
81
- * @returns The serialized auth witness for the given message hash.
82
- */
83
- getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
84
-
85
- /**
86
- * Adds a capsule.
87
- * @param contract - The address of the contract to add the capsule to.
88
- * @param storageSlot - The storage slot to add the capsule to.
89
- * @param capsule - An array of field elements representing the capsule.
90
- * @remarks A capsule is a "blob" of data that is passed to the contract through an oracle. It works similarly
91
- * to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
92
- * network state it's backed by local PXE db.
93
- */
94
- storeCapsule(contract: AztecAddress, storageSlot: Fr, capsule: Fr[]): Promise<void>;
95
-
96
58
  /**
97
59
  * Registers a user account in PXE given its master encryption private key.
98
60
  * Once a new account is registered, the PXE Service will trial-decrypt all published notes on
@@ -166,14 +128,13 @@ export interface PXE {
166
128
  getContracts(): Promise<AztecAddress[]>;
167
129
 
168
130
  /**
169
- * Creates a proving result based on the provided preauthenticated execution request and the results
170
- * of executing the private part of the transaction. This will assemble the zero-knowledge proof for the private execution.
171
- * It returns an object that contains the proof and public inputs of the tail circuit, which can be converted into a Tx ready to be sent to the network
131
+ * Proves the private portion of a simulated transaction, ready to send to the network
132
+ * (where valiators prove the public portion).
172
133
  *
173
134
  * @param txRequest - An authenticated tx request ready for proving
174
135
  * @param privateExecutionResult - The result of the private execution of the transaction
175
- * @returns A transaction ready to be sent to the network for execution.
176
- * @throws If the code for the functions executed in this transaction has not been made available via `addContracts`.
136
+ * @returns A result containing the proof and public inputs of the tail circuit.
137
+ * @throws If contract code not found, or public simulation reverts.
177
138
  * Also throws if simulatePublic is true and public simulation reverts.
178
139
  */
179
140
  proveTx(txRequest: TxExecutionRequest, privateExecutionResult: PrivateExecutionResult): Promise<TxProvingResult>;
@@ -193,10 +154,10 @@ export interface PXE {
193
154
  * @param simulatePublic - Whether to simulate the public part of the transaction.
194
155
  * @param msgSender - (Optional) The message sender to use for the simulation.
195
156
  * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
196
- * @param profile - (Optional) If true, will run the private kernel prover with profiling enabled and include the result (gate count) in TxSimulationResult.
157
+ * @param skipFeeEnforcement - (Optional) If false, fees are enforced.
197
158
  * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
198
159
  * @returns A simulated transaction result object that includes public and private return values.
199
- * @throws If the code for the functions executed in this transaction has not been made available via `addContracts`.
160
+ * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
200
161
  * Also throws if simulatePublic is true and public simulation reverts.
201
162
  */
202
163
  simulateTx(
@@ -205,10 +166,24 @@ export interface PXE {
205
166
  msgSender?: AztecAddress,
206
167
  skipTxValidation?: boolean,
207
168
  skipFeeEnforcement?: boolean,
208
- profile?: boolean,
209
169
  scopes?: AztecAddress[],
210
170
  ): Promise<TxSimulationResult>;
211
171
 
172
+ /**
173
+ * Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
174
+ *
175
+ * @param txRequest - An authenticated tx request ready for simulation
176
+ * @param msgSender - (Optional) The message sender to use for the simulation.
177
+ * @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
178
+ * @returns A trace of the program execution with gate counts.
179
+ * @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
180
+ */
181
+ profileTx(
182
+ txRequest: TxExecutionRequest,
183
+ profileMode: 'gates' | 'execution-steps' | 'full',
184
+ msgSender?: AztecAddress,
185
+ ): Promise<TxProfileResult>;
186
+
212
187
  /**
213
188
  * Sends a transaction to an Aztec node to be broadcasted to the network and mined.
214
189
  * @param tx - The transaction as created via `proveTx`.
@@ -305,6 +280,7 @@ export interface PXE {
305
280
  functionName: string,
306
281
  args: any[],
307
282
  to: AztecAddress,
283
+ authwits?: AuthWitness[],
308
284
  from?: AztecAddress,
309
285
  scopes?: AztecAddress[],
310
286
  ): Promise<AbiDecoded>;
@@ -454,12 +430,6 @@ const PXEInfoSchema = z.object({
454
430
 
455
431
  export const PXESchema: ApiSchemaFor<PXE> = {
456
432
  isL1ToL2MessageSynced: z.function().args(schemas.Fr).returns(z.boolean()),
457
- addAuthWitness: z.function().args(AuthWitness.schema).returns(z.void()),
458
- getAuthWitness: z
459
- .function()
460
- .args(schemas.Fr)
461
- .returns(z.union([z.undefined(), z.array(schemas.Fr)])),
462
- storeCapsule: z.function().args(schemas.AztecAddress, schemas.Fr, z.array(schemas.Fr)).returns(z.void()),
463
433
  registerAccount: z.function().args(schemas.Fr, schemas.Fr).returns(CompleteAddress.schema),
464
434
  getRegisteredAccounts: z.function().returns(z.array(CompleteAddress.schema)),
465
435
  registerSender: z.function().args(schemas.AztecAddress).returns(schemas.AztecAddress),
@@ -473,6 +443,14 @@ export const PXESchema: ApiSchemaFor<PXE> = {
473
443
  updateContract: z.function().args(schemas.AztecAddress, ContractArtifactSchema).returns(z.void()),
474
444
  getContracts: z.function().returns(z.array(schemas.AztecAddress)),
475
445
  proveTx: z.function().args(TxExecutionRequest.schema, PrivateExecutionResult.schema).returns(TxProvingResult.schema),
446
+ profileTx: z
447
+ .function()
448
+ .args(
449
+ TxExecutionRequest.schema,
450
+ z.union([z.literal('gates'), z.literal('full'), z.literal('execution-steps')]),
451
+ optional(schemas.AztecAddress),
452
+ )
453
+ .returns(TxProfileResult.schema),
476
454
  simulateTx: z
477
455
  .function()
478
456
  .args(
@@ -481,7 +459,6 @@ export const PXESchema: ApiSchemaFor<PXE> = {
481
459
  optional(schemas.AztecAddress),
482
460
  optional(z.boolean()),
483
461
  optional(z.boolean()),
484
- optional(z.boolean()),
485
462
  optional(z.array(schemas.AztecAddress)),
486
463
  )
487
464
  .returns(TxSimulationResult.schema),
@@ -513,6 +490,7 @@ export const PXESchema: ApiSchemaFor<PXE> = {
513
490
  z.string(),
514
491
  z.array(z.any()),
515
492
  schemas.AztecAddress,
493
+ optional(z.array(AuthWitness.schema)),
516
494
  optional(schemas.AztecAddress),
517
495
  optional(z.array(schemas.AztecAddress)),
518
496
  )
@@ -26,5 +26,5 @@ export * from './note_hash.js';
26
26
  export * from './private_log_data.js';
27
27
  export * from './private_call_request.js';
28
28
  export * from './private_validation_requests.js';
29
- export * from './private_kernel_prover_profile_result.js';
30
29
  export * from './private_kernel_simulated_output.js';
30
+ export * from './private_kernel_prover_output.js';
@@ -0,0 +1,44 @@
1
+ import { bufferSchema, mapSchema } from '@aztec/foundation/schemas';
2
+ import type { WitnessMap } from '@aztec/noir-acvm_js';
3
+
4
+ import { z } from 'zod';
5
+
6
+ import type { ClientIvcProof } from '../proofs/client_ivc_proof.js';
7
+ import type { VerificationKeyAsFields } from '../vks/verification_key.js';
8
+ import type { PrivateKernelCircuitPublicInputs } from './private_kernel_circuit_public_inputs.js';
9
+ import type { PrivateKernelTailCircuitPublicInputs } from './private_kernel_tail_circuit_public_inputs.js';
10
+
11
+ export const PrivateExecutionStepSchema = z.object({
12
+ functionName: z.string(),
13
+ gateCount: z.number().optional(),
14
+ bytecode: bufferSchema,
15
+ witness: mapSchema(z.number(), z.string()),
16
+ });
17
+
18
+ /**
19
+ * Represents either a simulated private kernel circuit or one of our application function circuits.
20
+ */
21
+ export interface PrivateExecutionStep {
22
+ functionName: string;
23
+ gateCount?: number;
24
+ bytecode: Buffer;
25
+ witness: WitnessMap;
26
+ }
27
+
28
+ /** Represents the output of proven PrivateKernelSimulateOutput.*/
29
+ export interface PrivateKernelExecutionProofOutput<
30
+ PublicInputsType extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs,
31
+ > {
32
+ /** The public inputs used by the proof generation process. */
33
+ publicInputs: PublicInputsType;
34
+ /** The private IVC proof optimized for user devices. It will be consumed by an Aztec prover,
35
+ * which recursively verifies it through the "tube" circuit.*/
36
+ clientIvcProof: ClientIvcProof;
37
+ verificationKey: VerificationKeyAsFields;
38
+ /**
39
+ * The trace the clientIvcProof corresponds to.
40
+ * A trace of app circuits interleaved with private kernel circuits.
41
+ * If simulate is ran with profiling mode, also includes gate counts.
42
+ */
43
+ executionSteps: PrivateExecutionStep[];
44
+ }
@@ -1,31 +1,22 @@
1
1
  import type { WitnessMap } from '@aztec/noir-acvm_js';
2
2
 
3
- import type { ClientIvcProof } from '../proofs/client_ivc_proof.js';
4
3
  import type { VerificationKeyAsFields } from '../vks/verification_key.js';
5
4
  import type { PrivateKernelCircuitPublicInputs } from './private_kernel_circuit_public_inputs.js';
6
- import type { PrivateKernelProverProfileResult } from './private_kernel_prover_profile_result.js';
7
5
  import type { PrivateKernelTailCircuitPublicInputs } from './private_kernel_tail_circuit_public_inputs.js';
8
6
 
9
7
  /**
10
8
  * Represents the output of the proof creation process for init and inner private kernel circuit.
11
9
  * Contains the public inputs required for the init and inner private kernel circuit and the generated proof.
12
10
  */
13
- export type PrivateKernelSimulateOutput<
11
+ export interface PrivateKernelSimulateOutput<
14
12
  PublicInputsType extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs,
15
- > = {
13
+ > {
16
14
  /** The public inputs required for the proof generation process. */
17
15
  publicInputs: PublicInputsType;
18
-
19
- clientIvcProof?: ClientIvcProof;
20
-
21
- verificationKey: VerificationKeyAsFields;
22
-
23
16
  outputWitness: WitnessMap;
24
-
17
+ verificationKey: VerificationKeyAsFields;
25
18
  bytecode: Buffer;
26
-
27
- profileResult?: PrivateKernelProverProfileResult;
28
- };
19
+ }
29
20
 
30
21
  /**
31
22
  * Represents the output of the circuit simulation process for init and inner private kernel circuit.
@@ -28,6 +28,14 @@ export class ContractClassLog {
28
28
  return [this.contractAddress.toField(), ...this.fields];
29
29
  }
30
30
 
31
+ equals(other: ContractClassLog) {
32
+ return (
33
+ this.contractAddress.equals(other.contractAddress) &&
34
+ this.fields.length === other.fields.length &&
35
+ this.fields.every((f, i) => f.equals(other.fields[i]))
36
+ );
37
+ }
38
+
31
39
  static fromFields(fields: Fr[] | FieldReader) {
32
40
  const reader = FieldReader.asReader(fields);
33
41
  // Below line gives error 'Type instantiation is excessively deep and possibly infinite. ts(2589)'
@@ -1,2 +1,2 @@
1
1
  export * from './encrypted_log_payload.js';
2
- export * from './l1_note_payload.js';
2
+ export * from './shared_secret_derivation.js';
@@ -1,8 +1,8 @@
1
1
  import { MAX_NOTE_HASHES_PER_TX, PUBLIC_LOG_DATA_SIZE_IN_FIELDS } from '@aztec/constants';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
 
4
- // TypeScript representation of the Noir aztec::oracle::note_discovery::LogWithTxData struct. This is used as a response
5
- // for PXE's custom getLogByTag oracle.
4
+ // TypeScript representation of the Noir aztec::oracle::message_discovery::LogWithTxData struct. This is used as a
5
+ // response for PXE's custom getLogByTag oracle.
6
6
  export class LogWithTxData {
7
7
  constructor(
8
8
  public logContent: Fr[],
@@ -1,4 +1,4 @@
1
- import { PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
1
+ import { PRIVATE_LOG_SIZE_IN_FIELDS, PUBLIC_LOG_DATA_SIZE_IN_FIELDS } from '@aztec/constants';
2
2
  import { makeTuple } from '@aztec/foundation/array';
3
3
  import { Fr } from '@aztec/foundation/fields';
4
4
  import { schemas } from '@aztec/foundation/schemas';
@@ -38,8 +38,8 @@ export class PrivateLog {
38
38
  return new PrivateLog(reader.readArray(PRIVATE_LOG_SIZE_IN_FIELDS, Fr));
39
39
  }
40
40
 
41
- static random() {
42
- return new PrivateLog(makeTuple(PRIVATE_LOG_SIZE_IN_FIELDS, Fr.random));
41
+ static random(tag = Fr.random()) {
42
+ return PrivateLog.fromFields([tag, ...Array.from({ length: PRIVATE_LOG_SIZE_IN_FIELDS - 1 }, () => Fr.random())]);
43
43
  }
44
44
 
45
45
  getEmittedLength() {
@@ -54,6 +54,12 @@ export class PrivateLog {
54
54
  }
55
55
 
56
56
  static get schema() {
57
+ if (PUBLIC_LOG_DATA_SIZE_IN_FIELDS + 1 == PRIVATE_LOG_SIZE_IN_FIELDS) {
58
+ throw new Error(
59
+ 'Constants got updated and schema for PublicLog matches that of PrivateLog. This needs to be updated now as Zod is no longer able to differentiate the 2 in TxScopedL2Log.',
60
+ );
61
+ }
62
+
57
63
  return z
58
64
  .object({
59
65
  fields: z.array(schemas.Fr),
@@ -61,6 +67,10 @@ export class PrivateLog {
61
67
  .transform(({ fields }) => PrivateLog.fromFields(fields));
62
68
  }
63
69
 
70
+ equals(other: PrivateLog) {
71
+ return this.fields.every((field, i) => field.equals(other.fields[i]));
72
+ }
73
+
64
74
  [inspect.custom](): string {
65
75
  return `PrivateLog {
66
76
  fields: [${this.fields.map(x => inspect(x)).join(', ')}],
@@ -1,4 +1,8 @@
1
- import { PUBLIC_LOG_DATA_SIZE_IN_FIELDS, PUBLIC_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
1
+ import {
2
+ PRIVATE_LOG_SIZE_IN_FIELDS,
3
+ PUBLIC_LOG_DATA_SIZE_IN_FIELDS,
4
+ PUBLIC_LOG_SIZE_IN_FIELDS,
5
+ } from '@aztec/constants';
2
6
  import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
3
7
  import { Fr } from '@aztec/foundation/fields';
4
8
  import { type ZodFor, schemas } from '@aztec/foundation/schemas';
@@ -78,6 +82,12 @@ export class PublicLog {
78
82
  }
79
83
 
80
84
  static get schema(): ZodFor<PublicLog> {
85
+ if (PUBLIC_LOG_DATA_SIZE_IN_FIELDS + 1 == PRIVATE_LOG_SIZE_IN_FIELDS) {
86
+ throw new Error(
87
+ 'Constants got updated and schema for PrivateLog matches that of PublicLog. This needs to be updated now as Zod is no longer able to differentiate the 2 in TxScopedL2Log.',
88
+ );
89
+ }
90
+
81
91
  return z
82
92
  .object({
83
93
  contractAddress: AztecAddress.schema,
@@ -1,10 +1,10 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
1
  import { BufferReader, boolToBuffer, numToUInt32BE } from '@aztec/foundation/serialize';
3
2
 
4
3
  import { z } from 'zod';
5
4
 
6
- import { schemas } from '../schemas/schemas.js';
7
5
  import { TxHash } from '../tx/tx_hash.js';
6
+ import { PrivateLog } from './private_log.js';
7
+ import { PublicLog } from './public_log.js';
8
8
 
9
9
  export class TxScopedL2Log {
10
10
  constructor(
@@ -22,53 +22,55 @@ export class TxScopedL2Log {
22
22
  */
23
23
  public blockNumber: number,
24
24
  /*
25
- * Indicates if the log comes from the public logs stream (partial note)
25
+ * The log data as either a PrivateLog or PublicLog
26
26
  */
27
- public isFromPublic: boolean,
28
- /*
29
- * The log data
30
- */
31
- public logData: Buffer,
27
+ public log: PrivateLog | PublicLog,
32
28
  ) {}
33
29
 
30
+ get isFromPublic() {
31
+ return this.log instanceof PublicLog;
32
+ }
33
+
34
34
  static get schema() {
35
35
  return z
36
36
  .object({
37
37
  txHash: TxHash.schema,
38
38
  dataStartIndexForTx: z.number(),
39
39
  blockNumber: z.number(),
40
- isFromPublic: z.boolean(),
41
- logData: schemas.Buffer,
40
+ log: z.union([PrivateLog.schema, PublicLog.schema]),
42
41
  })
43
42
  .transform(
44
- ({ txHash, dataStartIndexForTx, blockNumber, isFromPublic, logData }) =>
45
- new TxScopedL2Log(txHash, dataStartIndexForTx, blockNumber, isFromPublic, logData),
43
+ ({ txHash, dataStartIndexForTx, blockNumber, log }) =>
44
+ new TxScopedL2Log(txHash, dataStartIndexForTx, blockNumber, log),
46
45
  );
47
46
  }
48
47
 
49
48
  toBuffer() {
49
+ const isFromPublic = this.log instanceof PublicLog;
50
50
  return Buffer.concat([
51
51
  this.txHash.toBuffer(),
52
52
  numToUInt32BE(this.dataStartIndexForTx),
53
53
  numToUInt32BE(this.blockNumber),
54
- boolToBuffer(this.isFromPublic),
55
- this.logData,
54
+ boolToBuffer(isFromPublic),
55
+ this.log.toBuffer(),
56
56
  ]);
57
57
  }
58
58
 
59
59
  static fromBuffer(buffer: Buffer) {
60
60
  const reader = BufferReader.asReader(buffer);
61
- return new TxScopedL2Log(
62
- reader.readObject(TxHash),
63
- reader.readNumber(),
64
- reader.readNumber(),
65
- reader.readBoolean(),
66
- reader.readToEnd(),
67
- );
61
+ const txHash = reader.readObject(TxHash);
62
+ const dataStartIndexForTx = reader.readNumber();
63
+ const blockNumber = reader.readNumber();
64
+ const isFromPublic = reader.readBoolean();
65
+ const log = isFromPublic ? PublicLog.fromBuffer(reader) : PrivateLog.fromBuffer(reader);
66
+
67
+ return new TxScopedL2Log(txHash, dataStartIndexForTx, blockNumber, log);
68
68
  }
69
69
 
70
- static random() {
71
- return new TxScopedL2Log(TxHash.random(), 1, 1, false, Fr.random().toBuffer());
70
+ static async random() {
71
+ const isFromPublic = Math.random() < 0.5;
72
+ const log = isFromPublic ? await PublicLog.random() : PrivateLog.random();
73
+ return new TxScopedL2Log(TxHash.random(), 1, 1, log);
72
74
  }
73
75
 
74
76
  equals(other: TxScopedL2Log) {
@@ -76,8 +78,9 @@ export class TxScopedL2Log {
76
78
  this.txHash.equals(other.txHash) &&
77
79
  this.dataStartIndexForTx === other.dataStartIndexForTx &&
78
80
  this.blockNumber === other.blockNumber &&
79
- this.isFromPublic === other.isFromPublic &&
80
- this.logData.equals(other.logData)
81
+ ((this.log instanceof PublicLog && other.log instanceof PublicLog) ||
82
+ (this.log instanceof PrivateLog && other.log instanceof PrivateLog)) &&
83
+ this.log.equals(other.log as any)
81
84
  );
82
85
  }
83
86
  }
package/src/noir/index.ts CHANGED
@@ -75,7 +75,7 @@ export interface NoirCompiledContract {
75
75
  }
76
76
 
77
77
  /**
78
- * The compilation result of an Aztec.nr contract.
78
+ * The compilation result of a protocol (non-contract) circuit.
79
79
  */
80
80
  export interface NoirCompiledCircuit {
81
81
  /** The hash of the circuit. */
@@ -92,6 +92,11 @@ export interface NoirCompiledCircuit {
92
92
  file_map: DebugFileMap;
93
93
  }
94
94
 
95
+ export interface NoirCompiledCircuitWithName extends NoirCompiledCircuit {
96
+ /** The name of the circuit. */
97
+ name: string;
98
+ }
99
+
95
100
  /**
96
101
  * The debug metadata of an Aztec.nr contract.
97
102
  */
@@ -4,7 +4,6 @@ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
4
4
 
5
5
  import { z } from 'zod';
6
6
 
7
- import { NoteSelector } from '../abi/note_selector.js';
8
7
  import { AztecAddress } from '../aztec-address/index.js';
9
8
  import { type ZodFor, schemas } from '../schemas/index.js';
10
9
  import { TxHash } from '../tx/tx_hash.js';
@@ -17,54 +16,43 @@ export class ExtendedNote {
17
16
  constructor(
18
17
  /** The note as emitted from the Noir contract. */
19
18
  public note: Note,
20
- /** The owner whose public key was used to encrypt the note. */
21
- public owner: AztecAddress,
19
+ /** The address whose public key was used to encrypt the note. */
20
+ public recipient: AztecAddress,
22
21
  /** The contract address this note is created in. */
23
22
  public contractAddress: AztecAddress,
24
23
  /** The specific storage location of the note on the contract. */
25
24
  public storageSlot: Fr,
26
- /** The type identifier of the note on the contract. */
27
- public noteTypeId: NoteSelector,
28
25
  /** The hash of the tx the note was created in. */
29
26
  public txHash: TxHash,
30
27
  ) {}
31
28
 
32
29
  toBuffer(): Buffer {
33
- return serializeToBuffer([
34
- this.note,
35
- this.owner,
36
- this.contractAddress,
37
- this.storageSlot,
38
- this.noteTypeId,
39
- this.txHash,
40
- ]);
30
+ return serializeToBuffer([this.note, this.recipient, this.contractAddress, this.storageSlot, this.txHash]);
41
31
  }
42
32
 
43
33
  static fromBuffer(buffer: Buffer | BufferReader) {
44
34
  const reader = BufferReader.asReader(buffer);
45
35
 
46
36
  const note = reader.readObject(Note);
47
- const owner = reader.readObject(AztecAddress);
37
+ const recipient = reader.readObject(AztecAddress);
48
38
  const contractAddress = reader.readObject(AztecAddress);
49
39
  const storageSlot = reader.readObject(Fr);
50
- const noteTypeId = reader.readObject(NoteSelector);
51
40
  const txHash = reader.readObject(TxHash);
52
41
 
53
- return new this(note, owner, contractAddress, storageSlot, noteTypeId, txHash);
42
+ return new this(note, recipient, contractAddress, storageSlot, txHash);
54
43
  }
55
44
 
56
45
  static get schema(): ZodFor<ExtendedNote> {
57
46
  return z
58
47
  .object({
59
48
  note: Note.schema,
60
- owner: schemas.AztecAddress,
49
+ recipient: schemas.AztecAddress,
61
50
  contractAddress: schemas.AztecAddress,
62
51
  storageSlot: schemas.Fr,
63
- noteTypeId: schemas.NoteSelector,
64
52
  txHash: TxHash.schema,
65
53
  })
66
- .transform(({ note, owner, contractAddress, storageSlot, noteTypeId, txHash }) => {
67
- return new ExtendedNote(note, owner, contractAddress, storageSlot, noteTypeId, txHash);
54
+ .transform(({ note, recipient, contractAddress, storageSlot, txHash }) => {
55
+ return new ExtendedNote(note, recipient, contractAddress, storageSlot, txHash);
68
56
  });
69
57
  }
70
58
 
@@ -82,7 +70,6 @@ export class ExtendedNote {
82
70
  await AztecAddress.random(),
83
71
  await AztecAddress.random(),
84
72
  Fr.random(),
85
- NoteSelector.random(),
86
73
  TxHash.random(),
87
74
  );
88
75
  }
@@ -92,45 +79,41 @@ export class UniqueNote extends ExtendedNote {
92
79
  constructor(
93
80
  /** The note as emitted from the Noir contract. */
94
81
  note: Note,
95
- /** The owner whose public key was used to encrypt the note. */
96
- owner: AztecAddress,
82
+ /** The recipient whose public key was used to encrypt the note. */
83
+ recipient: AztecAddress,
97
84
  /** The contract address this note is created in. */
98
85
  contractAddress: AztecAddress,
99
86
  /** The specific storage location of the note on the contract. */
100
87
  storageSlot: Fr,
101
- /** The type identifier of the note on the contract. */
102
- noteTypeId: NoteSelector,
103
88
  /** The hash of the tx the note was created in. */
104
89
  txHash: TxHash,
105
90
  /** The nonce of the note. */
106
91
  public nonce: Fr,
107
92
  ) {
108
- super(note, owner, contractAddress, storageSlot, noteTypeId, txHash);
93
+ super(note, recipient, contractAddress, storageSlot, txHash);
109
94
  }
110
95
 
111
96
  static override get schema() {
112
97
  return z
113
98
  .object({
114
99
  note: Note.schema,
115
- owner: schemas.AztecAddress,
100
+ recipient: schemas.AztecAddress,
116
101
  contractAddress: schemas.AztecAddress,
117
102
  storageSlot: schemas.Fr,
118
- noteTypeId: schemas.NoteSelector,
119
103
  txHash: TxHash.schema,
120
104
  nonce: schemas.Fr,
121
105
  })
122
- .transform(({ note, owner, contractAddress, storageSlot, noteTypeId, txHash, nonce }) => {
123
- return new UniqueNote(note, owner, contractAddress, storageSlot, noteTypeId, txHash, nonce);
106
+ .transform(({ note, recipient, contractAddress, storageSlot, txHash, nonce }) => {
107
+ return new UniqueNote(note, recipient, contractAddress, storageSlot, txHash, nonce);
124
108
  });
125
109
  }
126
110
 
127
111
  override toBuffer(): Buffer {
128
112
  return serializeToBuffer([
129
113
  this.note,
130
- this.owner,
114
+ this.recipient,
131
115
  this.contractAddress,
132
116
  this.storageSlot,
133
- this.noteTypeId,
134
117
  this.txHash,
135
118
  this.nonce,
136
119
  ]);
@@ -142,7 +125,6 @@ export class UniqueNote extends ExtendedNote {
142
125
  await AztecAddress.random(),
143
126
  await AztecAddress.random(),
144
127
  Fr.random(),
145
- NoteSelector.random(),
146
128
  TxHash.random(),
147
129
  Fr.random(),
148
130
  );
@@ -152,14 +134,13 @@ export class UniqueNote extends ExtendedNote {
152
134
  const reader = BufferReader.asReader(buffer);
153
135
 
154
136
  const note = reader.readObject(Note);
155
- const owner = reader.readObject(AztecAddress);
137
+ const recipient = reader.readObject(AztecAddress);
156
138
  const contractAddress = reader.readObject(AztecAddress);
157
139
  const storageSlot = reader.readObject(Fr);
158
- const noteTypeId = reader.readObject(NoteSelector);
159
140
  const txHash = reader.readObject(TxHash);
160
141
  const nonce = reader.readObject(Fr);
161
142
 
162
- return new this(note, owner, contractAddress, storageSlot, noteTypeId, txHash, nonce);
143
+ return new this(note, recipient, contractAddress, storageSlot, txHash, nonce);
163
144
  }
164
145
 
165
146
  static override fromString(str: string) {
@@ -18,8 +18,8 @@ export type NotesFilter = {
18
18
  contractAddress?: AztecAddress;
19
19
  /** The specific storage location of the note on the contract. */
20
20
  storageSlot?: Fr;
21
- /** The owner of the note (whose public key was used to encrypt the note). */
22
- owner?: AztecAddress;
21
+ /** The recipient of the note (whose public key was used to encrypt the note). */
22
+ recipient?: AztecAddress;
23
23
  /** The status of the note. Defaults to 'ACTIVE'. */
24
24
  status?: NoteStatus;
25
25
  /** The siloed nullifier for the note. */
@@ -32,7 +32,7 @@ export const NotesFilterSchema: ZodFor<NotesFilter> = z.object({
32
32
  txHash: TxHash.schema.optional(),
33
33
  contractAddress: schemas.AztecAddress.optional(),
34
34
  storageSlot: schemas.Fr.optional(),
35
- owner: schemas.AztecAddress.optional(),
35
+ recipient: schemas.AztecAddress.optional(),
36
36
  status: z.nativeEnum(NoteStatus).optional(),
37
37
  siloedNullifier: schemas.Fr.optional(),
38
38
  scopes: z.array(schemas.AztecAddress).optional(),