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