@aztec/pxe 0.0.1-commit.e2b2873ed → 0.0.1-commit.e304674f1
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.
- package/dest/block_synchronizer/block_synchronizer.d.ts +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +6 -0
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +14 -7
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +138 -45
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -5
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -9
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -6
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +5 -10
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +50 -45
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +38 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +64 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +187 -97
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +23 -48
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +50 -81
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +66 -46
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +190 -99
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +9 -2
- package/dest/contract_logging.d.ts +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/contract_sync/contract_sync_service.d.ts +7 -5
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +45 -38
- package/dest/contract_sync/helpers.d.ts +2 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +9 -4
- package/dest/debug/pxe_debug_utils.d.ts +4 -3
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +4 -4
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +2 -2
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +2 -2
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +2 -2
- package/dest/events/event_service.d.ts +3 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +16 -4
- package/dest/logs/log_service.d.ts +6 -6
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +34 -32
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- package/dest/notes/note_service.d.ts +4 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +17 -7
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +3 -3
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +19 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +7 -3
- package/dest/pxe.d.ts +18 -14
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +74 -48
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +33 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +140 -64
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +3 -2
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +2 -2
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- package/dest/tagging/index.d.ts +3 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
- package/package.json +16 -16
- package/src/block_synchronizer/block_synchronizer.ts +6 -0
- package/src/config/index.ts +1 -1
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +254 -65
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -8
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -9
- package/src/contract_function_simulator/oracle/interfaces.ts +63 -54
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +98 -0
- package/src/contract_function_simulator/oracle/oracle.ts +223 -139
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +58 -102
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +320 -122
- package/src/contract_function_simulator/pick_notes.ts +9 -2
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +79 -54
- package/src/contract_sync/helpers.ts +8 -3
- package/src/debug/pxe_debug_utils.ts +8 -7
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +2 -3
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +2 -3
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +1 -0
- package/src/entrypoints/server/utils.ts +2 -3
- package/src/events/event_service.ts +17 -4
- package/src/logs/log_service.ts +68 -51
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +19 -8
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +3 -3
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +19 -12
- package/src/private_kernel/private_kernel_oracle.ts +7 -7
- package/src/pxe.ts +104 -61
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +34 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +170 -71
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +4 -3
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/index.ts +2 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +7 -10
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- 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 "
|
|
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('
|
|
95
|
+
if (!name.startsWith('aztec_prv_') && !name.startsWith('aztec_utl_')) {
|
|
76
96
|
throw new Error(
|
|
77
|
-
`Oracle function "${name}" must be prefixed with either "
|
|
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
|
-
|
|
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
|
-
|
|
96
|
-
|
|
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
|
-
|
|
101
|
-
|
|
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
|
-
|
|
106
|
-
|
|
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
|
-
|
|
111
|
-
|
|
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
|
-
|
|
116
|
-
|
|
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
|
-
|
|
121
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
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().
|
|
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
|
-
|
|
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().
|
|
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
|
-
|
|
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().
|
|
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
|
-
|
|
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().
|
|
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
|
-
|
|
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().
|
|
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,28 +249,31 @@ export class Oracle {
|
|
|
229
249
|
return witness.toNoirRepresentation();
|
|
230
250
|
}
|
|
231
251
|
|
|
232
|
-
|
|
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().
|
|
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
|
-
|
|
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().
|
|
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
|
-
|
|
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 result = await this.handlerAsUtility().
|
|
276
|
+
const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
|
|
254
277
|
|
|
255
278
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
256
279
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -263,7 +286,8 @@ export class Oracle {
|
|
|
263
286
|
}
|
|
264
287
|
}
|
|
265
288
|
|
|
266
|
-
|
|
289
|
+
// eslint-disable-next-line camelcase
|
|
290
|
+
async aztec_utl_getNotes(
|
|
267
291
|
[ownerSome]: ACVMField[],
|
|
268
292
|
[ownerValue]: ACVMField[],
|
|
269
293
|
[storageSlot]: ACVMField[],
|
|
@@ -285,7 +309,7 @@ export class Oracle {
|
|
|
285
309
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
286
310
|
// Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
|
|
287
311
|
const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
|
|
288
|
-
const noteDatas = await this.handlerAsUtility().
|
|
312
|
+
const noteDatas = await this.handlerAsUtility().getNotes(
|
|
289
313
|
owner,
|
|
290
314
|
Fr.fromString(storageSlot),
|
|
291
315
|
+numSelects,
|
|
@@ -324,7 +348,8 @@ export class Oracle {
|
|
|
324
348
|
return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
|
|
325
349
|
}
|
|
326
350
|
|
|
327
|
-
|
|
351
|
+
// eslint-disable-next-line camelcase
|
|
352
|
+
aztec_prv_notifyCreatedNote(
|
|
328
353
|
[owner]: ACVMField[],
|
|
329
354
|
[storageSlot]: ACVMField[],
|
|
330
355
|
[randomness]: ACVMField[],
|
|
@@ -333,7 +358,7 @@ export class Oracle {
|
|
|
333
358
|
[noteHash]: ACVMField[],
|
|
334
359
|
[counter]: ACVMField[],
|
|
335
360
|
): Promise<ACVMField[]> {
|
|
336
|
-
this.handlerAsPrivate().
|
|
361
|
+
this.handlerAsPrivate().notifyCreatedNote(
|
|
337
362
|
AztecAddress.fromString(owner),
|
|
338
363
|
Fr.fromString(storageSlot),
|
|
339
364
|
Fr.fromString(randomness),
|
|
@@ -345,43 +370,47 @@ export class Oracle {
|
|
|
345
370
|
return Promise.resolve([]);
|
|
346
371
|
}
|
|
347
372
|
|
|
348
|
-
|
|
373
|
+
// eslint-disable-next-line camelcase
|
|
374
|
+
async aztec_prv_notifyNullifiedNote(
|
|
349
375
|
[innerNullifier]: ACVMField[],
|
|
350
376
|
[noteHash]: ACVMField[],
|
|
351
377
|
[counter]: ACVMField[],
|
|
352
378
|
): Promise<ACVMField[]> {
|
|
353
|
-
await this.handlerAsPrivate().
|
|
354
|
-
Fr.fromString(innerNullifier),
|
|
355
|
-
Fr.fromString(noteHash),
|
|
356
|
-
+counter,
|
|
357
|
-
);
|
|
379
|
+
await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
|
|
358
380
|
return [];
|
|
359
381
|
}
|
|
360
382
|
|
|
361
|
-
|
|
362
|
-
|
|
383
|
+
// eslint-disable-next-line camelcase
|
|
384
|
+
async aztec_prv_notifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
|
|
385
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
|
|
363
386
|
return [];
|
|
364
387
|
}
|
|
365
388
|
|
|
366
|
-
|
|
367
|
-
|
|
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(
|
|
368
395
|
Fr.fromString(innerNullifier),
|
|
369
396
|
AztecAddress.fromString(contractAddress),
|
|
370
397
|
);
|
|
371
398
|
return [toACVMField(isPending)];
|
|
372
399
|
}
|
|
373
400
|
|
|
374
|
-
|
|
375
|
-
|
|
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));
|
|
376
404
|
return [toACVMField(exists)];
|
|
377
405
|
}
|
|
378
406
|
|
|
379
|
-
|
|
407
|
+
// eslint-disable-next-line camelcase
|
|
408
|
+
async aztec_utl_getL1ToL2MembershipWitness(
|
|
380
409
|
[contractAddress]: ACVMField[],
|
|
381
410
|
[messageHash]: ACVMField[],
|
|
382
411
|
[secret]: ACVMField[],
|
|
383
412
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
384
|
-
const message = await this.handlerAsUtility().
|
|
413
|
+
const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(
|
|
385
414
|
AztecAddress.fromString(contractAddress),
|
|
386
415
|
Fr.fromString(messageHash),
|
|
387
416
|
Fr.fromString(secret),
|
|
@@ -389,13 +418,14 @@ export class Oracle {
|
|
|
389
418
|
return message.toNoirRepresentation();
|
|
390
419
|
}
|
|
391
420
|
|
|
392
|
-
|
|
421
|
+
// eslint-disable-next-line camelcase
|
|
422
|
+
async aztec_utl_getFromPublicStorage(
|
|
393
423
|
[blockHash]: ACVMField[],
|
|
394
424
|
[contractAddress]: ACVMField[],
|
|
395
425
|
[startStorageSlot]: ACVMField[],
|
|
396
426
|
[numberOfElements]: ACVMField[],
|
|
397
427
|
): Promise<ACVMField[][]> {
|
|
398
|
-
const values = await this.handlerAsUtility().
|
|
428
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(
|
|
399
429
|
BlockHash.fromString(blockHash),
|
|
400
430
|
new AztecAddress(Fr.fromString(contractAddress)),
|
|
401
431
|
Fr.fromString(startStorageSlot),
|
|
@@ -404,7 +434,8 @@ export class Oracle {
|
|
|
404
434
|
return [values.map(toACVMField)];
|
|
405
435
|
}
|
|
406
436
|
|
|
407
|
-
|
|
437
|
+
// eslint-disable-next-line camelcase
|
|
438
|
+
aztec_prv_notifyCreatedContractClassLog(
|
|
408
439
|
[contractAddress]: ACVMField[],
|
|
409
440
|
message: ACVMField[],
|
|
410
441
|
[length]: ACVMField[],
|
|
@@ -413,11 +444,12 @@ export class Oracle {
|
|
|
413
444
|
const logFields = new ContractClassLogFields(message.map(Fr.fromString));
|
|
414
445
|
const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
|
|
415
446
|
|
|
416
|
-
this.handlerAsPrivate().
|
|
447
|
+
this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
|
|
417
448
|
return Promise.resolve([]);
|
|
418
449
|
}
|
|
419
450
|
|
|
420
|
-
|
|
451
|
+
// eslint-disable-next-line camelcase
|
|
452
|
+
async aztec_utl_log(
|
|
421
453
|
level: ACVMField[],
|
|
422
454
|
message: ACVMField[],
|
|
423
455
|
_ignoredFieldsSize: ACVMField[],
|
|
@@ -426,20 +458,21 @@ export class Oracle {
|
|
|
426
458
|
const levelFr = Fr.fromString(level[0]);
|
|
427
459
|
const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
|
|
428
460
|
const fieldsFr = fields.map(Fr.fromString);
|
|
429
|
-
await this.handlerAsMisc().
|
|
461
|
+
await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
|
|
430
462
|
return [];
|
|
431
463
|
}
|
|
432
464
|
|
|
433
465
|
// This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
|
|
434
466
|
// change the name here.
|
|
435
|
-
|
|
467
|
+
// eslint-disable-next-line camelcase
|
|
468
|
+
async aztec_prv_callPrivateFunction(
|
|
436
469
|
[contractAddress]: ACVMField[],
|
|
437
470
|
[functionSelector]: ACVMField[],
|
|
438
471
|
[argsHash]: ACVMField[],
|
|
439
472
|
[sideEffectCounter]: ACVMField[],
|
|
440
473
|
[isStaticCall]: ACVMField[],
|
|
441
474
|
): Promise<ACVMField[][]> {
|
|
442
|
-
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().
|
|
475
|
+
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(
|
|
443
476
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
444
477
|
FunctionSelector.fromField(Fr.fromString(functionSelector)),
|
|
445
478
|
Fr.fromString(argsHash),
|
|
@@ -449,113 +482,127 @@ export class Oracle {
|
|
|
449
482
|
return [[endSideEffectCounter, returnsHash].map(toACVMField)];
|
|
450
483
|
}
|
|
451
484
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
[sideEffectCounter]: ACVMField[],
|
|
456
|
-
[isStaticCall]: ACVMField[],
|
|
457
|
-
): Promise<ACVMField[]> {
|
|
458
|
-
await this.handlerAsPrivate().privateNotifyEnqueuedPublicFunctionCall(
|
|
459
|
-
AztecAddress.fromString(contractAddress),
|
|
460
|
-
Fr.fromString(calldataHash),
|
|
461
|
-
Fr.fromString(sideEffectCounter).toNumber(),
|
|
462
|
-
Fr.fromString(isStaticCall).toBool(),
|
|
463
|
-
);
|
|
464
|
-
return [];
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
async privateNotifySetPublicTeardownFunctionCall(
|
|
468
|
-
[contractAddress]: ACVMField[],
|
|
469
|
-
[calldataHash]: ACVMField[],
|
|
470
|
-
[sideEffectCounter]: ACVMField[],
|
|
471
|
-
[isStaticCall]: ACVMField[],
|
|
472
|
-
): Promise<ACVMField[]> {
|
|
473
|
-
await this.handlerAsPrivate().privateNotifySetPublicTeardownFunctionCall(
|
|
474
|
-
AztecAddress.fromString(contractAddress),
|
|
475
|
-
Fr.fromString(calldataHash),
|
|
476
|
-
Fr.fromString(sideEffectCounter).toNumber(),
|
|
477
|
-
Fr.fromString(isStaticCall).toBool(),
|
|
478
|
-
);
|
|
485
|
+
// eslint-disable-next-line camelcase
|
|
486
|
+
async aztec_prv_assertValidPublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
|
|
487
|
+
await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
|
|
479
488
|
return [];
|
|
480
489
|
}
|
|
481
490
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(
|
|
486
|
-
Fr.fromString(minRevertibleSideEffectCounter).toNumber(),
|
|
487
|
-
);
|
|
491
|
+
// eslint-disable-next-line camelcase
|
|
492
|
+
async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
|
|
493
|
+
await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
488
494
|
return Promise.resolve([]);
|
|
489
495
|
}
|
|
490
496
|
|
|
491
|
-
|
|
492
|
-
|
|
497
|
+
// eslint-disable-next-line camelcase
|
|
498
|
+
async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
|
|
499
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(
|
|
493
500
|
Fr.fromString(sideEffectCounter).toNumber(),
|
|
494
501
|
);
|
|
495
502
|
return Promise.resolve([toACVMField(isRevertible)]);
|
|
496
503
|
}
|
|
497
504
|
|
|
498
|
-
|
|
499
|
-
|
|
505
|
+
// eslint-disable-next-line camelcase
|
|
506
|
+
async aztec_prv_getNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
|
|
507
|
+
const tag = await this.handlerAsPrivate().getNextAppTagAsSender(
|
|
500
508
|
AztecAddress.fromString(sender),
|
|
501
509
|
AztecAddress.fromString(recipient),
|
|
502
510
|
);
|
|
503
511
|
return [toACVMField(tag.value)];
|
|
504
512
|
}
|
|
505
513
|
|
|
506
|
-
|
|
507
|
-
|
|
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
|
+
);
|
|
508
523
|
return [];
|
|
509
524
|
}
|
|
510
525
|
|
|
511
|
-
|
|
526
|
+
// eslint-disable-next-line camelcase
|
|
527
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
512
528
|
[contractAddress]: ACVMField[],
|
|
513
529
|
[noteValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
514
530
|
[eventValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
531
|
+
[maxNotePackedLen]: ACVMField[],
|
|
532
|
+
[maxEventSerializedLen]: ACVMField[],
|
|
533
|
+
[scope]: ACVMField[],
|
|
515
534
|
): Promise<ACVMField[]> {
|
|
516
|
-
await this.handlerAsUtility().
|
|
535
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
517
536
|
AztecAddress.fromString(contractAddress),
|
|
518
537
|
Fr.fromString(noteValidationRequestsArrayBaseSlot),
|
|
519
538
|
Fr.fromString(eventValidationRequestsArrayBaseSlot),
|
|
539
|
+
Fr.fromString(maxNotePackedLen).toNumber(),
|
|
540
|
+
Fr.fromString(maxEventSerializedLen).toNumber(),
|
|
541
|
+
AztecAddress.fromString(scope),
|
|
520
542
|
);
|
|
521
543
|
|
|
522
544
|
return [];
|
|
523
545
|
}
|
|
524
546
|
|
|
525
|
-
|
|
547
|
+
// eslint-disable-next-line camelcase
|
|
548
|
+
async aztec_utl_getLogsByTag(
|
|
526
549
|
[contractAddress]: ACVMField[],
|
|
527
550
|
[logRetrievalRequestsArrayBaseSlot]: ACVMField[],
|
|
528
551
|
[logRetrievalResponsesArrayBaseSlot]: ACVMField[],
|
|
552
|
+
[scope]: ACVMField[],
|
|
529
553
|
): Promise<ACVMField[]> {
|
|
530
|
-
await this.handlerAsUtility().
|
|
554
|
+
await this.handlerAsUtility().getLogsByTag(
|
|
531
555
|
AztecAddress.fromString(contractAddress),
|
|
532
556
|
Fr.fromString(logRetrievalRequestsArrayBaseSlot),
|
|
533
557
|
Fr.fromString(logRetrievalResponsesArrayBaseSlot),
|
|
558
|
+
AztecAddress.fromString(scope),
|
|
534
559
|
);
|
|
535
560
|
return [];
|
|
536
561
|
}
|
|
537
562
|
|
|
538
|
-
|
|
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),
|
|
575
|
+
);
|
|
576
|
+
return [];
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// eslint-disable-next-line camelcase
|
|
580
|
+
aztec_utl_setCapsule(
|
|
539
581
|
[contractAddress]: ACVMField[],
|
|
540
582
|
[slot]: ACVMField[],
|
|
541
583
|
capsule: ACVMField[],
|
|
584
|
+
[scope]: ACVMField[],
|
|
542
585
|
): Promise<ACVMField[]> {
|
|
543
|
-
|
|
586
|
+
this.handlerAsUtility().setCapsule(
|
|
544
587
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
545
588
|
Fr.fromString(slot),
|
|
546
589
|
capsule.map(Fr.fromString),
|
|
590
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
547
591
|
);
|
|
548
|
-
return [];
|
|
592
|
+
return Promise.resolve([]);
|
|
549
593
|
}
|
|
550
594
|
|
|
551
|
-
|
|
595
|
+
// eslint-disable-next-line camelcase
|
|
596
|
+
async aztec_utl_getCapsule(
|
|
552
597
|
[contractAddress]: ACVMField[],
|
|
553
598
|
[slot]: ACVMField[],
|
|
554
599
|
[tSize]: ACVMField[],
|
|
600
|
+
[scope]: ACVMField[],
|
|
555
601
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
556
|
-
const values = await this.handlerAsUtility().
|
|
602
|
+
const values = await this.handlerAsUtility().getCapsule(
|
|
557
603
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
558
604
|
Fr.fromString(slot),
|
|
605
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
559
606
|
);
|
|
560
607
|
|
|
561
608
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
@@ -569,30 +616,40 @@ export class Oracle {
|
|
|
569
616
|
}
|
|
570
617
|
}
|
|
571
618
|
|
|
572
|
-
|
|
573
|
-
|
|
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(
|
|
574
626
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
575
627
|
Fr.fromString(slot),
|
|
628
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
576
629
|
);
|
|
577
|
-
return [];
|
|
630
|
+
return Promise.resolve([]);
|
|
578
631
|
}
|
|
579
632
|
|
|
580
|
-
|
|
633
|
+
// eslint-disable-next-line camelcase
|
|
634
|
+
async aztec_utl_copyCapsule(
|
|
581
635
|
[contractAddress]: ACVMField[],
|
|
582
636
|
[srcSlot]: ACVMField[],
|
|
583
637
|
[dstSlot]: ACVMField[],
|
|
584
638
|
[numEntries]: ACVMField[],
|
|
639
|
+
[scope]: ACVMField[],
|
|
585
640
|
): Promise<ACVMField[]> {
|
|
586
|
-
await this.handlerAsUtility().
|
|
641
|
+
await this.handlerAsUtility().copyCapsule(
|
|
587
642
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
588
643
|
Fr.fromString(srcSlot),
|
|
589
644
|
Fr.fromString(dstSlot),
|
|
590
645
|
Fr.fromString(numEntries).toNumber(),
|
|
646
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
591
647
|
);
|
|
592
648
|
return [];
|
|
593
649
|
}
|
|
594
650
|
|
|
595
|
-
|
|
651
|
+
// eslint-disable-next-line camelcase
|
|
652
|
+
async aztec_utl_decryptAes128(
|
|
596
653
|
ciphertextBVecStorage: ACVMField[],
|
|
597
654
|
[ciphertextLength]: ACVMField[],
|
|
598
655
|
iv: ACVMField[],
|
|
@@ -602,36 +659,63 @@ export class Oracle {
|
|
|
602
659
|
const ivBuffer = fromUintArray(iv, 8);
|
|
603
660
|
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
604
661
|
|
|
605
|
-
|
|
606
|
-
|
|
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
|
+
}
|
|
607
671
|
}
|
|
608
672
|
|
|
609
|
-
|
|
673
|
+
// eslint-disable-next-line camelcase
|
|
674
|
+
async aztec_utl_getSharedSecret(
|
|
610
675
|
[address]: ACVMField[],
|
|
611
676
|
[ephPKField0]: ACVMField[],
|
|
612
677
|
[ephPKField1]: ACVMField[],
|
|
613
678
|
[ephPKField2]: ACVMField[],
|
|
679
|
+
[contractAddress]: ACVMField[],
|
|
614
680
|
): Promise<ACVMField[]> {
|
|
615
|
-
const secret = await this.handlerAsUtility().
|
|
681
|
+
const secret = await this.handlerAsUtility().getSharedSecret(
|
|
616
682
|
AztecAddress.fromField(Fr.fromString(address)),
|
|
617
683
|
Point.fromFields([ephPKField0, ephPKField1, ephPKField2].map(Fr.fromString)),
|
|
684
|
+
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
618
685
|
);
|
|
619
|
-
return secret
|
|
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,
|
|
699
|
+
);
|
|
700
|
+
return Promise.resolve([]);
|
|
620
701
|
}
|
|
621
702
|
|
|
622
|
-
|
|
623
|
-
|
|
703
|
+
// eslint-disable-next-line camelcase
|
|
704
|
+
async aztec_utl_emitOffchainEffect(data: ACVMField[]) {
|
|
705
|
+
await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
|
|
624
706
|
return [];
|
|
625
707
|
}
|
|
626
708
|
|
|
627
|
-
|
|
628
|
-
|
|
709
|
+
// eslint-disable-next-line camelcase
|
|
710
|
+
async aztec_prv_getSenderForTags(): Promise<ACVMField[]> {
|
|
711
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
629
712
|
// Return [1, address] for Some(address), [0, 0] for None
|
|
630
713
|
return sender ? [toACVMField(1n), toACVMField(sender)] : [toACVMField(0n), toACVMField(0n)];
|
|
631
714
|
}
|
|
632
715
|
|
|
633
|
-
|
|
634
|
-
|
|
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)));
|
|
635
719
|
return [];
|
|
636
720
|
}
|
|
637
721
|
}
|