@aztec/pxe 0.0.1-commit.c949de6bc → 0.0.1-commit.cbf2c2d5d
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/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +28 -6
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +17 -9
- 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 +163 -94
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +22 -47
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +30 -62
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +53 -35
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +101 -43
- package/dest/contract_sync/contract_sync_service.d.ts +5 -3
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +47 -30
- 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/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +3 -3
- package/dest/pxe.d.ts +8 -4
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +39 -22
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
- 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/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
- 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 +2 -1
- 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 +24 -11
- package/package.json +16 -16
- package/src/config/index.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +39 -7
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
- 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 +54 -54
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
- package/src/contract_function_simulator/oracle/oracle.ts +176 -138
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +32 -80
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +136 -53
- package/src/contract_sync/contract_sync_service.ts +67 -38
- package/src/messages/message_context_service.ts +45 -0
- package/src/oracle_version.ts +3 -3
- package/src/pxe.ts +57 -21
- package/src/storage/metadata.ts +1 -1
- package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
- package/src/tagging/index.ts +1 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
- 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 +19 -9
|
@@ -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,17 +145,15 @@ export class Oracle {
|
|
|
137
145
|
].map(toACVMField);
|
|
138
146
|
}
|
|
139
147
|
|
|
140
|
-
|
|
148
|
+
// eslint-disable-next-line camelcase
|
|
149
|
+
async aztec_utl_getNoteHashMembershipWitness(
|
|
141
150
|
[anchorBlockHash]: ACVMField[],
|
|
142
151
|
[noteHash]: ACVMField[],
|
|
143
152
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
144
153
|
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
145
154
|
const parsedNoteHash = Fr.fromString(noteHash);
|
|
146
155
|
|
|
147
|
-
const witness = await this.handlerAsUtility().
|
|
148
|
-
parsedAnchorBlockHash,
|
|
149
|
-
parsedNoteHash,
|
|
150
|
-
);
|
|
156
|
+
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
|
|
151
157
|
if (!witness) {
|
|
152
158
|
throw new Error(
|
|
153
159
|
`Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`,
|
|
@@ -156,17 +162,15 @@ export class Oracle {
|
|
|
156
162
|
return witness.toNoirRepresentation();
|
|
157
163
|
}
|
|
158
164
|
|
|
159
|
-
|
|
165
|
+
// eslint-disable-next-line camelcase
|
|
166
|
+
async aztec_utl_getBlockHashMembershipWitness(
|
|
160
167
|
[anchorBlockHash]: ACVMField[],
|
|
161
168
|
[blockHash]: ACVMField[],
|
|
162
169
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
163
170
|
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
164
171
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
165
172
|
|
|
166
|
-
const witness = await this.handlerAsUtility().
|
|
167
|
-
parsedAnchorBlockHash,
|
|
168
|
-
parsedBlockHash,
|
|
169
|
-
);
|
|
173
|
+
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
|
|
170
174
|
if (!witness) {
|
|
171
175
|
throw new Error(
|
|
172
176
|
`Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`,
|
|
@@ -175,17 +179,15 @@ export class Oracle {
|
|
|
175
179
|
return witness.toNoirRepresentation();
|
|
176
180
|
}
|
|
177
181
|
|
|
178
|
-
|
|
182
|
+
// eslint-disable-next-line camelcase
|
|
183
|
+
async aztec_utl_getNullifierMembershipWitness(
|
|
179
184
|
[blockHash]: ACVMField[],
|
|
180
185
|
[nullifier]: ACVMField[], // nullifier, we try to find the witness for (to prove inclusion)
|
|
181
186
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
182
187
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
183
188
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
184
189
|
|
|
185
|
-
const witness = await this.handlerAsUtility().
|
|
186
|
-
parsedBlockHash,
|
|
187
|
-
parsedNullifier,
|
|
188
|
-
);
|
|
190
|
+
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
189
191
|
if (!witness) {
|
|
190
192
|
throw new Error(
|
|
191
193
|
`Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
|
|
@@ -194,17 +196,15 @@ export class Oracle {
|
|
|
194
196
|
return witness.toNoirRepresentation();
|
|
195
197
|
}
|
|
196
198
|
|
|
197
|
-
|
|
199
|
+
// eslint-disable-next-line camelcase
|
|
200
|
+
async aztec_utl_getLowNullifierMembershipWitness(
|
|
198
201
|
[blockHash]: ACVMField[],
|
|
199
202
|
[nullifier]: ACVMField[], // nullifier, we try to find the low nullifier witness for (to prove non-inclusion)
|
|
200
203
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
201
204
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
202
205
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
203
206
|
|
|
204
|
-
const witness = await this.handlerAsUtility().
|
|
205
|
-
parsedBlockHash,
|
|
206
|
-
parsedNullifier,
|
|
207
|
-
);
|
|
207
|
+
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
208
208
|
if (!witness) {
|
|
209
209
|
throw new Error(
|
|
210
210
|
`Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
|
|
@@ -213,14 +213,15 @@ export class Oracle {
|
|
|
213
213
|
return witness.toNoirRepresentation();
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
// eslint-disable-next-line camelcase
|
|
217
|
+
async aztec_utl_getPublicDataWitness(
|
|
217
218
|
[blockHash]: ACVMField[],
|
|
218
219
|
[leafSlot]: ACVMField[],
|
|
219
220
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
220
221
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
221
222
|
const parsedLeafSlot = Fr.fromString(leafSlot);
|
|
222
223
|
|
|
223
|
-
const witness = await this.handlerAsUtility().
|
|
224
|
+
const witness = await this.handlerAsUtility().getPublicDataWitness(parsedBlockHash, parsedLeafSlot);
|
|
224
225
|
if (!witness) {
|
|
225
226
|
throw new Error(
|
|
226
227
|
`Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`,
|
|
@@ -229,28 +230,31 @@ export class Oracle {
|
|
|
229
230
|
return witness.toNoirRepresentation();
|
|
230
231
|
}
|
|
231
232
|
|
|
232
|
-
|
|
233
|
+
// eslint-disable-next-line camelcase
|
|
234
|
+
async aztec_utl_getBlockHeader([blockNumber]: ACVMField[]): Promise<ACVMField[]> {
|
|
233
235
|
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
234
236
|
|
|
235
|
-
const header = await this.handlerAsUtility().
|
|
237
|
+
const header = await this.handlerAsUtility().getBlockHeader(BlockNumber(parsedBlockNumber));
|
|
236
238
|
if (!header) {
|
|
237
239
|
throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
|
|
238
240
|
}
|
|
239
241
|
return header.toFields().map(toACVMField);
|
|
240
242
|
}
|
|
241
243
|
|
|
242
|
-
|
|
244
|
+
// eslint-disable-next-line camelcase
|
|
245
|
+
async aztec_utl_getAuthWitness([messageHash]: ACVMField[]): Promise<ACVMField[][]> {
|
|
243
246
|
const messageHashField = Fr.fromString(messageHash);
|
|
244
|
-
const witness = await this.handlerAsUtility().
|
|
247
|
+
const witness = await this.handlerAsUtility().getAuthWitness(messageHashField);
|
|
245
248
|
if (!witness) {
|
|
246
249
|
throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
|
|
247
250
|
}
|
|
248
251
|
return [witness.map(toACVMField)];
|
|
249
252
|
}
|
|
250
253
|
|
|
251
|
-
|
|
254
|
+
// eslint-disable-next-line camelcase
|
|
255
|
+
async aztec_utl_tryGetPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
|
|
252
256
|
const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
|
|
253
|
-
const result = await this.handlerAsUtility().
|
|
257
|
+
const result = await this.handlerAsUtility().tryGetPublicKeysAndPartialAddress(parsedAddress);
|
|
254
258
|
|
|
255
259
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
256
260
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -263,7 +267,8 @@ export class Oracle {
|
|
|
263
267
|
}
|
|
264
268
|
}
|
|
265
269
|
|
|
266
|
-
|
|
270
|
+
// eslint-disable-next-line camelcase
|
|
271
|
+
async aztec_utl_getNotes(
|
|
267
272
|
[ownerSome]: ACVMField[],
|
|
268
273
|
[ownerValue]: ACVMField[],
|
|
269
274
|
[storageSlot]: ACVMField[],
|
|
@@ -285,7 +290,7 @@ export class Oracle {
|
|
|
285
290
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
286
291
|
// Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
|
|
287
292
|
const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
|
|
288
|
-
const noteDatas = await this.handlerAsUtility().
|
|
293
|
+
const noteDatas = await this.handlerAsUtility().getNotes(
|
|
289
294
|
owner,
|
|
290
295
|
Fr.fromString(storageSlot),
|
|
291
296
|
+numSelects,
|
|
@@ -324,7 +329,8 @@ export class Oracle {
|
|
|
324
329
|
return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
|
|
325
330
|
}
|
|
326
331
|
|
|
327
|
-
|
|
332
|
+
// eslint-disable-next-line camelcase
|
|
333
|
+
aztec_prv_notifyCreatedNote(
|
|
328
334
|
[owner]: ACVMField[],
|
|
329
335
|
[storageSlot]: ACVMField[],
|
|
330
336
|
[randomness]: ACVMField[],
|
|
@@ -333,7 +339,7 @@ export class Oracle {
|
|
|
333
339
|
[noteHash]: ACVMField[],
|
|
334
340
|
[counter]: ACVMField[],
|
|
335
341
|
): Promise<ACVMField[]> {
|
|
336
|
-
this.handlerAsPrivate().
|
|
342
|
+
this.handlerAsPrivate().notifyCreatedNote(
|
|
337
343
|
AztecAddress.fromString(owner),
|
|
338
344
|
Fr.fromString(storageSlot),
|
|
339
345
|
Fr.fromString(randomness),
|
|
@@ -345,43 +351,47 @@ export class Oracle {
|
|
|
345
351
|
return Promise.resolve([]);
|
|
346
352
|
}
|
|
347
353
|
|
|
348
|
-
|
|
354
|
+
// eslint-disable-next-line camelcase
|
|
355
|
+
async aztec_prv_notifyNullifiedNote(
|
|
349
356
|
[innerNullifier]: ACVMField[],
|
|
350
357
|
[noteHash]: ACVMField[],
|
|
351
358
|
[counter]: ACVMField[],
|
|
352
359
|
): Promise<ACVMField[]> {
|
|
353
|
-
await this.handlerAsPrivate().
|
|
354
|
-
Fr.fromString(innerNullifier),
|
|
355
|
-
Fr.fromString(noteHash),
|
|
356
|
-
+counter,
|
|
357
|
-
);
|
|
360
|
+
await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
|
|
358
361
|
return [];
|
|
359
362
|
}
|
|
360
363
|
|
|
361
|
-
|
|
362
|
-
|
|
364
|
+
// eslint-disable-next-line camelcase
|
|
365
|
+
async aztec_prv_notifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
|
|
366
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
|
|
363
367
|
return [];
|
|
364
368
|
}
|
|
365
369
|
|
|
366
|
-
|
|
367
|
-
|
|
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(
|
|
368
376
|
Fr.fromString(innerNullifier),
|
|
369
377
|
AztecAddress.fromString(contractAddress),
|
|
370
378
|
);
|
|
371
379
|
return [toACVMField(isPending)];
|
|
372
380
|
}
|
|
373
381
|
|
|
374
|
-
|
|
375
|
-
|
|
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));
|
|
376
385
|
return [toACVMField(exists)];
|
|
377
386
|
}
|
|
378
387
|
|
|
379
|
-
|
|
388
|
+
// eslint-disable-next-line camelcase
|
|
389
|
+
async aztec_utl_getL1ToL2MembershipWitness(
|
|
380
390
|
[contractAddress]: ACVMField[],
|
|
381
391
|
[messageHash]: ACVMField[],
|
|
382
392
|
[secret]: ACVMField[],
|
|
383
393
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
384
|
-
const message = await this.handlerAsUtility().
|
|
394
|
+
const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(
|
|
385
395
|
AztecAddress.fromString(contractAddress),
|
|
386
396
|
Fr.fromString(messageHash),
|
|
387
397
|
Fr.fromString(secret),
|
|
@@ -389,13 +399,14 @@ export class Oracle {
|
|
|
389
399
|
return message.toNoirRepresentation();
|
|
390
400
|
}
|
|
391
401
|
|
|
392
|
-
|
|
402
|
+
// eslint-disable-next-line camelcase
|
|
403
|
+
async aztec_utl_storageRead(
|
|
393
404
|
[blockHash]: ACVMField[],
|
|
394
405
|
[contractAddress]: ACVMField[],
|
|
395
406
|
[startStorageSlot]: ACVMField[],
|
|
396
407
|
[numberOfElements]: ACVMField[],
|
|
397
408
|
): Promise<ACVMField[][]> {
|
|
398
|
-
const values = await this.handlerAsUtility().
|
|
409
|
+
const values = await this.handlerAsUtility().storageRead(
|
|
399
410
|
BlockHash.fromString(blockHash),
|
|
400
411
|
new AztecAddress(Fr.fromString(contractAddress)),
|
|
401
412
|
Fr.fromString(startStorageSlot),
|
|
@@ -404,7 +415,8 @@ export class Oracle {
|
|
|
404
415
|
return [values.map(toACVMField)];
|
|
405
416
|
}
|
|
406
417
|
|
|
407
|
-
|
|
418
|
+
// eslint-disable-next-line camelcase
|
|
419
|
+
aztec_prv_notifyCreatedContractClassLog(
|
|
408
420
|
[contractAddress]: ACVMField[],
|
|
409
421
|
message: ACVMField[],
|
|
410
422
|
[length]: ACVMField[],
|
|
@@ -413,11 +425,12 @@ export class Oracle {
|
|
|
413
425
|
const logFields = new ContractClassLogFields(message.map(Fr.fromString));
|
|
414
426
|
const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
|
|
415
427
|
|
|
416
|
-
this.handlerAsPrivate().
|
|
428
|
+
this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
|
|
417
429
|
return Promise.resolve([]);
|
|
418
430
|
}
|
|
419
431
|
|
|
420
|
-
|
|
432
|
+
// eslint-disable-next-line camelcase
|
|
433
|
+
async aztec_utl_log(
|
|
421
434
|
level: ACVMField[],
|
|
422
435
|
message: ACVMField[],
|
|
423
436
|
_ignoredFieldsSize: ACVMField[],
|
|
@@ -426,20 +439,21 @@ export class Oracle {
|
|
|
426
439
|
const levelFr = Fr.fromString(level[0]);
|
|
427
440
|
const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
|
|
428
441
|
const fieldsFr = fields.map(Fr.fromString);
|
|
429
|
-
await this.handlerAsMisc().
|
|
442
|
+
await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
|
|
430
443
|
return [];
|
|
431
444
|
}
|
|
432
445
|
|
|
433
446
|
// This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
|
|
434
447
|
// change the name here.
|
|
435
|
-
|
|
448
|
+
// eslint-disable-next-line camelcase
|
|
449
|
+
async aztec_prv_callPrivateFunction(
|
|
436
450
|
[contractAddress]: ACVMField[],
|
|
437
451
|
[functionSelector]: ACVMField[],
|
|
438
452
|
[argsHash]: ACVMField[],
|
|
439
453
|
[sideEffectCounter]: ACVMField[],
|
|
440
454
|
[isStaticCall]: ACVMField[],
|
|
441
455
|
): Promise<ACVMField[][]> {
|
|
442
|
-
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().
|
|
456
|
+
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(
|
|
443
457
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
444
458
|
FunctionSelector.fromField(Fr.fromString(functionSelector)),
|
|
445
459
|
Fr.fromString(argsHash),
|
|
@@ -449,85 +463,65 @@ export class Oracle {
|
|
|
449
463
|
return [[endSideEffectCounter, returnsHash].map(toACVMField)];
|
|
450
464
|
}
|
|
451
465
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
[sideEffectCounter]: ACVMField[],
|
|
456
|
-
[isStaticCall]: ACVMField[],
|
|
457
|
-
): Promise<ACVMField[]> {
|
|
458
|
-
await this.handlerAsPrivate().privateNotifyEnqueuedPublicFunctionCall(
|
|
459
|
-
AztecAddress.fromString(contractAddress),
|
|
460
|
-
Fr.fromString(calldataHash),
|
|
461
|
-
Fr.fromString(sideEffectCounter).toNumber(),
|
|
462
|
-
Fr.fromString(isStaticCall).toBool(),
|
|
463
|
-
);
|
|
466
|
+
// eslint-disable-next-line camelcase
|
|
467
|
+
async aztec_prv_validatePublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
|
|
468
|
+
await this.handlerAsPrivate().validatePublicCalldata(Fr.fromString(calldataHash));
|
|
464
469
|
return [];
|
|
465
470
|
}
|
|
466
471
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
[sideEffectCounter]: ACVMField[],
|
|
471
|
-
[isStaticCall]: ACVMField[],
|
|
472
|
-
): Promise<ACVMField[]> {
|
|
473
|
-
await this.handlerAsPrivate().privateNotifySetPublicTeardownFunctionCall(
|
|
474
|
-
AztecAddress.fromString(contractAddress),
|
|
475
|
-
Fr.fromString(calldataHash),
|
|
476
|
-
Fr.fromString(sideEffectCounter).toNumber(),
|
|
477
|
-
Fr.fromString(isStaticCall).toBool(),
|
|
478
|
-
);
|
|
479
|
-
return [];
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
async privateNotifySetMinRevertibleSideEffectCounter([minRevertibleSideEffectCounter]: ACVMField[]): Promise<
|
|
483
|
-
ACVMField[]
|
|
484
|
-
> {
|
|
485
|
-
await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(
|
|
486
|
-
Fr.fromString(minRevertibleSideEffectCounter).toNumber(),
|
|
487
|
-
);
|
|
472
|
+
// eslint-disable-next-line camelcase
|
|
473
|
+
async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
|
|
474
|
+
await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
488
475
|
return Promise.resolve([]);
|
|
489
476
|
}
|
|
490
477
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
);
|
|
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());
|
|
495
481
|
return Promise.resolve([toACVMField(isRevertible)]);
|
|
496
482
|
}
|
|
497
483
|
|
|
498
|
-
|
|
499
|
-
|
|
484
|
+
// eslint-disable-next-line camelcase
|
|
485
|
+
async aztec_prv_getNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
|
|
486
|
+
const tag = await this.handlerAsPrivate().getNextAppTagAsSender(
|
|
500
487
|
AztecAddress.fromString(sender),
|
|
501
488
|
AztecAddress.fromString(recipient),
|
|
502
489
|
);
|
|
503
490
|
return [toACVMField(tag.value)];
|
|
504
491
|
}
|
|
505
492
|
|
|
506
|
-
|
|
507
|
-
|
|
493
|
+
// eslint-disable-next-line camelcase
|
|
494
|
+
async aztec_utl_fetchTaggedLogs([pendingTaggedLogArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
|
|
495
|
+
await this.handlerAsUtility().fetchTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot));
|
|
508
496
|
return [];
|
|
509
497
|
}
|
|
510
498
|
|
|
511
|
-
|
|
499
|
+
// eslint-disable-next-line camelcase
|
|
500
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
512
501
|
[contractAddress]: ACVMField[],
|
|
513
502
|
[noteValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
514
503
|
[eventValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
504
|
+
[maxNotePackedLen]: ACVMField[],
|
|
505
|
+
[maxEventSerializedLen]: ACVMField[],
|
|
515
506
|
): Promise<ACVMField[]> {
|
|
516
|
-
await this.handlerAsUtility().
|
|
507
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
517
508
|
AztecAddress.fromString(contractAddress),
|
|
518
509
|
Fr.fromString(noteValidationRequestsArrayBaseSlot),
|
|
519
510
|
Fr.fromString(eventValidationRequestsArrayBaseSlot),
|
|
511
|
+
Fr.fromString(maxNotePackedLen).toNumber(),
|
|
512
|
+
Fr.fromString(maxEventSerializedLen).toNumber(),
|
|
520
513
|
);
|
|
521
514
|
|
|
522
515
|
return [];
|
|
523
516
|
}
|
|
524
517
|
|
|
525
|
-
|
|
518
|
+
// eslint-disable-next-line camelcase
|
|
519
|
+
async aztec_utl_bulkRetrieveLogs(
|
|
526
520
|
[contractAddress]: ACVMField[],
|
|
527
521
|
[logRetrievalRequestsArrayBaseSlot]: ACVMField[],
|
|
528
522
|
[logRetrievalResponsesArrayBaseSlot]: ACVMField[],
|
|
529
523
|
): Promise<ACVMField[]> {
|
|
530
|
-
await this.handlerAsUtility().
|
|
524
|
+
await this.handlerAsUtility().bulkRetrieveLogs(
|
|
531
525
|
AztecAddress.fromString(contractAddress),
|
|
532
526
|
Fr.fromString(logRetrievalRequestsArrayBaseSlot),
|
|
533
527
|
Fr.fromString(logRetrievalResponsesArrayBaseSlot),
|
|
@@ -535,12 +529,27 @@ export class Oracle {
|
|
|
535
529
|
return [];
|
|
536
530
|
}
|
|
537
531
|
|
|
538
|
-
|
|
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(
|
|
539
548
|
[contractAddress]: ACVMField[],
|
|
540
549
|
[slot]: ACVMField[],
|
|
541
550
|
capsule: ACVMField[],
|
|
542
551
|
): Promise<ACVMField[]> {
|
|
543
|
-
await this.handlerAsUtility().
|
|
552
|
+
await this.handlerAsUtility().storeCapsule(
|
|
544
553
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
545
554
|
Fr.fromString(slot),
|
|
546
555
|
capsule.map(Fr.fromString),
|
|
@@ -548,12 +557,13 @@ export class Oracle {
|
|
|
548
557
|
return [];
|
|
549
558
|
}
|
|
550
559
|
|
|
551
|
-
|
|
560
|
+
// eslint-disable-next-line camelcase
|
|
561
|
+
async aztec_utl_loadCapsule(
|
|
552
562
|
[contractAddress]: ACVMField[],
|
|
553
563
|
[slot]: ACVMField[],
|
|
554
564
|
[tSize]: ACVMField[],
|
|
555
565
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
556
|
-
const values = await this.handlerAsUtility().
|
|
566
|
+
const values = await this.handlerAsUtility().loadCapsule(
|
|
557
567
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
558
568
|
Fr.fromString(slot),
|
|
559
569
|
);
|
|
@@ -569,21 +579,23 @@ export class Oracle {
|
|
|
569
579
|
}
|
|
570
580
|
}
|
|
571
581
|
|
|
572
|
-
|
|
573
|
-
|
|
582
|
+
// eslint-disable-next-line camelcase
|
|
583
|
+
async aztec_utl_deleteCapsule([contractAddress]: ACVMField[], [slot]: ACVMField[]): Promise<ACVMField[]> {
|
|
584
|
+
await this.handlerAsUtility().deleteCapsule(
|
|
574
585
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
575
586
|
Fr.fromString(slot),
|
|
576
587
|
);
|
|
577
588
|
return [];
|
|
578
589
|
}
|
|
579
590
|
|
|
580
|
-
|
|
591
|
+
// eslint-disable-next-line camelcase
|
|
592
|
+
async aztec_utl_copyCapsule(
|
|
581
593
|
[contractAddress]: ACVMField[],
|
|
582
594
|
[srcSlot]: ACVMField[],
|
|
583
595
|
[dstSlot]: ACVMField[],
|
|
584
596
|
[numEntries]: ACVMField[],
|
|
585
597
|
): Promise<ACVMField[]> {
|
|
586
|
-
await this.handlerAsUtility().
|
|
598
|
+
await this.handlerAsUtility().copyCapsule(
|
|
587
599
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
588
600
|
Fr.fromString(srcSlot),
|
|
589
601
|
Fr.fromString(dstSlot),
|
|
@@ -592,7 +604,8 @@ export class Oracle {
|
|
|
592
604
|
return [];
|
|
593
605
|
}
|
|
594
606
|
|
|
595
|
-
|
|
607
|
+
// eslint-disable-next-line camelcase
|
|
608
|
+
async aztec_utl_tryAes128Decrypt(
|
|
596
609
|
ciphertextBVecStorage: ACVMField[],
|
|
597
610
|
[ciphertextLength]: ACVMField[],
|
|
598
611
|
iv: ACVMField[],
|
|
@@ -602,36 +615,61 @@ export class Oracle {
|
|
|
602
615
|
const ivBuffer = fromUintArray(iv, 8);
|
|
603
616
|
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
604
617
|
|
|
605
|
-
|
|
606
|
-
|
|
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
|
+
}
|
|
607
627
|
}
|
|
608
628
|
|
|
609
|
-
|
|
629
|
+
// eslint-disable-next-line camelcase
|
|
630
|
+
async aztec_utl_getSharedSecret(
|
|
610
631
|
[address]: ACVMField[],
|
|
611
632
|
[ephPKField0]: ACVMField[],
|
|
612
633
|
[ephPKField1]: ACVMField[],
|
|
613
634
|
[ephPKField2]: ACVMField[],
|
|
614
635
|
): Promise<ACVMField[]> {
|
|
615
|
-
const secret = await this.handlerAsUtility().
|
|
636
|
+
const secret = await this.handlerAsUtility().getSharedSecret(
|
|
616
637
|
AztecAddress.fromField(Fr.fromString(address)),
|
|
617
638
|
Point.fromFields([ephPKField0, ephPKField1, ephPKField2].map(Fr.fromString)),
|
|
618
639
|
);
|
|
619
640
|
return secret.toFields().map(toACVMField);
|
|
620
641
|
}
|
|
621
642
|
|
|
622
|
-
|
|
623
|
-
|
|
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));
|
|
624
660
|
return [];
|
|
625
661
|
}
|
|
626
662
|
|
|
627
|
-
|
|
628
|
-
|
|
663
|
+
// eslint-disable-next-line camelcase
|
|
664
|
+
async aztec_prv_getSenderForTags(): Promise<ACVMField[]> {
|
|
665
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
629
666
|
// Return [1, address] for Some(address), [0, 0] for None
|
|
630
667
|
return sender ? [toACVMField(1n), toACVMField(sender)] : [toACVMField(0n), toACVMField(0n)];
|
|
631
668
|
}
|
|
632
669
|
|
|
633
|
-
|
|
634
|
-
|
|
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)));
|
|
635
673
|
return [];
|
|
636
674
|
}
|
|
637
675
|
}
|