@cloak.dev/sdk 0.2.5-staging.4b3a899 → 0.2.6-staging.4f665f8
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/CHANGELOG.md +156 -0
- package/README.md +192 -43
- package/dist/index.cjs +2455 -251
- package/dist/index.d.cts +769 -155
- package/dist/index.d.ts +769 -155
- package/dist/index.js +2435 -256
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -985,9 +985,10 @@ declare const REQUEST_AUTH_MAX_AGE_SECONDS = 300;
|
|
|
985
985
|
* How far ahead of the relay's clock a request may be stamped
|
|
986
986
|
* (`REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS`, `api/request_auth.rs`).
|
|
987
987
|
*
|
|
988
|
-
* `auth_issued_at`
|
|
989
|
-
*
|
|
990
|
-
*
|
|
988
|
+
* `auth_issued_at` is read from the relay's own clock (`relayNowSeconds`, `relay/clock.ts`), learned
|
|
989
|
+
* from the `x-cloak-server-time` header on every relay response, so a machine clock that is off
|
|
990
|
+
* does not matter. Before the first relay response, or against a relay without the header, it
|
|
991
|
+
* falls back to `Date.now()`, where a machine more than 30 seconds fast is refused.
|
|
991
992
|
*/
|
|
992
993
|
declare const REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS = 30;
|
|
993
994
|
/**
|
|
@@ -1123,8 +1124,15 @@ declare function signRelayAuthPayload(signer: RelayAuthSigner, payload: Uint8Arr
|
|
|
1123
1124
|
* arrive as the same bare 401. Two of them are not the caller's mistake at all: an approval that
|
|
1124
1125
|
* sat too long, and a machine clock that is simply wrong. Returns `null` for anything that is not
|
|
1125
1126
|
* an authentication rejection, so callers can append it only when there is something to add.
|
|
1127
|
+
*
|
|
1128
|
+
* `context.carriedAffiliateCode` says the rejected body carried `affiliate_code`. A relay older
|
|
1129
|
+
* than the affiliate release (REL-010/REL-011) ignores that field and leaves it out of the digest
|
|
1130
|
+
* it recomputes, so the request fails as a body mismatch even though nothing was tampered with.
|
|
1131
|
+
* Only that case gets the extra hint; without the flag the output is unchanged.
|
|
1126
1132
|
*/
|
|
1127
|
-
declare function explainRelayAuthRejection(responseText: string
|
|
1133
|
+
declare function explainRelayAuthRejection(responseText: string, context?: {
|
|
1134
|
+
carriedAffiliateCode?: boolean;
|
|
1135
|
+
}): string | null;
|
|
1128
1136
|
declare const REQUEST_AUTH_BATCH_DOMAIN = "CLOAK_RELAY_BATCH_AUTH_V1";
|
|
1129
1137
|
/**
|
|
1130
1138
|
* How long the relay accepts an item that arrives under a batch signature
|
|
@@ -1539,6 +1547,14 @@ declare class MerkleTree {
|
|
|
1539
1547
|
* @param height Tree height (default: 32)
|
|
1540
1548
|
*/
|
|
1541
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
|
+
}
|
|
1542
1558
|
|
|
1543
1559
|
/**
|
|
1544
1560
|
* Error Utilities
|
|
@@ -3431,6 +3447,20 @@ interface TransactOptions {
|
|
|
3431
3447
|
* passing nk at every call site — e.g. pass a getter from your key manager.
|
|
3432
3448
|
*/
|
|
3433
3449
|
getChainNoteViewingKeyNk?: () => Promise<string | Uint8Array | null>;
|
|
3450
|
+
/**
|
|
3451
|
+
* The wallet's long-lived UTXO keypair (`deriveUtxoKeypairFromSpendKey(skSpend)`).
|
|
3452
|
+
*
|
|
3453
|
+
* It OWNS every self-owned note a flow creates: change, merges, send-to-self outputs and swap
|
|
3454
|
+
* refund leaves. The SDK never takes that owner from an input or output note, because a note's
|
|
3455
|
+
* own key may be a legacy key derived from the viewing key `nk`, and `nk` must only ever VIEW.
|
|
3456
|
+
*
|
|
3457
|
+
* When no explicit `chainNoteViewingKeyNk` / `getChainNoteViewingKeyNk` is given, the canonical
|
|
3458
|
+
* `nk` is derived from it (`getNkFromUtxoPrivateKey(privateKey)`).
|
|
3459
|
+
*
|
|
3460
|
+
* Required by `transfer`, `partialWithdraw`, `fullWithdraw`, `swapUtxo` and `swapWithChange`
|
|
3461
|
+
* (see {@link SpendOptions}). Optional for `transact`, which then requires an explicit `nk`.
|
|
3462
|
+
*/
|
|
3463
|
+
ownerUtxoKeypair?: UtxoKeypair;
|
|
3434
3464
|
/**
|
|
3435
3465
|
* Pin the chain note's 96-bit `noteSalt` instead of drawing a fresh one (VK-01).
|
|
3436
3466
|
*
|
|
@@ -3558,7 +3588,38 @@ interface TransactOptions {
|
|
|
3558
3588
|
* relay does not authenticate this way.
|
|
3559
3589
|
*/
|
|
3560
3590
|
relayAuthBatch?: RelayBatchAuthItemHandle;
|
|
3591
|
+
/**
|
|
3592
|
+
* Referral code attached to fee-bearing relay requests (SDK-001).
|
|
3593
|
+
*
|
|
3594
|
+
* Sent as `affiliate_code`, and signed inside the relay request, only when it is a non-empty
|
|
3595
|
+
* string AND the request is fee-bearing: a withdrawal / send to a public address
|
|
3596
|
+
* (`externalAmount < 0` with a recipient) or a swap intake. Deposits and shield-to-shield sends
|
|
3597
|
+
* never carry it, whatever is passed here. Omitted, every request is byte-identical to one built
|
|
3598
|
+
* without this option (INV-007). Requires a relay that accepts `affiliate_code`.
|
|
3599
|
+
*
|
|
3600
|
+
* @internal For Cloak's own web and mobile apps. Not part of the public API, not documented, and
|
|
3601
|
+
* may change without notice.
|
|
3602
|
+
*/
|
|
3603
|
+
affiliateCode?: string;
|
|
3604
|
+
/**
|
|
3605
|
+
* Extra HTTP headers sent with this flow's relay submissions (`POST /transact` and
|
|
3606
|
+
* `POST /transact_swap`), e.g. `{ "X-Cloak-Client": "cloak-mobile/ios/1.4.0" }` (SDK-004).
|
|
3607
|
+
* They never replace a header the SDK sets itself; malformed entries are dropped. Omitted, the
|
|
3608
|
+
* requests are exactly what they were.
|
|
3609
|
+
*
|
|
3610
|
+
* @internal For Cloak's own mobile app. Not part of the public API, and a browser caller should
|
|
3611
|
+
* not set it: a non-safelisted header makes every submission a CORS preflight.
|
|
3612
|
+
*/
|
|
3613
|
+
relayHeaders?: Record<string, string>;
|
|
3561
3614
|
}
|
|
3615
|
+
/**
|
|
3616
|
+
* Options for the spend flows that create self-owned notes (`transfer`, `partialWithdraw`,
|
|
3617
|
+
* `fullWithdraw`, `swapUtxo`, `swapWithChange`): {@link TransactOptions} with the wallet's
|
|
3618
|
+
* long-lived UTXO keypair made mandatory.
|
|
3619
|
+
*/
|
|
3620
|
+
type SpendOptions = TransactOptions & {
|
|
3621
|
+
ownerUtxoKeypair: UtxoKeypair;
|
|
3622
|
+
};
|
|
3562
3623
|
/**
|
|
3563
3624
|
* Switchboard-style response: a pre-built instruction.
|
|
3564
3625
|
*
|
|
@@ -3611,6 +3672,13 @@ interface TransactRequestBodyParams {
|
|
|
3611
3672
|
externalAmount: bigint;
|
|
3612
3673
|
/** Base64 CLKD1 envelopes, from `buildRecipientDeliveryNotes`. Omitted when the rail is off. */
|
|
3613
3674
|
recipientDeliveryNotes?: string[];
|
|
3675
|
+
/**
|
|
3676
|
+
* `TransactOptions.affiliateCode`. Only a withdrawal (`externalAmount < 0` with a recipient)
|
|
3677
|
+
* carries it; for any other shape it is ignored.
|
|
3678
|
+
*
|
|
3679
|
+
* @internal
|
|
3680
|
+
*/
|
|
3681
|
+
affiliateCode?: string;
|
|
3614
3682
|
}
|
|
3615
3683
|
/**
|
|
3616
3684
|
* Assemble the `/transact` body.
|
|
@@ -3676,6 +3744,13 @@ interface SubmitTransactToRelayArgs {
|
|
|
3676
3744
|
requestTimeoutMs?: number;
|
|
3677
3745
|
/** Injection seam for tests; defaults to global fetch. */
|
|
3678
3746
|
fetchImpl?: typeof fetch;
|
|
3747
|
+
/**
|
|
3748
|
+
* Extra headers for the `/transact` POST, e.g. the mobile app's `X-Cloak-Client` (SDK-004).
|
|
3749
|
+
* Never replace `Content-Type`; omitted, the request headers are exactly what they were.
|
|
3750
|
+
*
|
|
3751
|
+
* @internal
|
|
3752
|
+
*/
|
|
3753
|
+
extraHeaders?: Record<string, string>;
|
|
3679
3754
|
onProgress?: (status: string) => void;
|
|
3680
3755
|
/** Total window allowed for the on-chain settlement check after a reported success. */
|
|
3681
3756
|
settlementTimeoutMs?: number;
|
|
@@ -3709,6 +3784,12 @@ interface SubmitTransactToRelayArgs {
|
|
|
3709
3784
|
* captured across attempts, and every terminal failure that could plausibly have been submitted
|
|
3710
3785
|
* is resolved against chain into a `SettlementVerificationError` that states the outcome and
|
|
3711
3786
|
* carries the signature.
|
|
3787
|
+
*
|
|
3788
|
+
* WARNING [preflight 0x1020]: this posts an already-built request and does NOT run
|
|
3789
|
+
* `preflightNullifiers`. Notes restored from an untrusted source (the relay's note index can hide a
|
|
3790
|
+
* nullifier, so a spent note can look unspent) must go through `transact` / `partialWithdraw` /
|
|
3791
|
+
* `fullWithdraw` / `swapUtxo`, which run the preflight before proof generation; a caller that
|
|
3792
|
+
* builds its own request must `await preflightNullifiers(inputUtxos, connection, programId)` first.
|
|
3712
3793
|
*/
|
|
3713
3794
|
declare function submitTransactToRelay(args: SubmitTransactToRelayArgs): Promise<RelaySubmissionResult>;
|
|
3714
3795
|
declare function transact(params: TransactParams, options: TransactOptions): Promise<TransactResult>;
|
|
@@ -3718,24 +3799,31 @@ declare function transact(params: TransactParams, options: TransactOptions): Pro
|
|
|
3718
3799
|
* Transfers funds from your UTXOs to another recipient's public key,
|
|
3719
3800
|
* keeping everything within the shielded pool.
|
|
3720
3801
|
*
|
|
3802
|
+
* Change (and a send to yourself) is owned by `options.ownerUtxoKeypair`, the wallet's long-lived
|
|
3803
|
+
* UTXO keypair, never by `inputUtxos[0]`'s key. The chain note is encrypted under the wallet's nk
|
|
3804
|
+
* (explicit, or the canonical nk of `ownerUtxoKeypair`).
|
|
3805
|
+
*
|
|
3721
3806
|
* @param inputUtxos Your UTXOs to spend
|
|
3722
3807
|
* @param recipientPubkey Recipient's UTXO public key
|
|
3723
3808
|
* @param amount Amount to transfer
|
|
3724
|
-
* @param options Transaction options
|
|
3809
|
+
* @param options Transaction options, including the mandatory `ownerUtxoKeypair`
|
|
3725
3810
|
*/
|
|
3726
|
-
declare function transfer(inputUtxos: Utxo[], recipientPubkey: bigint, amount: bigint, options:
|
|
3811
|
+
declare function transfer(inputUtxos: Utxo[], recipientPubkey: bigint, amount: bigint, options: SpendOptions): Promise<TransactResult>;
|
|
3727
3812
|
/**
|
|
3728
3813
|
* Execute a partial withdrawal
|
|
3729
3814
|
*
|
|
3730
3815
|
* Withdraws a portion of funds to an external Solana address,
|
|
3731
3816
|
* keeping the remainder shielded.
|
|
3732
3817
|
*
|
|
3818
|
+
* The change note (and any consolidation merge) is owned by `options.ownerUtxoKeypair`, the
|
|
3819
|
+
* wallet's long-lived UTXO keypair, never by `inputUtxos[0]`'s key.
|
|
3820
|
+
*
|
|
3733
3821
|
* @param inputUtxos Your UTXOs to spend
|
|
3734
3822
|
* @param recipient External Solana address
|
|
3735
3823
|
* @param withdrawAmount Amount to withdraw
|
|
3736
|
-
* @param options Transaction options
|
|
3824
|
+
* @param options Transaction options, including the mandatory `ownerUtxoKeypair`
|
|
3737
3825
|
*/
|
|
3738
|
-
declare function partialWithdraw(inputUtxos: Utxo[], recipient: Address, withdrawAmount: bigint, options:
|
|
3826
|
+
declare function partialWithdraw(inputUtxos: Utxo[], recipient: Address, withdrawAmount: bigint, options: SpendOptions): Promise<TransactResult>;
|
|
3739
3827
|
/**
|
|
3740
3828
|
* Execute a full withdrawal
|
|
3741
3829
|
*
|
|
@@ -3743,9 +3831,9 @@ declare function partialWithdraw(inputUtxos: Utxo[], recipient: Address, withdra
|
|
|
3743
3831
|
*
|
|
3744
3832
|
* @param inputUtxos Your UTXOs to spend
|
|
3745
3833
|
* @param recipient External Solana address
|
|
3746
|
-
* @param options Transaction options
|
|
3834
|
+
* @param options Transaction options, including the mandatory `ownerUtxoKeypair`
|
|
3747
3835
|
*/
|
|
3748
|
-
declare function fullWithdraw(inputUtxos: Utxo[], recipient: Address, options:
|
|
3836
|
+
declare function fullWithdraw(inputUtxos: Utxo[], recipient: Address, options: SpendOptions): Promise<TransactResult>;
|
|
3749
3837
|
/**
|
|
3750
3838
|
* Parameters for UTXO swap operation
|
|
3751
3839
|
*/
|
|
@@ -3776,20 +3864,19 @@ interface UtxoSwapResult extends TransactResult {
|
|
|
3776
3864
|
/** Relay request ID for swap execution status */
|
|
3777
3865
|
requestId?: string;
|
|
3778
3866
|
/**
|
|
3779
|
-
* V3-04 refund-fallback
|
|
3780
|
-
* out before TX2. On a timeout close the program builds the amount-bound note
|
|
3867
|
+
* V3-04 refund-fallback authorization. On a timeout close the program builds the amount-bound note
|
|
3781
3868
|
* R_fb = Poseidon(amountAfterFee, publicKey, blinding, WSOL)
|
|
3782
3869
|
* where `amountAfterFee` is the principal it locked (read authoritatively from the on-chain
|
|
3783
|
-
* `SwapState.sol_amount`, = gross swap amount minus the on-chain swap fee).
|
|
3784
|
-
*
|
|
3870
|
+
* `SwapState.sol_amount`, = gross swap amount minus the on-chain swap fee). R_fb is an ordinary
|
|
3871
|
+
* leaf of the main pool tree, spent with the ordinary `transact()` path. All values are hex.
|
|
3785
3872
|
*
|
|
3786
|
-
*
|
|
3787
|
-
* the
|
|
3788
|
-
*
|
|
3789
|
-
*
|
|
3873
|
+
* `publicKey` is the wallet's long-lived UTXO public key (`options.ownerUtxoKeypair`), so R_fb is
|
|
3874
|
+
* spent with the wallet's own keypair; the private key is deliberately not repeated here. The
|
|
3875
|
+
* blinding is derived from the wallet's `nk` and the swap's public first input nullifier
|
|
3876
|
+
* (`derivedFromNk` is always true), so `discoverSwapRefunds` finds the leaf again from key
|
|
3877
|
+
* material if this object is lost.
|
|
3790
3878
|
*/
|
|
3791
3879
|
refund: {
|
|
3792
|
-
privateKey: string;
|
|
3793
3880
|
publicKey: string;
|
|
3794
3881
|
blinding: string;
|
|
3795
3882
|
derivedFromNk: boolean;
|
|
@@ -3807,7 +3894,7 @@ interface UtxoSwapResult extends TransactResult {
|
|
|
3807
3894
|
* @param options Transaction options
|
|
3808
3895
|
* @returns UtxoSwapResult with SwapState PDA for executing the swap
|
|
3809
3896
|
*/
|
|
3810
|
-
declare function swapUtxo(params: UtxoSwapParams, options:
|
|
3897
|
+
declare function swapUtxo(params: UtxoSwapParams, options: SpendOptions): Promise<UtxoSwapResult>;
|
|
3811
3898
|
/**
|
|
3812
3899
|
* Execute a swap with change
|
|
3813
3900
|
*
|
|
@@ -3820,7 +3907,7 @@ declare function swapUtxo(params: UtxoSwapParams, options: TransactOptions): Pro
|
|
|
3820
3907
|
* @param minOutputAmount Minimum output (slippage protection)
|
|
3821
3908
|
* @param options Transaction options
|
|
3822
3909
|
*/
|
|
3823
|
-
declare function swapWithChange(inputUtxos: Utxo[], swapAmount: bigint, outputMint: Address, recipientAta: Address, minOutputAmount: bigint, options:
|
|
3910
|
+
declare function swapWithChange(inputUtxos: Utxo[], swapAmount: bigint, outputMint: Address, recipientAta: Address, minOutputAmount: bigint, options: SpendOptions, recipientWallet?: Address): Promise<UtxoSwapResult>;
|
|
3824
3911
|
|
|
3825
3912
|
/**
|
|
3826
3913
|
* Circuit artifact loading and integrity verification.
|
|
@@ -4268,77 +4355,45 @@ declare function parseDeliveryCarrierMemo(data: Uint8Array): ParsedDeliveryCarri
|
|
|
4268
4355
|
/**
|
|
4269
4356
|
* Recoverable deposit notes (VK-01, deposit shape).
|
|
4270
4357
|
*
|
|
4271
|
-
* ──
|
|
4272
|
-
* A
|
|
4273
|
-
*
|
|
4274
|
-
*
|
|
4275
|
-
*
|
|
4276
|
-
*
|
|
4277
|
-
*
|
|
4278
|
-
*
|
|
4279
|
-
*
|
|
4280
|
-
*
|
|
4281
|
-
*
|
|
4282
|
-
*
|
|
4283
|
-
*
|
|
4284
|
-
*
|
|
4285
|
-
*
|
|
4286
|
-
*
|
|
4287
|
-
*
|
|
4288
|
-
*
|
|
4289
|
-
*
|
|
4290
|
-
*
|
|
4291
|
-
* The shielded-send shape was fixed with a CLKD1 delivery envelope because a send's output is owned
|
|
4292
|
-
* by SOMEONE ELSE: the only way to reach them is to encrypt to their key. A deposit's output is
|
|
4293
|
-
* SELF-owned. There is nobody to deliver to, and an envelope would cost 112 bytes on the one
|
|
4294
|
-
* transaction in the protocol that is wallet-signed and already tight against the 1232-byte packet
|
|
4295
|
-
* limit (a v4 chain note's extra 41 bytes is measured at 1282 and is exactly why deposits stay v3).
|
|
4296
|
-
*
|
|
4297
|
-
* So make the existing chain-note path recoverable instead. Both missing values become a PRF of the
|
|
4298
|
-
* wallet's own `nk` and the note salt the chain note ALREADY carries:
|
|
4299
|
-
*
|
|
4300
|
-
* seed = BLAKE3("cloak_deposit_note_v1" || nk || noteSalt(32B BE) || info)
|
|
4301
|
-
* privateKey = seed("sk") reduced into the field
|
|
4302
|
-
* blinding = seed("blinding") reduced into the field
|
|
4303
|
-
* publicKey = PoseidonEx(privateKey, KEYPAIR_) [L-02, matches keypair.circom]
|
|
4304
|
-
*
|
|
4305
|
-
* A cold scanner decrypts the chain note with `nk` (AES-GCM, HKDF-salted by the output commitment),
|
|
4306
|
-
* reads `noteSalt` out of the plaintext, replays those three lines, recomputes
|
|
4307
|
-
* `Poseidon(amount, publicKey, blinding, mint)` and requires it to equal a commitment the
|
|
4308
|
-
* transaction actually published. That equality is the authentication: it is not a heuristic, and a
|
|
4309
|
-
* wrong `nk` cannot produce it. Zero extra bytes on chain, no new envelope, no relay change.
|
|
4310
|
-
*
|
|
4311
|
-
* This is the same shape already blessed for swap timeout refunds in `notes/swap-refund.ts`
|
|
4312
|
-
* (PRF(nk, nullifier0)), for the same reason: unrecoverable randomness becomes recoverable
|
|
4313
|
-
* randomness without changing anything an observer can see.
|
|
4314
|
-
*
|
|
4315
|
-
* ── The consequence to be explicit about ──────────────────────────────────────────────────────
|
|
4316
|
-
* The deposit note is owned by a PER-DEPOSIT key rather than by the wallet's single long-lived UTXO
|
|
4317
|
-
* keypair. It is still fully spendable — the wallet re-derives `privateKey` from `nk` whenever it
|
|
4318
|
-
* needs it — and it is strictly better for privacy, because `outPubkey0` no longer links a wallet's
|
|
4319
|
-
* deposits to each other. But it means the caller MUST persist (or be able to re-derive) `nk`, which
|
|
4320
|
-
* a Cloak wallet already does, and it means `transact` must be given an explicit `nk` rather than
|
|
4321
|
-
* inferring one from the output note's own key. `transact` enforces that rather than trusting it.
|
|
4358
|
+
* ── What a deposit note is ────────────────────────────────────────────────────────────────────
|
|
4359
|
+
* A deposit's output note is owned by the wallet's long-lived UTXO keypair (passed explicitly by
|
|
4360
|
+
* the caller) and carries a blinding derived from the wallet's viewing key:
|
|
4361
|
+
*
|
|
4362
|
+
* blinding = BLAKE3("cloak_deposit_note_v1" || nk || noteSalt(32B BE) || "blinding") -> field
|
|
4363
|
+
* owner = ownerUtxoKeypair (deriveUtxoKeypairFromSpendKey(skSpend)), never derived from nk
|
|
4364
|
+
*
|
|
4365
|
+
* The chain note (encrypted under `nk`) publishes `noteSalt`, so a scan holding `nk` and the
|
|
4366
|
+
* wallet's UTXO PUBLIC key can replay the blinding, recompute `Poseidon(amount, ownerPub, blinding,
|
|
4367
|
+
* mint)` and require it to equal a commitment the transaction actually published. That equality is
|
|
4368
|
+
* the authentication. Spending still needs the owner's PRIVATE key, which `nk` cannot produce: the
|
|
4369
|
+
* nullifier is `Poseidon(commitment, index, Poseidon(privateKey, commitment, index))`.
|
|
4370
|
+
*
|
|
4371
|
+
* ── nk is view-only ───────────────────────────────────────────────────────────────────────────
|
|
4372
|
+
* `nk` is registered with the relay for compliance and may be shared with an auditor, so it must
|
|
4373
|
+
* only ever VIEW. The first version of this module derived the owner private key as well, as
|
|
4374
|
+
* PRF(nk, noteSalt). Notes built that way still exist on chain; they are recovered by
|
|
4375
|
+
* {@link matchDepositNote} through {@link deriveLegacyDepositNoteSecrets} and come back flagged
|
|
4376
|
+
* `legacyExposed: true`, so an app can offer to move them under the wallet's own key. No API here
|
|
4377
|
+
* creates a note in that shape any more.
|
|
4322
4378
|
*
|
|
4323
4379
|
* ── Guardrails preserved ──────────────────────────────────────────────────────────────────────
|
|
4324
|
-
* [L-02]
|
|
4325
|
-
*
|
|
4326
|
-
*
|
|
4327
|
-
* `chainNoteHash`; it is only ever published inside the note's own authenticated ciphertext.
|
|
4380
|
+
* [L-02] public keys come from the capacity-tagged `derivePublicKey`. [H-04-shaped] the reduction
|
|
4381
|
+
* forces a non-zero blinding. [M-04] `noteSalt` stays a private input to `chainNoteHash`; it is
|
|
4382
|
+
* only ever published inside the note's own authenticated ciphertext.
|
|
4328
4383
|
*/
|
|
4329
4384
|
|
|
4330
4385
|
/**
|
|
4331
|
-
* The chain note salt is 96 bits
|
|
4386
|
+
* The chain note salt is 96 bits: the circuit constrains it with `Num2Bits(96)` and `transact`
|
|
4332
4387
|
* generates exactly 12 bytes. A salt outside that range would produce a proof the circuit rejects,
|
|
4333
4388
|
* so it is refused here rather than at proof time.
|
|
4334
4389
|
*/
|
|
4335
4390
|
declare const CHAIN_NOTE_SALT_BITS = 96;
|
|
4336
|
-
/** The secrets a deposit note is built from
|
|
4391
|
+
/** The secrets a deposit note is built from. */
|
|
4337
4392
|
interface DepositNoteSecrets {
|
|
4338
4393
|
keypair: UtxoKeypair;
|
|
4339
4394
|
blinding: bigint;
|
|
4340
4395
|
}
|
|
4341
|
-
/** A deposit note recovered
|
|
4396
|
+
/** A deposit note recovered by a scan. */
|
|
4342
4397
|
interface RecoveredDepositNote extends DepositNoteSecrets {
|
|
4343
4398
|
amount: bigint;
|
|
4344
4399
|
mintAddress: Address;
|
|
@@ -4346,30 +4401,67 @@ interface RecoveredDepositNote extends DepositNoteSecrets {
|
|
|
4346
4401
|
commitment: bigint;
|
|
4347
4402
|
/** The salt the chain note carried, which anchored the derivation. */
|
|
4348
4403
|
noteSalt: bigint;
|
|
4404
|
+
/**
|
|
4405
|
+
* `false`: the note is owned by the wallet's long-lived UTXO keypair. `keypair` is the owner
|
|
4406
|
+
* keypair the matcher was given, so `keypair.privateKey` is `0n` when only the public key was
|
|
4407
|
+
* supplied (a view-only scan); substitute the wallet's own keypair before spending.
|
|
4408
|
+
*
|
|
4409
|
+
* `true`: a legacy deposit whose owner key was derived from `nk` (the pre-fix shape). `keypair`
|
|
4410
|
+
* is complete and spendable, and the same is true for anyone holding `nk`, so an app should offer
|
|
4411
|
+
* to move these funds into a note owned by the wallet's long-lived keypair.
|
|
4412
|
+
*/
|
|
4413
|
+
legacyExposed: boolean;
|
|
4349
4414
|
}
|
|
4350
4415
|
/** A fresh 96-bit chain-note salt, from the same fail-closed source `transact` uses. */
|
|
4351
4416
|
declare function randomDepositNoteSalt(): bigint;
|
|
4352
4417
|
/**
|
|
4353
|
-
* Derive a deposit note's
|
|
4418
|
+
* Derive a deposit note's BLINDING from `(nk, noteSalt)`.
|
|
4354
4419
|
*
|
|
4355
|
-
* Deterministic by design: this is
|
|
4356
|
-
*
|
|
4420
|
+
* Deterministic by design: this is what lets a scan rebuild the commitment. The blinding is a view
|
|
4421
|
+
* secret (it hides the amount and owner inside the commitment); it cannot spend anything, because
|
|
4422
|
+
* spending needs the owner's private key. Both current and legacy deposit notes use this blinding.
|
|
4357
4423
|
*/
|
|
4358
|
-
declare function
|
|
4424
|
+
declare function deriveDepositNoteBlinding(viewingKeyNk: Uint8Array, noteSalt: bigint): bigint;
|
|
4425
|
+
/**
|
|
4426
|
+
* LEGACY. The secrets of a deposit note built by the first recoverable-deposit release, whose owner
|
|
4427
|
+
* private key was PRF(nk, noteSalt).
|
|
4428
|
+
*
|
|
4429
|
+
* Exists only so scans can still find and spend those notes. Never build a new note from this: the
|
|
4430
|
+
* owner key is derivable by anyone who holds `nk`.
|
|
4431
|
+
*/
|
|
4432
|
+
declare function deriveLegacyDepositNoteSecrets(viewingKeyNk: Uint8Array, noteSalt: bigint): Promise<DepositNoteSecrets>;
|
|
4433
|
+
/** Parameters for {@link createRecoverableDepositUtxo}. */
|
|
4434
|
+
interface CreateRecoverableDepositUtxoParams {
|
|
4435
|
+
/** Deposit amount in base units. */
|
|
4436
|
+
amount: bigint;
|
|
4437
|
+
/** The wallet's 32-byte viewing base `nk`. Derives the blinding and encrypts the chain note. */
|
|
4438
|
+
viewingKeyNk: Uint8Array;
|
|
4439
|
+
/**
|
|
4440
|
+
* The wallet's long-lived UTXO keypair, which OWNS the note. Required: a deposit note is never
|
|
4441
|
+
* owned by a key derived from `nk`.
|
|
4442
|
+
*/
|
|
4443
|
+
ownerUtxoKeypair: UtxoKeypair;
|
|
4444
|
+
/** Pool mint. Defaults to native SOL. */
|
|
4445
|
+
mintAddress?: Address;
|
|
4446
|
+
/** Pin the 96-bit chain-note salt. Defaults to a fresh random salt. */
|
|
4447
|
+
noteSalt?: bigint;
|
|
4448
|
+
}
|
|
4359
4449
|
/**
|
|
4360
|
-
* Build a deposit output note that a
|
|
4450
|
+
* Build a deposit output note that a scan holding `nk` plus the wallet's UTXO public key can
|
|
4451
|
+
* recover, and that only the holder of the owner's private key can spend.
|
|
4361
4452
|
*
|
|
4362
4453
|
* Returns the UTXO to pass as `outputUtxos[0]` AND the salt that anchored it. The SAME salt must be
|
|
4363
|
-
* handed to `transact` as `options.chainNoteSalt`, because the chain note is what publishes it
|
|
4364
|
-
* salt that does not reach the note leaves the deposit exactly as undiscoverable as before.
|
|
4454
|
+
* handed to `transact` as `options.chainNoteSalt`, because the chain note is what publishes it.
|
|
4365
4455
|
*
|
|
4366
4456
|
* ```ts
|
|
4367
|
-
* const { utxo, noteSalt } = await createRecoverableDepositUtxo(
|
|
4457
|
+
* const { utxo, noteSalt } = await createRecoverableDepositUtxo({
|
|
4458
|
+
* amount, viewingKeyNk: nk, ownerUtxoKeypair, mintAddress: mint,
|
|
4459
|
+
* });
|
|
4368
4460
|
* await transact({ ..., outputUtxos: [utxo], externalAmount: amount },
|
|
4369
|
-
* { chainNoteViewingKeyNk: nk, chainNoteSalt: noteSalt, ... });
|
|
4461
|
+
* { chainNoteViewingKeyNk: nk, chainNoteSalt: noteSalt, ownerUtxoKeypair, ... });
|
|
4370
4462
|
* ```
|
|
4371
4463
|
*/
|
|
4372
|
-
declare function createRecoverableDepositUtxo(
|
|
4464
|
+
declare function createRecoverableDepositUtxo(params: CreateRecoverableDepositUtxoParams): Promise<{
|
|
4373
4465
|
utxo: Utxo;
|
|
4374
4466
|
noteSalt: bigint;
|
|
4375
4467
|
}>;
|
|
@@ -4378,20 +4470,26 @@ interface MatchDepositNoteParams {
|
|
|
4378
4470
|
viewingKeyNk: Uint8Array;
|
|
4379
4471
|
/** `noteSalt`, read out of the decrypted chain note. */
|
|
4380
4472
|
noteSalt: bigint;
|
|
4381
|
-
/** Candidate note amount
|
|
4473
|
+
/** Candidate note amount. For a shield with no inputs this is the public deposit amount. */
|
|
4382
4474
|
amount: bigint;
|
|
4383
4475
|
/** Pool mint the commitment was computed under. */
|
|
4384
4476
|
mintAddress: Address;
|
|
4385
4477
|
/** Output commitments the transaction actually published, hex or field elements. */
|
|
4386
4478
|
outputCommitments: Array<string | bigint>;
|
|
4479
|
+
/**
|
|
4480
|
+
* The wallet's long-lived UTXO keypair. Only `publicKey` is needed for a match; pass
|
|
4481
|
+
* `privateKey: 0n` for a view-only scan, or the real keypair to get a spendable result. Without
|
|
4482
|
+
* it only legacy (nk-owned) deposits can be matched.
|
|
4483
|
+
*/
|
|
4484
|
+
ownerUtxoKeypair?: UtxoKeypair;
|
|
4387
4485
|
}
|
|
4388
4486
|
/**
|
|
4389
|
-
* Decide whether a deposit's published commitment is one this
|
|
4390
|
-
*
|
|
4487
|
+
* Decide whether a deposit's published commitment is one of this wallet's notes, and if so return
|
|
4488
|
+
* it. Returns `null` for everything that is not ours.
|
|
4391
4489
|
*
|
|
4392
|
-
*
|
|
4393
|
-
*
|
|
4394
|
-
*
|
|
4490
|
+
* Tries the current shape first (owner = `ownerUtxoKeypair`), then the legacy shape (owner derived
|
|
4491
|
+
* from `nk`, flagged `legacyExposed`). The commitment equality is the authentication; nothing here
|
|
4492
|
+
* trusts the chain note's own claim about what it describes.
|
|
4395
4493
|
*/
|
|
4396
4494
|
declare function matchDepositNote(params: MatchDepositNoteParams): Promise<RecoveredDepositNote | null>;
|
|
4397
4495
|
|
|
@@ -4433,16 +4531,19 @@ declare function matchDepositNote(params: MatchDepositNoteParams): Promise<Recov
|
|
|
4433
4531
|
* derive one blinding, and `transact`'s fail-closed check could not tell which slot it was looking
|
|
4434
4532
|
* at. With it, every slot has its own answer.
|
|
4435
4533
|
*
|
|
4436
|
-
* ──
|
|
4437
|
-
*
|
|
4438
|
-
*
|
|
4439
|
-
*
|
|
4440
|
-
*
|
|
4441
|
-
* a
|
|
4442
|
-
*
|
|
4534
|
+
* ── Who owns change ───────────────────────────────────────────────────────────────────────────
|
|
4535
|
+
* Change is owned by the wallet's long-lived UTXO keypair, passed explicitly by the caller
|
|
4536
|
+
* (`ownerUtxoKeypair` on the spend flows). It is never inherited from `inputUtxos[0]`: an input may
|
|
4537
|
+
* be a legacy note whose key was derived from `nk`, and inheriting that key would keep the change
|
|
4538
|
+
* spendable by anyone holding the viewing key. Owning change under the wallet key also means that
|
|
4539
|
+
* spending a legacy note produces safe change, which is how legacy funds migrate.
|
|
4540
|
+
*
|
|
4541
|
+
* Only the blinding comes from `nk`. The blinding is a view secret; spending needs the owner's
|
|
4542
|
+
* private key, which `nk` cannot produce.
|
|
4443
4543
|
*
|
|
4444
4544
|
* ── What a cold scan can rebuild, and what it cannot ──────────────────────────────────────────
|
|
4445
|
-
* For the shape that lost the money
|
|
4545
|
+
* For the shape that lost the money (a partial withdrawal) a scan holding `nk` finds the note and
|
|
4546
|
+
* rebuilds its commitment; spending it needs the owner's private key, which the wallet holds.
|
|
4446
4547
|
* `partialWithdraw` emits the change as `outputUtxos[0]`, and a v4 chain note binds
|
|
4447
4548
|
* `noteSemantics = Poseidon(outAmount0, outPubkey0, isSendToSelfKey0)` and carries all three in its
|
|
4448
4549
|
* (encrypted, authenticated) plaintext. So a scanner holding `nk` decrypts the note, reads
|
|
@@ -4461,8 +4562,7 @@ declare function matchDepositNote(params: MatchDepositNoteParams): Promise<Recov
|
|
|
4461
4562
|
* ── Guardrails preserved ──────────────────────────────────────────────────────────────────────
|
|
4462
4563
|
* [M-04] `noteSalt` stays a private input to `chainNoteHash`; it is only ever published inside the
|
|
4463
4564
|
* note's own authenticated ciphertext, so nothing an observer can see changes. [H-04-shaped] the
|
|
4464
|
-
* reduction forces non-zero, because a zero blinding is an unspendable note.
|
|
4465
|
-
* `nk` keep the previous random-blinding behaviour unchanged, so this is additive.
|
|
4565
|
+
* reduction forces non-zero, because a zero blinding is an unspendable note.
|
|
4466
4566
|
*/
|
|
4467
4567
|
|
|
4468
4568
|
/** A change note recovered from `nk` (plus the owner key the spender already holds). */
|
|
@@ -4475,6 +4575,13 @@ interface RecoveredChangeNote {
|
|
|
4475
4575
|
commitment: bigint;
|
|
4476
4576
|
/** The salt the chain note carried, which anchored the derivation. */
|
|
4477
4577
|
noteSalt: bigint;
|
|
4578
|
+
/**
|
|
4579
|
+
* `true` when the note is NOT owned by the wallet's long-lived UTXO keypair: legacy change that
|
|
4580
|
+
* inherited the key of the note it spent (for example an nk-derived deposit or refund key). Such
|
|
4581
|
+
* a note may be spendable by anyone holding `nk`; an app should offer to migrate it. Only
|
|
4582
|
+
* decidable when the wallet's public key is known, so it is `false` when it was not supplied.
|
|
4583
|
+
*/
|
|
4584
|
+
legacyExposed: boolean;
|
|
4478
4585
|
}
|
|
4479
4586
|
/** A fresh 96-bit chain-note salt, from the same fail-closed source `transact` uses. */
|
|
4480
4587
|
declare function randomChangeNoteSalt(): bigint;
|
|
@@ -4486,14 +4593,17 @@ declare function randomChangeNoteSalt(): bigint;
|
|
|
4486
4593
|
*/
|
|
4487
4594
|
declare function deriveChangeNoteBlinding(viewingKeyNk: Uint8Array, noteSalt: bigint, outputIndex: number): bigint;
|
|
4488
4595
|
/**
|
|
4489
|
-
* Build a change output note whose blinding a
|
|
4596
|
+
* Build a change output note whose blinding a scan holding `nk` can re-derive.
|
|
4597
|
+
*
|
|
4598
|
+
* `ownerUtxoKeypair` is the wallet's long-lived UTXO keypair. It is validated (non-zero private key,
|
|
4599
|
+
* public key derived from it), because change must be owned by a key only the wallet holds.
|
|
4490
4600
|
*
|
|
4491
4601
|
* Returns the UTXO AND the salt that anchored it. The SAME salt must reach `transact` as
|
|
4492
4602
|
* `options.chainNoteSalt`, because the chain note is what publishes it — a salt that does not reach
|
|
4493
4603
|
* the note leaves the change exactly as unrecoverable as before. `partialWithdraw` and `transfer`
|
|
4494
4604
|
* do this for you; the pairing is only your concern if you call `transact` directly.
|
|
4495
4605
|
*/
|
|
4496
|
-
declare function createRecoverableChangeUtxo(amount: bigint,
|
|
4606
|
+
declare function createRecoverableChangeUtxo(amount: bigint, ownerUtxoKeypair: UtxoKeypair, viewingKeyNk: Uint8Array, mintAddress?: Address, noteSalt?: bigint, outputIndex?: number): Promise<{
|
|
4497
4607
|
utxo: Utxo;
|
|
4498
4608
|
noteSalt: bigint;
|
|
4499
4609
|
}>;
|
|
@@ -4515,6 +4625,11 @@ interface MatchChangeNoteParams {
|
|
|
4515
4625
|
outputIndex: number;
|
|
4516
4626
|
/** Output commitments the transaction actually published, hex or field elements. */
|
|
4517
4627
|
outputCommitments: Array<string | bigint>;
|
|
4628
|
+
/**
|
|
4629
|
+
* The wallet's long-lived UTXO public key. When supplied, a match whose owner differs from it is
|
|
4630
|
+
* flagged `legacyExposed`.
|
|
4631
|
+
*/
|
|
4632
|
+
ownerUtxoPublicKey?: bigint;
|
|
4518
4633
|
}
|
|
4519
4634
|
/**
|
|
4520
4635
|
* Decide whether a published commitment is a change note this `nk` can rebuild, and if so return it
|
|
@@ -4541,25 +4656,30 @@ declare function matchChangeNote(params: MatchChangeNoteParams): Promise<Recover
|
|
|
4541
4656
|
* viewing key and the swap creator's, and found nothing under either.
|
|
4542
4657
|
*
|
|
4543
4658
|
* ── The fix, and why it is SDK-only ───────────────────────────────────────────────────────────
|
|
4544
|
-
*
|
|
4545
|
-
* nullifier:
|
|
4659
|
+
* The refund leaf is owned by the wallet's long-lived UTXO keypair (passed explicitly), and only
|
|
4660
|
+
* its BLINDING is derived, as a PRF of the owner's `nk` and the swap's own first input nullifier:
|
|
4546
4661
|
*
|
|
4547
|
-
*
|
|
4662
|
+
* blinding = BLAKE3("cloak_swap_refund_v1" || nk || nullifier0 || "blinding") -> field
|
|
4663
|
+
* owner = ownerUtxoKeypair (never derived from nk)
|
|
4548
4664
|
*
|
|
4549
|
-
* `nullifier0` is published in the TransactSwap public inputs, so a
|
|
4550
|
-
*
|
|
4551
|
-
*
|
|
4552
|
-
*
|
|
4553
|
-
*
|
|
4665
|
+
* `nullifier0` is published in the TransactSwap public inputs, so a scanner holding `nk` and the
|
|
4666
|
+
* wallet's UTXO public key can replay the blinding for every swap it sees, recompute R_fb and match
|
|
4667
|
+
* it against the commitment `CloseSwapState` declared. Spending R_fb needs the owner's private key,
|
|
4668
|
+
* which `nk` cannot produce, so the viewing key stays view-only. Every R_fb is distinct because the
|
|
4669
|
+
* blinding differs per `nullifier0`.
|
|
4554
4670
|
*
|
|
4555
4671
|
* This changes NOTHING on chain or in the relay. `refund_pubkey` / `refund_blinding` remain
|
|
4556
|
-
* caller-supplied values bound into `computeSwapExtDataHash`; only their provenance changes
|
|
4557
|
-
*
|
|
4672
|
+
* caller-supplied values bound into `computeSwapExtDataHash`; only their provenance changes.
|
|
4673
|
+
*
|
|
4674
|
+
* ── Legacy refunds ────────────────────────────────────────────────────────────────────────────
|
|
4675
|
+
* The first release of this derivation also derived the refund PRIVATE key from `(nk, nullifier0)`.
|
|
4676
|
+
* Those refunds are still matched (see {@link deriveLegacySwapRefundAuthorization}) and come back
|
|
4677
|
+
* flagged `legacyExposed: true`, because anyone holding `nk` can spend them; an app should migrate
|
|
4678
|
+
* them. No API builds a refund in that shape any more.
|
|
4558
4679
|
*
|
|
4559
4680
|
* ── Guardrails preserved ──────────────────────────────────────────────────────────────────────
|
|
4560
|
-
* [H-04 / DD-01] the
|
|
4561
|
-
*
|
|
4562
|
-
* the capacity-tagged `derivePublicKey`, matching `keypair.circom`.
|
|
4681
|
+
* [H-04 / DD-01] the authorization is rejected unless publicKey and blinding are both non-zero.
|
|
4682
|
+
* [L-02] public keys come from the capacity-tagged `derivePublicKey`, matching `keypair.circom`.
|
|
4563
4683
|
*
|
|
4564
4684
|
* ── FORWARD-LOOKING ONLY ──────────────────────────────────────────────────────────────────────
|
|
4565
4685
|
* Everything here — including `discoverSwapRefunds`, the RPC walker at the bottom of this file —
|
|
@@ -4576,20 +4696,44 @@ interface SwapRefundAuthorization {
|
|
|
4576
4696
|
publicKey: bigint;
|
|
4577
4697
|
blinding: bigint;
|
|
4578
4698
|
}
|
|
4579
|
-
/** A refund leaf matched back to its owner
|
|
4699
|
+
/** A refund leaf matched back to its owner. */
|
|
4580
4700
|
interface RecoveredSwapRefund {
|
|
4701
|
+
/**
|
|
4702
|
+
* The owner keypair. For a current refund this is the `ownerUtxoKeypair` the matcher was given
|
|
4703
|
+
* (`privateKey` is `0n` if only the public key was supplied; substitute the wallet's keypair before
|
|
4704
|
+
* spending). For a legacy refund it is the nk-derived keypair, complete and spendable.
|
|
4705
|
+
*/
|
|
4581
4706
|
keypair: UtxoKeypair;
|
|
4582
4707
|
blinding: bigint;
|
|
4583
4708
|
amount: bigint;
|
|
4584
4709
|
/** R_fb as a field element, identical to the commitment `CloseSwapState` appended. */
|
|
4585
4710
|
commitment: bigint;
|
|
4711
|
+
/**
|
|
4712
|
+
* `true` for a legacy refund whose key was derived from `nk`: spendable by anyone holding `nk`,
|
|
4713
|
+
* so an app should offer to move it under the wallet's own key.
|
|
4714
|
+
*/
|
|
4715
|
+
legacyExposed: boolean;
|
|
4586
4716
|
}
|
|
4587
4717
|
/**
|
|
4588
|
-
* Derive a swap's
|
|
4718
|
+
* Derive a swap refund leaf's BLINDING from the owner's `nk` and the swap's first input nullifier.
|
|
4719
|
+
*
|
|
4720
|
+
* Deterministic by design: this is what makes the refund leaf findable from key material. The
|
|
4721
|
+
* blinding is a view secret and cannot spend the leaf.
|
|
4722
|
+
*/
|
|
4723
|
+
declare function deriveSwapRefundBlinding(viewingKeyNk: Uint8Array, inputNullifier: Uint8Array | bigint): bigint;
|
|
4724
|
+
/**
|
|
4725
|
+
* The refund authorization `swapUtxo` binds into the swap ext-data hash: the wallet's long-lived
|
|
4726
|
+
* UTXO keypair as owner, plus the derived blinding.
|
|
4589
4727
|
*
|
|
4590
|
-
*
|
|
4728
|
+
* `ownerUtxoKeypair` is required and validated. The refund key is never derived from `nk`.
|
|
4729
|
+
*/
|
|
4730
|
+
declare function deriveSwapRefundAuthorization(viewingKeyNk: Uint8Array, inputNullifier: Uint8Array | bigint, ownerUtxoKeypair: UtxoKeypair): Promise<SwapRefundAuthorization>;
|
|
4731
|
+
/**
|
|
4732
|
+
* LEGACY. The refund authorization of the first derived-refund release, whose private key was
|
|
4733
|
+
* PRF(nk, nullifier0). Exists only so scans can still find and spend those refunds; never bind a new
|
|
4734
|
+
* swap to it, because anyone holding `nk` can spend the leaf.
|
|
4591
4735
|
*/
|
|
4592
|
-
declare function
|
|
4736
|
+
declare function deriveLegacySwapRefundAuthorization(viewingKeyNk: Uint8Array, inputNullifier: Uint8Array | bigint): Promise<SwapRefundAuthorization>;
|
|
4593
4737
|
/**
|
|
4594
4738
|
* R_fb, exactly as `CloseSwapState` computes it. The swap principal is always WSOL-locked, so the
|
|
4595
4739
|
* mint term is the native-SOL sentinel.
|
|
@@ -4604,11 +4748,18 @@ interface MatchSwapRefundLeafParams {
|
|
|
4604
4748
|
amountAfterFee: bigint;
|
|
4605
4749
|
/** R_fb as appended on chain. */
|
|
4606
4750
|
commitment: bigint | Uint8Array;
|
|
4751
|
+
/**
|
|
4752
|
+
* The wallet's long-lived UTXO keypair (`privateKey: 0n` is fine for a view-only match). Without
|
|
4753
|
+
* it only legacy refunds can be matched.
|
|
4754
|
+
*/
|
|
4755
|
+
ownerUtxoKeypair?: UtxoKeypair;
|
|
4607
4756
|
}
|
|
4608
4757
|
/**
|
|
4609
|
-
* Decide whether a public refund leaf belongs to
|
|
4610
|
-
*
|
|
4611
|
-
*
|
|
4758
|
+
* Decide whether a public refund leaf belongs to this wallet, and if so return it. Returns `null`
|
|
4759
|
+
* for every leaf that is not ours; a scanner runs this against every close it can see.
|
|
4760
|
+
*
|
|
4761
|
+
* Tries the current shape first (owner = `ownerUtxoKeypair`, blinding from `nk`), then the legacy
|
|
4762
|
+
* shape (key and blinding both from `nk`, flagged `legacyExposed`).
|
|
4612
4763
|
*/
|
|
4613
4764
|
declare function matchSwapRefundLeaf(params: MatchSwapRefundLeafParams): Promise<RecoveredSwapRefund | null>;
|
|
4614
4765
|
/** One recovered refund leaf, with the chain coordinates that produced it. */
|
|
@@ -4623,6 +4774,13 @@ interface DiscoveredSwapRefund extends RecoveredSwapRefund {
|
|
|
4623
4774
|
swapSignature?: string;
|
|
4624
4775
|
}
|
|
4625
4776
|
interface DiscoverSwapRefundsOptions {
|
|
4777
|
+
/**
|
|
4778
|
+
* The wallet's long-lived UTXO keypair: the owner of every refund leaf built by the current SDK.
|
|
4779
|
+
* Required. Pass the real keypair to get spendable results, or `{ privateKey: 0n, publicKey }`
|
|
4780
|
+
* for a view-only scan. Legacy (nk-owned) refunds are found either way and flagged
|
|
4781
|
+
* `legacyExposed`.
|
|
4782
|
+
*/
|
|
4783
|
+
ownerUtxoKeypair: UtxoKeypair;
|
|
4626
4784
|
/** Maximum program signatures to walk. Omit or 0 to walk the whole history. */
|
|
4627
4785
|
limit?: number;
|
|
4628
4786
|
/** Stop when this signature is reached (exclusive) — the cursor from a previous run. */
|
|
@@ -4638,16 +4796,18 @@ interface DiscoverSwapRefundsOptions {
|
|
|
4638
4796
|
poolMint?: Address;
|
|
4639
4797
|
}
|
|
4640
4798
|
/**
|
|
4641
|
-
* Find every swap timeout-refund leaf on chain that belongs to
|
|
4642
|
-
* return each
|
|
4799
|
+
* Find every swap timeout-refund leaf on chain that belongs to this wallet (`viewingKeyNk` plus
|
|
4800
|
+
* `options.ownerUtxoKeypair`), and return each with `keypair`, `blinding`, `amount`, `commitment`
|
|
4801
|
+
* and `legacyExposed`.
|
|
4643
4802
|
*
|
|
4644
4803
|
* Key material only — no relay, no local note store, no prior knowledge of the swap. This is the
|
|
4645
4804
|
* recovery path for the exact situation VK-02 described: `CloseSwapState` appended a funded leaf and
|
|
4646
4805
|
* its owner could not see it under any key they held.
|
|
4647
4806
|
*
|
|
4648
|
-
* FORWARD-LOOKING ONLY. This finds refunds whose
|
|
4649
|
-
*
|
|
4650
|
-
*
|
|
4807
|
+
* FORWARD-LOOKING ONLY. This finds refunds whose blinding was DERIVED from (nk, nullifier0), owned
|
|
4808
|
+
* either by the wallet's UTXO keypair (current) or by an nk-derived key (legacy, flagged).
|
|
4809
|
+
* A swap whose refund keypair and blinding were drawn from raw randomness (every swap submitted
|
|
4810
|
+
* before that derivation shipped) has no derivation to replay,
|
|
4651
4811
|
* and no key-only scan can ever recover it. Those secrets existed solely in the caller's in-memory
|
|
4652
4812
|
* `UtxoSwapResult.refund`. An empty result is therefore NOT proof that a wallet has no stranded
|
|
4653
4813
|
* refund; it means none of the leaves in the scanned window were derivable from this `nk`.
|
|
@@ -4656,7 +4816,7 @@ interface DiscoverSwapRefundsOptions {
|
|
|
4656
4816
|
* @param programId Shield-pool program id.
|
|
4657
4817
|
* @param viewingKeyNk 32-byte `nk` — the same value chain notes are decrypted with.
|
|
4658
4818
|
*/
|
|
4659
|
-
declare function discoverSwapRefunds(connection: CloakRpc, programId: Address, viewingKeyNk: Uint8Array, options
|
|
4819
|
+
declare function discoverSwapRefunds(connection: CloakRpc, programId: Address, viewingKeyNk: Uint8Array, options: DiscoverSwapRefundsOptions): Promise<DiscoveredSwapRefund[]>;
|
|
4660
4820
|
|
|
4661
4821
|
/**
|
|
4662
4822
|
* Compact deterministic chain note format.
|
|
@@ -4767,12 +4927,17 @@ interface ScanResult {
|
|
|
4767
4927
|
*/
|
|
4768
4928
|
deliveredNotes: DeliveredNote[];
|
|
4769
4929
|
/**
|
|
4770
|
-
* This wallet's OWN deposits, rebuilt
|
|
4930
|
+
* This wallet's OWN deposits, rebuilt from `nk` plus `ownerUtxoPublicKey` (VK-01).
|
|
4931
|
+
*
|
|
4932
|
+
* `transactions` records that a deposit happened and for how much. These carry the owner key and
|
|
4933
|
+
* blinding as well. Only deposits built with {@link createRecoverableDepositUtxo} appear here; a
|
|
4934
|
+
* deposit whose blinding came from raw randomness has nothing to rebuild and shows up as a history
|
|
4935
|
+
* row only.
|
|
4771
4936
|
*
|
|
4772
|
-
*
|
|
4773
|
-
*
|
|
4774
|
-
*
|
|
4775
|
-
*
|
|
4937
|
+
* Current deposits are owned by the wallet's long-lived UTXO keypair and need `ownerUtxoPublicKey`
|
|
4938
|
+
* to be matched; they come back with `keypair.privateKey === 0n` (nk cannot produce it) and
|
|
4939
|
+
* `legacyExposed: false`, so substitute the wallet's own keypair before spending. Legacy deposits
|
|
4940
|
+
* (owner key derived from nk) come back complete and flagged `legacyExposed: true`.
|
|
4776
4941
|
*
|
|
4777
4942
|
* Additive, for the same reason as `deliveredNotes`: note secrets are not compliance rows.
|
|
4778
4943
|
*/
|
|
@@ -4783,10 +4948,12 @@ interface ScanResult {
|
|
|
4783
4948
|
* `partialWithdraw` and `swapWithChange` emit change as output 0, and a v4 chain note carries
|
|
4784
4949
|
* `outAmount0`/`outPubkey0`, so `nk` plus the derived blinding is everything the note needs.
|
|
4785
4950
|
*
|
|
4786
|
-
*
|
|
4787
|
-
* the
|
|
4788
|
-
*
|
|
4789
|
-
*
|
|
4951
|
+
* A change note's owner key is never derived from nk: it is the wallet's long-lived UTXO keypair
|
|
4952
|
+
* (or, for legacy change, the key of the note that was spent). So `keypair.privateKey` comes back
|
|
4953
|
+
* as `0n` and the caller supplies its own before spending. Two exceptions, both flagged
|
|
4954
|
+
* `legacyExposed: true`: change owned by a legacy nk-derived deposit key found in the same scan
|
|
4955
|
+
* comes back with that key's private half filled in, and change whose owner is not
|
|
4956
|
+
* `ownerUtxoPublicKey` (when supplied) is flagged so an app can migrate it.
|
|
4790
4957
|
*/
|
|
4791
4958
|
recoveredChangeNotes: RecoveredChangeNoteRecord[];
|
|
4792
4959
|
}
|
|
@@ -4844,9 +5011,14 @@ interface ScanOptions {
|
|
|
4844
5011
|
*/
|
|
4845
5012
|
includeRecipientDeliveries?: boolean;
|
|
4846
5013
|
/**
|
|
4847
|
-
* This wallet's UTXO public key. Supply it to
|
|
4848
|
-
*
|
|
4849
|
-
*
|
|
5014
|
+
* This wallet's long-lived UTXO public key. Supply it to:
|
|
5015
|
+
* - match this wallet's own deposits, which are owned by it (without it only legacy, nk-owned
|
|
5016
|
+
* deposits can be recovered into `recoveredDepositNotes`);
|
|
5017
|
+
* - flag legacy change (`legacyExposed`) whose owner is not this key;
|
|
5018
|
+
* - authenticate each delivery carrier's declared commitment (see
|
|
5019
|
+
* `ScanRecipientDeliveryOptions.ownerUtxoPublicKey`); without it the commitment is reported
|
|
5020
|
+
* unverified.
|
|
5021
|
+
* A public key cannot spend anything, so passing it keeps the scan view-only.
|
|
4850
5022
|
*/
|
|
4851
5023
|
ownerUtxoPublicKey?: bigint;
|
|
4852
5024
|
/** Candidate pool mints for delivery-carrier commitment verification. Defaults to native SOL. */
|
|
@@ -4941,6 +5113,406 @@ declare function toComplianceReport(result: ScanResult): ComplianceReport;
|
|
|
4941
5113
|
/** Format compliance report as CSV for export. */
|
|
4942
5114
|
declare function formatComplianceCsv(report: ComplianceReport): string;
|
|
4943
5115
|
|
|
5116
|
+
/**
|
|
5117
|
+
* Note Index v1 transport (contract revision 2): the head and the pages.
|
|
5118
|
+
*
|
|
5119
|
+
* Every request goes through `relayFetch`, the origin-allowlisted egress chokepoint
|
|
5120
|
+
* (`relay/endpoint.ts`), so nothing here can reach a host the build is not pinned to.
|
|
5121
|
+
*
|
|
5122
|
+
* ── Privacy rule ──────────────────────────────────────────────────────────────────────────────
|
|
5123
|
+
* No request here carries anything that points at a specific note, commitment, nullifier, wallet,
|
|
5124
|
+
* pool or time window. Pages are addressed by epoch and page number only, and every page is
|
|
5125
|
+
* downloaded. Trees are rebuilt from the pages themselves, so nothing else is ever requested.
|
|
5126
|
+
*
|
|
5127
|
+
* Caching: complete pages are served `immutable` with a strong ETag and the tail with
|
|
5128
|
+
* `max-age=5`, so a browser's HTTP cache makes a refresh cheap without any client-side store.
|
|
5129
|
+
* Nothing here persists an ETag (the contract forbids persisting a tail ETag). Compression is
|
|
5130
|
+
* negotiated by the fetch implementation; the decoded size is capped while streaming.
|
|
5131
|
+
*/
|
|
5132
|
+
/** `GET /note-index/v1/head`. */
|
|
5133
|
+
interface NoteIndexHead {
|
|
5134
|
+
format: 1;
|
|
5135
|
+
/** Random id of this index instance; a rebuild or restore gets a new one. */
|
|
5136
|
+
epoch: bigint;
|
|
5137
|
+
pageSize: number;
|
|
5138
|
+
/** Number of published items. */
|
|
5139
|
+
watermark: number;
|
|
5140
|
+
/** Pages with exactly `pageSize` items; they never change. */
|
|
5141
|
+
completePages: number;
|
|
5142
|
+
/** chain_{completePages}, 64 lowercase hex. */
|
|
5143
|
+
chainTip: string;
|
|
5144
|
+
}
|
|
5145
|
+
/** Transport options shared by every note-index request. */
|
|
5146
|
+
interface NoteIndexFetchOptions {
|
|
5147
|
+
signal?: AbortSignal;
|
|
5148
|
+
/** Per-attempt timeout. Default 30 s. */
|
|
5149
|
+
timeoutMs?: number;
|
|
5150
|
+
/** Retries after the first attempt, for network errors, 429 and 5xx. Default 3. */
|
|
5151
|
+
maxRetries?: number;
|
|
5152
|
+
}
|
|
5153
|
+
/** Fetch and validate `GET /note-index/v1/head`. */
|
|
5154
|
+
declare function fetchNoteIndexHead(relayUrl: string, options?: NoteIndexFetchOptions): Promise<NoteIndexHead>;
|
|
5155
|
+
/**
|
|
5156
|
+
* Fetch the raw bytes of `GET /note-index/v1/e/{epoch}/pages/{n}`, with the decoded size bounded
|
|
5157
|
+
* to {@link NOTE_INDEX_MAX_PAGE_BYTES} while streaming. Parse with
|
|
5158
|
+
* `parseNoteIndexPage(bytes, { epoch, page })`.
|
|
5159
|
+
*/
|
|
5160
|
+
declare function fetchNoteIndexPage(relayUrl: string, epoch: bigint, page: number, options?: NoteIndexFetchOptions): Promise<Uint8Array>;
|
|
5161
|
+
|
|
5162
|
+
/** Items per page. A page is complete iff it holds exactly this many items. */
|
|
5163
|
+
declare const NOTE_INDEX_PAGE_SIZE = 1024;
|
|
5164
|
+
/** Leaf index of an all-zero (never appended) commitment. */
|
|
5165
|
+
declare const NOTE_INDEX_NO_LEAF = 18446744073709551615n;
|
|
5166
|
+
/** Thrown for every byte sequence that is not a well-formed Note Index v1 page or head. */
|
|
5167
|
+
declare class NoteIndexFormatError extends Error {
|
|
5168
|
+
constructor(message: string);
|
|
5169
|
+
}
|
|
5170
|
+
/** kind 1: one confirmed Cloak Transact / TransactSwap instruction, with its note if any. */
|
|
5171
|
+
interface NoteIndexTxItem {
|
|
5172
|
+
kind: 1;
|
|
5173
|
+
mint: Uint8Array;
|
|
5174
|
+
slot: bigint;
|
|
5175
|
+
blockPos: number;
|
|
5176
|
+
/** 0 Transact, 1 TransactSwap. */
|
|
5177
|
+
ixTag: number;
|
|
5178
|
+
/** Signed public amount from the public inputs (positive for a deposit). */
|
|
5179
|
+
publicAmount: bigint;
|
|
5180
|
+
nullifier0: Uint8Array;
|
|
5181
|
+
nullifier1: Uint8Array;
|
|
5182
|
+
comm0: Uint8Array;
|
|
5183
|
+
/** {@link NOTE_INDEX_NO_LEAF} iff comm0 is all zero. */
|
|
5184
|
+
leaf0: bigint;
|
|
5185
|
+
comm1: Uint8Array;
|
|
5186
|
+
leaf1: bigint;
|
|
5187
|
+
/** 0 none, 1 inline in the instruction data, 2 CLK1 carrier. */
|
|
5188
|
+
noteSource: number;
|
|
5189
|
+
/** The bare chain-note envelope `[version][AES-GCM ct || tag]`; empty when noteSource is 0. */
|
|
5190
|
+
note: Uint8Array;
|
|
5191
|
+
/** The Cloak program transaction. Relay-supplied metadata, not proof of anything. */
|
|
5192
|
+
signature: Uint8Array;
|
|
5193
|
+
}
|
|
5194
|
+
/** kind 2: a CLKD1 recipient-delivery envelope. */
|
|
5195
|
+
interface NoteIndexDeliveryItem {
|
|
5196
|
+
kind: 2;
|
|
5197
|
+
mint: Uint8Array;
|
|
5198
|
+
slot: bigint;
|
|
5199
|
+
/** output_commitment[0] of the source transaction. */
|
|
5200
|
+
commitment: Uint8Array;
|
|
5201
|
+
leaf: bigint;
|
|
5202
|
+
envelope: Uint8Array;
|
|
5203
|
+
signature: Uint8Array;
|
|
5204
|
+
}
|
|
5205
|
+
/** kind 3: an R_fb swap refund leaf appended by CloseSwapState. */
|
|
5206
|
+
interface NoteIndexSwapRefundItem {
|
|
5207
|
+
kind: 3;
|
|
5208
|
+
/** Always WSOL. */
|
|
5209
|
+
mint: Uint8Array;
|
|
5210
|
+
slot: bigint;
|
|
5211
|
+
commitment: Uint8Array;
|
|
5212
|
+
leaf: bigint;
|
|
5213
|
+
amountAfterFee: bigint;
|
|
5214
|
+
/** The swap's first input nullifier (TransactSwap public inputs +104). */
|
|
5215
|
+
nullifier0: Uint8Array;
|
|
5216
|
+
/** The close transaction. */
|
|
5217
|
+
signature: Uint8Array;
|
|
5218
|
+
}
|
|
5219
|
+
type NoteIndexItem = NoteIndexTxItem | NoteIndexDeliveryItem | NoteIndexSwapRefundItem;
|
|
5220
|
+
interface NoteIndexPage {
|
|
5221
|
+
epoch: bigint;
|
|
5222
|
+
page: bigint;
|
|
5223
|
+
firstSeq: bigint;
|
|
5224
|
+
complete: boolean;
|
|
5225
|
+
/** The item count the header declared, unknown kinds included. */
|
|
5226
|
+
count: number;
|
|
5227
|
+
/** chain_page: the hash chain value BEFORE this page. */
|
|
5228
|
+
prevChain: Uint8Array;
|
|
5229
|
+
/** Items of known kinds, in page order. */
|
|
5230
|
+
items: NoteIndexItem[];
|
|
5231
|
+
/** Raw `kind | body_len | body` bytes of each entry of `items`, same order. */
|
|
5232
|
+
rawItems: Uint8Array[];
|
|
5233
|
+
/** Items of unknown kinds, skipped by `body_len`. */
|
|
5234
|
+
skippedUnknown: number;
|
|
5235
|
+
}
|
|
5236
|
+
/** Input to {@link encodeNoteIndexPage}. */
|
|
5237
|
+
interface EncodeNoteIndexPageParams {
|
|
5238
|
+
epoch: bigint | number;
|
|
5239
|
+
page: bigint | number;
|
|
5240
|
+
firstSeq: bigint | number;
|
|
5241
|
+
complete: boolean;
|
|
5242
|
+
prevChain: Uint8Array;
|
|
5243
|
+
items: NoteIndexItem[];
|
|
5244
|
+
}
|
|
5245
|
+
/**
|
|
5246
|
+
* Parse one page, strictly. Throws {@link NoteIndexFormatError} on anything that is not exactly a
|
|
5247
|
+
* Note Index v1 page: wrong magic/version, unknown flag bits, non-zero reserved bytes, a count over
|
|
5248
|
+
* 1024, a complete page whose count is not 1024, first_seq that is not page * 1024, an epoch or page
|
|
5249
|
+
* other than `expect`, an item whose body_len differs from the exact length of its kind, a note
|
|
5250
|
+
* whose version disagrees with its length, an out-of-range ix_tag / note_source, a refund whose mint
|
|
5251
|
+
* is not WSOL, an unknown kind longer than 1024 bytes, a truncated item, or trailing bytes.
|
|
5252
|
+
*/
|
|
5253
|
+
declare function parseNoteIndexPage(bytes: Uint8Array, expect?: {
|
|
5254
|
+
epoch: bigint;
|
|
5255
|
+
page: number;
|
|
5256
|
+
}): NoteIndexPage;
|
|
5257
|
+
/**
|
|
5258
|
+
* Parse ONE raw item (`kind | body_len | body`), as kept in `NoteIndexPage.rawItems` and in a
|
|
5259
|
+
* persisted cursor. Same strictness as the page parser; unknown kinds are an error here.
|
|
5260
|
+
*/
|
|
5261
|
+
declare function parseNoteIndexItem(raw: Uint8Array): NoteIndexItem;
|
|
5262
|
+
/** chain_{n+1} = sha256(chain_n || items bytes of page n), for a COMPLETE page's raw bytes. */
|
|
5263
|
+
declare function computeNoteIndexChain(prevChain: Uint8Array, pageBytes: Uint8Array): Uint8Array;
|
|
5264
|
+
/** Encode one item as `kind | body_len | body`. */
|
|
5265
|
+
declare function encodeNoteIndexItem(item: NoteIndexItem): Uint8Array;
|
|
5266
|
+
/**
|
|
5267
|
+
* Encode a page exactly as the relay serves it. The relay is the producer; this exists so both
|
|
5268
|
+
* sides pin the same golden vector and so tests can serve real pages from a stub.
|
|
5269
|
+
*/
|
|
5270
|
+
declare function encodeNoteIndexPage(params: EncodeNoteIndexPageParams): Uint8Array;
|
|
5271
|
+
|
|
5272
|
+
/**
|
|
5273
|
+
* Restore a wallet's notes from the relay's Note Index v1 (contract revision 2.1), without walking
|
|
5274
|
+
* the chain and without telling anyone which notes, pools or nullifiers are its own.
|
|
5275
|
+
*
|
|
5276
|
+
* ── What this replaces ────────────────────────────────────────────────────────────────────────
|
|
5277
|
+
* `scanTransactions` enumerates the program's whole signature history and fetches every
|
|
5278
|
+
* transaction over RPC (thousands of paid calls, minutes). The relay indexes every confirmed Cloak
|
|
5279
|
+
* transaction once and serves all of it in bulk; this downloads every page, decrypts and matches
|
|
5280
|
+
* locally, rebuilds every listed pool's commitment tree from the index's own leaf stream, and spends
|
|
5281
|
+
* exactly ONE RPC request: a `getMultipleAccounts` of every listed pool's tree account, to check the
|
|
5282
|
+
* rebuilt trees. Spent status comes from the nullifiers in the index, so no nullifier of the user
|
|
5283
|
+
* reaches the relay or the RPC.
|
|
5284
|
+
*
|
|
5285
|
+
* ── Trust model (every byte from the relay is untrusted) ──────────────────────────────────────
|
|
5286
|
+
* A note is returned only when all of these hold:
|
|
5287
|
+
* (a) it decrypts / opens under the caller's own keys;
|
|
5288
|
+
* (b) the commitment recomputed from the decrypted values and an owner public key equals the
|
|
5289
|
+
* item's commitment, that owner key is the caller's `ownerUtxoKeypair.publicKey` (or a legacy
|
|
5290
|
+
* key this same recovery derived from nk), and derivePublicKey(privateKey) === publicKey for
|
|
5291
|
+
* the keypair returned. A relay cannot plant a note under somebody else's key and have it
|
|
5292
|
+
* counted as balance (the R2 fake-balance fix: `matchChangeNote` accepts any `outPubkey0`,
|
|
5293
|
+
* so the index path refuses every owner that is not the caller's);
|
|
5294
|
+
* (c) the commitment sits at the item's leaf in the tree rebuilt from the index's leaf stream,
|
|
5295
|
+
* and that leaf lies in a prefix of the stream the chain's tree account authenticates: the
|
|
5296
|
+
* whole stream when its root is the account's current root or one in its root history, or
|
|
5297
|
+
* the leaves under a COMPLETE node the account still stores in its frontier (`subtrees`,
|
|
5298
|
+
* see `readTreeAccountFrontier`), which keeps old notes verifiable when a busy pool has
|
|
5299
|
+
* moved more than the 100-root history past the index. Unverifiable candidates are counted
|
|
5300
|
+
* in `pending`, never returned, and carried in the cursor until they verify.
|
|
5301
|
+
* A lying relay can hide items. It cannot inject a note, alter one, or point one at a wrong leaf.
|
|
5302
|
+
* A HIDDEN nullifier makes a spent note look unspent; the spend-time `preflightNullifiers` in every
|
|
5303
|
+
* spend entry point is what catches that, and it stays mandatory.
|
|
5304
|
+
*
|
|
5305
|
+
* ── The cursor never depends on what the wallet owns (contract property 1) ────────────────────
|
|
5306
|
+
* Every run downloads from the persisted cursor page, so that page must be a function of public
|
|
5307
|
+
* data only. It is always `floor(complete_pages / 8) * 8` of the head this run saw (or the previous
|
|
5308
|
+
* page when a public condition holds it: more out-of-order leaves than the cursor may carry). It is
|
|
5309
|
+
* NEVER held back by this wallet's candidates: a candidate that cannot be verified yet travels
|
|
5310
|
+
* INSIDE the cursor instead (its raw item bytes, plus the stream's own value at its leaf, which is
|
|
5311
|
+
* exactly the value the client hashed into its frontier), bounded by `MAX_CARRIED_PENDING`, so a
|
|
5312
|
+
* later run can verify it without re-reading the pages it came from. A full re-sync from page 0 is
|
|
5313
|
+
* likewise only ever triggered by public conditions (an epoch change, a broken hash chain, a later
|
|
5314
|
+
* item that rewrites or fills the tree before the cursor, a rebuilt tree the chain disproves), never
|
|
5315
|
+
* by anything about this wallet's own items, so the request pattern of two wallets with the same
|
|
5316
|
+
* cursor is identical.
|
|
5317
|
+
*
|
|
5318
|
+
* ── Legacy (nk-derived owner keys) ────────────────────────────────────────────────────────────
|
|
5319
|
+
* Notes whose owner key older releases derived from nk are spendable by anyone holding nk. They are
|
|
5320
|
+
* returned in `atRisk`, never in `notes`, so an app can migrate them without counting them as
|
|
5321
|
+
* balance.
|
|
5322
|
+
*
|
|
5323
|
+
* Some older clients also encrypted their chain notes under a viewing key that is not the wallet's
|
|
5324
|
+
* canonical nk (mobile used SHA-512 of the public wallet address, or the embedded wallet's nsk).
|
|
5325
|
+
* Pass those as `legacyViewingKeyNks` to find such notes in the same download, at no extra request:
|
|
5326
|
+
* every item is trial-opened under the canonical nk first, then under each legacy key. A legacy key
|
|
5327
|
+
* only ever FINDS notes. Everything that opened only under one is returned in `atRisk`, whatever
|
|
5328
|
+
* its owner key (a legacy key may be public, so the relay and anyone else can read those notes), it
|
|
5329
|
+
* never opens a recipient delivery (the delivery rail never used one), and nothing a legacy key opens
|
|
5330
|
+
* can enter `notes`. A note of this wallet's that spends a legacy note and is encrypted under the
|
|
5331
|
+
* canonical nk (a migration) is matched normally and lands in `notes`.
|
|
5332
|
+
*
|
|
5333
|
+
* ── Refund leaves ─────────────────────────────────────────────────────────────────────────────
|
|
5334
|
+
* CloseSwapState appends R_fb to the WSOL MAIN tree (`["merkle_tree", WSOL]`; the separate refund
|
|
5335
|
+
* tree belonged to the retired ClaimRefund design and the program rejects it). So SWAP_REFUND
|
|
5336
|
+
* leaves are part of the WSOL leaf stream here, interleaved with TX leaves. Treating them as a
|
|
5337
|
+
* separate tree would leave a gap at every refund leaf and the WSOL root could never verify.
|
|
5338
|
+
*/
|
|
5339
|
+
|
|
5340
|
+
type IndexedRecoveredNoteKind = "deposit" | "change" | "received" | "swap_refund";
|
|
5341
|
+
/** A verified note restored from the index. */
|
|
5342
|
+
interface IndexedRecoveredNote {
|
|
5343
|
+
kind: IndexedRecoveredNoteKind;
|
|
5344
|
+
/**
|
|
5345
|
+
* Ready to spend: `keypair` has the real private key, plus `blinding`, `amount`, `mintAddress`,
|
|
5346
|
+
* `index` (leaf, verified against the on-chain tree) and `commitment`.
|
|
5347
|
+
*/
|
|
5348
|
+
utxo: Utxo;
|
|
5349
|
+
/** Base58 signature the relay attached. Metadata only, NOT proof of payment. */
|
|
5350
|
+
signature: string;
|
|
5351
|
+
/**
|
|
5352
|
+
* `true` for every `atRisk` note (owner key derivable from nk, or found through a legacy viewing
|
|
5353
|
+
* key), `false` for `notes`.
|
|
5354
|
+
*/
|
|
5355
|
+
legacyExposed: boolean;
|
|
5356
|
+
}
|
|
5357
|
+
/**
|
|
5358
|
+
* The persisted resume point. JSON-serializable and holds NO key material, but `own` records which
|
|
5359
|
+
* index items are this wallet's, so store it as privately as the notes themselves, and never hand
|
|
5360
|
+
* one wallet's cursor to another wallet.
|
|
5361
|
+
*
|
|
5362
|
+
* Version 2. Any other version (including the v1 cursor of the first release), or anything that
|
|
5363
|
+
* fails validation, is ignored with a warning and the run re-syncs from page 0.
|
|
5364
|
+
*/
|
|
5365
|
+
interface NoteIndexCursor {
|
|
5366
|
+
v: 2;
|
|
5367
|
+
/** Index epoch (u64, decimal). A different epoch at the relay means a full re-sync. */
|
|
5368
|
+
epoch: string;
|
|
5369
|
+
/**
|
|
5370
|
+
* First page the next run downloads: `floor(complete_pages / 8) * 8` of a head this wallet saw.
|
|
5371
|
+
* Public data only; it never depends on which items are this wallet's.
|
|
5372
|
+
*/
|
|
5373
|
+
page: number;
|
|
5374
|
+
/** chain_page, 64 hex. */
|
|
5375
|
+
chain: string;
|
|
5376
|
+
/** Highest watermark seen in this epoch; a lower one is refused (`NoteIndexHeadBehindError`). */
|
|
5377
|
+
watermark: number;
|
|
5378
|
+
/** Items below this seq were covered by a pass from page 0; only later items can trigger one. */
|
|
5379
|
+
fullPassSeq: number;
|
|
5380
|
+
/** Per listed pool mint: its leaf stream as rebuilt from every page before `page`. Public data. */
|
|
5381
|
+
trees: Record<string, {
|
|
5382
|
+
frontier: MerkleFrontierState;
|
|
5383
|
+
/** Leaves past a gap, `[leaf, 64 hex]`, waiting for the gap to fill. */
|
|
5384
|
+
pending: Array<[number, string]>;
|
|
5385
|
+
/** Values (64 hex each, concatenated) of the leaves right below `frontier.nextIndex`. */
|
|
5386
|
+
window: string;
|
|
5387
|
+
/** Leaves `[0, verified)` were authenticated against the chain. */
|
|
5388
|
+
verified: number;
|
|
5389
|
+
/** `[leaf, 64 hex]` corrections the chain accepted over the first item for that leaf. */
|
|
5390
|
+
overrides: Array<[number, string]>;
|
|
5391
|
+
/** The chain disproved this stream and a pass from page 0 did not fix it. */
|
|
5392
|
+
mismatch: boolean;
|
|
5393
|
+
}>;
|
|
5394
|
+
/** This wallet's state. Private. */
|
|
5395
|
+
own: {
|
|
5396
|
+
/** Raw items (hex) from pages before `page` that hold a verified or a carried pending note. */
|
|
5397
|
+
items: Array<{
|
|
5398
|
+
seq: number;
|
|
5399
|
+
item: string;
|
|
5400
|
+
}>;
|
|
5401
|
+
/** `mint:leaf:commitmentHex` of every note that verified. */
|
|
5402
|
+
verified: string[];
|
|
5403
|
+
/** Nullifiers (hex) already seen spending one of this wallet's notes. */
|
|
5404
|
+
spent: string[];
|
|
5405
|
+
/** `[mint, leaf, 64 hex]`: the stream's value at each carried pending note's leaf. */
|
|
5406
|
+
pendingLeaves: Array<[string, number, string]>;
|
|
5407
|
+
/** Identities (32 hex) of items rejected for good. */
|
|
5408
|
+
rejected: string[];
|
|
5409
|
+
};
|
|
5410
|
+
}
|
|
5411
|
+
interface RecoverNotesFromIndexParams {
|
|
5412
|
+
/** Relay base URL. Must be on this build's origin allowlist. */
|
|
5413
|
+
relayUrl: string;
|
|
5414
|
+
/** Used for exactly one request: a `getMultipleAccounts` of every listed pool's tree account. */
|
|
5415
|
+
connection: CloakRpc;
|
|
5416
|
+
programId: Address;
|
|
5417
|
+
/** Every active pool mint. Trees are rebuilt and checked for ALL of them, not only where notes are. */
|
|
5418
|
+
poolMints: Address[];
|
|
5419
|
+
/** The wallet's 32-byte viewing base. */
|
|
5420
|
+
viewingKeyNk: Uint8Array;
|
|
5421
|
+
/**
|
|
5422
|
+
* Other 32-byte viewing keys older clients of this wallet encrypted chain notes under (at most
|
|
5423
|
+
* 8). Scan only: every note found through one is returned in `atRisk`, never in `notes`, and a
|
|
5424
|
+
* legacy key never opens a recipient delivery. Costs local trial decryptions, no extra request.
|
|
5425
|
+
* Entries equal to `viewingKeyNk` are ignored.
|
|
5426
|
+
*/
|
|
5427
|
+
legacyViewingKeyNks?: Uint8Array[];
|
|
5428
|
+
/** The wallet's long-lived UTXO keypair, with its real private key. */
|
|
5429
|
+
ownerUtxoKeypair: UtxoKeypair;
|
|
5430
|
+
/** The `cursor` of the previous run. Omit for a full sync. */
|
|
5431
|
+
cursor?: NoteIndexCursor;
|
|
5432
|
+
/** Per mint: ignore legacy-shaped (nk-owned) notes at or after this leaf (a release cutoff). */
|
|
5433
|
+
legacyCutoffLeaf?: Record<string, bigint>;
|
|
5434
|
+
/** Pages in flight. Default 6. */
|
|
5435
|
+
concurrency?: number;
|
|
5436
|
+
onProgress?: (p: {
|
|
5437
|
+
pagesDone: number;
|
|
5438
|
+
pagesTotal: number;
|
|
5439
|
+
itemsChecked: number;
|
|
5440
|
+
notesFound: number;
|
|
5441
|
+
}) => void;
|
|
5442
|
+
signal?: AbortSignal;
|
|
5443
|
+
}
|
|
5444
|
+
interface NoteIndexRecoveryStats {
|
|
5445
|
+
/** Pages downloaded and parsed. */
|
|
5446
|
+
pages: number;
|
|
5447
|
+
/** Items checked (known kinds). */
|
|
5448
|
+
items: number;
|
|
5449
|
+
/** Bytes downloaded (decoded). */
|
|
5450
|
+
bytes: number;
|
|
5451
|
+
/** RPC requests sent through `connection`. */
|
|
5452
|
+
rpcCalls: number;
|
|
5453
|
+
ms: number;
|
|
5454
|
+
/**
|
|
5455
|
+
* Candidates rejected for good: commitment not reproducible from the opened values, not at the
|
|
5456
|
+
* declared leaf of the verified tree, a duplicate (mint, leaf), a legacy note past the cutoff, a
|
|
5457
|
+
* keypair that failed the derivePublicKey check, or an item already rejected by an earlier run.
|
|
5458
|
+
*/
|
|
5459
|
+
dropped: number;
|
|
5460
|
+
/** Items that opened under this wallet's keys. */
|
|
5461
|
+
decrypted: number;
|
|
5462
|
+
/** Matched candidates before the tree and spent checks. */
|
|
5463
|
+
candidates: number;
|
|
5464
|
+
/** Verified notes whose nullifier the index shows as spent. */
|
|
5465
|
+
spent: number;
|
|
5466
|
+
/** Leaves two items assigned different commitments to. */
|
|
5467
|
+
conflicts: number;
|
|
5468
|
+
/** Pending candidates over the carry limit, not carried to the next run. */
|
|
5469
|
+
pendingDropped: number;
|
|
5470
|
+
}
|
|
5471
|
+
interface RecoverNotesFromIndexResult {
|
|
5472
|
+
/** Verified, unspent, owned by `ownerUtxoKeypair`; deduped by (mint, leaf). */
|
|
5473
|
+
notes: IndexedRecoveredNote[];
|
|
5474
|
+
/**
|
|
5475
|
+
* Verified, unspent, and either owned by an nk-derived legacy key (spendable by nk holders) or
|
|
5476
|
+
* found only through a `legacyViewingKeyNks` entry (readable by whoever holds that key). Migrate.
|
|
5477
|
+
*/
|
|
5478
|
+
atRisk: IndexedRecoveredNote[];
|
|
5479
|
+
/**
|
|
5480
|
+
* Candidates not verifiable yet (tree or root not caught up). Carried in the cursor. It depends on
|
|
5481
|
+
* what this wallet owns (a relay can make it non-zero for the owner of one item), so never let it
|
|
5482
|
+
* decide whether or what to download: gate polls on the public head (epoch, watermark) alone.
|
|
5483
|
+
*/
|
|
5484
|
+
pending: number;
|
|
5485
|
+
/** Persist and pass back as `cursor`. */
|
|
5486
|
+
cursor: NoteIndexCursor;
|
|
5487
|
+
stats: NoteIndexRecoveryStats;
|
|
5488
|
+
/** Non-fatal events, e.g. a re-sync from page 0. Generic text: never a key, a mint or a note. */
|
|
5489
|
+
warnings: string[];
|
|
5490
|
+
}
|
|
5491
|
+
/**
|
|
5492
|
+
* The relay's head is behind a watermark this cursor already saw in the same epoch: a cached head
|
|
5493
|
+
* from a stale CDN edge, or a rollback. Nothing was discarded; retry later with the SAME cursor.
|
|
5494
|
+
* If it persists, the index was rolled back without a new epoch (a relay bug): only then drop the
|
|
5495
|
+
* cursor to re-sync from page 0.
|
|
5496
|
+
*/
|
|
5497
|
+
declare class NoteIndexHeadBehindError extends Error {
|
|
5498
|
+
readonly cursorWatermark: number;
|
|
5499
|
+
readonly headWatermark: number;
|
|
5500
|
+
readonly retryable: true;
|
|
5501
|
+
constructor(cursorWatermark: number, headWatermark: number);
|
|
5502
|
+
}
|
|
5503
|
+
/**
|
|
5504
|
+
* Restore every verified, unspent note this wallet owns from the relay's note index.
|
|
5505
|
+
*
|
|
5506
|
+
* Downloads every page from the cursor (or page 0), opens each item locally, rebuilds every listed
|
|
5507
|
+
* pool's tree from the index's leaf stream, checks the trees with ONE `getMultipleAccounts`, and
|
|
5508
|
+
* computes spent status from the index's nullifiers. Persist the returned `cursor`; the next run
|
|
5509
|
+
* re-downloads from it, so dedupe against held notes by (mint, leaf).
|
|
5510
|
+
*
|
|
5511
|
+
* Throws `NoteIndexHeadBehindError` (retryable, nothing discarded) when the relay's head is behind
|
|
5512
|
+
* the cursor. An unusable cursor is never an exception: it is ignored with a warning.
|
|
5513
|
+
*/
|
|
5514
|
+
declare function recoverNotesFromIndex(params: RecoverNotesFromIndexParams): Promise<RecoverNotesFromIndexResult>;
|
|
5515
|
+
|
|
4944
5516
|
/**
|
|
4945
5517
|
* Automatic UTXO Wallet Manager
|
|
4946
5518
|
*
|
|
@@ -5317,12 +5889,27 @@ declare function fundReceiverViaPaymaster(relayUrl: string, receiver: KeyPairSig
|
|
|
5317
5889
|
/**
|
|
5318
5890
|
* Deriving a bridge receiving address.
|
|
5319
5891
|
*
|
|
5320
|
-
* One single-use address per deposit, from the wallet's own key material.
|
|
5321
|
-
* and stateless
|
|
5322
|
-
* seen this deposit before.
|
|
5892
|
+
* One single-use address per deposit, from the wallet's own SPEND-level key material.
|
|
5893
|
+
* Deterministic, offline, and stateless, which is what lets every other function here work on a
|
|
5894
|
+
* device that has never seen this deposit before.
|
|
5895
|
+
*
|
|
5896
|
+
* The receiver is a full Solana signer and bridged funds sit at it in transit, so it must not be
|
|
5897
|
+
* derivable from the viewing key `nk` (which is registered with the relay and may be shared). It is
|
|
5898
|
+
* derived from the wallet's long-lived UTXO private key:
|
|
5899
|
+
*
|
|
5900
|
+
* key = BLAKE3("cloak_bridge_receiver_key_v2" || utxoPrivateKey(32B BE))
|
|
5901
|
+
* seed = HMAC-SHA512(key, "cloak_bridge_escrow_v2:<index>")[0..32]
|
|
5902
|
+
* receiver = ed25519 signer from seed
|
|
5903
|
+
*
|
|
5904
|
+
* Receivers from the first release were HMAC-SHA512(nk, "cloak_bridge_escrow:<index>"). They are
|
|
5905
|
+
* still derived by {@link deriveLegacyBridgeReceiver} so discovery can find in-flight legacy
|
|
5906
|
+
* deposits and finish them; no new deposit is ever routed to one.
|
|
5323
5907
|
*/
|
|
5324
5908
|
|
|
5909
|
+
/** LEGACY label: receivers derived from the viewing key `nk`. Discovery only. */
|
|
5325
5910
|
declare const BRIDGE_ESCROW_LABEL = "cloak_bridge_escrow";
|
|
5911
|
+
/** Current label: receivers derived from the wallet's spend-level key material. */
|
|
5912
|
+
declare const BRIDGE_ESCROW_LABEL_V2 = "cloak_bridge_escrow_v2";
|
|
5326
5913
|
/**
|
|
5327
5914
|
* The index MUST be a small sequential counter (0, 1, 2, …), never a timestamp.
|
|
5328
5915
|
*
|
|
@@ -5340,12 +5927,21 @@ declare const BRIDGE_ESCROW_LABEL = "cloak_bridge_escrow";
|
|
|
5340
5927
|
*/
|
|
5341
5928
|
declare const MAX_RECEIVER_INDEX = 10000;
|
|
5342
5929
|
/**
|
|
5930
|
+
* Derive the bridge receiving address for `index` from the wallet's long-lived UTXO keypair.
|
|
5931
|
+
*
|
|
5343
5932
|
* Async because kit derives a signer's public key through WebCrypto's non-extractable ed25519 key
|
|
5344
|
-
* import (`signerFromSecretKey`, `solana/signer.ts`)
|
|
5345
|
-
* `KeyPairSigner`.
|
|
5346
|
-
|
|
5933
|
+
* import (`signerFromSecretKey`, `solana/signer.ts`); there is no synchronous path to a kit
|
|
5934
|
+
* `KeyPairSigner`.
|
|
5935
|
+
*/
|
|
5936
|
+
declare function deriveBridgeReceiver(ownerUtxoKeypair: UtxoKeypair, index: number): Promise<KeyPairSigner>;
|
|
5937
|
+
/**
|
|
5938
|
+
* LEGACY. The receiving address the first bridge release derived from the viewing key `nk`.
|
|
5939
|
+
*
|
|
5940
|
+
* Exists only so discovery can find, finish and clean up deposits that were routed to these
|
|
5941
|
+
* addresses before the fix. Never quote or route a new deposit to one: anyone holding `nk` can sign
|
|
5942
|
+
* for it.
|
|
5347
5943
|
*/
|
|
5348
|
-
declare function
|
|
5944
|
+
declare function deriveLegacyBridgeReceiver(nk: Uint8Array | Buffer, index: number): Promise<KeyPairSigner>;
|
|
5349
5945
|
|
|
5350
5946
|
type BridgeDepositState =
|
|
5351
5947
|
/** Nothing ever happened at this index. */
|
|
@@ -5390,6 +5986,16 @@ interface BridgeDeposit {
|
|
|
5390
5986
|
shieldSignatures?: string[];
|
|
5391
5987
|
/** Set only when state is "unknown": the failure that made this index's status unconfirmable. */
|
|
5392
5988
|
error?: string;
|
|
5989
|
+
/**
|
|
5990
|
+
* `true` when the receiver is a LEGACY address derived from a viewing key `nk` (the first bridge
|
|
5991
|
+
* release). Anyone holding that `nk` can sign for it, so funds still sitting there should be
|
|
5992
|
+
* shielded promptly. Re-derive its signer with `deriveLegacyBridgeReceiver(legacyViewingKeyNk,
|
|
5993
|
+
* index)`. Legacy indices are a separate address space from current ones, so they never count
|
|
5994
|
+
* toward the next free current index.
|
|
5995
|
+
*/
|
|
5996
|
+
legacyExposed: boolean;
|
|
5997
|
+
/** For a legacy entry: the `nk` its receiver was derived from. */
|
|
5998
|
+
legacyViewingKeyNk?: Uint8Array;
|
|
5393
5999
|
}
|
|
5394
6000
|
interface DiscoverOptions {
|
|
5395
6001
|
/**
|
|
@@ -5413,6 +6019,14 @@ interface DiscoverOptions {
|
|
|
5413
6019
|
stopAfterUnused?: number;
|
|
5414
6020
|
programId: Address;
|
|
5415
6021
|
mint: Address;
|
|
6022
|
+
/**
|
|
6023
|
+
* Also scan the LEGACY nk-derived receivers, so deposits routed to them before the fix are still
|
|
6024
|
+
* found (flagged `legacyExposed`). Default true. The canonical `nk` of `ownerUtxoKeypair` is always
|
|
6025
|
+
* included; add any other viewing keys the wallet has used in `legacyViewingKeyNks`.
|
|
6026
|
+
*/
|
|
6027
|
+
includeLegacy?: boolean;
|
|
6028
|
+
/** Extra viewing keys whose legacy receivers should be scanned (deduplicated). */
|
|
6029
|
+
legacyViewingKeyNks?: Uint8Array[];
|
|
5416
6030
|
}
|
|
5417
6031
|
/**
|
|
5418
6032
|
* A terminal state needs TWO conjuncts, never one.
|
|
@@ -5423,7 +6037,7 @@ interface DiscoverOptions {
|
|
|
5423
6037
|
* Completion therefore requires the shield-pool transaction to be present in the receiver's own
|
|
5424
6038
|
* history as well.
|
|
5425
6039
|
*/
|
|
5426
|
-
declare function listBridgeDeposits(rpc: CloakRpc,
|
|
6040
|
+
declare function listBridgeDeposits(rpc: CloakRpc, ownerUtxoKeypair: UtxoKeypair, opts: DiscoverOptions): Promise<BridgeDeposit[]>;
|
|
5427
6041
|
|
|
5428
6042
|
interface DepositOutcome {
|
|
5429
6043
|
signature: string;
|
|
@@ -5748,8 +6362,8 @@ declare function withShieldRetries<T>(attempt: (attemptNo: number) => Promise<T>
|
|
|
5748
6362
|
* @packageDocumentation
|
|
5749
6363
|
*/
|
|
5750
6364
|
|
|
5751
|
-
declare const VERSION = "0.2.
|
|
6365
|
+
declare const VERSION = "0.2.6";
|
|
5752
6366
|
/** True when scanner supports TransactSwap (tag 1). Check this to verify the correct SDK bundle is loaded. */
|
|
5753
6367
|
declare const SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
5754
6368
|
|
|
5755
|
-
export { BRIDGE_ESCROW_LABEL, 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, 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 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, deriveDepositNoteSecrets, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, 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 };
|
|
6369
|
+
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 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 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, 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, 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, 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 };
|