@aztec/wallet-sdk 0.0.1-commit.0c875d939 → 0.0.1-commit.0ec55a70b

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.
Files changed (58) hide show
  1. package/dest/base-wallet/base_wallet.d.ts +66 -41
  2. package/dest/base-wallet/base_wallet.d.ts.map +1 -1
  3. package/dest/base-wallet/base_wallet.js +197 -82
  4. package/dest/base-wallet/index.d.ts +2 -2
  5. package/dest/base-wallet/index.d.ts.map +1 -1
  6. package/dest/base-wallet/utils.d.ts +5 -3
  7. package/dest/base-wallet/utils.d.ts.map +1 -1
  8. package/dest/base-wallet/utils.js +9 -4
  9. package/dest/crypto.d.ts +39 -1
  10. package/dest/crypto.d.ts.map +1 -1
  11. package/dest/crypto.js +88 -0
  12. package/dest/extension/provider/extension_wallet.d.ts +4 -6
  13. package/dest/extension/provider/extension_wallet.d.ts.map +1 -1
  14. package/dest/extension/provider/extension_wallet.js +9 -2
  15. package/dest/extension/provider/index.d.ts +2 -2
  16. package/dest/extension/provider/index.d.ts.map +1 -1
  17. package/dest/iframe/handlers/iframe_connection_handler.d.ts +118 -0
  18. package/dest/iframe/handlers/iframe_connection_handler.d.ts.map +1 -0
  19. package/dest/iframe/handlers/iframe_connection_handler.js +228 -0
  20. package/dest/iframe/handlers/index.d.ts +2 -0
  21. package/dest/iframe/handlers/index.d.ts.map +1 -0
  22. package/dest/iframe/handlers/index.js +1 -0
  23. package/dest/iframe/provider/iframe_discovery.d.ts +25 -0
  24. package/dest/iframe/provider/iframe_discovery.d.ts.map +1 -0
  25. package/dest/iframe/provider/iframe_discovery.js +167 -0
  26. package/dest/iframe/provider/iframe_provider.d.ts +65 -0
  27. package/dest/iframe/provider/iframe_provider.d.ts.map +1 -0
  28. package/dest/iframe/provider/iframe_provider.js +257 -0
  29. package/dest/iframe/provider/iframe_wallet.d.ts +68 -0
  30. package/dest/iframe/provider/iframe_wallet.d.ts.map +1 -0
  31. package/dest/iframe/provider/iframe_wallet.js +200 -0
  32. package/dest/iframe/provider/index.d.ts +4 -0
  33. package/dest/iframe/provider/index.d.ts.map +1 -0
  34. package/dest/iframe/provider/index.js +3 -0
  35. package/dest/manager/types.d.ts +6 -5
  36. package/dest/manager/types.d.ts.map +1 -1
  37. package/dest/manager/wallet_manager.d.ts +1 -1
  38. package/dest/manager/wallet_manager.d.ts.map +1 -1
  39. package/dest/manager/wallet_manager.js +48 -18
  40. package/dest/types.d.ts +14 -2
  41. package/dest/types.d.ts.map +1 -1
  42. package/dest/types.js +4 -0
  43. package/package.json +12 -8
  44. package/src/base-wallet/base_wallet.ts +275 -135
  45. package/src/base-wallet/index.ts +6 -1
  46. package/src/base-wallet/utils.ts +14 -4
  47. package/src/crypto.ts +104 -0
  48. package/src/extension/provider/extension_wallet.ts +13 -10
  49. package/src/extension/provider/index.ts +1 -1
  50. package/src/iframe/handlers/iframe_connection_handler.ts +328 -0
  51. package/src/iframe/handlers/index.ts +7 -0
  52. package/src/iframe/provider/iframe_discovery.ts +185 -0
  53. package/src/iframe/provider/iframe_provider.ts +331 -0
  54. package/src/iframe/provider/iframe_wallet.ts +229 -0
  55. package/src/iframe/provider/index.ts +3 -0
  56. package/src/manager/types.ts +5 -4
  57. package/src/manager/wallet_manager.ts +55 -23
  58. package/src/types.ts +13 -0
@@ -1,14 +1,18 @@
1
- import { NO_WAIT } from '@aztec/aztec.js/contracts';
1
+ import { NO_FROM } from '@aztec/aztec.js/account';
2
+ import { NO_WAIT, extractOffchainOutput } from '@aztec/aztec.js/contracts';
2
3
  import { waitForTx } from '@aztec/aztec.js/node';
3
- import { GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
4
+ import { ContractInitializationStatus, TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
4
5
  import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
6
+ import { DefaultEntrypoint } from '@aztec/entrypoints/default';
5
7
  import { Fr } from '@aztec/foundation/curves/bn254';
6
8
  import { createLogger } from '@aztec/foundation/log';
9
+ import { displayDebugLogs } from '@aztec/pxe/client/lazy';
7
10
  import { decodeFromAbi } from '@aztec/stdlib/abi';
11
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
12
  import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
9
13
  import { SimulationError } from '@aztec/stdlib/errors';
10
- import { Gas, GasSettings } from '@aztec/stdlib/gas';
11
- import { siloNullifier } from '@aztec/stdlib/hash';
14
+ import { Gas, GasFees, GasSettings, ManaUsageEstimate } from '@aztec/stdlib/gas';
15
+ import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier } from '@aztec/stdlib/hash';
12
16
  import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
13
17
  import { inspect } from 'util';
14
18
  import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
@@ -20,6 +24,9 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
20
24
  log;
21
25
  minFeePadding;
22
26
  cancellableTransactions;
27
+ // A wallet is instantiated for a particular chain, so chain info never changes during its lifetime.
28
+ // We cache it here because getChainInfo is called frequently (every tx simulation, send, auth wit, etc.).
29
+ nodeInfoPromise;
23
30
  // Protected because we want to force wallets to instantiate their own PXE.
24
31
  constructor(pxe, aztecNode, log = createLogger('wallet-sdk:base_wallet')){
25
32
  this.pxe = pxe;
@@ -28,12 +35,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
28
35
  this.minFeePadding = 0.5;
29
36
  this.cancellableTransactions = false;
30
37
  }
31
- // When `from` is the zero address (e.g. when deploying a new account contract), we return an
32
- // empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
33
- scopesFor(from) {
34
- return from.isZero() ? [] : [
35
- from
38
+ scopesFrom(from, additionalScopes = []) {
39
+ const allScopes = from === NO_FROM ? additionalScopes : [
40
+ from,
41
+ ...additionalScopes
36
42
  ];
43
+ const scopeSet = new Set(allScopes.map((address)=>address.toString()));
44
+ return [
45
+ ...scopeSet
46
+ ].map(AztecAddress.fromString);
47
+ }
48
+ /**
49
+ * Picks the sender address PXE should tag private messages with. Returns `undefined` when there is no signing
50
+ * account (`from === NO_FROM`) and no explicit override; in that case any private log emitted by the tx will fail
51
+ * the contract-side `Sender for tags is not set` assertion unless `set_sender_for_tags` is called first.
52
+ * @param from - Tx sender, or `NO_FROM`.
53
+ * @param sendMessagesAs - Explicit override.
54
+ */ senderForTagsFrom(from, sendMessagesAs) {
55
+ return sendMessagesAs ?? (from === NO_FROM ? undefined : from);
37
56
  }
38
57
  /**
39
58
  * Returns the list of aliased contacts associated with the wallet.
@@ -49,7 +68,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
49
68
  }));
50
69
  }
51
70
  async getChainInfo() {
52
- const { l1ChainId, rollupVersion } = await this.aztecNode.getNodeInfo();
71
+ if (!this.nodeInfoPromise) {
72
+ this.nodeInfoPromise = this.aztecNode.getNodeInfo();
73
+ }
74
+ const { l1ChainId, rollupVersion } = await this.nodeInfoPromise;
53
75
  return {
54
76
  chainId: new Fr(l1ChainId),
55
77
  version: new Fr(rollupVersion)
@@ -57,18 +79,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
57
79
  }
58
80
  async createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions) {
59
81
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
60
- const executionOptions = {
61
- txNonce: Fr.random(),
62
- cancellable: this.cancellableTransactions,
63
- feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
64
- };
65
82
  const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
66
83
  feeExecutionPayload,
67
84
  executionPayload
68
85
  ]) : executionPayload;
69
- const fromAccount = await this.getAccountFromAddress(from);
70
86
  const chainInfo = await this.getChainInfo();
71
- return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
87
+ if (from === NO_FROM) {
88
+ const entrypoint = new DefaultEntrypoint();
89
+ return entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
90
+ } else {
91
+ const fromAccount = await this.getAccountFromAddress(from);
92
+ const executionOptions = {
93
+ txNonce: Fr.random(),
94
+ cancellable: this.cancellableTransactions,
95
+ // If from is an address, feeOptions include the way the account contract should handle the fee payment
96
+ feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
97
+ };
98
+ return fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
99
+ }
72
100
  }
73
101
  async createAuthWit(from, messageHashOrIntent) {
74
102
  const account = await this.getAccountFromAddress(from);
@@ -111,26 +139,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
111
139
  }
112
140
  /**
113
141
  * Completes partial user-provided fee options with wallet defaults.
114
- * @param from - The address where the transaction is being sent from
115
- * @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
116
- * @param gasSettings - User-provided partial gas settings
117
- * @returns - Complete fee options that can be used to create a transaction execution request
118
- */ async completeFeeOptions(from, feePayer, gasSettings) {
119
- const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
142
+ * @param config - Fee completion config.
143
+ */ async completeFeeOptions(config) {
144
+ const { from, feePayer, gasSettings, forEstimation, congestionEstimate } = config;
145
+ const maxFeesPerGas = gasSettings?.maxFeesPerGas ?? (await this.getMinFees(congestionEstimate)).mul(1 + this.minFeePadding);
120
146
  let accountFeePaymentMethodOptions;
121
- // The transaction does not include a fee payment method, so we set the flag
122
- // for the account to use its fee juice balance
123
- if (!feePayer) {
124
- accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
125
- } else {
126
- // The transaction includes fee payment method, so we check if we are the fee payer for it
127
- // (this can only happen if the embedded payment method is FeeJuiceWithClaim)
128
- accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
147
+ // If from is an address, we need to determine the appropriate fee payment method options for the
148
+ // account contract entrypoint to use
149
+ if (from !== NO_FROM) {
150
+ if (!feePayer) {
151
+ // The transaction does not include a fee payment method, so we set the flag
152
+ // for the account to use its fee juice balance
153
+ accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE;
154
+ } else {
155
+ // The transaction includes fee payment method, so we check if we are the fee payer for it
156
+ // (this can only happen if the embedded payment method is FeeJuiceWithClaim)
157
+ accountFeePaymentMethodOptions = from.equals(feePayer) ? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM : AccountFeePaymentMethodOptions.EXTERNAL;
158
+ }
129
159
  }
130
- const fullGasSettings = GasSettings.default({
131
- ...gasSettings,
132
- maxFeesPerGas
133
- });
160
+ const gasSettingsOverrides = {
161
+ gasLimits: gasSettings?.gasLimits ? Gas.from(gasSettings.gasLimits) : undefined,
162
+ teardownGasLimits: gasSettings?.teardownGasLimits ? Gas.from(gasSettings.teardownGasLimits) : undefined,
163
+ maxFeesPerGas,
164
+ maxPriorityFeesPerGas: gasSettings?.maxPriorityFeesPerGas ?? GasFees.empty()
165
+ };
166
+ // When estimating gas (simulation), use high limits so the simulation doesn't run out of gas.
167
+ // When sending for real, use protocol max limits that the network will actually accept.
168
+ const fullGasSettings = forEstimation ? GasSettings.forEstimation(gasSettingsOverrides) : GasSettings.fallback(gasSettingsOverrides);
134
169
  this.log.debug(`Using L2 gas settings`, fullGasSettings);
135
170
  return {
136
171
  gasSettings: fullGasSettings,
@@ -139,22 +174,24 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
139
174
  };
140
175
  }
141
176
  /**
142
- * Completes partial user-provided fee options with unreasonably high gas limits
143
- * for gas estimation. Uses the same logic as completeFeeOptions but sets high limits
144
- * to avoid running out of gas during estimation.
145
- * @param from - The address where the transaction is being sent from
146
- * @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
147
- * @param gasSettings - User-provided partial gas settings
148
- */ async completeFeeOptionsForEstimation(from, feePayer, gasSettings) {
149
- const defaultFeeOptions = await this.completeFeeOptions(from, feePayer, gasSettings);
150
- const { gasSettings: { maxFeesPerGas, maxPriorityFeesPerGas } } = defaultFeeOptions;
151
- // Use unrealistically high gas limits for estimation to avoid running out of gas.
152
- // They will be tuned down after the simulation.
153
- const gasSettingsForEstimation = new GasSettings(new Gas(GAS_ESTIMATION_DA_GAS_LIMIT, GAS_ESTIMATION_L2_GAS_LIMIT), new Gas(GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT, GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT), maxFeesPerGas, maxPriorityFeesPerGas);
154
- return {
155
- ...defaultFeeOptions,
156
- gasSettings: gasSettingsForEstimation
157
- };
177
+ * Returns the worst-case min fee across predicted future slots.
178
+ * Falls back to getCurrentMinFees if the node doesn't support getPredictedMinFees.
179
+ * @param estimate - The mana usage estimate to use for fee prediction. Defaults to Limit for conservative estimation.
180
+ */ async getMinFees(estimate = ManaUsageEstimate.Limit) {
181
+ try {
182
+ const predicted = await this.aztecNode.getPredictedMinFees(estimate);
183
+ if (predicted.length === 0) {
184
+ return this.aztecNode.getCurrentMinFees();
185
+ }
186
+ return predicted.reduce((worst, fees)=>fees.feePerL2Gas > worst.feePerL2Gas ? fees : worst);
187
+ } catch (err) {
188
+ // Fallback for old nodes that don't support getPredictedMinFees.
189
+ // Only fall back on method-not-found errors (JSON-RPC code -32601); rethrow others.
190
+ if (err?.cause?.code === -32601 || err?.message?.includes('Method not found')) {
191
+ return this.aztecNode.getCurrentMinFees();
192
+ }
193
+ throw err;
194
+ }
158
195
  }
159
196
  registerSender(address, _alias = '') {
160
197
  return this.pxe.registerSender(address);
@@ -194,19 +231,30 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
194
231
  /**
195
232
  * Simulates calls through the standard PXE path (account entrypoint).
196
233
  * @param executionPayload - The execution payload to simulate.
197
- * @param from - The sender address.
198
- * @param feeOptions - Fee options for the transaction.
199
- * @param skipTxValidation - Whether to skip tx validation.
200
- * @param skipFeeEnforcement - Whether to skip fee enforcement.
201
- * @param scopes - The scopes to use for the simulation.
202
- */ async simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement) {
203
- const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions);
204
- return this.pxe.simulateTx(txRequest, {
234
+ * @param opts - Simulation options.
235
+ */ async simulateViaEntrypoint(executionPayload, opts) {
236
+ const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, opts.feeOptions);
237
+ const result = await this.pxe.simulateTx(txRequest, {
205
238
  simulatePublic: true,
206
- skipTxValidation,
207
- skipFeeEnforcement,
208
- scopes
239
+ skipTxValidation: opts.skipTxValidation,
240
+ skipFeeEnforcement: opts.skipFeeEnforcement,
241
+ scopes: this.scopesFrom(opts.from, opts.additionalScopes),
242
+ senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs)
209
243
  });
244
+ const appCallOffset = await this.computeAppCallOffset(opts.from, opts.feeOptions);
245
+ return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
246
+ }
247
+ /**
248
+ * Computes the index where the app's calls begin in the flattened array of calls (0 = entrypoint/root, 1..N = fee
249
+ * calls, N+1 = app).
250
+ * @param from - The sender address, or NO_FROM for the default entrypoint.
251
+ * @param feeOptions - Fee options containing the wallet fee payment method.
252
+ */ async computeAppCallOffset(from, feeOptions) {
253
+ if (from === NO_FROM) {
254
+ return 0;
255
+ }
256
+ const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
257
+ return (feeExecutionPayload?.calls.length ?? 0) + 1; // +1 for entrypoint
210
258
  }
211
259
  /**
212
260
  * Simulates a transaction, optimizing leading public static calls by running them directly
@@ -216,7 +264,13 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
216
264
  * @param opts - Simulation options (from address, fee settings, etc.).
217
265
  * @returns The merged simulation result.
218
266
  */ async simulateTx(executionPayload, opts) {
219
- const feeOptions = opts.fee?.estimateGas ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings) : await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
267
+ const feeOptions = await this.completeFeeOptions({
268
+ from: opts.from,
269
+ feePayer: executionPayload.feePayer,
270
+ gasSettings: opts.fee?.gasSettings,
271
+ forEstimation: true,
272
+ congestionEstimate: opts.fee?.congestionEstimate
273
+ });
220
274
  const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
221
275
  const remainingPayload = {
222
276
  ...executionPayload,
@@ -229,27 +283,50 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
229
283
  try {
230
284
  blockHeader = await this.pxe.getSyncedBlockHeader();
231
285
  } catch {
232
- blockHeader = await this.aztecNode.getBlockHeader();
286
+ blockHeader = await this.aztecNode.getBlockHeader('latest');
233
287
  }
288
+ const simulationOrigin = opts.from === NO_FROM ? AztecAddress.ZERO : opts.from;
234
289
  const [optimizedResults, normalResult] = await Promise.all([
235
- optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, opts.from, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true) : Promise.resolve([]),
236
- remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, opts.from, feeOptions, this.scopesFor(opts.from), opts.skipTxValidation, opts.skipFeeEnforcement ?? true) : Promise.resolve(null)
290
+ optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, simulationOrigin, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true, this.getContractName.bind(this)) : Promise.resolve([]),
291
+ remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, {
292
+ from: opts.from,
293
+ feeOptions,
294
+ additionalScopes: opts.additionalScopes,
295
+ skipTxValidation: opts.skipTxValidation,
296
+ skipFeeEnforcement: opts.skipFeeEnforcement ?? true,
297
+ sendMessagesAs: opts.sendMessagesAs
298
+ }) : Promise.resolve(null)
237
299
  ]);
238
300
  return buildMergedSimulationResult(optimizedResults, normalResult);
239
301
  }
240
302
  async profileTx(executionPayload, opts) {
241
- const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
303
+ const feeOptions = await this.completeFeeOptions({
304
+ from: opts.from,
305
+ feePayer: executionPayload.feePayer,
306
+ gasSettings: opts.fee?.gasSettings,
307
+ congestionEstimate: opts.fee?.congestionEstimate
308
+ });
242
309
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
243
310
  return this.pxe.profileTx(txRequest, {
244
311
  profileMode: opts.profileMode,
245
312
  skipProofGeneration: opts.skipProofGeneration ?? true,
246
- scopes: this.scopesFor(opts.from)
313
+ scopes: this.scopesFrom(opts.from, opts.additionalScopes),
314
+ senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs)
247
315
  });
248
316
  }
249
317
  async sendTx(executionPayload, opts) {
250
- const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
318
+ const feeOptions = await this.completeFeeOptions({
319
+ from: opts.from,
320
+ feePayer: executionPayload.feePayer,
321
+ gasSettings: opts.fee?.gasSettings,
322
+ congestionEstimate: opts.fee?.congestionEstimate
323
+ });
251
324
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
252
- const provenTx = await this.pxe.proveTx(txRequest, this.scopesFor(opts.from));
325
+ const provenTx = await this.pxe.proveTx(txRequest, {
326
+ scopes: this.scopesFrom(opts.from, opts.additionalScopes),
327
+ senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs)
328
+ });
329
+ const offchainOutput = extractOffchainOutput(provenTx.getOffchainEffects(), provenTx.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp);
253
330
  const tx = await provenTx.toTx();
254
331
  const txHash = tx.getTxHash();
255
332
  if (await this.aztecNode.getTxEffect(txHash)) {
@@ -262,11 +339,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
262
339
  this.log.info(`Sent transaction ${txHash}`);
263
340
  // If wait is NO_WAIT, return txHash immediately
264
341
  if (opts.wait === NO_WAIT) {
265
- return txHash;
342
+ return {
343
+ txHash,
344
+ ...offchainOutput
345
+ };
266
346
  }
267
347
  // Otherwise, wait for the full receipt (default behavior on wait: undefined)
268
348
  const waitOpts = typeof opts.wait === 'object' ? opts.wait : undefined;
269
- return await waitForTx(this.aztecNode, txHash, waitOpts);
349
+ const receipt = await waitForTx(this.aztecNode, txHash, waitOpts);
350
+ // Display debug logs from public execution if present (served in test mode only)
351
+ if (receipt.debugLogs?.length) {
352
+ await displayDebugLogs(receipt.debugLogs, this.getContractName.bind(this));
353
+ }
354
+ return {
355
+ receipt,
356
+ ...offchainOutput
357
+ };
358
+ }
359
+ /**
360
+ * Resolves a contract address to a human-readable name via PXE, if available.
361
+ * @param address - The contract address to resolve.
362
+ */ async getContractName(address) {
363
+ const instance = await this.pxe.getContractInstance(address);
364
+ if (!instance) {
365
+ return undefined;
366
+ }
367
+ const artifact = await this.pxe.getContractArtifact(instance.currentContractClassId);
368
+ return artifact?.name;
270
369
  }
271
370
  contextualizeError(err, ...context) {
272
371
  let contextStr = '';
@@ -281,12 +380,10 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
281
380
  }
282
381
  return err;
283
382
  }
284
- simulateUtility(call, opts) {
285
- return this.pxe.simulateUtility(call, {
383
+ executeUtility(call, opts) {
384
+ return this.pxe.executeUtility(call, {
286
385
  authwits: opts.authWitnesses,
287
- scopes: [
288
- opts.scope
289
- ]
386
+ scopes: opts.scopes
290
387
  });
291
388
  }
292
389
  async getPrivateEvents(eventDef, eventFilter) {
@@ -305,15 +402,33 @@ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simul
305
402
  });
306
403
  return decodedEvents;
307
404
  }
308
- async getContractMetadata(address) {
405
+ /**
406
+ * Returns metadata about a contract, including whether it has been initialized, published, and updated.
407
+ * @param address - The contract address to query.
408
+ */ async getContractMetadata(address) {
309
409
  const instance = await this.pxe.getContractInstance(address);
310
- const initNullifier = await siloNullifier(address, address.toField());
311
- const publiclyRegisteredContract = await this.aztecNode.getContract(address);
312
- const initNullifierMembershipWitness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
410
+ const publiclyRegisteredContractPromise = this.aztecNode.getContract(address);
411
+ let initializationStatus;
412
+ if (instance) {
413
+ // We have the instance, so we can compute the private initialization nullifier (which includes init_hash and is
414
+ // emitted by both private and public initializers) and get a definitive INITIALIZED/UNINITIALIZED answer.
415
+ const initNullifier = await computeSiloedPrivateInitializationNullifier(address, instance.initializationHash);
416
+ const witness = await this.aztecNode.getNullifierMembershipWitness('latest', initNullifier);
417
+ initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNINITIALIZED;
418
+ } else {
419
+ // Without the instance we lack the init_hash needed for the private nullifier. We fall back to checking the
420
+ // public initialization nullifier (computed from address alone). Not all contracts emit it (only those with
421
+ // public functions that require initialization checks), so its absence doesn't mean the contract is
422
+ // uninitialized.
423
+ const publicNullifier = await computeSiloedPublicInitializationNullifier(address);
424
+ const witness = await this.aztecNode.getNullifierMembershipWitness('latest', publicNullifier);
425
+ initializationStatus = witness ? ContractInitializationStatus.INITIALIZED : ContractInitializationStatus.UNKNOWN;
426
+ }
427
+ const publiclyRegisteredContract = await publiclyRegisteredContractPromise;
313
428
  const isContractUpdated = publiclyRegisteredContract && !publiclyRegisteredContract.currentContractClassId.equals(publiclyRegisteredContract.originalContractClassId);
314
429
  return {
315
430
  instance: instance ?? undefined,
316
- isContractInitialized: !!initNullifierMembershipWitness,
431
+ initializationStatus,
317
432
  isContractPublished: !!publiclyRegisteredContract,
318
433
  isContractUpdated: !!isContractUpdated,
319
434
  updatedContractClassId: isContractUpdated ? publiclyRegisteredContract.currentContractClassId : undefined
@@ -1,3 +1,3 @@
1
- export { BaseWallet, type FeeOptions } from './base_wallet.js';
1
+ export { BaseWallet, type CompleteFeeOptionsConfig, type FeeOptions, type SimulateViaEntrypointOptions, } from './base_wallet.js';
2
2
  export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLEtBQUssVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDL0QsT0FBTyxFQUFFLGVBQWUsRUFBRSwyQkFBMkIsRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLFlBQVksQ0FBQyJ9
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsVUFBVSxFQUNWLEtBQUssd0JBQXdCLEVBQzdCLEtBQUssVUFBVSxFQUNmLEtBQUssNEJBQTRCLEdBQ2xDLE1BQU0sa0JBQWtCLENBQUM7QUFDMUIsT0FBTyxFQUFFLGVBQWUsRUFBRSwyQkFBMkIsRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLFlBQVksQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EACf,KAAK,4BAA4B,GAClC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import type { AztecNode } from '@aztec/aztec.js/node';
2
+ import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
2
3
  import type { ChainInfo } from '@aztec/entrypoints/interfaces';
4
+ import type { ContractNameResolver } from '@aztec/pxe/client/lazy';
3
5
  import { type FunctionCall } from '@aztec/stdlib/abi';
4
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
7
  import type { GasSettings } from '@aztec/stdlib/gas';
@@ -33,7 +35,7 @@ export declare function extractOptimizablePublicStaticCalls(payload: ExecutionPa
33
35
  * @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
34
36
  * @returns Array of TxSimulationResult, one per batch.
35
37
  */
36
- export declare function simulateViaNode(node: AztecNode, publicStaticCalls: FunctionCall[], from: AztecAddress, chainInfo: ChainInfo, gasSettings: GasSettings, blockHeader: BlockHeader, skipFeeEnforcement?: boolean): Promise<TxSimulationResult[]>;
38
+ export declare function simulateViaNode(node: AztecNode, publicStaticCalls: FunctionCall[], from: AztecAddress, chainInfo: ChainInfo, gasSettings: GasSettings, blockHeader: BlockHeader, skipFeeEnforcement: boolean | undefined, getContractName: ContractNameResolver): Promise<TxSimulationResult[]>;
37
39
  /**
38
40
  * Merges simulation results from the optimized (public static) and normal paths.
39
41
  * Since optimized calls are always a leading prefix, return values are simply
@@ -44,5 +46,5 @@ export declare function simulateViaNode(node: AztecNode, publicStaticCalls: Func
44
46
  * @param normalResult - Result from normal simulation (null if all calls were optimized).
45
47
  * @returns A single TxSimulationResult with return values in original call order.
46
48
  */
47
- export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalResult: TxSimulationResult | null): TxSimulationResult;
48
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUV0RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUsvRCxPQUFPLEVBQUUsS0FBSyxZQUFZLEVBQW9CLE1BQU0sbUJBQW1CLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFRckQsT0FBTyxFQUNMLEtBQUssV0FBVyxFQUNoQixLQUFLLGdCQUFnQixFQU9yQixrQkFBa0IsRUFDbkIsTUFBTSxrQkFBa0IsQ0FBQztBQUUxQjs7Ozs7Ozs7O0dBU0c7QUFDSCx3QkFBZ0IsbUNBQW1DLENBQUMsT0FBTyxFQUFFLGdCQUFnQixHQUFHO0lBQzlFLHVFQUF1RTtJQUN2RSxnQkFBZ0IsRUFBRSxZQUFZLEVBQUUsQ0FBQztJQUNqQywyQkFBMkI7SUFDM0IsY0FBYyxFQUFFLFlBQVksRUFBRSxDQUFDO0NBQ2hDLENBT0E7QUFtR0Q7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsd0JBQXNCLGVBQWUsQ0FDbkMsSUFBSSxFQUFFLFNBQVMsRUFDZixpQkFBaUIsRUFBRSxZQUFZLEVBQUUsRUFDakMsSUFBSSxFQUFFLFlBQVksRUFDbEIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsV0FBVyxFQUFFLFdBQVcsRUFDeEIsV0FBVyxFQUFFLFdBQVcsRUFDeEIsa0JBQWtCLEdBQUUsT0FBYyxHQUNqQyxPQUFPLENBQUMsa0JBQWtCLEVBQUUsQ0FBQyxDQXVCL0I7QUFFRDs7Ozs7Ozs7O0dBU0c7QUFDSCx3QkFBZ0IsMkJBQTJCLENBQ3pDLGdCQUFnQixFQUFFLGtCQUFrQixFQUFFLEVBQ3RDLFlBQVksRUFBRSxrQkFBa0IsR0FBRyxJQUFJLEdBQ3RDLGtCQUFrQixDQW9CcEIifQ==
49
+ export declare function buildMergedSimulationResult(optimizedResults: TxSimulationResult[], normalResult: TxSimulationResultWithAppOffset | null): TxSimulationResultWithAppOffset;
50
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsK0JBQStCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUV6RSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQzt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ZLEVBQUUsK0JBQStCLEdBQUcsSUFBSSxHQUNuRCwrQkFBK0IsQ0FxQmpDIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base-wallet/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAK/D,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQrD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAOrB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,gBAAgB,GAAG;IAC9E,uEAAuE;IACvE,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,2BAA2B;IAC3B,cAAc,EAAE,YAAY,EAAE,CAAC;CAChC,CAOA;AAmGD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,SAAS,EACf,iBAAiB,EAAE,YAAY,EAAE,EACjC,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,kBAAkB,GAAE,OAAc,GACjC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAuB/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,YAAY,EAAE,kBAAkB,GAAG,IAAI,GACtC,kBAAkB,CAoBpB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base-wallet/utils.ts"],"names":[],"mappings":"AAAA,OAA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  import { makeTuple } from '@aztec/foundation/array';
3
4
  import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { displayDebugLogs } from '@aztec/pxe/client/lazy';
4
6
  import { generateSimulatedProvingResult } from '@aztec/pxe/simulator';
5
7
  import { ClaimedLengthArray, CountedPublicCallRequest, PrivateCircuitPublicInputs, PublicCallRequest } from '@aztec/stdlib/kernel';
6
8
  import { ChonkProof } from '@aztec/stdlib/proofs';
@@ -34,7 +36,7 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
34
36
  * @param blockHeader - Block header to use as anchor.
35
37
  * @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
36
38
  * @returns TxSimulationResult with public return values.
37
- */ async function simulateBatchViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement) {
39
+ */ async function simulateBatchViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement, getContractName) {
38
40
  const txContext = new TxContext(chainInfo.chainId, chainInfo.version, gasSettings);
39
41
  const publicFunctionCalldata = [];
40
42
  for (const call of publicStaticCalls){
@@ -77,6 +79,8 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
77
79
  if (publicOutput.revertReason) {
78
80
  throw publicOutput.revertReason;
79
81
  }
82
+ // Display debug logs from the public simulation.
83
+ await displayDebugLogs(publicOutput.debugLogs, getContractName);
80
84
  return new TxSimulationResult(privateResult, provingResult.publicInputs, publicOutput, undefined);
81
85
  }
82
86
  /**
@@ -91,14 +95,14 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
91
95
  * @param blockHeader - Block header to use as anchor.
92
96
  * @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
93
97
  * @returns Array of TxSimulationResult, one per batch.
94
- */ export async function simulateViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement = true) {
98
+ */ export async function simulateViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement = true, getContractName) {
95
99
  const batches = [];
96
100
  for(let i = 0; i < publicStaticCalls.length; i += MAX_ENQUEUED_CALLS_PER_CALL){
97
101
  batches.push(publicStaticCalls.slice(i, i + MAX_ENQUEUED_CALLS_PER_CALL));
98
102
  }
99
103
  const results = [];
100
104
  for (const batch of batches){
101
- const result = await simulateBatchViaNode(node, batch, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement);
105
+ const result = await simulateBatchViaNode(node, batch, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement, getContractName);
102
106
  results.push(result);
103
107
  }
104
108
  return results;
@@ -124,5 +128,6 @@ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, T
124
128
  ...baseResult.publicOutput,
125
129
  publicReturnValues: allReturnValues
126
130
  } : undefined;
127
- return new TxSimulationResult(baseResult.privateExecutionResult, baseResult.publicInputs, mergedPublicOutput, normalResult?.stats);
131
+ const merged = new TxSimulationResult(baseResult.privateExecutionResult, baseResult.publicInputs, mergedPublicOutput, normalResult?.stats);
132
+ return TxSimulationResultWithAppOffset.fromResultAndOffset(merged, normalResult?.appCallOffset ?? 0);
128
133
  }
package/dest/crypto.d.ts CHANGED
@@ -189,4 +189,42 @@ export declare const DEFAULT_EMOJI_GRID_SIZE = 9;
189
189
  * ```
190
190
  */
191
191
  export declare function hashToEmoji(hash: string, count?: number): string;
192
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3J5cHRvLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY3J5cHRvLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQThEQTs7OztHQUlHO0FBQ0gsTUFBTSxXQUFXLGlCQUFpQjtJQUNoQyxnREFBZ0Q7SUFDaEQsR0FBRyxFQUFFLE1BQU0sQ0FBQztJQUNaLGtDQUFrQztJQUNsQyxHQUFHLEVBQUUsTUFBTSxDQ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sRUFBRSxhQUFhLEVBQ3pCLGFBQWEsRUFBRSxTQUFTLEVBQ3hCLEtBQUssRUFBRSxPQUFPLEdBQ2IsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQXdEdEI7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FpQkc7QUFDSCx3QkFBc0IsT0FBTyxDQUFDLEdBQUcsRUFBRSxTQUFTLEVBQUUsSUFBSSxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FVckY7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FpQkc7QUFDSCx3QkFBc0IsT0FBTyxDQUFDLENBQUMsR0FBRyxPQUFPLEVBQUUsR0FBRyxFQUFFLFNBQVMsRUFBRSxPQUFPLEVBQUUsZ0JBQWdCLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxDQVFoRztBQXdERDs7O0dBR0c7QUFDSCxlQUFPLE1BQU0sdUJBQXVCLElBQUksQ0FBQztBQUV6Qzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBcUJHO0FBQ0gsd0JBQWdCLFdBQVcsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLEtBQUssR0FBRSxNQUFnQyxHQUFHLE1BQU0sQ0FPekYifQ==
192
+ /**
193
+ * Derives an AES-256-GCM key from a passphrase using PBKDF2-SHA256.
194
+ *
195
+ * @param passphrase - The user-provided passphrase or PIN
196
+ * @param salt - Random salt bytes
197
+ * @param iterations - PBKDF2 iteration count (default: 2,000,000)
198
+ * @returns An AES-256-GCM CryptoKey
199
+ */
200
+ export declare function deriveKeyFromPassphrase(passphrase: string, salt: Uint8Array, iterations?: number): Promise<CryptoKey>;
201
+ /**
202
+ * Encrypts arbitrary bytes with a passphrase using PBKDF2 + AES-256-GCM.
203
+ *
204
+ * Output layout: `[salt (16)] [iv (12)] [ciphertext (...)]`
205
+ *
206
+ * @param plaintext - Data to encrypt
207
+ * @param passphrase - User passphrase or PIN
208
+ * @param iterations - PBKDF2 iteration count (default: 2,000,000)
209
+ * @returns A Uint8Array containing salt + iv + ciphertext
210
+ */
211
+ export declare function encryptWithPassphrase(plaintext: Uint8Array, passphrase: string, iterations?: number): Promise<Uint8Array>;
212
+ /**
213
+ * Decrypts data produced by {@link encryptWithPassphrase}.
214
+ *
215
+ * @param data - The encrypted blob (salt + iv + ciphertext)
216
+ * @param passphrase - The passphrase used during encryption
217
+ * @param iterations - PBKDF2 iteration count (must match encryption)
218
+ * @returns The decrypted plaintext bytes
219
+ * @throws On wrong passphrase (AES-GCM auth tag mismatch)
220
+ */
221
+ export declare function decryptWithPassphrase(data: Uint8Array, passphrase: string, iterations?: number): Promise<Uint8Array>;
222
+ /**
223
+ * Converts a Uint8Array to a base64 string.
224
+ */
225
+ export declare function uint8ToBase64(bytes: Uint8Array): string;
226
+ /**
227
+ * Converts a base64 string to a Uint8Array.
228
+ */
229
+ export declare function base64ToUint8(b64: string): Uint8Array;
230
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3J5cHRvLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY3J5cHRvLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQThEQTs7OztHQUlHO0FBQ0gsTUFBTSxXQUFXLGlCQUFpQjtJQUNoQyxnREFBZ0Q7SUFDaEQsR0FBRyxFQUFFLE1BQU0sQ0FBQztJQUNaLGtDQUFrQztJQUNsQyxHQUFHLEVBQUUsTUFBTSxDQUFDO0lBQ1osdUNBQXVDO0lBQ3ZDLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDVix1Q0FBdUM7SUFDdkMsQ0FBQyxFQUFFLE1BQU0sQ0FBQztDQUNYO0FBRUQ7Ozs7R0FJRztBQUNILE1BQU0sV0FBVyxnQkFBZ0I7SUFDL0IsdURBQXVEO0lBQ3ZELEVBQUUsRUFBRSxNQUFNLENBQUM7SUFD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