@aztec/pxe 0.0.1-commit.e3c1de76 → 0.0.1-commit.e588bc7e5
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 +4 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +13 -1
- 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 +60 -29
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +201 -72
- 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 +211 -109
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +53 -78
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +108 -86
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +100 -55
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +238 -121
- 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 +44 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +104 -0
- package/dest/contract_sync/helpers.d.ts +28 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/{index.js → helpers.js} +19 -13
- package/dest/debug/pxe_debug_utils.d.ts +14 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +16 -15
- 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 +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +9 -1
- 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 +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +9 -1
- package/dest/entrypoints/server/index.d.ts +3 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -1
- package/dest/entrypoints/server/utils.js +9 -1
- 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 +39 -44
- 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 +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- 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 +73 -24
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +126 -74
- 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 +145 -69
- 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 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +6 -4
- 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 +25 -16
- package/src/block_synchronizer/block_synchronizer.ts +12 -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 +360 -133
- 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 +69 -60
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +98 -0
- package/src/contract_function_simulator/oracle/oracle.ts +245 -144
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +134 -179
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +403 -138
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +170 -0
- package/src/contract_sync/{index.ts → helpers.ts} +22 -22
- package/src/debug/pxe_debug_utils.ts +48 -18
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +9 -1
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +9 -1
- package/src/entrypoints/server/index.ts +2 -1
- package/src/entrypoints/server/utils.ts +7 -7
- package/src/events/event_service.ts +17 -4
- package/src/logs/log_service.ts +74 -66
- 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 +229 -124
- 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 +174 -75
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +9 -5
- 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/contract_sync/index.d.ts +0 -23
- package/dest/contract_sync/index.d.ts.map +0 -1
- 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,45 +164,49 @@ export class Oracle {
|
|
|
137
164
|
].map(toACVMField);
|
|
138
165
|
}
|
|
139
166
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
[
|
|
167
|
+
// eslint-disable-next-line camelcase
|
|
168
|
+
async aztec_utl_getNoteHashMembershipWitness(
|
|
169
|
+
[anchorBlockHash]: ACVMField[],
|
|
170
|
+
[noteHash]: ACVMField[],
|
|
143
171
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
144
|
-
const
|
|
145
|
-
const
|
|
172
|
+
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
173
|
+
const parsedNoteHash = Fr.fromString(noteHash);
|
|
146
174
|
|
|
147
|
-
const witness = await this.handlerAsUtility().
|
|
175
|
+
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
|
|
148
176
|
if (!witness) {
|
|
149
|
-
throw new Error(
|
|
177
|
+
throw new Error(
|
|
178
|
+
`Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`,
|
|
179
|
+
);
|
|
150
180
|
}
|
|
151
181
|
return witness.toNoirRepresentation();
|
|
152
182
|
}
|
|
153
183
|
|
|
154
|
-
|
|
184
|
+
// eslint-disable-next-line camelcase
|
|
185
|
+
async aztec_utl_getBlockHashMembershipWitness(
|
|
186
|
+
[anchorBlockHash]: ACVMField[],
|
|
155
187
|
[blockHash]: ACVMField[],
|
|
156
|
-
[leafValue]: ACVMField[],
|
|
157
188
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
189
|
+
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
158
190
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
159
|
-
const parsedLeafValue = Fr.fromString(leafValue);
|
|
160
191
|
|
|
161
|
-
const witness = await this.handlerAsUtility().
|
|
192
|
+
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
|
|
162
193
|
if (!witness) {
|
|
163
|
-
throw new Error(
|
|
194
|
+
throw new Error(
|
|
195
|
+
`Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`,
|
|
196
|
+
);
|
|
164
197
|
}
|
|
165
198
|
return witness.toNoirRepresentation();
|
|
166
199
|
}
|
|
167
200
|
|
|
168
|
-
|
|
201
|
+
// eslint-disable-next-line camelcase
|
|
202
|
+
async aztec_utl_getNullifierMembershipWitness(
|
|
169
203
|
[blockHash]: ACVMField[],
|
|
170
204
|
[nullifier]: ACVMField[], // nullifier, we try to find the witness for (to prove inclusion)
|
|
171
205
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
172
206
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
173
207
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
174
208
|
|
|
175
|
-
const witness = await this.handlerAsUtility().
|
|
176
|
-
parsedBlockHash,
|
|
177
|
-
parsedNullifier,
|
|
178
|
-
);
|
|
209
|
+
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
179
210
|
if (!witness) {
|
|
180
211
|
throw new Error(
|
|
181
212
|
`Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
|
|
@@ -184,17 +215,15 @@ export class Oracle {
|
|
|
184
215
|
return witness.toNoirRepresentation();
|
|
185
216
|
}
|
|
186
217
|
|
|
187
|
-
|
|
218
|
+
// eslint-disable-next-line camelcase
|
|
219
|
+
async aztec_utl_getLowNullifierMembershipWitness(
|
|
188
220
|
[blockHash]: ACVMField[],
|
|
189
221
|
[nullifier]: ACVMField[], // nullifier, we try to find the low nullifier witness for (to prove non-inclusion)
|
|
190
222
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
191
223
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
192
224
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
193
225
|
|
|
194
|
-
const witness = await this.handlerAsUtility().
|
|
195
|
-
parsedBlockHash,
|
|
196
|
-
parsedNullifier,
|
|
197
|
-
);
|
|
226
|
+
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
198
227
|
if (!witness) {
|
|
199
228
|
throw new Error(
|
|
200
229
|
`Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
|
|
@@ -203,14 +232,15 @@ export class Oracle {
|
|
|
203
232
|
return witness.toNoirRepresentation();
|
|
204
233
|
}
|
|
205
234
|
|
|
206
|
-
|
|
235
|
+
// eslint-disable-next-line camelcase
|
|
236
|
+
async aztec_utl_getPublicDataWitness(
|
|
207
237
|
[blockHash]: ACVMField[],
|
|
208
238
|
[leafSlot]: ACVMField[],
|
|
209
239
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
210
240
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
211
241
|
const parsedLeafSlot = Fr.fromString(leafSlot);
|
|
212
242
|
|
|
213
|
-
const witness = await this.handlerAsUtility().
|
|
243
|
+
const witness = await this.handlerAsUtility().getPublicDataWitness(parsedBlockHash, parsedLeafSlot);
|
|
214
244
|
if (!witness) {
|
|
215
245
|
throw new Error(
|
|
216
246
|
`Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`,
|
|
@@ -219,34 +249,45 @@ export class Oracle {
|
|
|
219
249
|
return witness.toNoirRepresentation();
|
|
220
250
|
}
|
|
221
251
|
|
|
222
|
-
|
|
252
|
+
// eslint-disable-next-line camelcase
|
|
253
|
+
async aztec_utl_getBlockHeader([blockNumber]: ACVMField[]): Promise<ACVMField[]> {
|
|
223
254
|
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
224
255
|
|
|
225
|
-
const header = await this.handlerAsUtility().
|
|
256
|
+
const header = await this.handlerAsUtility().getBlockHeader(BlockNumber(parsedBlockNumber));
|
|
226
257
|
if (!header) {
|
|
227
258
|
throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
|
|
228
259
|
}
|
|
229
260
|
return header.toFields().map(toACVMField);
|
|
230
261
|
}
|
|
231
262
|
|
|
232
|
-
|
|
263
|
+
// eslint-disable-next-line camelcase
|
|
264
|
+
async aztec_utl_getAuthWitness([messageHash]: ACVMField[]): Promise<ACVMField[][]> {
|
|
233
265
|
const messageHashField = Fr.fromString(messageHash);
|
|
234
|
-
const witness = await this.handlerAsUtility().
|
|
266
|
+
const witness = await this.handlerAsUtility().getAuthWitness(messageHashField);
|
|
235
267
|
if (!witness) {
|
|
236
268
|
throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
|
|
237
269
|
}
|
|
238
270
|
return [witness.map(toACVMField)];
|
|
239
271
|
}
|
|
240
272
|
|
|
241
|
-
|
|
273
|
+
// eslint-disable-next-line camelcase
|
|
274
|
+
async aztec_utl_getPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
|
|
242
275
|
const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
|
|
243
|
-
const
|
|
244
|
-
await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(parsedAddress);
|
|
276
|
+
const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
|
|
245
277
|
|
|
246
|
-
return
|
|
278
|
+
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
279
|
+
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
280
|
+
if (result === undefined) {
|
|
281
|
+
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
282
|
+
return [toACVMField(0), Array(13).fill(toACVMField(0))];
|
|
283
|
+
} else {
|
|
284
|
+
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
285
|
+
return [toACVMField(1), [...result.publicKeys.toFields(), result.partialAddress].map(toACVMField)];
|
|
286
|
+
}
|
|
247
287
|
}
|
|
248
288
|
|
|
249
|
-
|
|
289
|
+
// eslint-disable-next-line camelcase
|
|
290
|
+
async aztec_utl_getNotes(
|
|
250
291
|
[ownerSome]: ACVMField[],
|
|
251
292
|
[ownerValue]: ACVMField[],
|
|
252
293
|
[storageSlot]: ACVMField[],
|
|
@@ -268,7 +309,7 @@ export class Oracle {
|
|
|
268
309
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
269
310
|
// Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
|
|
270
311
|
const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
|
|
271
|
-
const noteDatas = await this.handlerAsUtility().
|
|
312
|
+
const noteDatas = await this.handlerAsUtility().getNotes(
|
|
272
313
|
owner,
|
|
273
314
|
Fr.fromString(storageSlot),
|
|
274
315
|
+numSelects,
|
|
@@ -307,7 +348,8 @@ export class Oracle {
|
|
|
307
348
|
return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
|
|
308
349
|
}
|
|
309
350
|
|
|
310
|
-
|
|
351
|
+
// eslint-disable-next-line camelcase
|
|
352
|
+
aztec_prv_notifyCreatedNote(
|
|
311
353
|
[owner]: ACVMField[],
|
|
312
354
|
[storageSlot]: ACVMField[],
|
|
313
355
|
[randomness]: ACVMField[],
|
|
@@ -316,7 +358,7 @@ export class Oracle {
|
|
|
316
358
|
[noteHash]: ACVMField[],
|
|
317
359
|
[counter]: ACVMField[],
|
|
318
360
|
): Promise<ACVMField[]> {
|
|
319
|
-
this.handlerAsPrivate().
|
|
361
|
+
this.handlerAsPrivate().notifyCreatedNote(
|
|
320
362
|
AztecAddress.fromString(owner),
|
|
321
363
|
Fr.fromString(storageSlot),
|
|
322
364
|
Fr.fromString(randomness),
|
|
@@ -328,43 +370,47 @@ export class Oracle {
|
|
|
328
370
|
return Promise.resolve([]);
|
|
329
371
|
}
|
|
330
372
|
|
|
331
|
-
|
|
373
|
+
// eslint-disable-next-line camelcase
|
|
374
|
+
async aztec_prv_notifyNullifiedNote(
|
|
332
375
|
[innerNullifier]: ACVMField[],
|
|
333
376
|
[noteHash]: ACVMField[],
|
|
334
377
|
[counter]: ACVMField[],
|
|
335
378
|
): Promise<ACVMField[]> {
|
|
336
|
-
await this.handlerAsPrivate().
|
|
337
|
-
Fr.fromString(innerNullifier),
|
|
338
|
-
Fr.fromString(noteHash),
|
|
339
|
-
+counter,
|
|
340
|
-
);
|
|
379
|
+
await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
|
|
341
380
|
return [];
|
|
342
381
|
}
|
|
343
382
|
|
|
344
|
-
|
|
345
|
-
|
|
383
|
+
// eslint-disable-next-line camelcase
|
|
384
|
+
async aztec_prv_notifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
|
|
385
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
|
|
346
386
|
return [];
|
|
347
387
|
}
|
|
348
388
|
|
|
349
|
-
|
|
350
|
-
|
|
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(
|
|
351
395
|
Fr.fromString(innerNullifier),
|
|
352
396
|
AztecAddress.fromString(contractAddress),
|
|
353
397
|
);
|
|
354
398
|
return [toACVMField(isPending)];
|
|
355
399
|
}
|
|
356
400
|
|
|
357
|
-
|
|
358
|
-
|
|
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));
|
|
359
404
|
return [toACVMField(exists)];
|
|
360
405
|
}
|
|
361
406
|
|
|
362
|
-
|
|
407
|
+
// eslint-disable-next-line camelcase
|
|
408
|
+
async aztec_utl_getL1ToL2MembershipWitness(
|
|
363
409
|
[contractAddress]: ACVMField[],
|
|
364
410
|
[messageHash]: ACVMField[],
|
|
365
411
|
[secret]: ACVMField[],
|
|
366
412
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
367
|
-
const message = await this.handlerAsUtility().
|
|
413
|
+
const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(
|
|
368
414
|
AztecAddress.fromString(contractAddress),
|
|
369
415
|
Fr.fromString(messageHash),
|
|
370
416
|
Fr.fromString(secret),
|
|
@@ -372,13 +418,14 @@ export class Oracle {
|
|
|
372
418
|
return message.toNoirRepresentation();
|
|
373
419
|
}
|
|
374
420
|
|
|
375
|
-
|
|
421
|
+
// eslint-disable-next-line camelcase
|
|
422
|
+
async aztec_utl_getFromPublicStorage(
|
|
376
423
|
[blockHash]: ACVMField[],
|
|
377
424
|
[contractAddress]: ACVMField[],
|
|
378
425
|
[startStorageSlot]: ACVMField[],
|
|
379
426
|
[numberOfElements]: ACVMField[],
|
|
380
427
|
): Promise<ACVMField[][]> {
|
|
381
|
-
const values = await this.handlerAsUtility().
|
|
428
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(
|
|
382
429
|
BlockHash.fromString(blockHash),
|
|
383
430
|
new AztecAddress(Fr.fromString(contractAddress)),
|
|
384
431
|
Fr.fromString(startStorageSlot),
|
|
@@ -387,7 +434,8 @@ export class Oracle {
|
|
|
387
434
|
return [values.map(toACVMField)];
|
|
388
435
|
}
|
|
389
436
|
|
|
390
|
-
|
|
437
|
+
// eslint-disable-next-line camelcase
|
|
438
|
+
aztec_prv_notifyCreatedContractClassLog(
|
|
391
439
|
[contractAddress]: ACVMField[],
|
|
392
440
|
message: ACVMField[],
|
|
393
441
|
[length]: ACVMField[],
|
|
@@ -396,11 +444,12 @@ export class Oracle {
|
|
|
396
444
|
const logFields = new ContractClassLogFields(message.map(Fr.fromString));
|
|
397
445
|
const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
|
|
398
446
|
|
|
399
|
-
this.handlerAsPrivate().
|
|
447
|
+
this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
|
|
400
448
|
return Promise.resolve([]);
|
|
401
449
|
}
|
|
402
450
|
|
|
403
|
-
|
|
451
|
+
// eslint-disable-next-line camelcase
|
|
452
|
+
async aztec_utl_log(
|
|
404
453
|
level: ACVMField[],
|
|
405
454
|
message: ACVMField[],
|
|
406
455
|
_ignoredFieldsSize: ACVMField[],
|
|
@@ -409,20 +458,21 @@ export class Oracle {
|
|
|
409
458
|
const levelFr = Fr.fromString(level[0]);
|
|
410
459
|
const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
|
|
411
460
|
const fieldsFr = fields.map(Fr.fromString);
|
|
412
|
-
this.handlerAsMisc().
|
|
413
|
-
return
|
|
461
|
+
await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
|
|
462
|
+
return [];
|
|
414
463
|
}
|
|
415
464
|
|
|
416
465
|
// This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
|
|
417
466
|
// change the name here.
|
|
418
|
-
|
|
467
|
+
// eslint-disable-next-line camelcase
|
|
468
|
+
async aztec_prv_callPrivateFunction(
|
|
419
469
|
[contractAddress]: ACVMField[],
|
|
420
470
|
[functionSelector]: ACVMField[],
|
|
421
471
|
[argsHash]: ACVMField[],
|
|
422
472
|
[sideEffectCounter]: ACVMField[],
|
|
423
473
|
[isStaticCall]: ACVMField[],
|
|
424
474
|
): Promise<ACVMField[][]> {
|
|
425
|
-
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().
|
|
475
|
+
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(
|
|
426
476
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
427
477
|
FunctionSelector.fromField(Fr.fromString(functionSelector)),
|
|
428
478
|
Fr.fromString(argsHash),
|
|
@@ -432,113 +482,127 @@ export class Oracle {
|
|
|
432
482
|
return [[endSideEffectCounter, returnsHash].map(toACVMField)];
|
|
433
483
|
}
|
|
434
484
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
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
|
-
);
|
|
485
|
+
// eslint-disable-next-line camelcase
|
|
486
|
+
async aztec_prv_assertValidPublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
|
|
487
|
+
await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
|
|
447
488
|
return [];
|
|
448
489
|
}
|
|
449
490
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
-
);
|
|
462
|
-
return [];
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
async privateNotifySetMinRevertibleSideEffectCounter([minRevertibleSideEffectCounter]: ACVMField[]): Promise<
|
|
466
|
-
ACVMField[]
|
|
467
|
-
> {
|
|
468
|
-
await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(
|
|
469
|
-
Fr.fromString(minRevertibleSideEffectCounter).toNumber(),
|
|
470
|
-
);
|
|
491
|
+
// eslint-disable-next-line camelcase
|
|
492
|
+
async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
|
|
493
|
+
await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
471
494
|
return Promise.resolve([]);
|
|
472
495
|
}
|
|
473
496
|
|
|
474
|
-
|
|
475
|
-
|
|
497
|
+
// eslint-disable-next-line camelcase
|
|
498
|
+
async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
|
|
499
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(
|
|
476
500
|
Fr.fromString(sideEffectCounter).toNumber(),
|
|
477
501
|
);
|
|
478
502
|
return Promise.resolve([toACVMField(isRevertible)]);
|
|
479
503
|
}
|
|
480
504
|
|
|
481
|
-
|
|
482
|
-
|
|
505
|
+
// eslint-disable-next-line camelcase
|
|
506
|
+
async aztec_prv_getNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
|
|
507
|
+
const tag = await this.handlerAsPrivate().getNextAppTagAsSender(
|
|
483
508
|
AztecAddress.fromString(sender),
|
|
484
509
|
AztecAddress.fromString(recipient),
|
|
485
510
|
);
|
|
486
511
|
return [toACVMField(tag.value)];
|
|
487
512
|
}
|
|
488
513
|
|
|
489
|
-
|
|
490
|
-
|
|
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
|
+
);
|
|
491
523
|
return [];
|
|
492
524
|
}
|
|
493
525
|
|
|
494
|
-
|
|
526
|
+
// eslint-disable-next-line camelcase
|
|
527
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
495
528
|
[contractAddress]: ACVMField[],
|
|
496
529
|
[noteValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
497
530
|
[eventValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
531
|
+
[maxNotePackedLen]: ACVMField[],
|
|
532
|
+
[maxEventSerializedLen]: ACVMField[],
|
|
533
|
+
[scope]: ACVMField[],
|
|
498
534
|
): Promise<ACVMField[]> {
|
|
499
|
-
await this.handlerAsUtility().
|
|
535
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
500
536
|
AztecAddress.fromString(contractAddress),
|
|
501
537
|
Fr.fromString(noteValidationRequestsArrayBaseSlot),
|
|
502
538
|
Fr.fromString(eventValidationRequestsArrayBaseSlot),
|
|
539
|
+
Fr.fromString(maxNotePackedLen).toNumber(),
|
|
540
|
+
Fr.fromString(maxEventSerializedLen).toNumber(),
|
|
541
|
+
AztecAddress.fromString(scope),
|
|
503
542
|
);
|
|
504
543
|
|
|
505
544
|
return [];
|
|
506
545
|
}
|
|
507
546
|
|
|
508
|
-
|
|
547
|
+
// eslint-disable-next-line camelcase
|
|
548
|
+
async aztec_utl_getLogsByTag(
|
|
509
549
|
[contractAddress]: ACVMField[],
|
|
510
550
|
[logRetrievalRequestsArrayBaseSlot]: ACVMField[],
|
|
511
551
|
[logRetrievalResponsesArrayBaseSlot]: ACVMField[],
|
|
552
|
+
[scope]: ACVMField[],
|
|
512
553
|
): Promise<ACVMField[]> {
|
|
513
|
-
await this.handlerAsUtility().
|
|
554
|
+
await this.handlerAsUtility().getLogsByTag(
|
|
514
555
|
AztecAddress.fromString(contractAddress),
|
|
515
556
|
Fr.fromString(logRetrievalRequestsArrayBaseSlot),
|
|
516
557
|
Fr.fromString(logRetrievalResponsesArrayBaseSlot),
|
|
558
|
+
AztecAddress.fromString(scope),
|
|
559
|
+
);
|
|
560
|
+
return [];
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// eslint-disable-next-line camelcase
|
|
564
|
+
async aztec_utl_getMessageContextsByTxHash(
|
|
565
|
+
[contractAddress]: ACVMField[],
|
|
566
|
+
[messageContextRequestsArrayBaseSlot]: ACVMField[],
|
|
567
|
+
[messageContextResponsesArrayBaseSlot]: ACVMField[],
|
|
568
|
+
[scope]: ACVMField[],
|
|
569
|
+
): Promise<ACVMField[]> {
|
|
570
|
+
await this.handlerAsUtility().getMessageContextsByTxHash(
|
|
571
|
+
AztecAddress.fromString(contractAddress),
|
|
572
|
+
Fr.fromString(messageContextRequestsArrayBaseSlot),
|
|
573
|
+
Fr.fromString(messageContextResponsesArrayBaseSlot),
|
|
574
|
+
AztecAddress.fromString(scope),
|
|
517
575
|
);
|
|
518
576
|
return [];
|
|
519
577
|
}
|
|
520
578
|
|
|
521
|
-
|
|
579
|
+
// eslint-disable-next-line camelcase
|
|
580
|
+
aztec_utl_setCapsule(
|
|
522
581
|
[contractAddress]: ACVMField[],
|
|
523
582
|
[slot]: ACVMField[],
|
|
524
583
|
capsule: ACVMField[],
|
|
584
|
+
[scope]: ACVMField[],
|
|
525
585
|
): Promise<ACVMField[]> {
|
|
526
|
-
|
|
586
|
+
this.handlerAsUtility().setCapsule(
|
|
527
587
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
528
588
|
Fr.fromString(slot),
|
|
529
589
|
capsule.map(Fr.fromString),
|
|
590
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
530
591
|
);
|
|
531
|
-
return [];
|
|
592
|
+
return Promise.resolve([]);
|
|
532
593
|
}
|
|
533
594
|
|
|
534
|
-
|
|
595
|
+
// eslint-disable-next-line camelcase
|
|
596
|
+
async aztec_utl_getCapsule(
|
|
535
597
|
[contractAddress]: ACVMField[],
|
|
536
598
|
[slot]: ACVMField[],
|
|
537
599
|
[tSize]: ACVMField[],
|
|
600
|
+
[scope]: ACVMField[],
|
|
538
601
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
539
|
-
const values = await this.handlerAsUtility().
|
|
602
|
+
const values = await this.handlerAsUtility().getCapsule(
|
|
540
603
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
541
604
|
Fr.fromString(slot),
|
|
605
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
542
606
|
);
|
|
543
607
|
|
|
544
608
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
@@ -552,30 +616,40 @@ export class Oracle {
|
|
|
552
616
|
}
|
|
553
617
|
}
|
|
554
618
|
|
|
555
|
-
|
|
556
|
-
|
|
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(
|
|
557
626
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
558
627
|
Fr.fromString(slot),
|
|
628
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
559
629
|
);
|
|
560
|
-
return [];
|
|
630
|
+
return Promise.resolve([]);
|
|
561
631
|
}
|
|
562
632
|
|
|
563
|
-
|
|
633
|
+
// eslint-disable-next-line camelcase
|
|
634
|
+
async aztec_utl_copyCapsule(
|
|
564
635
|
[contractAddress]: ACVMField[],
|
|
565
636
|
[srcSlot]: ACVMField[],
|
|
566
637
|
[dstSlot]: ACVMField[],
|
|
567
638
|
[numEntries]: ACVMField[],
|
|
639
|
+
[scope]: ACVMField[],
|
|
568
640
|
): Promise<ACVMField[]> {
|
|
569
|
-
await this.handlerAsUtility().
|
|
641
|
+
await this.handlerAsUtility().copyCapsule(
|
|
570
642
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
571
643
|
Fr.fromString(srcSlot),
|
|
572
644
|
Fr.fromString(dstSlot),
|
|
573
645
|
Fr.fromString(numEntries).toNumber(),
|
|
646
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
574
647
|
);
|
|
575
648
|
return [];
|
|
576
649
|
}
|
|
577
650
|
|
|
578
|
-
|
|
651
|
+
// eslint-disable-next-line camelcase
|
|
652
|
+
async aztec_utl_decryptAes128(
|
|
579
653
|
ciphertextBVecStorage: ACVMField[],
|
|
580
654
|
[ciphertextLength]: ACVMField[],
|
|
581
655
|
iv: ACVMField[],
|
|
@@ -585,36 +659,63 @@ export class Oracle {
|
|
|
585
659
|
const ivBuffer = fromUintArray(iv, 8);
|
|
586
660
|
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
587
661
|
|
|
588
|
-
|
|
589
|
-
|
|
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
|
+
}
|
|
590
671
|
}
|
|
591
672
|
|
|
592
|
-
|
|
673
|
+
// eslint-disable-next-line camelcase
|
|
674
|
+
async aztec_utl_getSharedSecret(
|
|
593
675
|
[address]: ACVMField[],
|
|
594
676
|
[ephPKField0]: ACVMField[],
|
|
595
677
|
[ephPKField1]: ACVMField[],
|
|
596
678
|
[ephPKField2]: ACVMField[],
|
|
679
|
+
[contractAddress]: ACVMField[],
|
|
597
680
|
): Promise<ACVMField[]> {
|
|
598
|
-
const secret = await this.handlerAsUtility().
|
|
681
|
+
const secret = await this.handlerAsUtility().getSharedSecret(
|
|
599
682
|
AztecAddress.fromField(Fr.fromString(address)),
|
|
600
683
|
Point.fromFields([ephPKField0, ephPKField1, ephPKField2].map(Fr.fromString)),
|
|
684
|
+
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
601
685
|
);
|
|
602
|
-
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([]);
|
|
603
701
|
}
|
|
604
702
|
|
|
605
|
-
|
|
606
|
-
|
|
703
|
+
// eslint-disable-next-line camelcase
|
|
704
|
+
async aztec_utl_emitOffchainEffect(data: ACVMField[]) {
|
|
705
|
+
await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
|
|
607
706
|
return [];
|
|
608
707
|
}
|
|
609
708
|
|
|
610
|
-
|
|
611
|
-
|
|
709
|
+
// eslint-disable-next-line camelcase
|
|
710
|
+
async aztec_prv_getSenderForTags(): Promise<ACVMField[]> {
|
|
711
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
612
712
|
// Return [1, address] for Some(address), [0, 0] for None
|
|
613
713
|
return sender ? [toACVMField(1n), toACVMField(sender)] : [toACVMField(0n), toACVMField(0n)];
|
|
614
714
|
}
|
|
615
715
|
|
|
616
|
-
|
|
617
|
-
|
|
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)));
|
|
618
719
|
return [];
|
|
619
720
|
}
|
|
620
721
|
}
|