@cloak.dev/sdk 0.2.6-staging.af2dfc0 → 0.2.6-staging.d42dbe0

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/dist/index.d.cts CHANGED
@@ -1547,6 +1547,14 @@ declare class MerkleTree {
1547
1547
  * @param height Tree height (default: 32)
1548
1548
  */
1549
1549
  declare function buildMerkleTree(commitments: bigint[], height?: number): Promise<MerkleTree>;
1550
+ /**
1551
+ * Serializable state of a {@link MerkleFrontier}: the leaf count and, per level, the hash of the
1552
+ * last complete LEFT node still waiting for its right sibling (hex, `""` when that level has none).
1553
+ */
1554
+ interface MerkleFrontierState {
1555
+ nextIndex: number;
1556
+ left: string[];
1557
+ }
1550
1558
 
1551
1559
  /**
1552
1560
  * Error Utilities
@@ -3748,6 +3756,8 @@ interface SubmitTransactToRelayArgs {
3748
3756
  settlementTimeoutMs?: number;
3749
3757
  /** Shorter window used to ask "did it land anyway?" after a terminal relay failure. */
3750
3758
  failureProbeTimeoutMs?: number;
3759
+ /** Stops the wait for the relay's source lease to expire; the chain is still checked after. */
3760
+ signal?: AbortSignal;
3751
3761
  }
3752
3762
  /**
3753
3763
  * POST one logical `/transact` request and REPORT ONLY WHAT THE CHAIN CONFIRMS.
@@ -3776,6 +3786,12 @@ interface SubmitTransactToRelayArgs {
3776
3786
  * captured across attempts, and every terminal failure that could plausibly have been submitted
3777
3787
  * is resolved against chain into a `SettlementVerificationError` that states the outcome and
3778
3788
  * carries the signature.
3789
+ *
3790
+ * WARNING [preflight 0x1020]: this posts an already-built request and does NOT run
3791
+ * `preflightNullifiers`. Notes restored from an untrusted source (the relay's note index can hide a
3792
+ * nullifier, so a spent note can look unspent) must go through `transact` / `partialWithdraw` /
3793
+ * `fullWithdraw` / `swapUtxo`, which run the preflight before proof generation; a caller that
3794
+ * builds its own request must `await preflightNullifiers(inputUtxos, connection, programId)` first.
3779
3795
  */
3780
3796
  declare function submitTransactToRelay(args: SubmitTransactToRelayArgs): Promise<RelaySubmissionResult>;
3781
3797
  declare function transact(params: TransactParams, options: TransactOptions): Promise<TransactResult>;
@@ -3856,8 +3872,10 @@ interface UtxoSwapResult extends TransactResult {
3856
3872
  * `SwapState.sol_amount`, = gross swap amount minus the on-chain swap fee). R_fb is an ordinary
3857
3873
  * leaf of the main pool tree, spent with the ordinary `transact()` path. All values are hex.
3858
3874
  *
3859
- * `publicKey` is the wallet's long-lived UTXO public key (`options.ownerUtxoKeypair`), so R_fb is
3860
- * spent with the wallet's own keypair; the private key is deliberately not repeated here. The
3875
+ * `publicKey` is a PER-SWAP public key, derived from `options.ownerUtxoKeypair`'s private key and
3876
+ * the swap's first input nullifier, so no two swaps from one wallet share it and it is not the
3877
+ * wallet's UTXO public key. Spend R_fb with `deriveSwapRefundKeypair(owner, nullifier)`; the
3878
+ * private key is deliberately not repeated here and `nk` cannot produce it. The
3861
3879
  * blinding is derived from the wallet's `nk` and the swap's public first input nullifier
3862
3880
  * (`derivedFromNk` is always true), so `discoverSwapRefunds` finds the leaf again from key
3863
3881
  * material if this object is lost.
@@ -4642,26 +4660,34 @@ declare function matchChangeNote(params: MatchChangeNoteParams): Promise<Recover
4642
4660
  * viewing key and the swap creator's, and found nothing under either.
4643
4661
  *
4644
4662
  * ── The fix, and why it is SDK-only ───────────────────────────────────────────────────────────
4645
- * The refund leaf is owned by the wallet's long-lived UTXO keypair (passed explicitly), and only
4646
- * its BLINDING is derived, as a PRF of the owner's `nk` and the swap's own first input nullifier:
4663
+ * The refund leaf's BLINDING is derived as a PRF of the owner's `nk` and the swap's own first input
4664
+ * nullifier, and its OWNER KEY is derived per swap from the wallet's UTXO private key:
4647
4665
  *
4648
- * blinding = BLAKE3("cloak_swap_refund_v1" || nk || nullifier0 || "blinding") -> field
4649
- * owner = ownerUtxoKeypair (never derived from nk)
4666
+ * blinding = BLAKE3("cloak_swap_refund_v1" || nk || nullifier0 || "blinding") -> field
4667
+ * priv = BLAKE3("cloak_swap_refund_v2" || ownerPrivateKey || nullifier0 || "sk_v2") -> field
4668
+ * pub = derivePublicKey(priv)
4650
4669
  *
4651
- * `nullifier0` is published in the TransactSwap public inputs, so a scanner holding `nk` and the
4652
- * wallet's UTXO public key can replay the blinding for every swap it sees, recompute R_fb and match
4653
- * it against the commitment `CloseSwapState` declared. Spending R_fb needs the owner's private key,
4654
- * which `nk` cannot produce, so the viewing key stays view-only. Every R_fb is distinct because the
4655
- * blinding differs per `nullifier0`.
4670
+ * `nullifier0` is published in the TransactSwap public inputs, so a scanner holding `nk` can replay
4671
+ * the blinding for every swap it sees. `refund_pubkey` and `refund_blinding` are ALSO published, in
4672
+ * plain text, in the TransactSwap instruction data (and in SwapState), so a view-only scanner (nk
4673
+ * plus the owner PUBLIC key) reads the per-swap pubkey from there, checks that the published
4674
+ * blinding equals the nk-derived one, and checks that the commitment matches. Spending R_fb needs
4675
+ * `priv`, which needs the owner's private key: `nk` cannot produce it, so the viewing key stays
4676
+ * view-only, and the owner re-derives the spend key from its own private key plus the nullifier.
4677
+ *
4678
+ * Why not the owner key itself (0.2.6 - 0.2.8)? That shape published the wallet's permanent UTXO
4679
+ * public key as `refund_pubkey` on every swap, so anyone holding a user's receiving key could list
4680
+ * all of that wallet's swaps. A different public key per swap removes the link.
4656
4681
  *
4657
4682
  * This changes NOTHING on chain or in the relay. `refund_pubkey` / `refund_blinding` remain
4658
4683
  * caller-supplied values bound into `computeSwapExtDataHash`; only their provenance changes.
4659
4684
  *
4660
- * ── Legacy refunds ────────────────────────────────────────────────────────────────────────────
4661
- * The first release of this derivation also derived the refund PRIVATE key from `(nk, nullifier0)`.
4662
- * Those refunds are still matched (see {@link deriveLegacySwapRefundAuthorization}) and come back
4663
- * flagged `legacyExposed: true`, because anyone holding `nk` can spend them; an app should migrate
4664
- * them. No API builds a refund in that shape any more.
4685
+ * ── Three refund shapes, all still recognised ─────────────────────────────────────────────────
4686
+ * "per-swap" (0.2.9+) owner = per-swap key from the owner private key (above)
4687
+ * "owner" (0.2.6 - 0.2.8) owner = the wallet's permanent UTXO keypair; linkable across swaps
4688
+ * "legacy-nk" (< 0.2.6) owner key AND blinding from nk; `legacyExposed: true`, because anyone
4689
+ * holding `nk` can spend it. An app should migrate those refunds.
4690
+ * No API builds a refund in the last two shapes any more.
4665
4691
  *
4666
4692
  * ── Guardrails preserved ──────────────────────────────────────────────────────────────────────
4667
4693
  * [H-04 / DD-01] the authorization is rejected unless publicKey and blinding are both non-zero.
@@ -4682,14 +4708,20 @@ interface SwapRefundAuthorization {
4682
4708
  publicKey: bigint;
4683
4709
  blinding: bigint;
4684
4710
  }
4711
+ /** Which key shape owns a refund leaf; see the file header. */
4712
+ type SwapRefundShape = "per-swap" | "owner" | "legacy-nk";
4685
4713
  /** A refund leaf matched back to its owner. */
4686
4714
  interface RecoveredSwapRefund {
4687
4715
  /**
4688
- * The owner keypair. For a current refund this is the `ownerUtxoKeypair` the matcher was given
4689
- * (`privateKey` is `0n` if only the public key was supplied; substitute the wallet's keypair before
4690
- * spending). For a legacy refund it is the nk-derived keypair, complete and spendable.
4716
+ * The key that owns the leaf. `per-swap`: the key derived from the owner private key and the
4717
+ * swap nullifier (`privateKey` is `0n` for a view-only match: the public key is real, but the
4718
+ * spend key needs the owner private key, see {@link deriveSwapRefundKeypair}). `owner`: the
4719
+ * `ownerUtxoKeypair` the matcher was given (`privateKey` `0n` if only the public key was
4720
+ * supplied). `legacy-nk`: the nk-derived keypair, complete and spendable.
4691
4721
  */
4692
4722
  keypair: UtxoKeypair;
4723
+ /** Which of the three shapes matched. */
4724
+ shape: SwapRefundShape;
4693
4725
  blinding: bigint;
4694
4726
  amount: bigint;
4695
4727
  /** R_fb as a field element, identical to the commitment `CloseSwapState` appended. */
@@ -4708,8 +4740,15 @@ interface RecoveredSwapRefund {
4708
4740
  */
4709
4741
  declare function deriveSwapRefundBlinding(viewingKeyNk: Uint8Array, inputNullifier: Uint8Array | bigint): bigint;
4710
4742
  /**
4711
- * The refund authorization `swapUtxo` binds into the swap ext-data hash: the wallet's long-lived
4712
- * UTXO keypair as owner, plus the derived blinding.
4743
+ * The per-swap refund KEYPAIR: a different key for every swap, derived from the owner's private key
4744
+ * and the swap's first input nullifier. `nk` cannot reproduce it. Use this to spend a refund the
4745
+ * swap result reported, or any `per-swap` refund a view-only scan found.
4746
+ */
4747
+ declare function deriveSwapRefundKeypair(ownerUtxoKeypair: UtxoKeypair, inputNullifier: Uint8Array | bigint): Promise<UtxoKeypair>;
4748
+ /**
4749
+ * The refund authorization `swapUtxo` binds into the swap ext-data hash: a per-swap keypair derived
4750
+ * from the wallet's UTXO private key and the swap's first input nullifier, plus the nk-derived
4751
+ * blinding. The public key differs for every swap and differs from the wallet's UTXO public key.
4713
4752
  *
4714
4753
  * `ownerUtxoKeypair` is required and validated. The refund key is never derived from `nk`.
4715
4754
  */
@@ -4736,16 +4775,28 @@ interface MatchSwapRefundLeafParams {
4736
4775
  commitment: bigint | Uint8Array;
4737
4776
  /**
4738
4777
  * The wallet's long-lived UTXO keypair (`privateKey: 0n` is fine for a view-only match). Without
4739
- * it only legacy refunds can be matched.
4778
+ * it only legacy-nk refunds can be matched.
4740
4779
  */
4741
4780
  ownerUtxoKeypair?: UtxoKeypair;
4781
+ /**
4782
+ * `refund_pubkey` as published in the swap's TransactSwap instruction data (bytes 593-624) or its
4783
+ * SwapState. A view-only scanner needs it to match a `per-swap` refund, because it cannot derive
4784
+ * the key. Pass it together with {@link publishedRefundBlinding}.
4785
+ */
4786
+ publishedRefundPubkey?: bigint | Uint8Array;
4787
+ /** `refund_blinding` as published in the same place (bytes 625-656). */
4788
+ publishedRefundBlinding?: bigint | Uint8Array;
4742
4789
  }
4743
4790
  /**
4744
4791
  * Decide whether a public refund leaf belongs to this wallet, and if so return it. Returns `null`
4745
4792
  * for every leaf that is not ours; a scanner runs this against every close it can see.
4746
4793
  *
4747
- * Tries the current shape first (owner = `ownerUtxoKeypair`, blinding from `nk`), then the legacy
4748
- * shape (key and blinding both from `nk`, flagged `legacyExposed`).
4794
+ * Tries, in order: the per-swap shape (published pubkey, or re-derived when the owner private key
4795
+ * is present), the 0.2.6 - 0.2.8 owner-key shape, then the legacy nk shape (`legacyExposed`).
4796
+ * `shape` on the result says which one matched.
4797
+ *
4798
+ * A per-swap match from a view-only scan returns `keypair.privateKey === 0n`; the caller spends it
4799
+ * with {@link deriveSwapRefundKeypair} once it holds the owner private key.
4749
4800
  */
4750
4801
  declare function matchSwapRefundLeaf(params: MatchSwapRefundLeafParams): Promise<RecoveredSwapRefund | null>;
4751
4802
  /** One recovered refund leaf, with the chain coordinates that produced it. */
@@ -4761,9 +4812,11 @@ interface DiscoveredSwapRefund extends RecoveredSwapRefund {
4761
4812
  }
4762
4813
  interface DiscoverSwapRefundsOptions {
4763
4814
  /**
4764
- * The wallet's long-lived UTXO keypair: the owner of every refund leaf built by the current SDK.
4765
- * Required. Pass the real keypair to get spendable results, or `{ privateKey: 0n, publicKey }`
4766
- * for a view-only scan. Legacy (nk-owned) refunds are found either way and flagged
4815
+ * The wallet's long-lived UTXO keypair. Required. Pass the real keypair to get spendable
4816
+ * results (per-swap refunds come back with their derived keypair), or `{ privateKey: 0n,
4817
+ * publicKey }` for a view-only scan: per-swap refunds are then matched from the `refund_pubkey`
4818
+ * published in the swap instruction and come back with `privateKey: 0n` (re-derive it with
4819
+ * `deriveSwapRefundKeypair`). Legacy (nk-owned) refunds are found either way and flagged
4767
4820
  * `legacyExposed`.
4768
4821
  */
4769
4822
  ownerUtxoKeypair: UtxoKeypair;
@@ -4791,7 +4844,7 @@ interface DiscoverSwapRefundsOptions {
4791
4844
  * its owner could not see it under any key they held.
4792
4845
  *
4793
4846
  * FORWARD-LOOKING ONLY. This finds refunds whose blinding was DERIVED from (nk, nullifier0), owned
4794
- * either by the wallet's UTXO keypair (current) or by an nk-derived key (legacy, flagged).
4847
+ * by a per-swap key (0.2.9+), the wallet UTXO key (0.2.6-0.2.8) or an nk-derived key (legacy, flagged).
4795
4848
  * A swap whose refund keypair and blinding were drawn from raw randomness (every swap submitted
4796
4849
  * before that derivation shipped) has no derivation to replay,
4797
4850
  * and no key-only scan can ever recover it. Those secrets existed solely in the caller's in-memory
@@ -5099,6 +5152,459 @@ declare function toComplianceReport(result: ScanResult): ComplianceReport;
5099
5152
  /** Format compliance report as CSV for export. */
5100
5153
  declare function formatComplianceCsv(report: ComplianceReport): string;
5101
5154
 
5155
+ /**
5156
+ * Note Index v1 transport (contract revision 2): the head and the pages.
5157
+ *
5158
+ * Every request goes through `relayFetch`, the origin-allowlisted egress chokepoint
5159
+ * (`relay/endpoint.ts`), so nothing here can reach a host the build is not pinned to.
5160
+ *
5161
+ * ── Privacy rule ──────────────────────────────────────────────────────────────────────────────
5162
+ * No request here carries anything that points at a specific note, commitment, nullifier, wallet,
5163
+ * pool or time window. Pages are addressed by epoch and page number only, and every page is
5164
+ * downloaded. Trees are rebuilt from the pages themselves, so nothing else is ever requested.
5165
+ *
5166
+ * Caching: complete pages are served `immutable` with a strong ETag and the tail with
5167
+ * `max-age=5`, so a browser's HTTP cache makes a refresh cheap without any client-side store.
5168
+ * Nothing here persists an ETag (the contract forbids persisting a tail ETag). Compression is
5169
+ * negotiated by the fetch implementation; the decoded size is capped while streaming.
5170
+ */
5171
+ /** `GET /note-index/v1/head`. */
5172
+ interface NoteIndexHead {
5173
+ format: 1;
5174
+ /** Random id of this index instance; a rebuild or restore gets a new one. */
5175
+ epoch: bigint;
5176
+ pageSize: number;
5177
+ /** Number of published items. */
5178
+ watermark: number;
5179
+ /** Pages with exactly `pageSize` items; they never change. */
5180
+ completePages: number;
5181
+ /** chain_{completePages}, 64 lowercase hex. */
5182
+ chainTip: string;
5183
+ }
5184
+ /** Transport options shared by every note-index request. */
5185
+ interface NoteIndexFetchOptions {
5186
+ signal?: AbortSignal;
5187
+ /** Per-attempt timeout. Default 30 s. */
5188
+ timeoutMs?: number;
5189
+ /** Retries after the first attempt, for network errors, 429 and 5xx. Default 3. */
5190
+ maxRetries?: number;
5191
+ }
5192
+ /** Fetch and validate `GET /note-index/v1/head`. */
5193
+ declare function fetchNoteIndexHead(relayUrl: string, options?: NoteIndexFetchOptions): Promise<NoteIndexHead>;
5194
+ /**
5195
+ * Fetch the raw bytes of `GET /note-index/v1/e/{epoch}/pages/{n}`, with the decoded size bounded
5196
+ * to {@link NOTE_INDEX_MAX_PAGE_BYTES} while streaming. Parse with
5197
+ * `parseNoteIndexPage(bytes, { epoch, page })`.
5198
+ */
5199
+ declare function fetchNoteIndexPage(relayUrl: string, epoch: bigint, page: number, options?: NoteIndexFetchOptions): Promise<Uint8Array>;
5200
+
5201
+ /** Items per page. A page is complete iff it holds exactly this many items. */
5202
+ declare const NOTE_INDEX_PAGE_SIZE = 1024;
5203
+ /** Leaf index of an all-zero (never appended) commitment. */
5204
+ declare const NOTE_INDEX_NO_LEAF = 18446744073709551615n;
5205
+ /** Thrown for every byte sequence that is not a well-formed Note Index v1 page or head. */
5206
+ declare class NoteIndexFormatError extends Error {
5207
+ constructor(message: string);
5208
+ }
5209
+ /** kind 1: one confirmed Cloak Transact / TransactSwap instruction, with its note if any. */
5210
+ interface NoteIndexTxItem {
5211
+ kind: 1;
5212
+ mint: Uint8Array;
5213
+ slot: bigint;
5214
+ blockPos: number;
5215
+ /** 0 Transact, 1 TransactSwap. */
5216
+ ixTag: number;
5217
+ /** Signed public amount from the public inputs (positive for a deposit). */
5218
+ publicAmount: bigint;
5219
+ nullifier0: Uint8Array;
5220
+ nullifier1: Uint8Array;
5221
+ comm0: Uint8Array;
5222
+ /** {@link NOTE_INDEX_NO_LEAF} iff comm0 is all zero. */
5223
+ leaf0: bigint;
5224
+ comm1: Uint8Array;
5225
+ leaf1: bigint;
5226
+ /** 0 none, 1 inline in the instruction data, 2 CLK1 carrier. */
5227
+ noteSource: number;
5228
+ /** The bare chain-note envelope `[version][AES-GCM ct || tag]`; empty when noteSource is 0. */
5229
+ note: Uint8Array;
5230
+ /** The Cloak program transaction. Relay-supplied metadata, not proof of anything. */
5231
+ signature: Uint8Array;
5232
+ }
5233
+ /** kind 2: a CLKD1 recipient-delivery envelope. */
5234
+ interface NoteIndexDeliveryItem {
5235
+ kind: 2;
5236
+ mint: Uint8Array;
5237
+ slot: bigint;
5238
+ /** output_commitment[0] of the source transaction. */
5239
+ commitment: Uint8Array;
5240
+ leaf: bigint;
5241
+ envelope: Uint8Array;
5242
+ signature: Uint8Array;
5243
+ }
5244
+ /** kind 3: an R_fb swap refund leaf appended by CloseSwapState. */
5245
+ interface NoteIndexSwapRefundItem {
5246
+ kind: 3;
5247
+ /** Always WSOL. */
5248
+ mint: Uint8Array;
5249
+ slot: bigint;
5250
+ commitment: Uint8Array;
5251
+ leaf: bigint;
5252
+ amountAfterFee: bigint;
5253
+ /** The swap's first input nullifier (TransactSwap public inputs +104). */
5254
+ nullifier0: Uint8Array;
5255
+ /** The close transaction. */
5256
+ signature: Uint8Array;
5257
+ }
5258
+ type NoteIndexItem = NoteIndexTxItem | NoteIndexDeliveryItem | NoteIndexSwapRefundItem;
5259
+ interface NoteIndexPage {
5260
+ epoch: bigint;
5261
+ page: bigint;
5262
+ firstSeq: bigint;
5263
+ complete: boolean;
5264
+ /** The item count the header declared, unknown kinds included. */
5265
+ count: number;
5266
+ /** chain_page: the hash chain value BEFORE this page. */
5267
+ prevChain: Uint8Array;
5268
+ /** Items of known kinds, in page order. */
5269
+ items: NoteIndexItem[];
5270
+ /** Raw `kind | body_len | body` bytes of each entry of `items`, same order. */
5271
+ rawItems: Uint8Array[];
5272
+ /** Items of unknown kinds, skipped by `body_len`. */
5273
+ skippedUnknown: number;
5274
+ /**
5275
+ * Position in the page (0-based, unknown and malformed kinds counted) of each entry of `items`,
5276
+ * so `page * NOTE_INDEX_PAGE_SIZE + itemPositions[i]` is the item's real sequence number.
5277
+ */
5278
+ itemPositions: number[];
5279
+ /**
5280
+ * Known-kind items whose body failed that kind's checks and were skipped by `body_len`. Always 0
5281
+ * unless {@link ParseNoteIndexPageOptions.skipMalformedItems} is set (otherwise they throw).
5282
+ */
5283
+ skippedMalformed: number;
5284
+ }
5285
+ /** Options of {@link parseNoteIndexPage}. */
5286
+ interface ParseNoteIndexPageOptions {
5287
+ /**
5288
+ * Skip (and count in `skippedMalformed`) a known-kind item whose body fails that kind's checks,
5289
+ * instead of refusing the whole page. Only the BODY is forgiven: the page header, the item
5290
+ * framing (`kind | body_len` inside the page, no truncation, no trailing bytes) and the hash
5291
+ * chain stay strict, so a skipped item is exactly a hidden item, which an untrusted relay can
5292
+ * already do. `recoverNotesFromIndex` sets it, so that one bad entry cannot abort every
5293
+ * wallet's restore.
5294
+ */
5295
+ skipMalformedItems?: boolean;
5296
+ }
5297
+ /** Input to {@link encodeNoteIndexPage}. */
5298
+ interface EncodeNoteIndexPageParams {
5299
+ epoch: bigint | number;
5300
+ page: bigint | number;
5301
+ firstSeq: bigint | number;
5302
+ complete: boolean;
5303
+ prevChain: Uint8Array;
5304
+ items: NoteIndexItem[];
5305
+ }
5306
+ /**
5307
+ * Parse one page, strictly. Throws {@link NoteIndexFormatError} on anything that is not exactly a
5308
+ * Note Index v1 page: wrong magic/version, unknown flag bits, non-zero reserved bytes, a count over
5309
+ * 1024, a complete page whose count is not 1024, first_seq that is not page * 1024, an epoch or page
5310
+ * other than `expect`, an item whose body_len differs from the exact length of its kind, a note
5311
+ * whose version disagrees with its length, an out-of-range ix_tag / note_source, a refund whose mint
5312
+ * is not WSOL, an unknown kind longer than 1024 bytes, a truncated item, or trailing bytes.
5313
+ *
5314
+ * With `options.skipMalformedItems`, an item whose body alone is at fault (its framing inside the
5315
+ * page is intact) is skipped and counted in `skippedMalformed` instead; everything else above
5316
+ * still throws.
5317
+ */
5318
+ declare function parseNoteIndexPage(bytes: Uint8Array, expect?: {
5319
+ epoch: bigint;
5320
+ page: number;
5321
+ }, options?: ParseNoteIndexPageOptions): NoteIndexPage;
5322
+ /**
5323
+ * Parse ONE raw item (`kind | body_len | body`), as kept in `NoteIndexPage.rawItems` and in a
5324
+ * persisted cursor. Same strictness as the page parser; unknown kinds are an error here.
5325
+ */
5326
+ declare function parseNoteIndexItem(raw: Uint8Array): NoteIndexItem;
5327
+ /** chain_{n+1} = sha256(chain_n || items bytes of page n), for a COMPLETE page's raw bytes. */
5328
+ declare function computeNoteIndexChain(prevChain: Uint8Array, pageBytes: Uint8Array): Uint8Array;
5329
+ /** Encode one item as `kind | body_len | body`. */
5330
+ declare function encodeNoteIndexItem(item: NoteIndexItem): Uint8Array;
5331
+ /**
5332
+ * Encode a page exactly as the relay serves it. The relay is the producer; this exists so both
5333
+ * sides pin the same golden vector and so tests can serve real pages from a stub.
5334
+ */
5335
+ declare function encodeNoteIndexPage(params: EncodeNoteIndexPageParams): Uint8Array;
5336
+
5337
+ /**
5338
+ * Restore a wallet's notes from the relay's Note Index v1 (contract revision 2.1), without walking
5339
+ * the chain and without telling anyone which notes, pools or nullifiers are its own.
5340
+ *
5341
+ * ── What this replaces ────────────────────────────────────────────────────────────────────────
5342
+ * `scanTransactions` enumerates the program's whole signature history and fetches every
5343
+ * transaction over RPC (thousands of paid calls, minutes). The relay indexes every confirmed Cloak
5344
+ * transaction once and serves all of it in bulk; this downloads every page, decrypts and matches
5345
+ * locally, rebuilds every listed pool's commitment tree from the index's own leaf stream, and spends
5346
+ * exactly ONE RPC request: a `getMultipleAccounts` of every listed pool's tree account, to check the
5347
+ * rebuilt trees. Spent status comes from the nullifiers in the index, so no nullifier of the user
5348
+ * reaches the relay or the RPC.
5349
+ *
5350
+ * ── Trust model (every byte from the relay is untrusted) ──────────────────────────────────────
5351
+ * A note is returned only when all of these hold:
5352
+ * (a) it decrypts / opens under the caller's own keys;
5353
+ * (b) the commitment recomputed from the decrypted values and an owner public key equals the
5354
+ * item's commitment, that owner key is the caller's `ownerUtxoKeypair.publicKey` (or a legacy
5355
+ * key this same recovery derived from nk), and derivePublicKey(privateKey) === publicKey for
5356
+ * the keypair returned. A relay cannot plant a note under somebody else's key and have it
5357
+ * counted as balance (the R2 fake-balance fix: `matchChangeNote` accepts any `outPubkey0`,
5358
+ * so the index path refuses every owner that is not the caller's);
5359
+ * (c) the commitment sits at the item's leaf in the tree rebuilt from the index's leaf stream,
5360
+ * and that leaf lies in a prefix of the stream the chain's tree account authenticates: the
5361
+ * whole stream when its root is the account's current root or one in its root history, or
5362
+ * the leaves under a COMPLETE node the account still stores in its frontier (`subtrees`,
5363
+ * see `readTreeAccountFrontier`), which keeps old notes verifiable when a busy pool has
5364
+ * moved more than the 100-root history past the index. Unverifiable candidates are counted
5365
+ * in `pending`, never returned, and carried in the cursor until they verify.
5366
+ * A lying relay can hide items. It cannot inject a note, alter one, or point one at a wrong leaf.
5367
+ * A HIDDEN nullifier makes a spent note look unspent; the spend-time `preflightNullifiers` in every
5368
+ * spend entry point is what catches that, and it stays mandatory.
5369
+ *
5370
+ * What is NOT checked: the proof-bound `chainNoteHash`. An index item does not carry it (nor the
5371
+ * `extDataHash` its preimage needs), and fetching either per transaction would break the one-RPC
5372
+ * budget. It is not needed for (a) to (c): the chain note is AES-GCM under a key HKDF'd from nk
5373
+ * with the item's own `comm0` as salt (`comm1` for a v2 note), so a note written for one
5374
+ * transaction never opens when the relay attaches it to another (a mispaired CLK1 carrier), for its
5375
+ * real owner or anyone else, and whatever does open (a note crafted for the transaction it sits
5376
+ * on, say under a public legacy key) is still held to (b) and (c). The item's other public fields (`publicAmount`,
5377
+ * the nullifiers) feed only derivations whose result must reproduce a published commitment, so a
5378
+ * wrong value there can only make a note fail to match. The cost of a mispairing is therefore
5379
+ * hidden notes (the memo's real owner's, and the paired source's own), never a wrong note, and no
5380
+ * client-side check can recover them: only the relay can pair correctly.
5381
+ *
5382
+ * ── One bad entry never aborts a run ──────────────────────────────────────────────────────────
5383
+ * The index carries what anyone can put on chain, and a legacy viewing key may be public, so a
5384
+ * stranger can write a note that opens for a wallet. An item whose body is malformed (framing
5385
+ * intact), or whose opened contents make a matcher throw, is skipped and counted in
5386
+ * `stats.skipped`, exactly as if it were not this wallet's. Only page-level faults (header,
5387
+ * framing, hash chain, head) still fail the run, since they are not one entry's.
5388
+ *
5389
+ * ── The cursor never depends on what the wallet owns (contract property 1) ────────────────────
5390
+ * Every run downloads from the persisted cursor page, so that page must be a function of public
5391
+ * data only. It is always `floor(complete_pages / 8) * 8` of the head this run saw (or the previous
5392
+ * page when a public condition holds it: more out-of-order leaves than the cursor may carry). It is
5393
+ * NEVER held back by this wallet's candidates: a candidate that cannot be verified yet travels
5394
+ * INSIDE the cursor instead (its raw item bytes, plus the stream's own value at its leaf, which is
5395
+ * exactly the value the client hashed into its frontier), bounded by `MAX_CARRIED_PENDING`, so a
5396
+ * later run can verify it without re-reading the pages it came from. A full re-sync from page 0 is
5397
+ * likewise only ever triggered by public conditions (an epoch change, a broken hash chain, a later
5398
+ * item that rewrites or fills the tree before the cursor, a rebuilt tree the chain disproves), never
5399
+ * by anything about this wallet's own items, so the request pattern of two wallets with the same
5400
+ * cursor is identical.
5401
+ *
5402
+ * ── Legacy (nk-derived owner keys) ────────────────────────────────────────────────────────────
5403
+ * Notes whose owner key older releases derived from nk are spendable by anyone holding nk. They are
5404
+ * returned in `atRisk`, never in `notes`, so an app can migrate them without counting them as
5405
+ * balance.
5406
+ *
5407
+ * Some older clients also encrypted their chain notes under a viewing key that is not the wallet's
5408
+ * canonical nk (mobile used SHA-512 of the public wallet address, or the embedded wallet's nsk).
5409
+ * Pass those as `legacyViewingKeyNks` to find such notes in the same download, at no extra request:
5410
+ * every item is trial-opened under the canonical nk first, then under each legacy key. A legacy key
5411
+ * only ever FINDS notes. Everything that opened only under one is returned in `atRisk`, whatever
5412
+ * its owner key (a legacy key may be public, so the relay and anyone else can read those notes), it
5413
+ * never opens a recipient delivery (the delivery rail never used one), and nothing a legacy key opens
5414
+ * can enter `notes`. A note of this wallet's that spends a legacy note and is encrypted under the
5415
+ * canonical nk (a migration) is matched normally and lands in `notes`.
5416
+ *
5417
+ * ── Refund leaves ─────────────────────────────────────────────────────────────────────────────
5418
+ * CloseSwapState appends R_fb to the WSOL MAIN tree (`["merkle_tree", WSOL]`; the separate refund
5419
+ * tree belonged to the retired ClaimRefund design and the program rejects it). So SWAP_REFUND
5420
+ * leaves are part of the WSOL leaf stream here, interleaved with TX leaves. Treating them as a
5421
+ * separate tree would leave a gap at every refund leaf and the WSOL root could never verify.
5422
+ */
5423
+
5424
+ type IndexedRecoveredNoteKind = "deposit" | "change" | "received" | "swap_refund";
5425
+ /** A verified note restored from the index. */
5426
+ interface IndexedRecoveredNote {
5427
+ kind: IndexedRecoveredNoteKind;
5428
+ /**
5429
+ * Ready to spend: `keypair` has the real private key, plus `blinding`, `amount`, `mintAddress`,
5430
+ * `index` (leaf, verified against the on-chain tree) and `commitment`.
5431
+ */
5432
+ utxo: Utxo;
5433
+ /** Base58 signature the relay attached. Metadata only, NOT proof of payment. */
5434
+ signature: string;
5435
+ /**
5436
+ * `true` for every `atRisk` note (owner key derivable from nk, or found through a legacy viewing
5437
+ * key), `false` for `notes`.
5438
+ */
5439
+ legacyExposed: boolean;
5440
+ }
5441
+ /**
5442
+ * The persisted resume point. JSON-serializable and holds NO key material, but `own` records which
5443
+ * index items are this wallet's, so store it as privately as the notes themselves, and never hand
5444
+ * one wallet's cursor to another wallet.
5445
+ *
5446
+ * Version 2. Any other version (including the v1 cursor of the first release), or anything that
5447
+ * fails validation, is ignored with a warning and the run re-syncs from page 0.
5448
+ */
5449
+ interface NoteIndexCursor {
5450
+ v: 2;
5451
+ /** Index epoch (u64, decimal). A different epoch at the relay means a full re-sync. */
5452
+ epoch: string;
5453
+ /**
5454
+ * First page the next run downloads: `floor(complete_pages / 8) * 8` of a head this wallet saw.
5455
+ * Public data only; it never depends on which items are this wallet's.
5456
+ */
5457
+ page: number;
5458
+ /** chain_page, 64 hex. */
5459
+ chain: string;
5460
+ /** Highest watermark seen in this epoch; a lower one is refused (`NoteIndexHeadBehindError`). */
5461
+ watermark: number;
5462
+ /** Items below this seq were covered by a pass from page 0; only later items can trigger one. */
5463
+ fullPassSeq: number;
5464
+ /** Per listed pool mint: its leaf stream as rebuilt from every page before `page`. Public data. */
5465
+ trees: Record<string, {
5466
+ frontier: MerkleFrontierState;
5467
+ /** Leaves past a gap, `[leaf, 64 hex]`, waiting for the gap to fill. */
5468
+ pending: Array<[number, string]>;
5469
+ /** Values (64 hex each, concatenated) of the leaves right below `frontier.nextIndex`. */
5470
+ window: string;
5471
+ /** Leaves `[0, verified)` were authenticated against the chain. */
5472
+ verified: number;
5473
+ /** `[leaf, 64 hex]` corrections the chain accepted over the first item for that leaf. */
5474
+ overrides: Array<[number, string]>;
5475
+ /** The chain disproved this stream and a pass from page 0 did not fix it. */
5476
+ mismatch: boolean;
5477
+ }>;
5478
+ /** This wallet's state. Private. */
5479
+ own: {
5480
+ /** Raw items (hex) from pages before `page` that hold a verified or a carried pending note. */
5481
+ items: Array<{
5482
+ seq: number;
5483
+ item: string;
5484
+ }>;
5485
+ /** `mint:leaf:commitmentHex` of every note that verified. */
5486
+ verified: string[];
5487
+ /** Nullifiers (hex) already seen spending one of this wallet's notes. */
5488
+ spent: string[];
5489
+ /** `[mint, leaf, 64 hex]`: the stream's value at each carried pending note's leaf. */
5490
+ pendingLeaves: Array<[string, number, string]>;
5491
+ /** Identities (32 hex) of items rejected for good. */
5492
+ rejected: string[];
5493
+ };
5494
+ }
5495
+ interface RecoverNotesFromIndexParams {
5496
+ /** Relay base URL. Must be on this build's origin allowlist. */
5497
+ relayUrl: string;
5498
+ /** Used for exactly one request: a `getMultipleAccounts` of every listed pool's tree account. */
5499
+ connection: CloakRpc;
5500
+ programId: Address;
5501
+ /** Every active pool mint. Trees are rebuilt and checked for ALL of them, not only where notes are. */
5502
+ poolMints: Address[];
5503
+ /** The wallet's 32-byte viewing base. */
5504
+ viewingKeyNk: Uint8Array;
5505
+ /**
5506
+ * Other 32-byte viewing keys older clients of this wallet encrypted chain notes under (at most
5507
+ * 8). Scan only: every note found through one is returned in `atRisk`, never in `notes`, and a
5508
+ * legacy key never opens a recipient delivery. Costs local trial decryptions, no extra request.
5509
+ * Entries equal to `viewingKeyNk` are ignored.
5510
+ */
5511
+ legacyViewingKeyNks?: Uint8Array[];
5512
+ /** The wallet's long-lived UTXO keypair, with its real private key. */
5513
+ ownerUtxoKeypair: UtxoKeypair;
5514
+ /** The `cursor` of the previous run. Omit for a full sync. */
5515
+ cursor?: NoteIndexCursor;
5516
+ /** Per mint: ignore legacy-shaped (nk-owned) notes at or after this leaf (a release cutoff). */
5517
+ legacyCutoffLeaf?: Record<string, bigint>;
5518
+ /** Pages in flight. Default 6. */
5519
+ concurrency?: number;
5520
+ onProgress?: (p: {
5521
+ pagesDone: number;
5522
+ pagesTotal: number;
5523
+ itemsChecked: number;
5524
+ notesFound: number;
5525
+ }) => void;
5526
+ signal?: AbortSignal;
5527
+ }
5528
+ interface NoteIndexRecoveryStats {
5529
+ /** Pages downloaded and parsed. */
5530
+ pages: number;
5531
+ /** Items checked (known kinds). */
5532
+ items: number;
5533
+ /** Bytes downloaded (decoded). */
5534
+ bytes: number;
5535
+ /** RPC requests sent through `connection`. */
5536
+ rpcCalls: number;
5537
+ ms: number;
5538
+ /**
5539
+ * Candidates rejected for good: commitment not reproducible from the opened values, not at the
5540
+ * declared leaf of the verified tree, a duplicate (mint, leaf), a legacy note past the cutoff, a
5541
+ * keypair that failed the derivePublicKey check, or an item already rejected by an earlier run.
5542
+ */
5543
+ dropped: number;
5544
+ /** Items that opened under this wallet's keys. */
5545
+ decrypted: number;
5546
+ /** Matched candidates before the tree and spent checks. */
5547
+ candidates: number;
5548
+ /** Verified notes whose nullifier the index shows as spent. */
5549
+ spent: number;
5550
+ /** Leaves two items assigned different commitments to. */
5551
+ conflicts: number;
5552
+ /** Pending candidates over the carry limit, not carried to the next run. */
5553
+ pendingDropped: number;
5554
+ /**
5555
+ * Index entries skipped instead of failing the run (each one is treated as not this wallet's):
5556
+ * an item whose body fails its kind's format checks while its framing in the page is intact, and
5557
+ * an item that opened under this wallet's keys but whose contents no derivation accepts (a chain
5558
+ * note salt of 0 or over 96 bits, or anything else that throws while it is matched). Anyone who
5559
+ * can read a legacy viewing key can write such a note, so none of this may abort a restore.
5560
+ */
5561
+ skipped: number;
5562
+ }
5563
+ interface RecoverNotesFromIndexResult {
5564
+ /** Verified, unspent, owned by `ownerUtxoKeypair`; deduped by (mint, leaf). */
5565
+ notes: IndexedRecoveredNote[];
5566
+ /**
5567
+ * Verified, unspent, and either owned by an nk-derived legacy key (spendable by nk holders) or
5568
+ * found only through a `legacyViewingKeyNks` entry (readable by whoever holds that key). Migrate.
5569
+ */
5570
+ atRisk: IndexedRecoveredNote[];
5571
+ /**
5572
+ * Candidates not verifiable yet (tree or root not caught up). Carried in the cursor. It depends on
5573
+ * what this wallet owns (a relay can make it non-zero for the owner of one item), so never let it
5574
+ * decide whether or what to download: gate polls on the public head (epoch, watermark) alone.
5575
+ */
5576
+ pending: number;
5577
+ /** Persist and pass back as `cursor`. */
5578
+ cursor: NoteIndexCursor;
5579
+ stats: NoteIndexRecoveryStats;
5580
+ /** Non-fatal events, e.g. a re-sync from page 0. Generic text: never a key, a mint or a note. */
5581
+ warnings: string[];
5582
+ }
5583
+ /**
5584
+ * The relay's head is behind a watermark this cursor already saw in the same epoch: a cached head
5585
+ * from a stale CDN edge, or a rollback. Nothing was discarded; retry later with the SAME cursor.
5586
+ * If it persists, the index was rolled back without a new epoch (a relay bug): only then drop the
5587
+ * cursor to re-sync from page 0.
5588
+ */
5589
+ declare class NoteIndexHeadBehindError extends Error {
5590
+ readonly cursorWatermark: number;
5591
+ readonly headWatermark: number;
5592
+ readonly retryable: true;
5593
+ constructor(cursorWatermark: number, headWatermark: number);
5594
+ }
5595
+ /**
5596
+ * Restore every verified, unspent note this wallet owns from the relay's note index.
5597
+ *
5598
+ * Downloads every page from the cursor (or page 0), opens each item locally, rebuilds every listed
5599
+ * pool's tree from the index's leaf stream, checks the trees with ONE `getMultipleAccounts`, and
5600
+ * computes spent status from the index's nullifiers. Persist the returned `cursor`; the next run
5601
+ * re-downloads from it, so dedupe against held notes by (mint, leaf).
5602
+ *
5603
+ * Throws `NoteIndexHeadBehindError` (retryable, nothing discarded) when the relay's head is behind
5604
+ * the cursor. An unusable cursor is never an exception: it is ignored with a warning.
5605
+ */
5606
+ declare function recoverNotesFromIndex(params: RecoverNotesFromIndexParams): Promise<RecoverNotesFromIndexResult>;
5607
+
5102
5608
  /**
5103
5609
  * Automatic UTXO Wallet Manager
5104
5610
  *
@@ -5285,6 +5791,18 @@ interface WalletAdapterBridgeOptions {
5285
5791
  web3?: Web3Module;
5286
5792
  }
5287
5793
  declare function signerFromWalletAdapter(adapter: LegacyWalletAdapter, options?: WalletAdapterBridgeOptions): WalletSigner;
5794
+ /**
5795
+ * A wallet that signs a transaction given its wire bytes and returns the signed wire bytes: the
5796
+ * shape of the Wallet Standard `solana:signTransaction` feature. This is the bridge to use for a
5797
+ * Transaction V1 message, which `@solana/web3.js` 1.x cannot serialize; it works for v0 and legacy
5798
+ * messages too, and needs no web3.js at all.
5799
+ */
5800
+ interface TransactionBytesWallet {
5801
+ address: Address;
5802
+ signTransaction(transactionBytes: Uint8Array): Promise<Uint8Array>;
5803
+ signMessage?: (message: Uint8Array) => Promise<Uint8Array>;
5804
+ }
5805
+ declare function signerFromTransactionBytes(wallet: TransactionBytesWallet): WalletSigner;
5288
5806
  type Web3Module = {
5289
5807
  VersionedTransaction: {
5290
5808
  deserialize(bytes: Uint8Array): unknown;
@@ -5952,4 +6470,4 @@ declare const VERSION = "0.2.6";
5952
6470
  /** True when scanner supports TransactSwap (tag 1). Check this to verify the correct SDK bundle is loaded. */
5953
6471
  declare const SCANNER_SUPPORTS_TRANSACT_SWAP = true;
5954
6472
 
5955
- export { BRIDGE_ESCROW_LABEL, BRIDGE_ESCROW_LABEL_V2, BUILD_ALLOWS_LOCAL_ENDPOINTS, type BridgeDeliveryState, type BridgeDeposit, type BridgeDepositState, type BridgeQuoteAssessment, type BridgeQuoteInput, type BridgeRail, type BridgeRailAttestation, type BridgeRailProblem, type BridgeRailQuoteOption, type BridgeRailQuoteRequest, type BridgeRailQuoteResponse, type BridgeRailStatusResult, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLEANUP_FEE_BUDGET, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CleanupResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CloakRpc, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, type CreateRecoverableDepositUtxoParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, DepositError, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositOutcome, type DepositRef, type DepositResult, type DepositStatus, type DiscoverOptions, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, DoNotRetry, ECONOMIC_MINIMUM, EXPECTED_CIRCUIT_HASHES, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, InsecureRandomnessError, LAMPORTS_PER_SOL, type LegacyWalletAdapter, type WalletSigner as LegacyWalletSigner, LocalStorageAdapter, type LogLevel, type Logger, type LookupTable, MAINNET_RENT_0, MAINNET_RENT_1, MAX_RECEIVER_INDEX, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, MIN_DEPOSIT_SPL_BASE_UNITS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, type MessageSigner, NATIVE_SOL_MINT, type Network, type NoteData, ONECLICK_PUBKEY_B58, type OnchainMerkleProof, type ParsedDeliveryCarrier, type PaymasterTopUpExpectation, type PaymasterTopUpResult, type PendingDeposit, type PendingWithdrawal, type PostFailureVerdict, RECIPIENT_DELIVERY_CIPHERTEXT_LEN, RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN, RECIPIENT_DELIVERY_NONCE_LEN, RECIPIENT_DELIVERY_NOTE_BYTES, RECIPIENT_DELIVERY_PLAINTEXT_LEN, RECIPIENT_DELIVERY_TAG_LEN, RELAY_BATCH_AUTH_MAX_ITEMS, RELAY_ORIGIN_ALLOWLIST, REQUEST_AUTH_BATCH_DOMAIN, REQUEST_AUTH_BATCH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthMode, type RelayAuthPreimage, type RelayAuthSigner, RelayBatchAuthCoordinator, type RelayBatchAuthCoordinatorOptions, type RelayBatchAuthEnvelope, type RelayBatchAuthFields, type RelayBatchAuthItemHandle, RelayInternalError, RelayService, type RelaySubmissionResult, type RentRates, type RetryHooks, type RiskQuoteInstructionResponse, RootNotFoundError, SCANNER_SUPPORTS_TRANSACT_SWAP, SIGN_IN_MESSAGE, SanctionsQuoteError, type ScanOptions, type ScanRecipientDeliveryOptions, type ScanResult, type ScanSummary, type ScannedTransaction, type SettlementConnection, type SettlementContext, type SettlementStatus, type SettlementVerdict, SettlementVerificationError, ShieldPoolErrors, type ShieldPoolPDAs, SimpleWallet, type SpendKey, type SpendOptions, type StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactBatchItem, type TransactBatchItemOutcome, type TransactBatchOptions, type TransactBatchResult, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, TransactionConfirmationError, type TransactionMetadata, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, type Utxo, UtxoAlreadySpentError, type EncryptedNote as UtxoEncryptedNote, type UtxoKeypair, type UtxoSwapParams, type UtxoSwapResult, UtxoWallet, VARIABLE_FEE_DENOMINATOR, VARIABLE_FEE_NUMERATOR, VARIABLE_FEE_RATE, VERSION, type VerifyUtxosResult, type ViewKey, type ViewingKeyPair, WITHDRAW_FEE_BPS, WITHDRAW_FIXED_FEE, type WalletAdapterBridgeOptions, type WalletSigner$1 as WalletSigner, type WalletUtxo, type Web3Module, type WithdrawOptions, type WithdrawSubmissionResult, accountMeta, addressBytes, addressFromBytes, addressFromPublicKey, assertDirectSubmissionLanded, assertInputMints, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildAuthTransactionMessage, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildRelayBatchAuthMessage, buildTransactRequestBody, buildTransactionMessage, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmSignature, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createCloakRpc, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createRelayBatchAuthCoordinator, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteBlinding, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, deriveLegacyBridgeReceiver, deriveLegacyDepositNoteSecrets, deriveLegacySwapRefundAuthorization, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveSwapRefundBlinding, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchAccountBytes, fetchCommitments, fetchLatestBlockhash, fetchLookupTables, fetchRiskQuoteInstruction, fetchRiskQuoteIx, fetchSignaturesForAddress, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, findProgramAddress, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, fundReceiverViaPaymaster, generateCloakKeys, generateCommitmentAsync, generateMasterSeed, generateNoteFromWallet, generateUtxoKeypair, generateViewingKeyPair, getAddressExplorerUrl, getChainNoteRegistryPDA, getCircuitsPath, getDeliveryRegistryPDA, getDistributableAmount, getExplorerUrl, getNkFromUtxoPrivateKey, getNullifierPDA, getPendingOperationsSummary, getPoolAuthorityConfigPDA, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint$1 as hexToBigint, hexToBytes, importKeys, importWalletKeys, isBrowser, isBrowserLike, isDebugEnabled, isMessageSigner, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, messageSignerFromCallback, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, partiallySignTransaction, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, programInstruction, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, registerViewingKey, relayRequestDigestHex, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendInstructions, sendRawTransaction, sendTransaction, serializeAuthTransactionMessage, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signCompiledTransaction, signMessageBytes, signRelayAuthPayload, signTransaction, signerFromKeypair, signerFromSecretKey, signerFromWalletAdapter, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toAddress, toComplianceReport, transact, transactBatch, transactionBase64, transactionBytes, transactionFromBytes, transactionWireSize, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validatePaymasterTopUpTransaction, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyQuoteSignature, verifyUtxos, waitForRoot, withShieldRetries, withTiming, withdrawFeeFor };
6473
+ export { BRIDGE_ESCROW_LABEL, BRIDGE_ESCROW_LABEL_V2, BUILD_ALLOWS_LOCAL_ENDPOINTS, type BridgeDeliveryState, type BridgeDeposit, type BridgeDepositState, type BridgeQuoteAssessment, type BridgeQuoteInput, type BridgeRail, type BridgeRailAttestation, type BridgeRailProblem, type BridgeRailQuoteOption, type BridgeRailQuoteRequest, type BridgeRailQuoteResponse, type BridgeRailStatusResult, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLEANUP_FEE_BUDGET, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CleanupResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CloakRpc, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, type CreateRecoverableDepositUtxoParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, DepositError, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositOutcome, type DepositRef, type DepositResult, type DepositStatus, type DiscoverOptions, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, DoNotRetry, ECONOMIC_MINIMUM, EXPECTED_CIRCUIT_HASHES, type EncodeNoteIndexPageParams, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, type IndexedRecoveredNote, type IndexedRecoveredNoteKind, InsecureRandomnessError, LAMPORTS_PER_SOL, type LegacyWalletAdapter, type WalletSigner as LegacyWalletSigner, LocalStorageAdapter, type LogLevel, type Logger, type LookupTable, MAINNET_RENT_0, MAINNET_RENT_1, MAX_RECEIVER_INDEX, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, MIN_DEPOSIT_SPL_BASE_UNITS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, type MessageSigner, NATIVE_SOL_MINT, NOTE_INDEX_NO_LEAF, NOTE_INDEX_PAGE_SIZE, type Network, type NoteData, type NoteIndexCursor, type NoteIndexDeliveryItem, type NoteIndexFetchOptions, NoteIndexFormatError, type NoteIndexHead, NoteIndexHeadBehindError, type NoteIndexItem, type NoteIndexPage, type NoteIndexRecoveryStats, type NoteIndexSwapRefundItem, type NoteIndexTxItem, ONECLICK_PUBKEY_B58, type OnchainMerkleProof, type ParseNoteIndexPageOptions, type ParsedDeliveryCarrier, type PaymasterTopUpExpectation, type PaymasterTopUpResult, type PendingDeposit, type PendingWithdrawal, type PostFailureVerdict, RECIPIENT_DELIVERY_CIPHERTEXT_LEN, RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN, RECIPIENT_DELIVERY_NONCE_LEN, RECIPIENT_DELIVERY_NOTE_BYTES, RECIPIENT_DELIVERY_PLAINTEXT_LEN, RECIPIENT_DELIVERY_TAG_LEN, RELAY_BATCH_AUTH_MAX_ITEMS, RELAY_ORIGIN_ALLOWLIST, REQUEST_AUTH_BATCH_DOMAIN, REQUEST_AUTH_BATCH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoverNotesFromIndexParams, type RecoverNotesFromIndexResult, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthMode, type RelayAuthPreimage, type RelayAuthSigner, RelayBatchAuthCoordinator, type RelayBatchAuthCoordinatorOptions, type RelayBatchAuthEnvelope, type RelayBatchAuthFields, type RelayBatchAuthItemHandle, RelayInternalError, RelayService, type RelaySubmissionResult, type RentRates, type RetryHooks, type RiskQuoteInstructionResponse, RootNotFoundError, SCANNER_SUPPORTS_TRANSACT_SWAP, SIGN_IN_MESSAGE, SanctionsQuoteError, type ScanOptions, type ScanRecipientDeliveryOptions, type ScanResult, type ScanSummary, type ScannedTransaction, type SettlementConnection, type SettlementContext, type SettlementStatus, type SettlementVerdict, SettlementVerificationError, ShieldPoolErrors, type ShieldPoolPDAs, SimpleWallet, type SpendKey, type SpendOptions, type StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapRefundShape, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactBatchItem, type TransactBatchItemOutcome, type TransactBatchOptions, type TransactBatchResult, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, type TransactionBytesWallet, TransactionConfirmationError, type TransactionMetadata, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, type Utxo, UtxoAlreadySpentError, type EncryptedNote as UtxoEncryptedNote, type UtxoKeypair, type UtxoSwapParams, type UtxoSwapResult, UtxoWallet, VARIABLE_FEE_DENOMINATOR, VARIABLE_FEE_NUMERATOR, VARIABLE_FEE_RATE, VERSION, type VerifyUtxosResult, type ViewKey, type ViewingKeyPair, WITHDRAW_FEE_BPS, WITHDRAW_FIXED_FEE, type WalletAdapterBridgeOptions, type WalletSigner$1 as WalletSigner, type WalletUtxo, type Web3Module, type WithdrawOptions, type WithdrawSubmissionResult, accountMeta, addressBytes, addressFromBytes, addressFromPublicKey, assertDirectSubmissionLanded, assertInputMints, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildAuthTransactionMessage, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildRelayBatchAuthMessage, buildTransactRequestBody, buildTransactionMessage, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeNoteIndexChain, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmSignature, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createCloakRpc, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createRelayBatchAuthCoordinator, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteBlinding, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, deriveLegacyBridgeReceiver, deriveLegacyDepositNoteSecrets, deriveLegacySwapRefundAuthorization, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveSwapRefundBlinding, deriveSwapRefundKeypair, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteIndexItem, encodeNoteIndexPage, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchAccountBytes, fetchCommitments, fetchLatestBlockhash, fetchLookupTables, fetchNoteIndexHead, fetchNoteIndexPage, fetchRiskQuoteInstruction, fetchRiskQuoteIx, fetchSignaturesForAddress, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, findProgramAddress, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, fundReceiverViaPaymaster, generateCloakKeys, generateCommitmentAsync, generateMasterSeed, generateNoteFromWallet, generateUtxoKeypair, generateViewingKeyPair, getAddressExplorerUrl, getChainNoteRegistryPDA, getCircuitsPath, getDeliveryRegistryPDA, getDistributableAmount, getExplorerUrl, getNkFromUtxoPrivateKey, getNullifierPDA, getPendingOperationsSummary, getPoolAuthorityConfigPDA, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint$1 as hexToBigint, hexToBytes, importKeys, importWalletKeys, isBrowser, isBrowserLike, isDebugEnabled, isMessageSigner, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, messageSignerFromCallback, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseNoteIndexItem, parseNoteIndexPage, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, partiallySignTransaction, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, programInstruction, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, recoverNotesFromIndex, registerViewingKey, relayRequestDigestHex, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendInstructions, sendRawTransaction, sendTransaction, serializeAuthTransactionMessage, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signCompiledTransaction, signMessageBytes, signRelayAuthPayload, signTransaction, signerFromKeypair, signerFromSecretKey, signerFromTransactionBytes, signerFromWalletAdapter, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toAddress, toComplianceReport, transact, transactBatch, transactionBase64, transactionBytes, transactionFromBytes, transactionWireSize, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validatePaymasterTopUpTransaction, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyQuoteSignature, verifyUtxos, waitForRoot, withShieldRetries, withTiming, withdrawFeeFor };