@aztec/pxe 0.0.1-commit.c2595eba → 0.0.1-commit.c2eed6949

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