@aztec/pxe 0.0.1-commit.ec5f612 → 0.0.1-commit.ec7ac5448
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/bin/check_oracle_version.js +4 -4
- package/dest/block_synchronizer/block_synchronizer.d.ts +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +6 -0
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +10 -5
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +31 -8
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- 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 +4 -6
- 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 +8 -10
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- 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 +2 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
- 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 +6 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +61 -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 +47 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +281 -96
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +23 -49
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +40 -63
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +89 -56
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +272 -107
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +9 -2
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
- package/dest/contract_logging.d.ts +9 -4
- package/dest/contract_logging.d.ts.map +1 -1
- package/dest/contract_logging.js +21 -6
- package/dest/contract_sync/contract_sync_service.d.ts +6 -5
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +44 -37
- package/dest/contract_sync/helpers.d.ts +2 -3
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +7 -2
- package/dest/debug/pxe_debug_utils.d.ts +3 -3
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +2 -2
- package/dest/entrypoints/client/lazy/index.d.ts +1 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +0 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +2 -2
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +2 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -2
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +2 -2
- package/dest/events/event_service.d.ts +3 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +16 -4
- package/dest/logs/log_service.d.ts +5 -8
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +24 -37
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- package/dest/notes/note_service.d.ts +4 -5
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +14 -5
- package/dest/notes_filter.d.ts +2 -3
- package/dest/notes_filter.d.ts.map +1 -1
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/pxe.d.ts +11 -8
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +45 -26
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +33 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +1 -1
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +2 -2
- package/dest/storage/tagging_store/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/bin/check_oracle_version.ts +4 -4
- package/src/block_synchronizer/block_synchronizer.ts +6 -0
- package/src/config/index.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +44 -12
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- 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 +9 -9
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
- package/src/contract_function_simulator/oracle/interfaces.ts +82 -54
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/oracle.ts +363 -139
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +45 -84
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +444 -143
- package/src/contract_function_simulator/pick_notes.ts +9 -2
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_logging.ts +18 -5
- package/src/contract_sync/contract_sync_service.ts +77 -59
- package/src/contract_sync/helpers.ts +4 -4
- package/src/debug/pxe_debug_utils.ts +3 -3
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +2 -3
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +2 -3
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +1 -2
- package/src/entrypoints/server/utils.ts +2 -3
- package/src/events/event_service.ts +17 -4
- package/src/logs/log_service.ts +52 -78
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +18 -8
- package/src/notes_filter.ts +1 -3
- package/src/oracle_version.ts +20 -10
- package/src/pxe.ts +68 -31
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +34 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +2 -5
- 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
- package/dest/access_scopes.d.ts +0 -9
- package/dest/access_scopes.d.ts.map +0 -1
- package/dest/access_scopes.js +0 -6
- package/src/access_scopes.ts +0 -9
|
@@ -15,7 +15,9 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
15
15
|
import { BlockHash } from '@aztec/stdlib/block';
|
|
16
16
|
import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
|
|
17
17
|
|
|
18
|
+
import { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
|
|
18
19
|
import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from './interfaces.js';
|
|
20
|
+
import { buildLegacyOracleCallbacks } from './legacy_oracle_mappings.js';
|
|
19
21
|
import { packAsHintedNote } from './note_packing_utils.js';
|
|
20
22
|
|
|
21
23
|
export class UnavailableOracleError extends Error {
|
|
@@ -26,6 +28,25 @@ export class UnavailableOracleError extends Error {
|
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* A data source that has all the apis required by Aztec.nr.
|
|
31
|
+
*
|
|
32
|
+
* ## Oracle naming conventions
|
|
33
|
+
*
|
|
34
|
+
* We try to keep oracle naming consistent, please see below the conventions we adhere to.
|
|
35
|
+
*
|
|
36
|
+
* Each oracle method name has the form `aztec_{scope}_{verb}{Object}`, where:
|
|
37
|
+
*
|
|
38
|
+
* - **Scope prefix** indicates the execution context required:
|
|
39
|
+
* - `aztec_prv_` — available only during private function execution.
|
|
40
|
+
* - `aztec_utl_` — available during both utility and private execution.
|
|
41
|
+
*
|
|
42
|
+
* - **Verb** signals the operation's semantics (verb-first, then object):
|
|
43
|
+
* - `get` — read / lookup / get data from oracle into contract.
|
|
44
|
+
* - `does`/`is`/`has` — predicate (returns boolean).
|
|
45
|
+
* - `emit`/`notify` — propagate data from contract to oracle.
|
|
46
|
+
* - `set` — contract driven oracle state mutation (capsules, execution cache, tagging, etc).
|
|
47
|
+
* - `call` — trigger nested execution (control flow).
|
|
48
|
+
* - `assert` — validate a condition, throw on failure.
|
|
49
|
+
* - Standalone verbs (`delete`, `copy`, `decrypt`, `log`, etc) are used when no generic verb fits.
|
|
29
50
|
*/
|
|
30
51
|
export class Oracle {
|
|
31
52
|
constructor(private handler: IMiscOracle | IUtilityExecutionOracle | IPrivateExecutionOracle) {}
|
|
@@ -69,12 +90,12 @@ export class Oracle {
|
|
|
69
90
|
name => !excludedProps.includes(name as (typeof excludedProps)[number]),
|
|
70
91
|
);
|
|
71
92
|
|
|
72
|
-
// Validate oracle names - these must be prefixed with either "
|
|
93
|
+
// Validate oracle names - these must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate their scope
|
|
73
94
|
// and must correspond to a function on the Oracle class.
|
|
74
95
|
oracleNames.forEach(name => {
|
|
75
|
-
if (!name.startsWith('
|
|
96
|
+
if (!name.startsWith('aztec_prv_') && !name.startsWith('aztec_utl_')) {
|
|
76
97
|
throw new Error(
|
|
77
|
-
`Oracle function "${name}" must be prefixed with either "
|
|
98
|
+
`Oracle function "${name}" must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate its scope`,
|
|
78
99
|
);
|
|
79
100
|
}
|
|
80
101
|
|
|
@@ -85,48 +106,110 @@ export class Oracle {
|
|
|
85
106
|
});
|
|
86
107
|
|
|
87
108
|
// Build callback object and return it
|
|
88
|
-
|
|
109
|
+
const callback = oracleNames.reduce((acc, name) => {
|
|
89
110
|
const method = this[name as keyof Omit<Oracle, (typeof excludedProps)[number]>];
|
|
90
111
|
acc[name] = method.bind(this);
|
|
91
112
|
return acc;
|
|
92
113
|
}, {} as ACIRCallback);
|
|
114
|
+
|
|
115
|
+
const allCallbacks = { ...callback, ...buildLegacyOracleCallbacks(this) };
|
|
116
|
+
|
|
117
|
+
// Wrap in a Proxy to intercept access to missing oracle names and provide enhanced error messages when the
|
|
118
|
+
// contract's minor version is higher than the PXE's (i.e. the contract expects oracles that were added in a newer
|
|
119
|
+
// minor version).
|
|
120
|
+
const handler = this.handler;
|
|
121
|
+
return new Proxy(allCallbacks, {
|
|
122
|
+
get(target, prop: string) {
|
|
123
|
+
if (prop in target) {
|
|
124
|
+
return target[prop];
|
|
125
|
+
}
|
|
126
|
+
// Return a function that throws with an enhanced error message if applicable
|
|
127
|
+
return () => {
|
|
128
|
+
type NonOracleFunctionGetContractOracleVersion = {
|
|
129
|
+
nonOracleFunctionGetContractOracleVersion(): { major: number; minor: number } | undefined;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
let contractVersion = undefined;
|
|
133
|
+
if ('nonOracleFunctionGetContractOracleVersion' in handler) {
|
|
134
|
+
contractVersion = (
|
|
135
|
+
handler as unknown as NonOracleFunctionGetContractOracleVersion
|
|
136
|
+
).nonOracleFunctionGetContractOracleVersion();
|
|
137
|
+
}
|
|
138
|
+
if (!contractVersion) {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`Oracle '${prop}' not found and the contract's oracle version is unknown (the version check oracle ` +
|
|
141
|
+
`was not called before '${prop}'). This usually means the contract was not compiled with the ` +
|
|
142
|
+
`#[aztec] macro, which injects the version check as the first oracle call in every private/utility ` +
|
|
143
|
+
`external function. If you're using a custom entry point, ensure assert_compatible_oracle_version() ` +
|
|
144
|
+
`is called before any other oracle calls. See https://docs.aztec.network/errors/8`,
|
|
145
|
+
);
|
|
146
|
+
} else if (contractVersion.minor > ORACLE_VERSION_MINOR) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`Oracle '${prop}' not found.` +
|
|
149
|
+
` This usually means the contract requires a newer private execution environment than you have.` +
|
|
150
|
+
` Upgrade your private execution environment to a compatible version. The contract was compiled with` +
|
|
151
|
+
` Aztec.nr oracle version ${contractVersion.major}.${contractVersion.minor}, but this private` +
|
|
152
|
+
` execution environment only supports up to ${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}.` +
|
|
153
|
+
` See https://docs.aztec.network/errors/8`,
|
|
154
|
+
);
|
|
155
|
+
} else {
|
|
156
|
+
throw new Error(
|
|
157
|
+
`Oracle '${prop}' not found.` +
|
|
158
|
+
` The contract's oracle version (${contractVersion.major}.${contractVersion.minor}) is compatible` +
|
|
159
|
+
` with this private execution environment (${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}), so all` +
|
|
160
|
+
` standard oracles should be available. This could mean the contract was compiled against a modified` +
|
|
161
|
+
` version of Aztec.nr, or that it references an oracle that does not exist.` +
|
|
162
|
+
` See https://docs.aztec.network/errors/8`,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
});
|
|
93
168
|
}
|
|
94
169
|
|
|
95
|
-
|
|
96
|
-
|
|
170
|
+
// eslint-disable-next-line camelcase
|
|
171
|
+
aztec_utl_assertCompatibleOracleVersionV2([major]: ACVMField[], [minor]: ACVMField[]) {
|
|
172
|
+
this.handlerAsMisc().assertCompatibleOracleVersion(
|
|
173
|
+
Fr.fromString(major).toNumber(),
|
|
174
|
+
Fr.fromString(minor).toNumber(),
|
|
175
|
+
);
|
|
97
176
|
return Promise.resolve([]);
|
|
98
177
|
}
|
|
99
178
|
|
|
100
|
-
|
|
101
|
-
|
|
179
|
+
// eslint-disable-next-line camelcase
|
|
180
|
+
aztec_utl_getRandomField(): Promise<ACVMField[]> {
|
|
181
|
+
const val = this.handlerAsMisc().getRandomField();
|
|
102
182
|
return Promise.resolve([toACVMField(val)]);
|
|
103
183
|
}
|
|
104
184
|
|
|
105
|
-
|
|
106
|
-
|
|
185
|
+
// eslint-disable-next-line camelcase
|
|
186
|
+
aztec_prv_setHashPreimage(values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]> {
|
|
187
|
+
this.handlerAsPrivate().setHashPreimage(values.map(Fr.fromString), Fr.fromString(hash));
|
|
107
188
|
return Promise.resolve([]);
|
|
108
189
|
}
|
|
109
190
|
|
|
110
|
-
|
|
111
|
-
|
|
191
|
+
// eslint-disable-next-line camelcase
|
|
192
|
+
async aztec_prv_getHashPreimage([returnsHash]: ACVMField[]): Promise<ACVMField[][]> {
|
|
193
|
+
const values = await this.handlerAsPrivate().getHashPreimage(Fr.fromString(returnsHash));
|
|
112
194
|
return [values.map(toACVMField)];
|
|
113
195
|
}
|
|
114
196
|
|
|
115
|
-
|
|
116
|
-
|
|
197
|
+
// eslint-disable-next-line camelcase
|
|
198
|
+
aztec_utl_getUtilityContext(): Promise<(ACVMField | ACVMField[])[]> {
|
|
199
|
+
const context = this.handlerAsUtility().getUtilityContext();
|
|
117
200
|
return Promise.resolve(context.toNoirRepresentation());
|
|
118
201
|
}
|
|
119
202
|
|
|
120
|
-
|
|
121
|
-
|
|
203
|
+
// eslint-disable-next-line camelcase
|
|
204
|
+
async aztec_utl_getKeyValidationRequest([pkMHash]: ACVMField[]): Promise<ACVMField[]> {
|
|
205
|
+
const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(Fr.fromString(pkMHash));
|
|
122
206
|
|
|
123
207
|
return keyValidationRequest.toFields().map(toACVMField);
|
|
124
208
|
}
|
|
125
209
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
);
|
|
210
|
+
// eslint-disable-next-line camelcase
|
|
211
|
+
async aztec_utl_getContractInstance([address]: ACVMField[]): Promise<ACVMField[]> {
|
|
212
|
+
const instance = await this.handlerAsUtility().getContractInstance(AztecAddress.fromField(Fr.fromString(address)));
|
|
130
213
|
|
|
131
214
|
return [
|
|
132
215
|
instance.salt,
|
|
@@ -137,17 +220,15 @@ export class Oracle {
|
|
|
137
220
|
].map(toACVMField);
|
|
138
221
|
}
|
|
139
222
|
|
|
140
|
-
|
|
223
|
+
// eslint-disable-next-line camelcase
|
|
224
|
+
async aztec_utl_getNoteHashMembershipWitness(
|
|
141
225
|
[anchorBlockHash]: ACVMField[],
|
|
142
226
|
[noteHash]: ACVMField[],
|
|
143
227
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
144
228
|
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
145
229
|
const parsedNoteHash = Fr.fromString(noteHash);
|
|
146
230
|
|
|
147
|
-
const witness = await this.handlerAsUtility().
|
|
148
|
-
parsedAnchorBlockHash,
|
|
149
|
-
parsedNoteHash,
|
|
150
|
-
);
|
|
231
|
+
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
|
|
151
232
|
if (!witness) {
|
|
152
233
|
throw new Error(
|
|
153
234
|
`Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`,
|
|
@@ -156,17 +237,15 @@ export class Oracle {
|
|
|
156
237
|
return witness.toNoirRepresentation();
|
|
157
238
|
}
|
|
158
239
|
|
|
159
|
-
|
|
240
|
+
// eslint-disable-next-line camelcase
|
|
241
|
+
async aztec_utl_getBlockHashMembershipWitness(
|
|
160
242
|
[anchorBlockHash]: ACVMField[],
|
|
161
243
|
[blockHash]: ACVMField[],
|
|
162
244
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
163
245
|
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
164
246
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
165
247
|
|
|
166
|
-
const witness = await this.handlerAsUtility().
|
|
167
|
-
parsedAnchorBlockHash,
|
|
168
|
-
parsedBlockHash,
|
|
169
|
-
);
|
|
248
|
+
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
|
|
170
249
|
if (!witness) {
|
|
171
250
|
throw new Error(
|
|
172
251
|
`Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`,
|
|
@@ -175,17 +254,15 @@ export class Oracle {
|
|
|
175
254
|
return witness.toNoirRepresentation();
|
|
176
255
|
}
|
|
177
256
|
|
|
178
|
-
|
|
257
|
+
// eslint-disable-next-line camelcase
|
|
258
|
+
async aztec_utl_getNullifierMembershipWitness(
|
|
179
259
|
[blockHash]: ACVMField[],
|
|
180
260
|
[nullifier]: ACVMField[], // nullifier, we try to find the witness for (to prove inclusion)
|
|
181
261
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
182
262
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
183
263
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
184
264
|
|
|
185
|
-
const witness = await this.handlerAsUtility().
|
|
186
|
-
parsedBlockHash,
|
|
187
|
-
parsedNullifier,
|
|
188
|
-
);
|
|
265
|
+
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
189
266
|
if (!witness) {
|
|
190
267
|
throw new Error(
|
|
191
268
|
`Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
|
|
@@ -194,17 +271,15 @@ export class Oracle {
|
|
|
194
271
|
return witness.toNoirRepresentation();
|
|
195
272
|
}
|
|
196
273
|
|
|
197
|
-
|
|
274
|
+
// eslint-disable-next-line camelcase
|
|
275
|
+
async aztec_utl_getLowNullifierMembershipWitness(
|
|
198
276
|
[blockHash]: ACVMField[],
|
|
199
277
|
[nullifier]: ACVMField[], // nullifier, we try to find the low nullifier witness for (to prove non-inclusion)
|
|
200
278
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
201
279
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
202
280
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
203
281
|
|
|
204
|
-
const witness = await this.handlerAsUtility().
|
|
205
|
-
parsedBlockHash,
|
|
206
|
-
parsedNullifier,
|
|
207
|
-
);
|
|
282
|
+
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
208
283
|
if (!witness) {
|
|
209
284
|
throw new Error(
|
|
210
285
|
`Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
|
|
@@ -213,14 +288,15 @@ export class Oracle {
|
|
|
213
288
|
return witness.toNoirRepresentation();
|
|
214
289
|
}
|
|
215
290
|
|
|
216
|
-
|
|
291
|
+
// eslint-disable-next-line camelcase
|
|
292
|
+
async aztec_utl_getPublicDataWitness(
|
|
217
293
|
[blockHash]: ACVMField[],
|
|
218
294
|
[leafSlot]: ACVMField[],
|
|
219
295
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
220
296
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
221
297
|
const parsedLeafSlot = Fr.fromString(leafSlot);
|
|
222
298
|
|
|
223
|
-
const witness = await this.handlerAsUtility().
|
|
299
|
+
const witness = await this.handlerAsUtility().getPublicDataWitness(parsedBlockHash, parsedLeafSlot);
|
|
224
300
|
if (!witness) {
|
|
225
301
|
throw new Error(
|
|
226
302
|
`Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`,
|
|
@@ -229,28 +305,31 @@ export class Oracle {
|
|
|
229
305
|
return witness.toNoirRepresentation();
|
|
230
306
|
}
|
|
231
307
|
|
|
232
|
-
|
|
308
|
+
// eslint-disable-next-line camelcase
|
|
309
|
+
async aztec_utl_getBlockHeader([blockNumber]: ACVMField[]): Promise<ACVMField[]> {
|
|
233
310
|
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
234
311
|
|
|
235
|
-
const header = await this.handlerAsUtility().
|
|
312
|
+
const header = await this.handlerAsUtility().getBlockHeader(BlockNumber(parsedBlockNumber));
|
|
236
313
|
if (!header) {
|
|
237
314
|
throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
|
|
238
315
|
}
|
|
239
316
|
return header.toFields().map(toACVMField);
|
|
240
317
|
}
|
|
241
318
|
|
|
242
|
-
|
|
319
|
+
// eslint-disable-next-line camelcase
|
|
320
|
+
async aztec_utl_getAuthWitness([messageHash]: ACVMField[]): Promise<ACVMField[][]> {
|
|
243
321
|
const messageHashField = Fr.fromString(messageHash);
|
|
244
|
-
const witness = await this.handlerAsUtility().
|
|
322
|
+
const witness = await this.handlerAsUtility().getAuthWitness(messageHashField);
|
|
245
323
|
if (!witness) {
|
|
246
324
|
throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
|
|
247
325
|
}
|
|
248
326
|
return [witness.map(toACVMField)];
|
|
249
327
|
}
|
|
250
328
|
|
|
251
|
-
|
|
329
|
+
// eslint-disable-next-line camelcase
|
|
330
|
+
async aztec_utl_getPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
|
|
252
331
|
const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
|
|
253
|
-
const result = await this.handlerAsUtility().
|
|
332
|
+
const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
|
|
254
333
|
|
|
255
334
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
256
335
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -263,7 +342,8 @@ export class Oracle {
|
|
|
263
342
|
}
|
|
264
343
|
}
|
|
265
344
|
|
|
266
|
-
|
|
345
|
+
// eslint-disable-next-line camelcase
|
|
346
|
+
async aztec_utl_getNotes(
|
|
267
347
|
[ownerSome]: ACVMField[],
|
|
268
348
|
[ownerValue]: ACVMField[],
|
|
269
349
|
[storageSlot]: ACVMField[],
|
|
@@ -285,7 +365,7 @@ export class Oracle {
|
|
|
285
365
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
286
366
|
// Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
|
|
287
367
|
const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
|
|
288
|
-
const noteDatas = await this.handlerAsUtility().
|
|
368
|
+
const noteDatas = await this.handlerAsUtility().getNotes(
|
|
289
369
|
owner,
|
|
290
370
|
Fr.fromString(storageSlot),
|
|
291
371
|
+numSelects,
|
|
@@ -324,7 +404,8 @@ export class Oracle {
|
|
|
324
404
|
return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
|
|
325
405
|
}
|
|
326
406
|
|
|
327
|
-
|
|
407
|
+
// eslint-disable-next-line camelcase
|
|
408
|
+
aztec_prv_notifyCreatedNote(
|
|
328
409
|
[owner]: ACVMField[],
|
|
329
410
|
[storageSlot]: ACVMField[],
|
|
330
411
|
[randomness]: ACVMField[],
|
|
@@ -333,7 +414,7 @@ export class Oracle {
|
|
|
333
414
|
[noteHash]: ACVMField[],
|
|
334
415
|
[counter]: ACVMField[],
|
|
335
416
|
): Promise<ACVMField[]> {
|
|
336
|
-
this.handlerAsPrivate().
|
|
417
|
+
this.handlerAsPrivate().notifyCreatedNote(
|
|
337
418
|
AztecAddress.fromString(owner),
|
|
338
419
|
Fr.fromString(storageSlot),
|
|
339
420
|
Fr.fromString(randomness),
|
|
@@ -345,43 +426,47 @@ export class Oracle {
|
|
|
345
426
|
return Promise.resolve([]);
|
|
346
427
|
}
|
|
347
428
|
|
|
348
|
-
|
|
429
|
+
// eslint-disable-next-line camelcase
|
|
430
|
+
async aztec_prv_notifyNullifiedNote(
|
|
349
431
|
[innerNullifier]: ACVMField[],
|
|
350
432
|
[noteHash]: ACVMField[],
|
|
351
433
|
[counter]: ACVMField[],
|
|
352
434
|
): Promise<ACVMField[]> {
|
|
353
|
-
await this.handlerAsPrivate().
|
|
354
|
-
Fr.fromString(innerNullifier),
|
|
355
|
-
Fr.fromString(noteHash),
|
|
356
|
-
+counter,
|
|
357
|
-
);
|
|
435
|
+
await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
|
|
358
436
|
return [];
|
|
359
437
|
}
|
|
360
438
|
|
|
361
|
-
|
|
362
|
-
|
|
439
|
+
// eslint-disable-next-line camelcase
|
|
440
|
+
async aztec_prv_notifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
|
|
441
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
|
|
363
442
|
return [];
|
|
364
443
|
}
|
|
365
444
|
|
|
366
|
-
|
|
367
|
-
|
|
445
|
+
// eslint-disable-next-line camelcase
|
|
446
|
+
async aztec_prv_isNullifierPending(
|
|
447
|
+
[innerNullifier]: ACVMField[],
|
|
448
|
+
[contractAddress]: ACVMField[],
|
|
449
|
+
): Promise<ACVMField[]> {
|
|
450
|
+
const isPending = await this.handlerAsPrivate().isNullifierPending(
|
|
368
451
|
Fr.fromString(innerNullifier),
|
|
369
452
|
AztecAddress.fromString(contractAddress),
|
|
370
453
|
);
|
|
371
454
|
return [toACVMField(isPending)];
|
|
372
455
|
}
|
|
373
456
|
|
|
374
|
-
|
|
375
|
-
|
|
457
|
+
// eslint-disable-next-line camelcase
|
|
458
|
+
async aztec_utl_doesNullifierExist([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
|
|
459
|
+
const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
|
|
376
460
|
return [toACVMField(exists)];
|
|
377
461
|
}
|
|
378
462
|
|
|
379
|
-
|
|
463
|
+
// eslint-disable-next-line camelcase
|
|
464
|
+
async aztec_utl_getL1ToL2MembershipWitness(
|
|
380
465
|
[contractAddress]: ACVMField[],
|
|
381
466
|
[messageHash]: ACVMField[],
|
|
382
467
|
[secret]: ACVMField[],
|
|
383
468
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
384
|
-
const message = await this.handlerAsUtility().
|
|
469
|
+
const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(
|
|
385
470
|
AztecAddress.fromString(contractAddress),
|
|
386
471
|
Fr.fromString(messageHash),
|
|
387
472
|
Fr.fromString(secret),
|
|
@@ -389,13 +474,14 @@ export class Oracle {
|
|
|
389
474
|
return message.toNoirRepresentation();
|
|
390
475
|
}
|
|
391
476
|
|
|
392
|
-
|
|
477
|
+
// eslint-disable-next-line camelcase
|
|
478
|
+
async aztec_utl_getFromPublicStorage(
|
|
393
479
|
[blockHash]: ACVMField[],
|
|
394
480
|
[contractAddress]: ACVMField[],
|
|
395
481
|
[startStorageSlot]: ACVMField[],
|
|
396
482
|
[numberOfElements]: ACVMField[],
|
|
397
483
|
): Promise<ACVMField[][]> {
|
|
398
|
-
const values = await this.handlerAsUtility().
|
|
484
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(
|
|
399
485
|
BlockHash.fromString(blockHash),
|
|
400
486
|
new AztecAddress(Fr.fromString(contractAddress)),
|
|
401
487
|
Fr.fromString(startStorageSlot),
|
|
@@ -404,7 +490,8 @@ export class Oracle {
|
|
|
404
490
|
return [values.map(toACVMField)];
|
|
405
491
|
}
|
|
406
492
|
|
|
407
|
-
|
|
493
|
+
// eslint-disable-next-line camelcase
|
|
494
|
+
aztec_prv_notifyCreatedContractClassLog(
|
|
408
495
|
[contractAddress]: ACVMField[],
|
|
409
496
|
message: ACVMField[],
|
|
410
497
|
[length]: ACVMField[],
|
|
@@ -413,11 +500,12 @@ export class Oracle {
|
|
|
413
500
|
const logFields = new ContractClassLogFields(message.map(Fr.fromString));
|
|
414
501
|
const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
|
|
415
502
|
|
|
416
|
-
this.handlerAsPrivate().
|
|
503
|
+
this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
|
|
417
504
|
return Promise.resolve([]);
|
|
418
505
|
}
|
|
419
506
|
|
|
420
|
-
|
|
507
|
+
// eslint-disable-next-line camelcase
|
|
508
|
+
async aztec_utl_log(
|
|
421
509
|
level: ACVMField[],
|
|
422
510
|
message: ACVMField[],
|
|
423
511
|
_ignoredFieldsSize: ACVMField[],
|
|
@@ -426,20 +514,21 @@ export class Oracle {
|
|
|
426
514
|
const levelFr = Fr.fromString(level[0]);
|
|
427
515
|
const messageStr = message.map(acvmField => String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
|
|
428
516
|
const fieldsFr = fields.map(Fr.fromString);
|
|
429
|
-
await this.handlerAsMisc().
|
|
517
|
+
await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
|
|
430
518
|
return [];
|
|
431
519
|
}
|
|
432
520
|
|
|
433
521
|
// This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
|
|
434
522
|
// change the name here.
|
|
435
|
-
|
|
523
|
+
// eslint-disable-next-line camelcase
|
|
524
|
+
async aztec_prv_callPrivateFunction(
|
|
436
525
|
[contractAddress]: ACVMField[],
|
|
437
526
|
[functionSelector]: ACVMField[],
|
|
438
527
|
[argsHash]: ACVMField[],
|
|
439
528
|
[sideEffectCounter]: ACVMField[],
|
|
440
529
|
[isStaticCall]: ACVMField[],
|
|
441
530
|
): Promise<ACVMField[][]> {
|
|
442
|
-
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().
|
|
531
|
+
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(
|
|
443
532
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
444
533
|
FunctionSelector.fromField(Fr.fromString(functionSelector)),
|
|
445
534
|
Fr.fromString(argsHash),
|
|
@@ -449,113 +538,165 @@ export class Oracle {
|
|
|
449
538
|
return [[endSideEffectCounter, returnsHash].map(toACVMField)];
|
|
450
539
|
}
|
|
451
540
|
|
|
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
|
-
);
|
|
541
|
+
// eslint-disable-next-line camelcase
|
|
542
|
+
async aztec_prv_assertValidPublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
|
|
543
|
+
await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
|
|
464
544
|
return [];
|
|
465
545
|
}
|
|
466
546
|
|
|
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
|
-
);
|
|
547
|
+
// eslint-disable-next-line camelcase
|
|
548
|
+
async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
|
|
549
|
+
await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
488
550
|
return Promise.resolve([]);
|
|
489
551
|
}
|
|
490
552
|
|
|
491
|
-
|
|
492
|
-
|
|
553
|
+
// eslint-disable-next-line camelcase
|
|
554
|
+
async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
|
|
555
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(
|
|
493
556
|
Fr.fromString(sideEffectCounter).toNumber(),
|
|
494
557
|
);
|
|
495
558
|
return Promise.resolve([toACVMField(isRevertible)]);
|
|
496
559
|
}
|
|
497
560
|
|
|
498
|
-
|
|
499
|
-
|
|
561
|
+
// eslint-disable-next-line camelcase
|
|
562
|
+
async aztec_prv_getNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]> {
|
|
563
|
+
const tag = await this.handlerAsPrivate().getNextAppTagAsSender(
|
|
500
564
|
AztecAddress.fromString(sender),
|
|
501
565
|
AztecAddress.fromString(recipient),
|
|
502
566
|
);
|
|
503
567
|
return [toACVMField(tag.value)];
|
|
504
568
|
}
|
|
505
569
|
|
|
506
|
-
|
|
507
|
-
|
|
570
|
+
// eslint-disable-next-line camelcase
|
|
571
|
+
async aztec_utl_getPendingTaggedLogs(
|
|
572
|
+
[pendingTaggedLogArrayBaseSlot]: ACVMField[],
|
|
573
|
+
[scope]: ACVMField[],
|
|
574
|
+
): Promise<ACVMField[]> {
|
|
575
|
+
await this.handlerAsUtility().getPendingTaggedLogs(
|
|
576
|
+
Fr.fromString(pendingTaggedLogArrayBaseSlot),
|
|
577
|
+
AztecAddress.fromString(scope),
|
|
578
|
+
);
|
|
508
579
|
return [];
|
|
509
580
|
}
|
|
510
581
|
|
|
511
|
-
|
|
582
|
+
// eslint-disable-next-line camelcase
|
|
583
|
+
async aztec_utl_getPendingTaggedLogs_v2([scope]: ACVMField[]): Promise<ACVMField[]> {
|
|
584
|
+
const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(AztecAddress.fromString(scope));
|
|
585
|
+
return [toACVMField(slot)];
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// eslint-disable-next-line camelcase
|
|
589
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
512
590
|
[contractAddress]: ACVMField[],
|
|
513
591
|
[noteValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
514
592
|
[eventValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
593
|
+
[maxNotePackedLen]: ACVMField[],
|
|
594
|
+
[maxEventSerializedLen]: ACVMField[],
|
|
595
|
+
[scope]: ACVMField[],
|
|
515
596
|
): Promise<ACVMField[]> {
|
|
516
|
-
await this.handlerAsUtility().
|
|
597
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
517
598
|
AztecAddress.fromString(contractAddress),
|
|
518
599
|
Fr.fromString(noteValidationRequestsArrayBaseSlot),
|
|
519
600
|
Fr.fromString(eventValidationRequestsArrayBaseSlot),
|
|
601
|
+
Fr.fromString(maxNotePackedLen).toNumber(),
|
|
602
|
+
Fr.fromString(maxEventSerializedLen).toNumber(),
|
|
603
|
+
AztecAddress.fromString(scope),
|
|
520
604
|
);
|
|
521
605
|
|
|
522
606
|
return [];
|
|
523
607
|
}
|
|
524
608
|
|
|
525
|
-
|
|
609
|
+
// eslint-disable-next-line camelcase
|
|
610
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2(
|
|
611
|
+
[noteValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
612
|
+
[eventValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
613
|
+
[maxNotePackedLen]: ACVMField[],
|
|
614
|
+
[maxEventSerializedLen]: ACVMField[],
|
|
615
|
+
[scope]: ACVMField[],
|
|
616
|
+
): Promise<ACVMField[]> {
|
|
617
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(
|
|
618
|
+
Fr.fromString(noteValidationRequestsArrayBaseSlot),
|
|
619
|
+
Fr.fromString(eventValidationRequestsArrayBaseSlot),
|
|
620
|
+
Fr.fromString(maxNotePackedLen).toNumber(),
|
|
621
|
+
Fr.fromString(maxEventSerializedLen).toNumber(),
|
|
622
|
+
AztecAddress.fromString(scope),
|
|
623
|
+
);
|
|
624
|
+
return [];
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// eslint-disable-next-line camelcase
|
|
628
|
+
async aztec_utl_getLogsByTag(
|
|
526
629
|
[contractAddress]: ACVMField[],
|
|
527
630
|
[logRetrievalRequestsArrayBaseSlot]: ACVMField[],
|
|
528
631
|
[logRetrievalResponsesArrayBaseSlot]: ACVMField[],
|
|
632
|
+
[scope]: ACVMField[],
|
|
529
633
|
): Promise<ACVMField[]> {
|
|
530
|
-
await this.handlerAsUtility().
|
|
634
|
+
await this.handlerAsUtility().getLogsByTag(
|
|
531
635
|
AztecAddress.fromString(contractAddress),
|
|
532
636
|
Fr.fromString(logRetrievalRequestsArrayBaseSlot),
|
|
533
637
|
Fr.fromString(logRetrievalResponsesArrayBaseSlot),
|
|
638
|
+
AztecAddress.fromString(scope),
|
|
534
639
|
);
|
|
535
640
|
return [];
|
|
536
641
|
}
|
|
537
642
|
|
|
538
|
-
|
|
643
|
+
// eslint-disable-next-line camelcase
|
|
644
|
+
async aztec_utl_getMessageContextsByTxHash(
|
|
645
|
+
[contractAddress]: ACVMField[],
|
|
646
|
+
[messageContextRequestsArrayBaseSlot]: ACVMField[],
|
|
647
|
+
[messageContextResponsesArrayBaseSlot]: ACVMField[],
|
|
648
|
+
[scope]: ACVMField[],
|
|
649
|
+
): Promise<ACVMField[]> {
|
|
650
|
+
await this.handlerAsUtility().getMessageContextsByTxHash(
|
|
651
|
+
AztecAddress.fromString(contractAddress),
|
|
652
|
+
Fr.fromString(messageContextRequestsArrayBaseSlot),
|
|
653
|
+
Fr.fromString(messageContextResponsesArrayBaseSlot),
|
|
654
|
+
AztecAddress.fromString(scope),
|
|
655
|
+
);
|
|
656
|
+
return [];
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// eslint-disable-next-line camelcase
|
|
660
|
+
async aztec_utl_getLogsByTag_v2([requestArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
|
|
661
|
+
const responseSlot = await this.handlerAsUtility().getLogsByTagV2(Fr.fromString(requestArrayBaseSlot));
|
|
662
|
+
return [toACVMField(responseSlot)];
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// eslint-disable-next-line camelcase
|
|
666
|
+
async aztec_utl_getMessageContextsByTxHash_v2([requestArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
|
|
667
|
+
const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(
|
|
668
|
+
Fr.fromString(requestArrayBaseSlot),
|
|
669
|
+
);
|
|
670
|
+
return [toACVMField(responseSlot)];
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// eslint-disable-next-line camelcase
|
|
674
|
+
aztec_utl_setCapsule(
|
|
539
675
|
[contractAddress]: ACVMField[],
|
|
540
676
|
[slot]: ACVMField[],
|
|
541
677
|
capsule: ACVMField[],
|
|
678
|
+
[scope]: ACVMField[],
|
|
542
679
|
): Promise<ACVMField[]> {
|
|
543
|
-
|
|
680
|
+
this.handlerAsUtility().setCapsule(
|
|
544
681
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
545
682
|
Fr.fromString(slot),
|
|
546
683
|
capsule.map(Fr.fromString),
|
|
684
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
547
685
|
);
|
|
548
|
-
return [];
|
|
686
|
+
return Promise.resolve([]);
|
|
549
687
|
}
|
|
550
688
|
|
|
551
|
-
|
|
689
|
+
// eslint-disable-next-line camelcase
|
|
690
|
+
async aztec_utl_getCapsule(
|
|
552
691
|
[contractAddress]: ACVMField[],
|
|
553
692
|
[slot]: ACVMField[],
|
|
554
693
|
[tSize]: ACVMField[],
|
|
694
|
+
[scope]: ACVMField[],
|
|
555
695
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
556
|
-
const values = await this.handlerAsUtility().
|
|
696
|
+
const values = await this.handlerAsUtility().getCapsule(
|
|
557
697
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
558
698
|
Fr.fromString(slot),
|
|
699
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
559
700
|
);
|
|
560
701
|
|
|
561
702
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
@@ -569,30 +710,86 @@ export class Oracle {
|
|
|
569
710
|
}
|
|
570
711
|
}
|
|
571
712
|
|
|
572
|
-
|
|
573
|
-
|
|
713
|
+
// eslint-disable-next-line camelcase
|
|
714
|
+
aztec_utl_deleteCapsule(
|
|
715
|
+
[contractAddress]: ACVMField[],
|
|
716
|
+
[slot]: ACVMField[],
|
|
717
|
+
[scope]: ACVMField[],
|
|
718
|
+
): Promise<ACVMField[]> {
|
|
719
|
+
this.handlerAsUtility().deleteCapsule(
|
|
574
720
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
575
721
|
Fr.fromString(slot),
|
|
722
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
576
723
|
);
|
|
577
|
-
return [];
|
|
724
|
+
return Promise.resolve([]);
|
|
578
725
|
}
|
|
579
726
|
|
|
580
|
-
|
|
727
|
+
// eslint-disable-next-line camelcase
|
|
728
|
+
async aztec_utl_copyCapsule(
|
|
581
729
|
[contractAddress]: ACVMField[],
|
|
582
730
|
[srcSlot]: ACVMField[],
|
|
583
731
|
[dstSlot]: ACVMField[],
|
|
584
732
|
[numEntries]: ACVMField[],
|
|
733
|
+
[scope]: ACVMField[],
|
|
585
734
|
): Promise<ACVMField[]> {
|
|
586
|
-
await this.handlerAsUtility().
|
|
735
|
+
await this.handlerAsUtility().copyCapsule(
|
|
587
736
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
588
737
|
Fr.fromString(srcSlot),
|
|
589
738
|
Fr.fromString(dstSlot),
|
|
590
739
|
Fr.fromString(numEntries).toNumber(),
|
|
740
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
591
741
|
);
|
|
592
742
|
return [];
|
|
593
743
|
}
|
|
594
744
|
|
|
595
|
-
|
|
745
|
+
// eslint-disable-next-line camelcase
|
|
746
|
+
aztec_utl_pushEphemeral([slot]: ACVMField[], elements: ACVMField[]): Promise<ACVMField[]> {
|
|
747
|
+
const newLen = this.handlerAsUtility().pushEphemeral(Fr.fromString(slot), elements.map(Fr.fromString));
|
|
748
|
+
return Promise.resolve([toACVMField(newLen)]);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// eslint-disable-next-line camelcase
|
|
752
|
+
aztec_utl_popEphemeral([slot]: ACVMField[]): Promise<ACVMField[][]> {
|
|
753
|
+
const element = this.handlerAsUtility().popEphemeral(Fr.fromString(slot));
|
|
754
|
+
return Promise.resolve([element.map(toACVMField)]);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// eslint-disable-next-line camelcase
|
|
758
|
+
aztec_utl_getEphemeral([slot]: ACVMField[], [index]: ACVMField[]): Promise<ACVMField[][]> {
|
|
759
|
+
const element = this.handlerAsUtility().getEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
|
|
760
|
+
return Promise.resolve([element.map(toACVMField)]);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// eslint-disable-next-line camelcase
|
|
764
|
+
aztec_utl_setEphemeral([slot]: ACVMField[], [index]: ACVMField[], elements: ACVMField[]): Promise<ACVMField[]> {
|
|
765
|
+
this.handlerAsUtility().setEphemeral(
|
|
766
|
+
Fr.fromString(slot),
|
|
767
|
+
Fr.fromString(index).toNumber(),
|
|
768
|
+
elements.map(Fr.fromString),
|
|
769
|
+
);
|
|
770
|
+
return Promise.resolve([]);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// eslint-disable-next-line camelcase
|
|
774
|
+
aztec_utl_getEphemeralLen([slot]: ACVMField[]): Promise<ACVMField[]> {
|
|
775
|
+
const len = this.handlerAsUtility().getEphemeralLen(Fr.fromString(slot));
|
|
776
|
+
return Promise.resolve([toACVMField(len)]);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// eslint-disable-next-line camelcase
|
|
780
|
+
aztec_utl_removeEphemeral([slot]: ACVMField[], [index]: ACVMField[]): Promise<ACVMField[]> {
|
|
781
|
+
this.handlerAsUtility().removeEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
|
|
782
|
+
return Promise.resolve([]);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// eslint-disable-next-line camelcase
|
|
786
|
+
aztec_utl_clearEphemeral([slot]: ACVMField[]): Promise<ACVMField[]> {
|
|
787
|
+
this.handlerAsUtility().clearEphemeral(Fr.fromString(slot));
|
|
788
|
+
return Promise.resolve([]);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// eslint-disable-next-line camelcase
|
|
792
|
+
async aztec_utl_decryptAes128(
|
|
596
793
|
ciphertextBVecStorage: ACVMField[],
|
|
597
794
|
[ciphertextLength]: ACVMField[],
|
|
598
795
|
iv: ACVMField[],
|
|
@@ -602,36 +799,63 @@ export class Oracle {
|
|
|
602
799
|
const ivBuffer = fromUintArray(iv, 8);
|
|
603
800
|
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
604
801
|
|
|
605
|
-
|
|
606
|
-
|
|
802
|
+
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
803
|
+
try {
|
|
804
|
+
const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
|
|
805
|
+
const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
|
|
806
|
+
return [toACVMField(1), storage, length];
|
|
807
|
+
} catch {
|
|
808
|
+
const zeroStorage = Array(ciphertextBVecStorage.length).fill(toACVMField(0));
|
|
809
|
+
return [toACVMField(0), zeroStorage, toACVMField(0)];
|
|
810
|
+
}
|
|
607
811
|
}
|
|
608
812
|
|
|
609
|
-
|
|
813
|
+
// eslint-disable-next-line camelcase
|
|
814
|
+
async aztec_utl_getSharedSecret(
|
|
610
815
|
[address]: ACVMField[],
|
|
611
816
|
[ephPKField0]: ACVMField[],
|
|
612
817
|
[ephPKField1]: ACVMField[],
|
|
613
818
|
[ephPKField2]: ACVMField[],
|
|
819
|
+
[contractAddress]: ACVMField[],
|
|
614
820
|
): Promise<ACVMField[]> {
|
|
615
|
-
const secret = await this.handlerAsUtility().
|
|
821
|
+
const secret = await this.handlerAsUtility().getSharedSecret(
|
|
616
822
|
AztecAddress.fromField(Fr.fromString(address)),
|
|
617
823
|
Point.fromFields([ephPKField0, ephPKField1, ephPKField2].map(Fr.fromString)),
|
|
824
|
+
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
825
|
+
);
|
|
826
|
+
return [toACVMField(secret)];
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
// eslint-disable-next-line camelcase
|
|
830
|
+
aztec_utl_setContractSyncCacheInvalid(
|
|
831
|
+
[contractAddress]: ACVMField[],
|
|
832
|
+
scopes: ACVMField[],
|
|
833
|
+
[scopeCount]: ACVMField[],
|
|
834
|
+
): Promise<ACVMField[]> {
|
|
835
|
+
const scopeAddresses = scopes.slice(0, +scopeCount).map(s => AztecAddress.fromField(Fr.fromString(s)));
|
|
836
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(
|
|
837
|
+
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
838
|
+
scopeAddresses,
|
|
618
839
|
);
|
|
619
|
-
return
|
|
840
|
+
return Promise.resolve([]);
|
|
620
841
|
}
|
|
621
842
|
|
|
622
|
-
|
|
623
|
-
|
|
843
|
+
// eslint-disable-next-line camelcase
|
|
844
|
+
async aztec_utl_emitOffchainEffect(data: ACVMField[]) {
|
|
845
|
+
await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
|
|
624
846
|
return [];
|
|
625
847
|
}
|
|
626
848
|
|
|
627
|
-
|
|
628
|
-
|
|
849
|
+
// eslint-disable-next-line camelcase
|
|
850
|
+
async aztec_prv_getSenderForTags(): Promise<ACVMField[]> {
|
|
851
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
629
852
|
// Return [1, address] for Some(address), [0, 0] for None
|
|
630
853
|
return sender ? [toACVMField(1n), toACVMField(sender)] : [toACVMField(0n), toACVMField(0n)];
|
|
631
854
|
}
|
|
632
855
|
|
|
633
|
-
|
|
634
|
-
|
|
856
|
+
// eslint-disable-next-line camelcase
|
|
857
|
+
async aztec_prv_setSenderForTags([senderForTags]: ACVMField[]): Promise<ACVMField[]> {
|
|
858
|
+
await this.handlerAsPrivate().setSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
|
|
635
859
|
return [];
|
|
636
860
|
}
|
|
637
861
|
}
|