@aztec/pxe 0.0.1-commit.f146247c → 0.0.1-commit.f1b29a41e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- 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 +61 -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 +206 -104
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +54 -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 +99 -86
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +93 -53
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +233 -119
- 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 +46 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +124 -0
- package/dest/contract_sync/helpers.d.ts +29 -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 +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -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 +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -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 +4 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -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 +32 -43
- 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 +5 -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 +25 -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 +74 -24
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +126 -74
- package/dest/storage/capsule_store/capsule_service.d.ts +22 -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/access_scopes.ts +9 -0
- 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 +361 -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 +63 -54
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +98 -0
- package/src/contract_function_simulator/oracle/oracle.ts +233 -142
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +125 -179
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +399 -136
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +192 -0
- package/src/contract_sync/{index.ts → helpers.ts} +23 -22
- package/src/debug/pxe_debug_utils.ts +48 -18
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +9 -1
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +9 -1
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +7 -7
- package/src/events/event_service.ts +17 -4
- package/src/logs/log_service.ts +63 -65
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +20 -8
- package/src/notes_filter.ts +26 -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 +231 -124
- package/src/storage/capsule_store/capsule_service.ts +91 -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 +12 -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,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,34 +249,45 @@ 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
|
|
254
|
-
await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(parsedAddress);
|
|
276
|
+
const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
|
|
255
277
|
|
|
256
|
-
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
|
+
}
|
|
257
287
|
}
|
|
258
288
|
|
|
259
|
-
|
|
289
|
+
// eslint-disable-next-line camelcase
|
|
290
|
+
async aztec_utl_getNotes(
|
|
260
291
|
[ownerSome]: ACVMField[],
|
|
261
292
|
[ownerValue]: ACVMField[],
|
|
262
293
|
[storageSlot]: ACVMField[],
|
|
@@ -278,7 +309,7 @@ export class Oracle {
|
|
|
278
309
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
279
310
|
// Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
|
|
280
311
|
const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
|
|
281
|
-
const noteDatas = await this.handlerAsUtility().
|
|
312
|
+
const noteDatas = await this.handlerAsUtility().getNotes(
|
|
282
313
|
owner,
|
|
283
314
|
Fr.fromString(storageSlot),
|
|
284
315
|
+numSelects,
|
|
@@ -317,7 +348,8 @@ export class Oracle {
|
|
|
317
348
|
return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
|
|
318
349
|
}
|
|
319
350
|
|
|
320
|
-
|
|
351
|
+
// eslint-disable-next-line camelcase
|
|
352
|
+
aztec_prv_notifyCreatedNote(
|
|
321
353
|
[owner]: ACVMField[],
|
|
322
354
|
[storageSlot]: ACVMField[],
|
|
323
355
|
[randomness]: ACVMField[],
|
|
@@ -326,7 +358,7 @@ export class Oracle {
|
|
|
326
358
|
[noteHash]: ACVMField[],
|
|
327
359
|
[counter]: ACVMField[],
|
|
328
360
|
): Promise<ACVMField[]> {
|
|
329
|
-
this.handlerAsPrivate().
|
|
361
|
+
this.handlerAsPrivate().notifyCreatedNote(
|
|
330
362
|
AztecAddress.fromString(owner),
|
|
331
363
|
Fr.fromString(storageSlot),
|
|
332
364
|
Fr.fromString(randomness),
|
|
@@ -338,43 +370,47 @@ export class Oracle {
|
|
|
338
370
|
return Promise.resolve([]);
|
|
339
371
|
}
|
|
340
372
|
|
|
341
|
-
|
|
373
|
+
// eslint-disable-next-line camelcase
|
|
374
|
+
async aztec_prv_notifyNullifiedNote(
|
|
342
375
|
[innerNullifier]: ACVMField[],
|
|
343
376
|
[noteHash]: ACVMField[],
|
|
344
377
|
[counter]: ACVMField[],
|
|
345
378
|
): Promise<ACVMField[]> {
|
|
346
|
-
await this.handlerAsPrivate().
|
|
347
|
-
Fr.fromString(innerNullifier),
|
|
348
|
-
Fr.fromString(noteHash),
|
|
349
|
-
+counter,
|
|
350
|
-
);
|
|
379
|
+
await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
|
|
351
380
|
return [];
|
|
352
381
|
}
|
|
353
382
|
|
|
354
|
-
|
|
355
|
-
|
|
383
|
+
// eslint-disable-next-line camelcase
|
|
384
|
+
async aztec_prv_notifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
|
|
385
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
|
|
356
386
|
return [];
|
|
357
387
|
}
|
|
358
388
|
|
|
359
|
-
|
|
360
|
-
|
|
389
|
+
// eslint-disable-next-line camelcase
|
|
390
|
+
async aztec_prv_isNullifierPending(
|
|
391
|
+
[innerNullifier]: ACVMField[],
|
|
392
|
+
[contractAddress]: ACVMField[],
|
|
393
|
+
): Promise<ACVMField[]> {
|
|
394
|
+
const isPending = await this.handlerAsPrivate().isNullifierPending(
|
|
361
395
|
Fr.fromString(innerNullifier),
|
|
362
396
|
AztecAddress.fromString(contractAddress),
|
|
363
397
|
);
|
|
364
398
|
return [toACVMField(isPending)];
|
|
365
399
|
}
|
|
366
400
|
|
|
367
|
-
|
|
368
|
-
|
|
401
|
+
// eslint-disable-next-line camelcase
|
|
402
|
+
async aztec_utl_doesNullifierExist([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
|
|
403
|
+
const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
|
|
369
404
|
return [toACVMField(exists)];
|
|
370
405
|
}
|
|
371
406
|
|
|
372
|
-
|
|
407
|
+
// eslint-disable-next-line camelcase
|
|
408
|
+
async aztec_utl_getL1ToL2MembershipWitness(
|
|
373
409
|
[contractAddress]: ACVMField[],
|
|
374
410
|
[messageHash]: ACVMField[],
|
|
375
411
|
[secret]: ACVMField[],
|
|
376
412
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
377
|
-
const message = await this.handlerAsUtility().
|
|
413
|
+
const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(
|
|
378
414
|
AztecAddress.fromString(contractAddress),
|
|
379
415
|
Fr.fromString(messageHash),
|
|
380
416
|
Fr.fromString(secret),
|
|
@@ -382,13 +418,14 @@ export class Oracle {
|
|
|
382
418
|
return message.toNoirRepresentation();
|
|
383
419
|
}
|
|
384
420
|
|
|
385
|
-
|
|
421
|
+
// eslint-disable-next-line camelcase
|
|
422
|
+
async aztec_utl_getFromPublicStorage(
|
|
386
423
|
[blockHash]: ACVMField[],
|
|
387
424
|
[contractAddress]: ACVMField[],
|
|
388
425
|
[startStorageSlot]: ACVMField[],
|
|
389
426
|
[numberOfElements]: ACVMField[],
|
|
390
427
|
): Promise<ACVMField[][]> {
|
|
391
|
-
const values = await this.handlerAsUtility().
|
|
428
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(
|
|
392
429
|
BlockHash.fromString(blockHash),
|
|
393
430
|
new AztecAddress(Fr.fromString(contractAddress)),
|
|
394
431
|
Fr.fromString(startStorageSlot),
|
|
@@ -397,7 +434,8 @@ export class Oracle {
|
|
|
397
434
|
return [values.map(toACVMField)];
|
|
398
435
|
}
|
|
399
436
|
|
|
400
|
-
|
|
437
|
+
// eslint-disable-next-line camelcase
|
|
438
|
+
aztec_prv_notifyCreatedContractClassLog(
|
|
401
439
|
[contractAddress]: ACVMField[],
|
|
402
440
|
message: ACVMField[],
|
|
403
441
|
[length]: ACVMField[],
|
|
@@ -406,11 +444,12 @@ export class Oracle {
|
|
|
406
444
|
const logFields = new ContractClassLogFields(message.map(Fr.fromString));
|
|
407
445
|
const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
|
|
408
446
|
|
|
409
|
-
this.handlerAsPrivate().
|
|
447
|
+
this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
|
|
410
448
|
return Promise.resolve([]);
|
|
411
449
|
}
|
|
412
450
|
|
|
413
|
-
|
|
451
|
+
// eslint-disable-next-line camelcase
|
|
452
|
+
async aztec_utl_log(
|
|
414
453
|
level: ACVMField[],
|
|
415
454
|
message: ACVMField[],
|
|
416
455
|
_ignoredFieldsSize: ACVMField[],
|
|
@@ -419,20 +458,21 @@ export class Oracle {
|
|
|
419
458
|
const levelFr = Fr.fromString(level[0]);
|
|
420
459
|
const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
|
|
421
460
|
const fieldsFr = fields.map(Fr.fromString);
|
|
422
|
-
this.handlerAsMisc().
|
|
423
|
-
return
|
|
461
|
+
await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
|
|
462
|
+
return [];
|
|
424
463
|
}
|
|
425
464
|
|
|
426
465
|
// This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
|
|
427
466
|
// change the name here.
|
|
428
|
-
|
|
467
|
+
// eslint-disable-next-line camelcase
|
|
468
|
+
async aztec_prv_callPrivateFunction(
|
|
429
469
|
[contractAddress]: ACVMField[],
|
|
430
470
|
[functionSelector]: ACVMField[],
|
|
431
471
|
[argsHash]: ACVMField[],
|
|
432
472
|
[sideEffectCounter]: ACVMField[],
|
|
433
473
|
[isStaticCall]: ACVMField[],
|
|
434
474
|
): Promise<ACVMField[][]> {
|
|
435
|
-
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().
|
|
475
|
+
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(
|
|
436
476
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
437
477
|
FunctionSelector.fromField(Fr.fromString(functionSelector)),
|
|
438
478
|
Fr.fromString(argsHash),
|
|
@@ -442,113 +482,127 @@ export class Oracle {
|
|
|
442
482
|
return [[endSideEffectCounter, returnsHash].map(toACVMField)];
|
|
443
483
|
}
|
|
444
484
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
[sideEffectCounter]: ACVMField[],
|
|
449
|
-
[isStaticCall]: ACVMField[],
|
|
450
|
-
): Promise<ACVMField[]> {
|
|
451
|
-
await this.handlerAsPrivate().privateNotifyEnqueuedPublicFunctionCall(
|
|
452
|
-
AztecAddress.fromString(contractAddress),
|
|
453
|
-
Fr.fromString(calldataHash),
|
|
454
|
-
Fr.fromString(sideEffectCounter).toNumber(),
|
|
455
|
-
Fr.fromString(isStaticCall).toBool(),
|
|
456
|
-
);
|
|
457
|
-
return [];
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
async privateNotifySetPublicTeardownFunctionCall(
|
|
461
|
-
[contractAddress]: ACVMField[],
|
|
462
|
-
[calldataHash]: ACVMField[],
|
|
463
|
-
[sideEffectCounter]: ACVMField[],
|
|
464
|
-
[isStaticCall]: ACVMField[],
|
|
465
|
-
): Promise<ACVMField[]> {
|
|
466
|
-
await this.handlerAsPrivate().privateNotifySetPublicTeardownFunctionCall(
|
|
467
|
-
AztecAddress.fromString(contractAddress),
|
|
468
|
-
Fr.fromString(calldataHash),
|
|
469
|
-
Fr.fromString(sideEffectCounter).toNumber(),
|
|
470
|
-
Fr.fromString(isStaticCall).toBool(),
|
|
471
|
-
);
|
|
485
|
+
// eslint-disable-next-line camelcase
|
|
486
|
+
async aztec_prv_assertValidPublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
|
|
487
|
+
await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
|
|
472
488
|
return [];
|
|
473
489
|
}
|
|
474
490
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(
|
|
479
|
-
Fr.fromString(minRevertibleSideEffectCounter).toNumber(),
|
|
480
|
-
);
|
|
491
|
+
// eslint-disable-next-line camelcase
|
|
492
|
+
async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
|
|
493
|
+
await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
481
494
|
return Promise.resolve([]);
|
|
482
495
|
}
|
|
483
496
|
|
|
484
|
-
|
|
485
|
-
|
|
497
|
+
// eslint-disable-next-line camelcase
|
|
498
|
+
async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
|
|
499
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(
|
|
486
500
|
Fr.fromString(sideEffectCounter).toNumber(),
|
|
487
501
|
);
|
|
488
502
|
return Promise.resolve([toACVMField(isRevertible)]);
|
|
489
503
|
}
|
|
490
504
|
|
|
491
|
-
|
|
492
|
-
|
|
505
|
+
// eslint-disable-next-line camelcase
|
|
506
|
+
async aztec_prv_getNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
|
|
507
|
+
const tag = await this.handlerAsPrivate().getNextAppTagAsSender(
|
|
493
508
|
AztecAddress.fromString(sender),
|
|
494
509
|
AztecAddress.fromString(recipient),
|
|
495
510
|
);
|
|
496
511
|
return [toACVMField(tag.value)];
|
|
497
512
|
}
|
|
498
513
|
|
|
499
|
-
|
|
500
|
-
|
|
514
|
+
// eslint-disable-next-line camelcase
|
|
515
|
+
async aztec_utl_getPendingTaggedLogs(
|
|
516
|
+
[pendingTaggedLogArrayBaseSlot]: ACVMField[],
|
|
517
|
+
[scope]: ACVMField[],
|
|
518
|
+
): Promise<ACVMField[]> {
|
|
519
|
+
await this.handlerAsUtility().getPendingTaggedLogs(
|
|
520
|
+
Fr.fromString(pendingTaggedLogArrayBaseSlot),
|
|
521
|
+
AztecAddress.fromString(scope),
|
|
522
|
+
);
|
|
501
523
|
return [];
|
|
502
524
|
}
|
|
503
525
|
|
|
504
|
-
|
|
526
|
+
// eslint-disable-next-line camelcase
|
|
527
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
505
528
|
[contractAddress]: ACVMField[],
|
|
506
529
|
[noteValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
507
530
|
[eventValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
531
|
+
[maxNotePackedLen]: ACVMField[],
|
|
532
|
+
[maxEventSerializedLen]: ACVMField[],
|
|
533
|
+
[scope]: ACVMField[],
|
|
508
534
|
): Promise<ACVMField[]> {
|
|
509
|
-
await this.handlerAsUtility().
|
|
535
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
510
536
|
AztecAddress.fromString(contractAddress),
|
|
511
537
|
Fr.fromString(noteValidationRequestsArrayBaseSlot),
|
|
512
538
|
Fr.fromString(eventValidationRequestsArrayBaseSlot),
|
|
539
|
+
Fr.fromString(maxNotePackedLen).toNumber(),
|
|
540
|
+
Fr.fromString(maxEventSerializedLen).toNumber(),
|
|
541
|
+
AztecAddress.fromString(scope),
|
|
513
542
|
);
|
|
514
543
|
|
|
515
544
|
return [];
|
|
516
545
|
}
|
|
517
546
|
|
|
518
|
-
|
|
547
|
+
// eslint-disable-next-line camelcase
|
|
548
|
+
async aztec_utl_getLogsByTag(
|
|
519
549
|
[contractAddress]: ACVMField[],
|
|
520
550
|
[logRetrievalRequestsArrayBaseSlot]: ACVMField[],
|
|
521
551
|
[logRetrievalResponsesArrayBaseSlot]: ACVMField[],
|
|
552
|
+
[scope]: ACVMField[],
|
|
522
553
|
): Promise<ACVMField[]> {
|
|
523
|
-
await this.handlerAsUtility().
|
|
554
|
+
await this.handlerAsUtility().getLogsByTag(
|
|
524
555
|
AztecAddress.fromString(contractAddress),
|
|
525
556
|
Fr.fromString(logRetrievalRequestsArrayBaseSlot),
|
|
526
557
|
Fr.fromString(logRetrievalResponsesArrayBaseSlot),
|
|
558
|
+
AztecAddress.fromString(scope),
|
|
559
|
+
);
|
|
560
|
+
return [];
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// eslint-disable-next-line camelcase
|
|
564
|
+
async aztec_utl_getMessageContextsByTxHash(
|
|
565
|
+
[contractAddress]: ACVMField[],
|
|
566
|
+
[messageContextRequestsArrayBaseSlot]: ACVMField[],
|
|
567
|
+
[messageContextResponsesArrayBaseSlot]: ACVMField[],
|
|
568
|
+
[scope]: ACVMField[],
|
|
569
|
+
): Promise<ACVMField[]> {
|
|
570
|
+
await this.handlerAsUtility().getMessageContextsByTxHash(
|
|
571
|
+
AztecAddress.fromString(contractAddress),
|
|
572
|
+
Fr.fromString(messageContextRequestsArrayBaseSlot),
|
|
573
|
+
Fr.fromString(messageContextResponsesArrayBaseSlot),
|
|
574
|
+
AztecAddress.fromString(scope),
|
|
527
575
|
);
|
|
528
576
|
return [];
|
|
529
577
|
}
|
|
530
578
|
|
|
531
|
-
|
|
579
|
+
// eslint-disable-next-line camelcase
|
|
580
|
+
aztec_utl_setCapsule(
|
|
532
581
|
[contractAddress]: ACVMField[],
|
|
533
582
|
[slot]: ACVMField[],
|
|
534
583
|
capsule: ACVMField[],
|
|
584
|
+
[scope]: ACVMField[],
|
|
535
585
|
): Promise<ACVMField[]> {
|
|
536
|
-
|
|
586
|
+
this.handlerAsUtility().setCapsule(
|
|
537
587
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
538
588
|
Fr.fromString(slot),
|
|
539
589
|
capsule.map(Fr.fromString),
|
|
590
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
540
591
|
);
|
|
541
|
-
return [];
|
|
592
|
+
return Promise.resolve([]);
|
|
542
593
|
}
|
|
543
594
|
|
|
544
|
-
|
|
595
|
+
// eslint-disable-next-line camelcase
|
|
596
|
+
async aztec_utl_getCapsule(
|
|
545
597
|
[contractAddress]: ACVMField[],
|
|
546
598
|
[slot]: ACVMField[],
|
|
547
599
|
[tSize]: ACVMField[],
|
|
600
|
+
[scope]: ACVMField[],
|
|
548
601
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
549
|
-
const values = await this.handlerAsUtility().
|
|
602
|
+
const values = await this.handlerAsUtility().getCapsule(
|
|
550
603
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
551
604
|
Fr.fromString(slot),
|
|
605
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
552
606
|
);
|
|
553
607
|
|
|
554
608
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
@@ -562,30 +616,40 @@ export class Oracle {
|
|
|
562
616
|
}
|
|
563
617
|
}
|
|
564
618
|
|
|
565
|
-
|
|
566
|
-
|
|
619
|
+
// eslint-disable-next-line camelcase
|
|
620
|
+
aztec_utl_deleteCapsule(
|
|
621
|
+
[contractAddress]: ACVMField[],
|
|
622
|
+
[slot]: ACVMField[],
|
|
623
|
+
[scope]: ACVMField[],
|
|
624
|
+
): Promise<ACVMField[]> {
|
|
625
|
+
this.handlerAsUtility().deleteCapsule(
|
|
567
626
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
568
627
|
Fr.fromString(slot),
|
|
628
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
569
629
|
);
|
|
570
|
-
return [];
|
|
630
|
+
return Promise.resolve([]);
|
|
571
631
|
}
|
|
572
632
|
|
|
573
|
-
|
|
633
|
+
// eslint-disable-next-line camelcase
|
|
634
|
+
async aztec_utl_copyCapsule(
|
|
574
635
|
[contractAddress]: ACVMField[],
|
|
575
636
|
[srcSlot]: ACVMField[],
|
|
576
637
|
[dstSlot]: ACVMField[],
|
|
577
638
|
[numEntries]: ACVMField[],
|
|
639
|
+
[scope]: ACVMField[],
|
|
578
640
|
): Promise<ACVMField[]> {
|
|
579
|
-
await this.handlerAsUtility().
|
|
641
|
+
await this.handlerAsUtility().copyCapsule(
|
|
580
642
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
581
643
|
Fr.fromString(srcSlot),
|
|
582
644
|
Fr.fromString(dstSlot),
|
|
583
645
|
Fr.fromString(numEntries).toNumber(),
|
|
646
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
584
647
|
);
|
|
585
648
|
return [];
|
|
586
649
|
}
|
|
587
650
|
|
|
588
|
-
|
|
651
|
+
// eslint-disable-next-line camelcase
|
|
652
|
+
async aztec_utl_decryptAes128(
|
|
589
653
|
ciphertextBVecStorage: ACVMField[],
|
|
590
654
|
[ciphertextLength]: ACVMField[],
|
|
591
655
|
iv: ACVMField[],
|
|
@@ -595,36 +659,63 @@ export class Oracle {
|
|
|
595
659
|
const ivBuffer = fromUintArray(iv, 8);
|
|
596
660
|
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
597
661
|
|
|
598
|
-
|
|
599
|
-
|
|
662
|
+
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
663
|
+
try {
|
|
664
|
+
const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
|
|
665
|
+
const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
|
|
666
|
+
return [toACVMField(1), storage, length];
|
|
667
|
+
} catch {
|
|
668
|
+
const zeroStorage = Array(ciphertextBVecStorage.length).fill(toACVMField(0));
|
|
669
|
+
return [toACVMField(0), zeroStorage, toACVMField(0)];
|
|
670
|
+
}
|
|
600
671
|
}
|
|
601
672
|
|
|
602
|
-
|
|
673
|
+
// eslint-disable-next-line camelcase
|
|
674
|
+
async aztec_utl_getSharedSecret(
|
|
603
675
|
[address]: ACVMField[],
|
|
604
676
|
[ephPKField0]: ACVMField[],
|
|
605
677
|
[ephPKField1]: ACVMField[],
|
|
606
678
|
[ephPKField2]: ACVMField[],
|
|
679
|
+
[contractAddress]: ACVMField[],
|
|
607
680
|
): Promise<ACVMField[]> {
|
|
608
|
-
const secret = await this.handlerAsUtility().
|
|
681
|
+
const secret = await this.handlerAsUtility().getSharedSecret(
|
|
609
682
|
AztecAddress.fromField(Fr.fromString(address)),
|
|
610
683
|
Point.fromFields([ephPKField0, ephPKField1, ephPKField2].map(Fr.fromString)),
|
|
684
|
+
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
685
|
+
);
|
|
686
|
+
return [toACVMField(secret)];
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// eslint-disable-next-line camelcase
|
|
690
|
+
aztec_utl_setContractSyncCacheInvalid(
|
|
691
|
+
[contractAddress]: ACVMField[],
|
|
692
|
+
scopes: ACVMField[],
|
|
693
|
+
[scopeCount]: ACVMField[],
|
|
694
|
+
): Promise<ACVMField[]> {
|
|
695
|
+
const scopeAddresses = scopes.slice(0, +scopeCount).map(s => AztecAddress.fromField(Fr.fromString(s)));
|
|
696
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(
|
|
697
|
+
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
698
|
+
scopeAddresses,
|
|
611
699
|
);
|
|
612
|
-
return
|
|
700
|
+
return Promise.resolve([]);
|
|
613
701
|
}
|
|
614
702
|
|
|
615
|
-
|
|
616
|
-
|
|
703
|
+
// eslint-disable-next-line camelcase
|
|
704
|
+
async aztec_utl_emitOffchainEffect(data: ACVMField[]) {
|
|
705
|
+
await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
|
|
617
706
|
return [];
|
|
618
707
|
}
|
|
619
708
|
|
|
620
|
-
|
|
621
|
-
|
|
709
|
+
// eslint-disable-next-line camelcase
|
|
710
|
+
async aztec_prv_getSenderForTags(): Promise<ACVMField[]> {
|
|
711
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
622
712
|
// Return [1, address] for Some(address), [0, 0] for None
|
|
623
713
|
return sender ? [toACVMField(1n), toACVMField(sender)] : [toACVMField(0n), toACVMField(0n)];
|
|
624
714
|
}
|
|
625
715
|
|
|
626
|
-
|
|
627
|
-
|
|
716
|
+
// eslint-disable-next-line camelcase
|
|
717
|
+
async aztec_prv_setSenderForTags([senderForTags]: ACVMField[]): Promise<ACVMField[]> {
|
|
718
|
+
await this.handlerAsPrivate().setSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
|
|
628
719
|
return [];
|
|
629
720
|
}
|
|
630
721
|
}
|