@aztec/pxe 0.0.1-commit.f146247c → 0.0.1-commit.f1b29a41e

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 (212) hide show
  1. package/dest/access_scopes.d.ts +9 -0
  2. package/dest/access_scopes.d.ts.map +1 -0
  3. package/dest/access_scopes.js +6 -0
  4. package/dest/block_synchronizer/block_synchronizer.d.ts +4 -2
  5. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  6. package/dest/block_synchronizer/block_synchronizer.js +13 -1
  7. package/dest/config/index.d.ts +2 -2
  8. package/dest/config/index.d.ts.map +1 -1
  9. package/dest/config/index.js +1 -1
  10. package/dest/config/package_info.js +1 -1
  11. package/dest/contract_function_simulator/contract_function_simulator.d.ts +61 -29
  12. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/contract_function_simulator.js +201 -72
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  17. package/dest/contract_function_simulator/index.d.ts +2 -1
  18. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/index.js +1 -0
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -5
  21. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -9
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
  26. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -6
  27. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +5 -10
  29. package/dest/contract_function_simulator/oracle/interfaces.d.ts +50 -45
  30. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  32. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +38 -0
  34. package/dest/contract_function_simulator/oracle/oracle.d.ts +64 -44
  35. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/oracle.js +206 -104
  37. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  38. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +54 -78
  39. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +99 -86
  41. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +93 -53
  42. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +233 -119
  44. package/dest/contract_logging.d.ts +27 -0
  45. package/dest/contract_logging.d.ts.map +1 -0
  46. package/dest/contract_logging.js +38 -0
  47. package/dest/contract_sync/contract_sync_service.d.ts +46 -0
  48. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  49. package/dest/contract_sync/contract_sync_service.js +124 -0
  50. package/dest/contract_sync/helpers.d.ts +29 -0
  51. package/dest/contract_sync/helpers.d.ts.map +1 -0
  52. package/dest/contract_sync/{index.js → helpers.js} +19 -13
  53. package/dest/debug/pxe_debug_utils.d.ts +14 -10
  54. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  55. package/dest/debug/pxe_debug_utils.js +16 -15
  56. package/dest/entrypoints/client/bundle/index.d.ts +4 -1
  57. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  58. package/dest/entrypoints/client/bundle/index.js +3 -0
  59. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  60. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  61. package/dest/entrypoints/client/bundle/utils.js +9 -1
  62. package/dest/entrypoints/client/lazy/index.d.ts +4 -1
  63. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  64. package/dest/entrypoints/client/lazy/index.js +3 -0
  65. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  66. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  67. package/dest/entrypoints/client/lazy/utils.js +9 -1
  68. package/dest/entrypoints/server/index.d.ts +4 -2
  69. package/dest/entrypoints/server/index.d.ts.map +1 -1
  70. package/dest/entrypoints/server/index.js +3 -1
  71. package/dest/entrypoints/server/utils.js +9 -1
  72. package/dest/events/event_service.d.ts +3 -2
  73. package/dest/events/event_service.d.ts.map +1 -1
  74. package/dest/events/event_service.js +16 -4
  75. package/dest/logs/log_service.d.ts +6 -6
  76. package/dest/logs/log_service.d.ts.map +1 -1
  77. package/dest/logs/log_service.js +32 -43
  78. package/dest/messages/message_context_service.d.ts +17 -0
  79. package/dest/messages/message_context_service.d.ts.map +1 -0
  80. package/dest/messages/message_context_service.js +36 -0
  81. package/dest/notes/note_service.d.ts +5 -4
  82. package/dest/notes/note_service.d.ts.map +1 -1
  83. package/dest/notes/note_service.js +17 -7
  84. package/dest/notes_filter.d.ts +25 -0
  85. package/dest/notes_filter.d.ts.map +1 -0
  86. package/dest/notes_filter.js +4 -0
  87. package/dest/oracle_version.d.ts +2 -2
  88. package/dest/oracle_version.js +3 -3
  89. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  90. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  91. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  92. package/dest/private_kernel/hints/index.d.ts +1 -1
  93. package/dest/private_kernel/hints/index.js +1 -1
  94. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  95. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  96. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  97. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  98. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  99. package/dest/private_kernel/hints/test_utils.js +203 -0
  100. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  101. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  102. package/dest/private_kernel/private_kernel_execution_prover.js +19 -11
  103. package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
  104. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  105. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  106. package/dest/pxe.d.ts +74 -24
  107. package/dest/pxe.d.ts.map +1 -1
  108. package/dest/pxe.js +126 -74
  109. package/dest/storage/capsule_store/capsule_service.d.ts +22 -0
  110. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  111. package/dest/storage/capsule_store/capsule_service.js +50 -0
  112. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  113. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  114. package/dest/storage/capsule_store/capsule_store.js +33 -28
  115. package/dest/storage/capsule_store/index.d.ts +2 -1
  116. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  117. package/dest/storage/capsule_store/index.js +1 -0
  118. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  119. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  120. package/dest/storage/contract_store/contract_store.js +145 -69
  121. package/dest/storage/metadata.d.ts +1 -1
  122. package/dest/storage/metadata.js +1 -1
  123. package/dest/storage/note_store/note_store.d.ts +3 -3
  124. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  125. package/dest/storage/note_store/note_store.js +6 -4
  126. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  127. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  128. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  129. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  130. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  131. package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
  132. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  133. package/dest/tagging/get_all_logs_by_tags.js +17 -3
  134. package/dest/tagging/index.d.ts +3 -3
  135. package/dest/tagging/index.d.ts.map +1 -1
  136. package/dest/tagging/index.js +1 -1
  137. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  138. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  139. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
  140. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  141. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  142. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  143. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  144. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  145. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  146. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
  147. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  148. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  149. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  150. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
  151. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  152. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
  153. package/package.json +25 -16
  154. package/src/access_scopes.ts +9 -0
  155. package/src/block_synchronizer/block_synchronizer.ts +12 -0
  156. package/src/config/index.ts +1 -1
  157. package/src/config/package_info.ts +1 -1
  158. package/src/contract_function_simulator/contract_function_simulator.ts +361 -133
  159. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  160. package/src/contract_function_simulator/index.ts +1 -0
  161. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -8
  162. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
  163. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -9
  164. package/src/contract_function_simulator/oracle/interfaces.ts +63 -54
  165. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +98 -0
  166. package/src/contract_function_simulator/oracle/oracle.ts +233 -142
  167. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  168. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +125 -179
  169. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +399 -136
  170. package/src/contract_logging.ts +52 -0
  171. package/src/contract_sync/contract_sync_service.ts +192 -0
  172. package/src/contract_sync/{index.ts → helpers.ts} +23 -22
  173. package/src/debug/pxe_debug_utils.ts +48 -18
  174. package/src/entrypoints/client/bundle/index.ts +3 -0
  175. package/src/entrypoints/client/bundle/utils.ts +9 -1
  176. package/src/entrypoints/client/lazy/index.ts +3 -0
  177. package/src/entrypoints/client/lazy/utils.ts +9 -1
  178. package/src/entrypoints/server/index.ts +3 -1
  179. package/src/entrypoints/server/utils.ts +7 -7
  180. package/src/events/event_service.ts +17 -4
  181. package/src/logs/log_service.ts +63 -65
  182. package/src/messages/message_context_service.ts +44 -0
  183. package/src/notes/note_service.ts +20 -8
  184. package/src/notes_filter.ts +26 -0
  185. package/src/oracle_version.ts +3 -3
  186. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  187. package/src/private_kernel/hints/index.ts +1 -1
  188. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  189. package/src/private_kernel/hints/test_utils.ts +325 -0
  190. package/src/private_kernel/private_kernel_execution_prover.ts +19 -12
  191. package/src/private_kernel/private_kernel_oracle.ts +7 -7
  192. package/src/pxe.ts +231 -124
  193. package/src/storage/capsule_store/capsule_service.ts +91 -0
  194. package/src/storage/capsule_store/capsule_store.ts +34 -26
  195. package/src/storage/capsule_store/index.ts +1 -0
  196. package/src/storage/contract_store/contract_store.ts +174 -75
  197. package/src/storage/metadata.ts +1 -1
  198. package/src/storage/note_store/note_store.ts +12 -5
  199. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  200. package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
  201. package/src/tagging/get_all_logs_by_tags.ts +28 -4
  202. package/src/tagging/index.ts +2 -2
  203. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +7 -10
  204. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  205. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  206. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
  207. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  208. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
  209. package/dest/contract_sync/index.d.ts +0 -23
  210. package/dest/contract_sync/index.d.ts.map +0 -1
  211. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  212. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
@@ -16,6 +16,7 @@ import { BlockHash } from '@aztec/stdlib/block';
16
16
  import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
17
17
 
18
18
  import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from './interfaces.js';
19
+ import { buildLegacyOracleCallbacks } from './legacy_oracle_mappings.js';
19
20
  import { packAsHintedNote } from './note_packing_utils.js';
20
21
 
21
22
  export class UnavailableOracleError extends Error {
@@ -26,6 +27,25 @@ export class UnavailableOracleError extends Error {
26
27
 
27
28
  /**
28
29
  * A data source that has all the apis required by Aztec.nr.
30
+ *
31
+ * ## Oracle naming conventions
32
+ *
33
+ * We try to keep oracle naming consistent, please see below the conventions we adhere to.
34
+ *
35
+ * Each oracle method name has the form `aztec_{scope}_{verb}{Object}`, where:
36
+ *
37
+ * - **Scope prefix** indicates the execution context required:
38
+ * - `aztec_prv_` — available only during private function execution.
39
+ * - `aztec_utl_` — available during both utility and private execution.
40
+ *
41
+ * - **Verb** signals the operation's semantics (verb-first, then object):
42
+ * - `get` — read / lookup / get data from oracle into contract.
43
+ * - `does`/`is`/`has` — predicate (returns boolean).
44
+ * - `emit`/`notify` — propagate data from contract to oracle.
45
+ * - `set` — contract driven oracle state mutation (capsules, execution cache, tagging, etc).
46
+ * - `call` — trigger nested execution (control flow).
47
+ * - `assert` — validate a condition, throw on failure.
48
+ * - Standalone verbs (`delete`, `copy`, `decrypt`, `log`, etc) are used when no generic verb fits.
29
49
  */
30
50
  export class Oracle {
31
51
  constructor(private handler: IMiscOracle | IUtilityExecutionOracle | IPrivateExecutionOracle) {}
@@ -69,12 +89,12 @@ export class Oracle {
69
89
  name => !excludedProps.includes(name as (typeof excludedProps)[number]),
70
90
  );
71
91
 
72
- // Validate oracle names - these must be prefixed with either "private" or "utility" to indicate their scope
92
+ // Validate oracle names - these must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate their scope
73
93
  // and must correspond to a function on the Oracle class.
74
94
  oracleNames.forEach(name => {
75
- if (!name.startsWith('private') && !name.startsWith('utility')) {
95
+ if (!name.startsWith('aztec_prv_') && !name.startsWith('aztec_utl_')) {
76
96
  throw new Error(
77
- `Oracle function "${name}" must be prefixed with either "private" or "utility" to indicate its scope`,
97
+ `Oracle function "${name}" must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate its scope`,
78
98
  );
79
99
  }
80
100
 
@@ -85,48 +105,55 @@ export class Oracle {
85
105
  });
86
106
 
87
107
  // Build callback object and return it
88
- return oracleNames.reduce((acc, name) => {
108
+ const callback = oracleNames.reduce((acc, name) => {
89
109
  const method = this[name as keyof Omit<Oracle, (typeof excludedProps)[number]>];
90
110
  acc[name] = method.bind(this);
91
111
  return acc;
92
112
  }, {} as ACIRCallback);
113
+
114
+ return { ...callback, ...buildLegacyOracleCallbacks(this) };
93
115
  }
94
116
 
95
- utilityAssertCompatibleOracleVersion([version]: ACVMField[]) {
96
- this.handlerAsMisc().utilityAssertCompatibleOracleVersion(Fr.fromString(version).toNumber());
117
+ // eslint-disable-next-line camelcase
118
+ aztec_utl_assertCompatibleOracleVersion([version]: ACVMField[]) {
119
+ this.handlerAsMisc().assertCompatibleOracleVersion(Fr.fromString(version).toNumber());
97
120
  return Promise.resolve([]);
98
121
  }
99
122
 
100
- utilityGetRandomField(): Promise<ACVMField[]> {
101
- const val = this.handlerAsMisc().utilityGetRandomField();
123
+ // eslint-disable-next-line camelcase
124
+ aztec_utl_getRandomField(): Promise<ACVMField[]> {
125
+ const val = this.handlerAsMisc().getRandomField();
102
126
  return Promise.resolve([toACVMField(val)]);
103
127
  }
104
128
 
105
- privateStoreInExecutionCache(values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]> {
106
- this.handlerAsPrivate().privateStoreInExecutionCache(values.map(Fr.fromString), Fr.fromString(hash));
129
+ // eslint-disable-next-line camelcase
130
+ aztec_prv_setHashPreimage(values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]> {
131
+ this.handlerAsPrivate().setHashPreimage(values.map(Fr.fromString), Fr.fromString(hash));
107
132
  return Promise.resolve([]);
108
133
  }
109
134
 
110
- async privateLoadFromExecutionCache([returnsHash]: ACVMField[]): Promise<ACVMField[][]> {
111
- const values = await this.handlerAsPrivate().privateLoadFromExecutionCache(Fr.fromString(returnsHash));
135
+ // eslint-disable-next-line camelcase
136
+ async aztec_prv_getHashPreimage([returnsHash]: ACVMField[]): Promise<ACVMField[][]> {
137
+ const values = await this.handlerAsPrivate().getHashPreimage(Fr.fromString(returnsHash));
112
138
  return [values.map(toACVMField)];
113
139
  }
114
140
 
115
- utilityGetUtilityContext(): Promise<(ACVMField | ACVMField[])[]> {
116
- const context = this.handlerAsUtility().utilityGetUtilityContext();
141
+ // eslint-disable-next-line camelcase
142
+ aztec_utl_getUtilityContext(): Promise<(ACVMField | ACVMField[])[]> {
143
+ const context = this.handlerAsUtility().getUtilityContext();
117
144
  return Promise.resolve(context.toNoirRepresentation());
118
145
  }
119
146
 
120
- async utilityGetKeyValidationRequest([pkMHash]: ACVMField[]): Promise<ACVMField[]> {
121
- const keyValidationRequest = await this.handlerAsUtility().utilityGetKeyValidationRequest(Fr.fromString(pkMHash));
147
+ // eslint-disable-next-line camelcase
148
+ async aztec_utl_getKeyValidationRequest([pkMHash]: ACVMField[]): Promise<ACVMField[]> {
149
+ const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(Fr.fromString(pkMHash));
122
150
 
123
151
  return keyValidationRequest.toFields().map(toACVMField);
124
152
  }
125
153
 
126
- async utilityGetContractInstance([address]: ACVMField[]): Promise<ACVMField[]> {
127
- const instance = await this.handlerAsUtility().utilityGetContractInstance(
128
- AztecAddress.fromField(Fr.fromString(address)),
129
- );
154
+ // eslint-disable-next-line camelcase
155
+ async aztec_utl_getContractInstance([address]: ACVMField[]): Promise<ACVMField[]> {
156
+ const instance = await this.handlerAsUtility().getContractInstance(AztecAddress.fromField(Fr.fromString(address)));
130
157
 
131
158
  return [
132
159
  instance.salt,
@@ -137,17 +164,15 @@ export class Oracle {
137
164
  ].map(toACVMField);
138
165
  }
139
166
 
140
- async utilityGetNoteHashMembershipWitness(
167
+ // eslint-disable-next-line camelcase
168
+ async aztec_utl_getNoteHashMembershipWitness(
141
169
  [anchorBlockHash]: ACVMField[],
142
170
  [noteHash]: ACVMField[],
143
171
  ): Promise<(ACVMField | ACVMField[])[]> {
144
172
  const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
145
173
  const parsedNoteHash = Fr.fromString(noteHash);
146
174
 
147
- const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(
148
- parsedAnchorBlockHash,
149
- parsedNoteHash,
150
- );
175
+ const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
151
176
  if (!witness) {
152
177
  throw new Error(
153
178
  `Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`,
@@ -156,17 +181,15 @@ export class Oracle {
156
181
  return witness.toNoirRepresentation();
157
182
  }
158
183
 
159
- async utilityGetBlockHashMembershipWitness(
184
+ // eslint-disable-next-line camelcase
185
+ async aztec_utl_getBlockHashMembershipWitness(
160
186
  [anchorBlockHash]: ACVMField[],
161
187
  [blockHash]: ACVMField[],
162
188
  ): Promise<(ACVMField | ACVMField[])[]> {
163
189
  const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
164
190
  const parsedBlockHash = BlockHash.fromString(blockHash);
165
191
 
166
- const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(
167
- parsedAnchorBlockHash,
168
- parsedBlockHash,
169
- );
192
+ const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
170
193
  if (!witness) {
171
194
  throw new Error(
172
195
  `Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`,
@@ -175,17 +198,15 @@ export class Oracle {
175
198
  return witness.toNoirRepresentation();
176
199
  }
177
200
 
178
- async utilityGetNullifierMembershipWitness(
201
+ // eslint-disable-next-line camelcase
202
+ async aztec_utl_getNullifierMembershipWitness(
179
203
  [blockHash]: ACVMField[],
180
204
  [nullifier]: ACVMField[], // nullifier, we try to find the witness for (to prove inclusion)
181
205
  ): Promise<(ACVMField | ACVMField[])[]> {
182
206
  const parsedBlockHash = BlockHash.fromString(blockHash);
183
207
  const parsedNullifier = Fr.fromString(nullifier);
184
208
 
185
- const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(
186
- parsedBlockHash,
187
- parsedNullifier,
188
- );
209
+ const witness = await this.handlerAsUtility().getNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
189
210
  if (!witness) {
190
211
  throw new Error(
191
212
  `Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
@@ -194,17 +215,15 @@ export class Oracle {
194
215
  return witness.toNoirRepresentation();
195
216
  }
196
217
 
197
- async utilityGetLowNullifierMembershipWitness(
218
+ // eslint-disable-next-line camelcase
219
+ async aztec_utl_getLowNullifierMembershipWitness(
198
220
  [blockHash]: ACVMField[],
199
221
  [nullifier]: ACVMField[], // nullifier, we try to find the low nullifier witness for (to prove non-inclusion)
200
222
  ): Promise<(ACVMField | ACVMField[])[]> {
201
223
  const parsedBlockHash = BlockHash.fromString(blockHash);
202
224
  const parsedNullifier = Fr.fromString(nullifier);
203
225
 
204
- const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(
205
- parsedBlockHash,
206
- parsedNullifier,
207
- );
226
+ const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
208
227
  if (!witness) {
209
228
  throw new Error(
210
229
  `Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
@@ -213,14 +232,15 @@ export class Oracle {
213
232
  return witness.toNoirRepresentation();
214
233
  }
215
234
 
216
- async utilityGetPublicDataWitness(
235
+ // eslint-disable-next-line camelcase
236
+ async aztec_utl_getPublicDataWitness(
217
237
  [blockHash]: ACVMField[],
218
238
  [leafSlot]: ACVMField[],
219
239
  ): Promise<(ACVMField | ACVMField[])[]> {
220
240
  const parsedBlockHash = BlockHash.fromString(blockHash);
221
241
  const parsedLeafSlot = Fr.fromString(leafSlot);
222
242
 
223
- const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(parsedBlockHash, parsedLeafSlot);
243
+ const witness = await this.handlerAsUtility().getPublicDataWitness(parsedBlockHash, parsedLeafSlot);
224
244
  if (!witness) {
225
245
  throw new Error(
226
246
  `Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`,
@@ -229,34 +249,45 @@ export class Oracle {
229
249
  return witness.toNoirRepresentation();
230
250
  }
231
251
 
232
- async utilityGetBlockHeader([blockNumber]: ACVMField[]): Promise<ACVMField[]> {
252
+ // eslint-disable-next-line camelcase
253
+ async aztec_utl_getBlockHeader([blockNumber]: ACVMField[]): Promise<ACVMField[]> {
233
254
  const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
234
255
 
235
- const header = await this.handlerAsUtility().utilityGetBlockHeader(BlockNumber(parsedBlockNumber));
256
+ const header = await this.handlerAsUtility().getBlockHeader(BlockNumber(parsedBlockNumber));
236
257
  if (!header) {
237
258
  throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
238
259
  }
239
260
  return header.toFields().map(toACVMField);
240
261
  }
241
262
 
242
- async utilityGetAuthWitness([messageHash]: ACVMField[]): Promise<ACVMField[][]> {
263
+ // eslint-disable-next-line camelcase
264
+ async aztec_utl_getAuthWitness([messageHash]: ACVMField[]): Promise<ACVMField[][]> {
243
265
  const messageHashField = Fr.fromString(messageHash);
244
- const witness = await this.handlerAsUtility().utilityGetAuthWitness(messageHashField);
266
+ const witness = await this.handlerAsUtility().getAuthWitness(messageHashField);
245
267
  if (!witness) {
246
268
  throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
247
269
  }
248
270
  return [witness.map(toACVMField)];
249
271
  }
250
272
 
251
- async utilityGetPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<ACVMField[][]> {
273
+ // eslint-disable-next-line camelcase
274
+ async aztec_utl_getPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
252
275
  const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
253
- const { publicKeys, partialAddress } =
254
- await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(parsedAddress);
276
+ const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
255
277
 
256
- return [[...publicKeys.toFields(), partialAddress].map(toACVMField)];
278
+ // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
279
+ // with two fields: `some` (a boolean) and `value` (a field array in this case).
280
+ if (result === undefined) {
281
+ // No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
282
+ return [toACVMField(0), Array(13).fill(toACVMField(0))];
283
+ } else {
284
+ // Data was found so we set `some` to 1 and return it along with `value`.
285
+ return [toACVMField(1), [...result.publicKeys.toFields(), result.partialAddress].map(toACVMField)];
286
+ }
257
287
  }
258
288
 
259
- async utilityGetNotes(
289
+ // eslint-disable-next-line camelcase
290
+ async aztec_utl_getNotes(
260
291
  [ownerSome]: ACVMField[],
261
292
  [ownerValue]: ACVMField[],
262
293
  [storageSlot]: ACVMField[],
@@ -278,7 +309,7 @@ export class Oracle {
278
309
  ): Promise<(ACVMField | ACVMField[])[]> {
279
310
  // Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
280
311
  const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
281
- const noteDatas = await this.handlerAsUtility().utilityGetNotes(
312
+ const noteDatas = await this.handlerAsUtility().getNotes(
282
313
  owner,
283
314
  Fr.fromString(storageSlot),
284
315
  +numSelects,
@@ -317,7 +348,8 @@ export class Oracle {
317
348
  return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
318
349
  }
319
350
 
320
- privateNotifyCreatedNote(
351
+ // eslint-disable-next-line camelcase
352
+ aztec_prv_notifyCreatedNote(
321
353
  [owner]: ACVMField[],
322
354
  [storageSlot]: ACVMField[],
323
355
  [randomness]: ACVMField[],
@@ -326,7 +358,7 @@ export class Oracle {
326
358
  [noteHash]: ACVMField[],
327
359
  [counter]: ACVMField[],
328
360
  ): Promise<ACVMField[]> {
329
- this.handlerAsPrivate().privateNotifyCreatedNote(
361
+ this.handlerAsPrivate().notifyCreatedNote(
330
362
  AztecAddress.fromString(owner),
331
363
  Fr.fromString(storageSlot),
332
364
  Fr.fromString(randomness),
@@ -338,43 +370,47 @@ export class Oracle {
338
370
  return Promise.resolve([]);
339
371
  }
340
372
 
341
- async privateNotifyNullifiedNote(
373
+ // eslint-disable-next-line camelcase
374
+ async aztec_prv_notifyNullifiedNote(
342
375
  [innerNullifier]: ACVMField[],
343
376
  [noteHash]: ACVMField[],
344
377
  [counter]: ACVMField[],
345
378
  ): Promise<ACVMField[]> {
346
- await this.handlerAsPrivate().privateNotifyNullifiedNote(
347
- Fr.fromString(innerNullifier),
348
- Fr.fromString(noteHash),
349
- +counter,
350
- );
379
+ await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
351
380
  return [];
352
381
  }
353
382
 
354
- async privateNotifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
355
- await this.handlerAsPrivate().privateNotifyCreatedNullifier(Fr.fromString(innerNullifier));
383
+ // eslint-disable-next-line camelcase
384
+ async aztec_prv_notifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
385
+ await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
356
386
  return [];
357
387
  }
358
388
 
359
- async privateIsNullifierPending([innerNullifier]: ACVMField[], [contractAddress]: ACVMField[]): Promise<ACVMField[]> {
360
- const isPending = await this.handlerAsPrivate().privateIsNullifierPending(
389
+ // eslint-disable-next-line camelcase
390
+ async aztec_prv_isNullifierPending(
391
+ [innerNullifier]: ACVMField[],
392
+ [contractAddress]: ACVMField[],
393
+ ): Promise<ACVMField[]> {
394
+ const isPending = await this.handlerAsPrivate().isNullifierPending(
361
395
  Fr.fromString(innerNullifier),
362
396
  AztecAddress.fromString(contractAddress),
363
397
  );
364
398
  return [toACVMField(isPending)];
365
399
  }
366
400
 
367
- async utilityCheckNullifierExists([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
368
- const exists = await this.handlerAsUtility().utilityCheckNullifierExists(Fr.fromString(innerNullifier));
401
+ // eslint-disable-next-line camelcase
402
+ async aztec_utl_doesNullifierExist([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
403
+ const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
369
404
  return [toACVMField(exists)];
370
405
  }
371
406
 
372
- async utilityGetL1ToL2MembershipWitness(
407
+ // eslint-disable-next-line camelcase
408
+ async aztec_utl_getL1ToL2MembershipWitness(
373
409
  [contractAddress]: ACVMField[],
374
410
  [messageHash]: ACVMField[],
375
411
  [secret]: ACVMField[],
376
412
  ): Promise<(ACVMField | ACVMField[])[]> {
377
- const message = await this.handlerAsUtility().utilityGetL1ToL2MembershipWitness(
413
+ const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(
378
414
  AztecAddress.fromString(contractAddress),
379
415
  Fr.fromString(messageHash),
380
416
  Fr.fromString(secret),
@@ -382,13 +418,14 @@ export class Oracle {
382
418
  return message.toNoirRepresentation();
383
419
  }
384
420
 
385
- async utilityStorageRead(
421
+ // eslint-disable-next-line camelcase
422
+ async aztec_utl_getFromPublicStorage(
386
423
  [blockHash]: ACVMField[],
387
424
  [contractAddress]: ACVMField[],
388
425
  [startStorageSlot]: ACVMField[],
389
426
  [numberOfElements]: ACVMField[],
390
427
  ): Promise<ACVMField[][]> {
391
- const values = await this.handlerAsUtility().utilityStorageRead(
428
+ const values = await this.handlerAsUtility().getFromPublicStorage(
392
429
  BlockHash.fromString(blockHash),
393
430
  new AztecAddress(Fr.fromString(contractAddress)),
394
431
  Fr.fromString(startStorageSlot),
@@ -397,7 +434,8 @@ export class Oracle {
397
434
  return [values.map(toACVMField)];
398
435
  }
399
436
 
400
- privateNotifyCreatedContractClassLog(
437
+ // eslint-disable-next-line camelcase
438
+ aztec_prv_notifyCreatedContractClassLog(
401
439
  [contractAddress]: ACVMField[],
402
440
  message: ACVMField[],
403
441
  [length]: ACVMField[],
@@ -406,11 +444,12 @@ export class Oracle {
406
444
  const logFields = new ContractClassLogFields(message.map(Fr.fromString));
407
445
  const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
408
446
 
409
- this.handlerAsPrivate().privateNotifyCreatedContractClassLog(log, +counter);
447
+ this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
410
448
  return Promise.resolve([]);
411
449
  }
412
450
 
413
- utilityDebugLog(
451
+ // eslint-disable-next-line camelcase
452
+ async aztec_utl_log(
414
453
  level: ACVMField[],
415
454
  message: ACVMField[],
416
455
  _ignoredFieldsSize: ACVMField[],
@@ -419,20 +458,21 @@ export class Oracle {
419
458
  const levelFr = Fr.fromString(level[0]);
420
459
  const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
421
460
  const fieldsFr = fields.map(Fr.fromString);
422
- this.handlerAsMisc().utilityDebugLog(levelFr.toNumber(), messageStr, fieldsFr);
423
- return Promise.resolve([]);
461
+ await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
462
+ return [];
424
463
  }
425
464
 
426
465
  // This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
427
466
  // change the name here.
428
- async privateCallPrivateFunction(
467
+ // eslint-disable-next-line camelcase
468
+ async aztec_prv_callPrivateFunction(
429
469
  [contractAddress]: ACVMField[],
430
470
  [functionSelector]: ACVMField[],
431
471
  [argsHash]: ACVMField[],
432
472
  [sideEffectCounter]: ACVMField[],
433
473
  [isStaticCall]: ACVMField[],
434
474
  ): Promise<ACVMField[][]> {
435
- const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().privateCallPrivateFunction(
475
+ const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(
436
476
  AztecAddress.fromField(Fr.fromString(contractAddress)),
437
477
  FunctionSelector.fromField(Fr.fromString(functionSelector)),
438
478
  Fr.fromString(argsHash),
@@ -442,113 +482,127 @@ export class Oracle {
442
482
  return [[endSideEffectCounter, returnsHash].map(toACVMField)];
443
483
  }
444
484
 
445
- async privateNotifyEnqueuedPublicFunctionCall(
446
- [contractAddress]: ACVMField[],
447
- [calldataHash]: ACVMField[],
448
- [sideEffectCounter]: ACVMField[],
449
- [isStaticCall]: ACVMField[],
450
- ): Promise<ACVMField[]> {
451
- await this.handlerAsPrivate().privateNotifyEnqueuedPublicFunctionCall(
452
- AztecAddress.fromString(contractAddress),
453
- Fr.fromString(calldataHash),
454
- Fr.fromString(sideEffectCounter).toNumber(),
455
- Fr.fromString(isStaticCall).toBool(),
456
- );
457
- return [];
458
- }
459
-
460
- async privateNotifySetPublicTeardownFunctionCall(
461
- [contractAddress]: ACVMField[],
462
- [calldataHash]: ACVMField[],
463
- [sideEffectCounter]: ACVMField[],
464
- [isStaticCall]: ACVMField[],
465
- ): Promise<ACVMField[]> {
466
- await this.handlerAsPrivate().privateNotifySetPublicTeardownFunctionCall(
467
- AztecAddress.fromString(contractAddress),
468
- Fr.fromString(calldataHash),
469
- Fr.fromString(sideEffectCounter).toNumber(),
470
- Fr.fromString(isStaticCall).toBool(),
471
- );
485
+ // eslint-disable-next-line camelcase
486
+ async aztec_prv_assertValidPublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
487
+ await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
472
488
  return [];
473
489
  }
474
490
 
475
- async privateNotifySetMinRevertibleSideEffectCounter([minRevertibleSideEffectCounter]: ACVMField[]): Promise<
476
- ACVMField[]
477
- > {
478
- await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(
479
- Fr.fromString(minRevertibleSideEffectCounter).toNumber(),
480
- );
491
+ // eslint-disable-next-line camelcase
492
+ async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
493
+ await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
481
494
  return Promise.resolve([]);
482
495
  }
483
496
 
484
- async privateIsSideEffectCounterRevertible([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
485
- const isRevertible = await this.handlerAsPrivate().privateIsSideEffectCounterRevertible(
497
+ // eslint-disable-next-line camelcase
498
+ async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
499
+ const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(
486
500
  Fr.fromString(sideEffectCounter).toNumber(),
487
501
  );
488
502
  return Promise.resolve([toACVMField(isRevertible)]);
489
503
  }
490
504
 
491
- async privateGetNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
492
- const tag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(
505
+ // eslint-disable-next-line camelcase
506
+ async aztec_prv_getNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
507
+ const tag = await this.handlerAsPrivate().getNextAppTagAsSender(
493
508
  AztecAddress.fromString(sender),
494
509
  AztecAddress.fromString(recipient),
495
510
  );
496
511
  return [toACVMField(tag.value)];
497
512
  }
498
513
 
499
- async utilityFetchTaggedLogs([pendingTaggedLogArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
500
- await this.handlerAsUtility().utilityFetchTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot));
514
+ // eslint-disable-next-line camelcase
515
+ async aztec_utl_getPendingTaggedLogs(
516
+ [pendingTaggedLogArrayBaseSlot]: ACVMField[],
517
+ [scope]: ACVMField[],
518
+ ): Promise<ACVMField[]> {
519
+ await this.handlerAsUtility().getPendingTaggedLogs(
520
+ Fr.fromString(pendingTaggedLogArrayBaseSlot),
521
+ AztecAddress.fromString(scope),
522
+ );
501
523
  return [];
502
524
  }
503
525
 
504
- async utilityValidateAndStoreEnqueuedNotesAndEvents(
526
+ // eslint-disable-next-line camelcase
527
+ async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
505
528
  [contractAddress]: ACVMField[],
506
529
  [noteValidationRequestsArrayBaseSlot]: ACVMField[],
507
530
  [eventValidationRequestsArrayBaseSlot]: ACVMField[],
531
+ [maxNotePackedLen]: ACVMField[],
532
+ [maxEventSerializedLen]: ACVMField[],
533
+ [scope]: ACVMField[],
508
534
  ): Promise<ACVMField[]> {
509
- await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(
535
+ await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
510
536
  AztecAddress.fromString(contractAddress),
511
537
  Fr.fromString(noteValidationRequestsArrayBaseSlot),
512
538
  Fr.fromString(eventValidationRequestsArrayBaseSlot),
539
+ Fr.fromString(maxNotePackedLen).toNumber(),
540
+ Fr.fromString(maxEventSerializedLen).toNumber(),
541
+ AztecAddress.fromString(scope),
513
542
  );
514
543
 
515
544
  return [];
516
545
  }
517
546
 
518
- async utilityBulkRetrieveLogs(
547
+ // eslint-disable-next-line camelcase
548
+ async aztec_utl_getLogsByTag(
519
549
  [contractAddress]: ACVMField[],
520
550
  [logRetrievalRequestsArrayBaseSlot]: ACVMField[],
521
551
  [logRetrievalResponsesArrayBaseSlot]: ACVMField[],
552
+ [scope]: ACVMField[],
522
553
  ): Promise<ACVMField[]> {
523
- await this.handlerAsUtility().utilityBulkRetrieveLogs(
554
+ await this.handlerAsUtility().getLogsByTag(
524
555
  AztecAddress.fromString(contractAddress),
525
556
  Fr.fromString(logRetrievalRequestsArrayBaseSlot),
526
557
  Fr.fromString(logRetrievalResponsesArrayBaseSlot),
558
+ AztecAddress.fromString(scope),
559
+ );
560
+ return [];
561
+ }
562
+
563
+ // eslint-disable-next-line camelcase
564
+ async aztec_utl_getMessageContextsByTxHash(
565
+ [contractAddress]: ACVMField[],
566
+ [messageContextRequestsArrayBaseSlot]: ACVMField[],
567
+ [messageContextResponsesArrayBaseSlot]: ACVMField[],
568
+ [scope]: ACVMField[],
569
+ ): Promise<ACVMField[]> {
570
+ await this.handlerAsUtility().getMessageContextsByTxHash(
571
+ AztecAddress.fromString(contractAddress),
572
+ Fr.fromString(messageContextRequestsArrayBaseSlot),
573
+ Fr.fromString(messageContextResponsesArrayBaseSlot),
574
+ AztecAddress.fromString(scope),
527
575
  );
528
576
  return [];
529
577
  }
530
578
 
531
- async utilityStoreCapsule(
579
+ // eslint-disable-next-line camelcase
580
+ aztec_utl_setCapsule(
532
581
  [contractAddress]: ACVMField[],
533
582
  [slot]: ACVMField[],
534
583
  capsule: ACVMField[],
584
+ [scope]: ACVMField[],
535
585
  ): Promise<ACVMField[]> {
536
- await this.handlerAsUtility().utilityStoreCapsule(
586
+ this.handlerAsUtility().setCapsule(
537
587
  AztecAddress.fromField(Fr.fromString(contractAddress)),
538
588
  Fr.fromString(slot),
539
589
  capsule.map(Fr.fromString),
590
+ AztecAddress.fromField(Fr.fromString(scope)),
540
591
  );
541
- return [];
592
+ return Promise.resolve([]);
542
593
  }
543
594
 
544
- async utilityLoadCapsule(
595
+ // eslint-disable-next-line camelcase
596
+ async aztec_utl_getCapsule(
545
597
  [contractAddress]: ACVMField[],
546
598
  [slot]: ACVMField[],
547
599
  [tSize]: ACVMField[],
600
+ [scope]: ACVMField[],
548
601
  ): Promise<(ACVMField | ACVMField[])[]> {
549
- const values = await this.handlerAsUtility().utilityLoadCapsule(
602
+ const values = await this.handlerAsUtility().getCapsule(
550
603
  AztecAddress.fromField(Fr.fromString(contractAddress)),
551
604
  Fr.fromString(slot),
605
+ AztecAddress.fromField(Fr.fromString(scope)),
552
606
  );
553
607
 
554
608
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
@@ -562,30 +616,40 @@ export class Oracle {
562
616
  }
563
617
  }
564
618
 
565
- async utilityDeleteCapsule([contractAddress]: ACVMField[], [slot]: ACVMField[]): Promise<ACVMField[]> {
566
- await this.handlerAsUtility().utilityDeleteCapsule(
619
+ // eslint-disable-next-line camelcase
620
+ aztec_utl_deleteCapsule(
621
+ [contractAddress]: ACVMField[],
622
+ [slot]: ACVMField[],
623
+ [scope]: ACVMField[],
624
+ ): Promise<ACVMField[]> {
625
+ this.handlerAsUtility().deleteCapsule(
567
626
  AztecAddress.fromField(Fr.fromString(contractAddress)),
568
627
  Fr.fromString(slot),
628
+ AztecAddress.fromField(Fr.fromString(scope)),
569
629
  );
570
- return [];
630
+ return Promise.resolve([]);
571
631
  }
572
632
 
573
- async utilityCopyCapsule(
633
+ // eslint-disable-next-line camelcase
634
+ async aztec_utl_copyCapsule(
574
635
  [contractAddress]: ACVMField[],
575
636
  [srcSlot]: ACVMField[],
576
637
  [dstSlot]: ACVMField[],
577
638
  [numEntries]: ACVMField[],
639
+ [scope]: ACVMField[],
578
640
  ): Promise<ACVMField[]> {
579
- await this.handlerAsUtility().utilityCopyCapsule(
641
+ await this.handlerAsUtility().copyCapsule(
580
642
  AztecAddress.fromField(Fr.fromString(contractAddress)),
581
643
  Fr.fromString(srcSlot),
582
644
  Fr.fromString(dstSlot),
583
645
  Fr.fromString(numEntries).toNumber(),
646
+ AztecAddress.fromField(Fr.fromString(scope)),
584
647
  );
585
648
  return [];
586
649
  }
587
650
 
588
- async utilityAes128Decrypt(
651
+ // eslint-disable-next-line camelcase
652
+ async aztec_utl_decryptAes128(
589
653
  ciphertextBVecStorage: ACVMField[],
590
654
  [ciphertextLength]: ACVMField[],
591
655
  iv: ACVMField[],
@@ -595,36 +659,63 @@ export class Oracle {
595
659
  const ivBuffer = fromUintArray(iv, 8);
596
660
  const symKeyBuffer = fromUintArray(symKey, 8);
597
661
 
598
- const plaintext = await this.handlerAsUtility().utilityAes128Decrypt(ciphertext, ivBuffer, symKeyBuffer);
599
- return bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
662
+ // Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
663
+ try {
664
+ const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
665
+ const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
666
+ return [toACVMField(1), storage, length];
667
+ } catch {
668
+ const zeroStorage = Array(ciphertextBVecStorage.length).fill(toACVMField(0));
669
+ return [toACVMField(0), zeroStorage, toACVMField(0)];
670
+ }
600
671
  }
601
672
 
602
- async utilityGetSharedSecret(
673
+ // eslint-disable-next-line camelcase
674
+ async aztec_utl_getSharedSecret(
603
675
  [address]: ACVMField[],
604
676
  [ephPKField0]: ACVMField[],
605
677
  [ephPKField1]: ACVMField[],
606
678
  [ephPKField2]: ACVMField[],
679
+ [contractAddress]: ACVMField[],
607
680
  ): Promise<ACVMField[]> {
608
- const secret = await this.handlerAsUtility().utilityGetSharedSecret(
681
+ const secret = await this.handlerAsUtility().getSharedSecret(
609
682
  AztecAddress.fromField(Fr.fromString(address)),
610
683
  Point.fromFields([ephPKField0, ephPKField1, ephPKField2].map(Fr.fromString)),
684
+ AztecAddress.fromField(Fr.fromString(contractAddress)),
685
+ );
686
+ return [toACVMField(secret)];
687
+ }
688
+
689
+ // eslint-disable-next-line camelcase
690
+ aztec_utl_setContractSyncCacheInvalid(
691
+ [contractAddress]: ACVMField[],
692
+ scopes: ACVMField[],
693
+ [scopeCount]: ACVMField[],
694
+ ): Promise<ACVMField[]> {
695
+ const scopeAddresses = scopes.slice(0, +scopeCount).map(s => AztecAddress.fromField(Fr.fromString(s)));
696
+ this.handlerAsUtility().setContractSyncCacheInvalid(
697
+ AztecAddress.fromField(Fr.fromString(contractAddress)),
698
+ scopeAddresses,
611
699
  );
612
- return secret.toFields().map(toACVMField);
700
+ return Promise.resolve([]);
613
701
  }
614
702
 
615
- async utilityEmitOffchainEffect(data: ACVMField[]) {
616
- await this.handlerAsPrivate().utilityEmitOffchainEffect(data.map(Fr.fromString));
703
+ // eslint-disable-next-line camelcase
704
+ async aztec_utl_emitOffchainEffect(data: ACVMField[]) {
705
+ await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
617
706
  return [];
618
707
  }
619
708
 
620
- async privateGetSenderForTags(): Promise<ACVMField[]> {
621
- const sender = await this.handlerAsPrivate().privateGetSenderForTags();
709
+ // eslint-disable-next-line camelcase
710
+ async aztec_prv_getSenderForTags(): Promise<ACVMField[]> {
711
+ const sender = await this.handlerAsPrivate().getSenderForTags();
622
712
  // Return [1, address] for Some(address), [0, 0] for None
623
713
  return sender ? [toACVMField(1n), toACVMField(sender)] : [toACVMField(0n), toACVMField(0n)];
624
714
  }
625
715
 
626
- async privateSetSenderForTags([senderForTags]: ACVMField[]): Promise<ACVMField[]> {
627
- await this.handlerAsPrivate().privateSetSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
716
+ // eslint-disable-next-line camelcase
717
+ async aztec_prv_setSenderForTags([senderForTags]: ACVMField[]): Promise<ACVMField[]> {
718
+ await this.handlerAsPrivate().setSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
628
719
  return [];
629
720
  }
630
721
  }