@sip-protocol/sdk 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{TransportWebUSB-2KITI5HD.mjs → TransportWebUSB-TXDZJBGS.mjs} +12 -12
  2. package/dist/browser.d.mts +1 -1
  3. package/dist/browser.d.ts +1 -1
  4. package/dist/browser.js +868 -545
  5. package/dist/browser.mjs +17 -3
  6. package/dist/{chunk-L4RKPNIJ.mjs → chunk-4EHEBTKP.mjs} +132 -87
  7. package/dist/{chunk-7IUKXWDN.mjs → chunk-MKTCJPFH.mjs} +331 -94
  8. package/dist/{chunk-IBZVA5Y7.mjs → chunk-NMC5RNMV.mjs} +2 -2
  9. package/dist/{chunk-XGB3TDIC.mjs → chunk-S3F4CPQ5.mjs} +5 -1
  10. package/dist/{constants-DCJYTIU3.mjs → constants-NCGOQF7S.mjs} +1 -1
  11. package/dist/{dist-PYEXZNFD.mjs → dist-4KSUM2PU.mjs} +2 -2
  12. package/dist/{dist-IFHPYLDX.mjs → dist-4O5YILSN.mjs} +2 -2
  13. package/dist/{fulfillment_proof-ANHVPKTB.mjs → fulfillment_proof-WCEE5GGO.mjs} +1 -1
  14. package/dist/{funding_proof-ICFZ5LHY.mjs → funding_proof-X5IP4SG5.mjs} +1 -1
  15. package/dist/{index-Cwo3WhxX.d.mts → index-B_fGN4Fk.d.mts} +806 -597
  16. package/dist/{index-X8qPQdp6.d.ts → index-rqQpCeVM.d.ts} +806 -597
  17. package/dist/index.d.mts +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +868 -545
  20. package/dist/index.mjs +17 -3
  21. package/dist/proofs/halo2.mjs +1 -1
  22. package/dist/proofs/kimchi.mjs +1 -1
  23. package/dist/proofs/noir.mjs +1 -1
  24. package/dist/{solana-7QOA3HBZ.mjs → solana-VKZI66MK.mjs} +12 -2
  25. package/dist/{validity_proof-3POXLPNY.mjs → validity_proof-2GVV6GA6.mjs} +1 -1
  26. package/package.json +6 -5
  27. package/src/chains/solana/gasless-cashout.ts +331 -0
  28. package/src/chains/solana/index.ts +16 -0
  29. package/src/chains/solana/privacy-adapter.ts +1 -0
  30. package/src/chains/solana/providers/webhook.ts +1 -0
  31. package/src/chains/solana/relayer-fee.ts +39 -0
  32. package/src/chains/solana/scan.ts +11 -70
  33. package/src/chains/solana/stealth-scanner.ts +8 -0
  34. package/src/chains/solana/stealth-signer.ts +145 -0
  35. package/src/chains/solana/types.ts +2 -0
  36. package/src/index.ts +16 -0
  37. package/src/proofs/parallel/concurrency.ts +2 -2
  38. package/src/solana/jito-relayer.ts +40 -8
  39. package/src/wallet/solana/privacy-adapter.ts +29 -66
package/dist/index.js CHANGED
@@ -5,11 +5,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ var __esm = (fn, res, err) => function __init() {
9
+ if (err) throw err[0];
10
+ try {
11
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
+ } catch (e) {
13
+ throw err = [e], e;
14
+ }
10
15
  };
11
16
  var __commonJS = (cb, mod) => function __require() {
12
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ try {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ } catch (e) {
20
+ throw mod = 0, e;
21
+ }
13
22
  };
14
23
  var __export = (target, all) => {
15
24
  for (var name in all)
@@ -3148,6 +3157,77 @@ var init_utils2 = __esm({
3148
3157
  }
3149
3158
  });
3150
3159
 
3160
+ // src/chains/solana/stealth-signer.ts
3161
+ function modL(value) {
3162
+ const reduced = value % ED25519_ORDER;
3163
+ return reduced >= 0n ? reduced : reduced + ED25519_ORDER;
3164
+ }
3165
+ function signEd25519WithScalar(message, scalar) {
3166
+ const a = modL(bytesToBigIntLE(scalar));
3167
+ if (a === 0n) {
3168
+ throw new Error("Invalid stealth scalar: reduces to zero");
3169
+ }
3170
+ const A = import_ed255194.ed25519.ExtendedPoint.BASE.multiply(a).toRawBytes();
3171
+ const prefix = (0, import_sha5123.sha512)(scalar).slice(32, 64);
3172
+ const r = modL(bytesToBigIntLE((0, import_sha5123.sha512)(new Uint8Array([...prefix, ...message]))));
3173
+ if (r === 0n) {
3174
+ throw new Error("Invalid nonce: reduces to zero");
3175
+ }
3176
+ const R = import_ed255194.ed25519.ExtendedPoint.BASE.multiply(r).toRawBytes();
3177
+ const k = modL(bytesToBigIntLE((0, import_sha5123.sha512)(new Uint8Array([...R, ...A, ...message]))));
3178
+ const S = modL(r + k * a);
3179
+ return new Uint8Array([...R, ...bigIntToBytesLE(S, 32)]);
3180
+ }
3181
+ function deriveStealthSigner(params) {
3182
+ const {
3183
+ stealthAddress,
3184
+ ephemeralPublicKey,
3185
+ viewingPrivateKey,
3186
+ spendingPrivateKey,
3187
+ version = "2"
3188
+ } = params;
3189
+ const stealthAddressHex = solanaAddressToEd25519PublicKey(stealthAddress);
3190
+ const ephemeralPubKeyHex = solanaAddressToEd25519PublicKey(ephemeralPublicKey);
3191
+ const stealthAddressObj = {
3192
+ address: stealthAddressHex,
3193
+ ephemeralPublicKey: ephemeralPubKeyHex,
3194
+ viewTag: 0
3195
+ };
3196
+ const recovery = version === "1" ? deriveEd25519StealthPrivateKeyV1(stealthAddressObj, spendingPrivateKey, viewingPrivateKey) : deriveEd25519StealthPrivateKey(stealthAddressObj, spendingPrivateKey, viewingPrivateKey);
3197
+ const scalar = (0, import_utils18.hexToBytes)(recovery.privateKey.slice(2));
3198
+ const publicKey = new import_web35.PublicKey(stealthAddress);
3199
+ const expectedPubKeyBytes = publicKey.toBytes();
3200
+ const derivedPubKeyBytes = import_ed255194.ed25519.ExtendedPoint.BASE.multiply(modL(bytesToBigIntLE(scalar))).toRawBytes();
3201
+ if (!derivedPubKeyBytes.every((b, i) => b === expectedPubKeyBytes[i])) {
3202
+ throw new Error(
3203
+ "Stealth key derivation failed: derived scalar does not produce expected public key. This may indicate incorrect spending/viewing keys or corrupted announcement data."
3204
+ );
3205
+ }
3206
+ return {
3207
+ publicKey,
3208
+ signMessage(message) {
3209
+ return signEd25519WithScalar(message, scalar);
3210
+ },
3211
+ signTransaction(transaction) {
3212
+ const message = transaction.serializeMessage();
3213
+ const signature = signEd25519WithScalar(message, scalar);
3214
+ transaction.addSignature(publicKey, Buffer.from(signature));
3215
+ }
3216
+ };
3217
+ }
3218
+ var import_web35, import_ed255194, import_sha5123, import_utils18;
3219
+ var init_stealth_signer = __esm({
3220
+ "src/chains/solana/stealth-signer.ts"() {
3221
+ "use strict";
3222
+ import_web35 = require("@solana/web3.js");
3223
+ import_ed255194 = require("@noble/curves/ed25519");
3224
+ import_sha5123 = require("@noble/hashes/sha512");
3225
+ import_utils18 = require("@noble/hashes/utils");
3226
+ init_stealth2();
3227
+ init_utils();
3228
+ }
3229
+ });
3230
+
3151
3231
  // src/chains/solana/scan.ts
3152
3232
  async function scanForPayments(params) {
3153
3233
  const {
@@ -3160,7 +3240,7 @@ async function scanForPayments(params) {
3160
3240
  provider
3161
3241
  } = params;
3162
3242
  const results = [];
3163
- const memoProgram = new import_web35.PublicKey(MEMO_PROGRAM_ID);
3243
+ const memoProgram = new import_web36.PublicKey(MEMO_PROGRAM_ID);
3164
3244
  try {
3165
3245
  const signatures = await connection.getSignaturesForAddress(
3166
3246
  memoProgram,
@@ -3239,6 +3319,7 @@ async function scanForPayments(params) {
3239
3319
  results.push({
3240
3320
  stealthAddress: announcement.stealthAddress || "",
3241
3321
  ephemeralPublicKey: announcement.ephemeralPublicKey,
3322
+ version: announcement.version,
3242
3323
  amount,
3243
3324
  mint: transferInfo.mint,
3244
3325
  tokenSymbol,
@@ -3269,51 +3350,34 @@ async function claimStealthPayment(params) {
3269
3350
  mint,
3270
3351
  version = "2"
3271
3352
  } = params;
3272
- const stealthPubkeyForBalance = new import_web35.PublicKey(stealthAddress);
3353
+ const stealthPubkeyForBalance = new import_web36.PublicKey(stealthAddress);
3273
3354
  const solBalance = await connection.getBalance(stealthPubkeyForBalance);
3274
3355
  if (BigInt(solBalance) < MIN_SOL_FOR_FEES) {
3275
3356
  throw new Error(
3276
3357
  `Insufficient SOL for transaction fees. Stealth address has ${solBalance} lamports, needs at least ${MIN_SOL_FOR_FEES} lamports (~0.000005 SOL). Fund the stealth address with SOL before claiming.`
3277
3358
  );
3278
3359
  }
3279
- const stealthAddressHex = solanaAddressToEd25519PublicKey(stealthAddress);
3280
- const ephemeralPubKeyHex = solanaAddressToEd25519PublicKey(ephemeralPublicKey);
3281
- const stealthAddressObj = {
3282
- address: stealthAddressHex,
3283
- ephemeralPublicKey: ephemeralPubKeyHex,
3284
- viewTag: 0
3285
- // Not needed for derivation
3286
- };
3287
- const recovery = version === "1" ? deriveEd25519StealthPrivateKeyV1(stealthAddressObj, spendingPrivateKey, viewingPrivateKey) : deriveEd25519StealthPrivateKey(stealthAddressObj, spendingPrivateKey, viewingPrivateKey);
3288
- const stealthPrivKeyBytes = (0, import_utils19.hexToBytes)(recovery.privateKey.slice(2));
3289
- const stealthPubkey = new import_web35.PublicKey(stealthAddress);
3290
- const expectedPubKeyBytes = stealthPubkey.toBytes();
3291
- const scalarBigInt = bytesToBigIntLE2(stealthPrivKeyBytes);
3292
- const ED25519_ORDER6 = 2n ** 252n + 27742317777372353535851937790883648493n;
3293
- let validScalar = scalarBigInt % ED25519_ORDER6;
3294
- if (validScalar === 0n) validScalar = 1n;
3295
- const derivedPubKeyBytes = import_ed255194.ed25519.ExtendedPoint.BASE.multiply(validScalar).toRawBytes();
3296
- if (!derivedPubKeyBytes.every((b, i) => b === expectedPubKeyBytes[i])) {
3297
- throw new Error(
3298
- "Stealth key derivation failed: derived private key does not produce expected public key. This may indicate incorrect spending/viewing keys or corrupted announcement data."
3299
- );
3300
- }
3301
- const stealthKeypair = import_web35.Keypair.fromSecretKey(
3302
- new Uint8Array([...stealthPrivKeyBytes, ...expectedPubKeyBytes])
3303
- );
3360
+ const stealthSigner = deriveStealthSigner({
3361
+ stealthAddress,
3362
+ ephemeralPublicKey,
3363
+ viewingPrivateKey,
3364
+ spendingPrivateKey,
3365
+ version
3366
+ });
3367
+ const stealthPubkey = new import_web36.PublicKey(stealthAddress);
3304
3368
  const stealthATA = await (0, import_spl_token3.getAssociatedTokenAddress)(
3305
3369
  mint,
3306
3370
  stealthPubkey,
3307
3371
  true
3308
3372
  );
3309
- const destinationPubkey = new import_web35.PublicKey(destinationAddress);
3373
+ const destinationPubkey = new import_web36.PublicKey(destinationAddress);
3310
3374
  const destinationATA = await (0, import_spl_token3.getAssociatedTokenAddress)(
3311
3375
  mint,
3312
3376
  destinationPubkey
3313
3377
  );
3314
3378
  const stealthAccount = await (0, import_spl_token3.getAccount)(connection, stealthATA);
3315
3379
  const amount = stealthAccount.amount;
3316
- const transaction = new import_web35.Transaction();
3380
+ const transaction = new import_web36.Transaction();
3317
3381
  transaction.add(
3318
3382
  (0, import_spl_token3.createTransferInstruction)(
3319
3383
  stealthATA,
@@ -3326,7 +3390,7 @@ async function claimStealthPayment(params) {
3326
3390
  transaction.recentBlockhash = blockhash;
3327
3391
  transaction.lastValidBlockHeight = lastValidBlockHeight;
3328
3392
  transaction.feePayer = stealthPubkey;
3329
- transaction.sign(stealthKeypair);
3393
+ stealthSigner.signTransaction(transaction);
3330
3394
  const txSignature = await connection.sendRawTransaction(
3331
3395
  transaction.serialize(),
3332
3396
  {
@@ -3358,7 +3422,7 @@ async function getStealthBalance(connection, stealthAddress, mint, provider) {
3358
3422
  }
3359
3423
  }
3360
3424
  try {
3361
- const stealthPubkey = new import_web35.PublicKey(stealthAddress);
3425
+ const stealthPubkey = new import_web36.PublicKey(stealthAddress);
3362
3426
  const ata = await (0, import_spl_token3.getAssociatedTokenAddress)(mint, stealthPubkey, true);
3363
3427
  const account = await (0, import_spl_token3.getAccount)(connection, ata);
3364
3428
  return account.amount;
@@ -3378,25 +3442,17 @@ function detectCluster4(endpoint) {
3378
3442
  }
3379
3443
  return "mainnet-beta";
3380
3444
  }
3381
- function bytesToBigIntLE2(bytes) {
3382
- let result = 0n;
3383
- for (let i = bytes.length - 1; i >= 0; i--) {
3384
- result = result << 8n | BigInt(bytes[i]);
3385
- }
3386
- return result;
3387
- }
3388
- var import_web35, import_spl_token3, import_utils19, import_ed255194, MIN_SOL_FOR_FEES;
3445
+ var import_web36, import_spl_token3, MIN_SOL_FOR_FEES;
3389
3446
  var init_scan = __esm({
3390
3447
  "src/chains/solana/scan.ts"() {
3391
3448
  "use strict";
3392
- import_web35 = require("@solana/web3.js");
3449
+ import_web36 = require("@solana/web3.js");
3393
3450
  import_spl_token3 = require("@solana/spl-token");
3394
3451
  init_stealth2();
3395
3452
  init_types();
3396
3453
  init_constants();
3397
3454
  init_utils2();
3398
- import_utils19 = require("@noble/hashes/utils");
3399
- import_ed255194 = require("@noble/curves/ed25519");
3455
+ init_stealth_signer();
3400
3456
  MIN_SOL_FOR_FEES = 5000n;
3401
3457
  }
3402
3458
  });
@@ -3444,11 +3500,11 @@ async function fullHistoricalScan(options, recipients, scanOptions = {}, onProgr
3444
3500
  }
3445
3501
  return allPayments;
3446
3502
  }
3447
- var import_web36, StealthScanner;
3503
+ var import_web37, StealthScanner;
3448
3504
  var init_stealth_scanner = __esm({
3449
3505
  "src/chains/solana/stealth-scanner.ts"() {
3450
3506
  "use strict";
3451
- import_web36 = require("@solana/web3.js");
3507
+ import_web37 = require("@solana/web3.js");
3452
3508
  init_stealth2();
3453
3509
  init_types();
3454
3510
  init_constants();
@@ -3519,7 +3575,7 @@ var init_stealth_scanner = __esm({
3519
3575
  let scannedCount = 0;
3520
3576
  let lastSignature;
3521
3577
  let lastSlot;
3522
- const memoProgram = new import_web36.PublicKey(MEMO_PROGRAM_ID);
3578
+ const memoProgram = new import_web37.PublicKey(MEMO_PROGRAM_ID);
3523
3579
  try {
3524
3580
  const signatures = await this.connection.getSignaturesForAddress(
3525
3581
  memoProgram,
@@ -3587,7 +3643,7 @@ var init_stealth_scanner = __esm({
3587
3643
  }
3588
3644
  this.paymentCallback = onPayment;
3589
3645
  this.errorCallback = onError ?? null;
3590
- const memoProgram = new import_web36.PublicKey(MEMO_PROGRAM_ID);
3646
+ const memoProgram = new import_web37.PublicKey(MEMO_PROGRAM_ID);
3591
3647
  this.subscriptionId = this.connection.onLogs(
3592
3648
  memoProgram,
3593
3649
  async (logs) => {
@@ -3689,6 +3745,7 @@ var init_stealth_scanner = __esm({
3689
3745
  return {
3690
3746
  stealthAddress: announcement.stealthAddress || "",
3691
3747
  ephemeralPublicKey: announcement.ephemeralPublicKey,
3748
+ version: announcement.version,
3692
3749
  viewTag: viewTagNumber,
3693
3750
  amount,
3694
3751
  mint: transferInfo.mint,
@@ -3710,10 +3767,10 @@ var init_stealth_scanner = __esm({
3710
3767
 
3711
3768
  // src/chains/solana/ephemeral-keys.ts
3712
3769
  function generateEphemeralKeypair() {
3713
- const privateKeyBytes = (0, import_utils21.randomBytes)(32);
3770
+ const privateKeyBytes = (0, import_utils22.randomBytes)(32);
3714
3771
  const publicKeyBytes = import_ed255195.ed25519.getPublicKey(privateKeyBytes);
3715
- const privateKey = `0x${(0, import_utils21.bytesToHex)(privateKeyBytes)}`;
3716
- const publicKey = `0x${(0, import_utils21.bytesToHex)(publicKeyBytes)}`;
3772
+ const privateKey = `0x${(0, import_utils22.bytesToHex)(privateKeyBytes)}`;
3773
+ const publicKey = `0x${(0, import_utils22.bytesToHex)(publicKeyBytes)}`;
3717
3774
  const publicKeyBase58 = ed25519PublicKeyToSolanaAddress(publicKey);
3718
3775
  secureWipe(privateKeyBytes);
3719
3776
  return {
@@ -3723,10 +3780,10 @@ function generateEphemeralKeypair() {
3723
3780
  };
3724
3781
  }
3725
3782
  function generateManagedEphemeralKeypair() {
3726
- const privateKeyBytes = (0, import_utils21.randomBytes)(32);
3783
+ const privateKeyBytes = (0, import_utils22.randomBytes)(32);
3727
3784
  const publicKeyBytes = import_ed255195.ed25519.getPublicKey(privateKeyBytes);
3728
- const privateKeyHex = `0x${(0, import_utils21.bytesToHex)(privateKeyBytes)}`;
3729
- const publicKeyHex = `0x${(0, import_utils21.bytesToHex)(publicKeyBytes)}`;
3785
+ const privateKeyHex = `0x${(0, import_utils22.bytesToHex)(privateKeyBytes)}`;
3786
+ const publicKeyHex = `0x${(0, import_utils22.bytesToHex)(publicKeyBytes)}`;
3730
3787
  const publicKeyBase58 = ed25519PublicKeyToSolanaAddress(publicKeyHex);
3731
3788
  let disposed = false;
3732
3789
  const managed = {
@@ -3759,10 +3816,10 @@ function batchGenerateEphemeralKeypairs(options) {
3759
3816
  throw new Error("count cannot exceed 1000 (security limit)");
3760
3817
  }
3761
3818
  const keypairs = [];
3762
- let entropyState = entropyMixing ? (0, import_utils21.randomBytes)(32) : null;
3819
+ let entropyState = entropyMixing ? (0, import_utils22.randomBytes)(32) : null;
3763
3820
  for (let i = 0; i < count; i++) {
3764
3821
  if (entropyMixing && entropyState) {
3765
- const extraEntropy = (0, import_utils21.randomBytes)(32);
3822
+ const extraEntropy = (0, import_utils22.randomBytes)(32);
3766
3823
  entropyState = (0, import_sha2566.sha256)(new Uint8Array([...entropyState, ...extraEntropy]));
3767
3824
  }
3768
3825
  keypairs.push(generateEphemeralKeypair());
@@ -3781,10 +3838,10 @@ function batchGenerateManagedEphemeralKeypairs(options) {
3781
3838
  throw new Error("count cannot exceed 1000 (security limit)");
3782
3839
  }
3783
3840
  const keypairs = [];
3784
- let entropyState = entropyMixing ? (0, import_utils21.randomBytes)(32) : null;
3841
+ let entropyState = entropyMixing ? (0, import_utils22.randomBytes)(32) : null;
3785
3842
  for (let i = 0; i < count; i++) {
3786
3843
  if (entropyMixing && entropyState) {
3787
- const extraEntropy = (0, import_utils21.randomBytes)(32);
3844
+ const extraEntropy = (0, import_utils22.randomBytes)(32);
3788
3845
  entropyState = (0, import_sha2566.sha256)(new Uint8Array([...entropyState, ...extraEntropy]));
3789
3846
  }
3790
3847
  keypairs.push(generateManagedEphemeralKeypair());
@@ -3800,15 +3857,15 @@ function disposeEphemeralKeypairs(keypairs) {
3800
3857
  }
3801
3858
  }
3802
3859
  function wipeEphemeralPrivateKey(privateKeyHex) {
3803
- const bytes = (0, import_utils21.hexToBytes)(privateKeyHex.slice(2));
3860
+ const bytes = (0, import_utils22.hexToBytes)(privateKeyHex.slice(2));
3804
3861
  secureWipe(bytes);
3805
3862
  }
3806
- var import_ed255195, import_utils21, import_sha2566;
3863
+ var import_ed255195, import_utils22, import_sha2566;
3807
3864
  var init_ephemeral_keys = __esm({
3808
3865
  "src/chains/solana/ephemeral-keys.ts"() {
3809
3866
  "use strict";
3810
3867
  import_ed255195 = require("@noble/curves/ed25519");
3811
- import_utils21 = require("@noble/hashes/utils");
3868
+ import_utils22 = require("@noble/hashes/utils");
3812
3869
  import_sha2566 = require("@noble/hashes/sha256");
3813
3870
  init_secure_memory();
3814
3871
  init_stealth2();
@@ -4031,16 +4088,16 @@ var init_helius = __esm({
4031
4088
  // src/chains/solana/providers/generic.ts
4032
4089
  function validateSolanaAddress(address, paramName) {
4033
4090
  try {
4034
- return new import_web37.PublicKey(address);
4091
+ return new import_web38.PublicKey(address);
4035
4092
  } catch {
4036
4093
  throw new ValidationError("invalid Solana address format", paramName, void 0, "SIP_2007" /* INVALID_ADDRESS */);
4037
4094
  }
4038
4095
  }
4039
- var import_web37, import_spl_token4, CLUSTER_ENDPOINTS, GenericProvider;
4096
+ var import_web38, import_spl_token4, CLUSTER_ENDPOINTS, GenericProvider;
4040
4097
  var init_generic = __esm({
4041
4098
  "src/chains/solana/providers/generic.ts"() {
4042
4099
  "use strict";
4043
- import_web37 = require("@solana/web3.js");
4100
+ import_web38 = require("@solana/web3.js");
4044
4101
  import_spl_token4 = require("@solana/spl-token");
4045
4102
  init_errors();
4046
4103
  init_constants();
@@ -4057,7 +4114,7 @@ var init_generic = __esm({
4057
4114
  this.connection = config.connection;
4058
4115
  } else {
4059
4116
  const endpoint = config.endpoint ?? CLUSTER_ENDPOINTS[config.cluster ?? "mainnet-beta"];
4060
- this.connection = new import_web37.Connection(endpoint, "confirmed");
4117
+ this.connection = new import_web38.Connection(endpoint, "confirmed");
4061
4118
  }
4062
4119
  }
4063
4120
  /**
@@ -4153,7 +4210,7 @@ var init_generic = __esm({
4153
4210
  // src/chains/solana/providers/quicknode.ts
4154
4211
  function validateSolanaAddress2(address, paramName) {
4155
4212
  try {
4156
- return new import_web38.PublicKey(address);
4213
+ return new import_web39.PublicKey(address);
4157
4214
  } catch {
4158
4215
  throw new ValidationError("invalid Solana address format", paramName, void 0, "SIP_2007" /* INVALID_ADDRESS */);
4159
4216
  }
@@ -4163,11 +4220,11 @@ function getGrpcEndpoint(rpcEndpoint) {
4163
4220
  url.port = "10000";
4164
4221
  return url.origin + url.pathname.replace(/\/$/, "");
4165
4222
  }
4166
- var import_web38, import_spl_token5, import_yellowstone_grpc, import_base, QuickNodeProvider;
4223
+ var import_web39, import_spl_token5, import_yellowstone_grpc, import_base, QuickNodeProvider;
4167
4224
  var init_quicknode = __esm({
4168
4225
  "src/chains/solana/providers/quicknode.ts"() {
4169
4226
  "use strict";
4170
- import_web38 = require("@solana/web3.js");
4227
+ import_web39 = require("@solana/web3.js");
4171
4228
  import_spl_token5 = require("@solana/spl-token");
4172
4229
  import_yellowstone_grpc = __toESM(require("@triton-one/yellowstone-grpc"));
4173
4230
  import_base = require("@scure/base");
@@ -4202,7 +4259,7 @@ var init_quicknode = __esm({
4202
4259
  "SIP_2001" /* INVALID_INPUT */
4203
4260
  );
4204
4261
  }
4205
- this.connection = new import_web38.Connection(config.endpoint, "confirmed");
4262
+ this.connection = new import_web39.Connection(config.endpoint, "confirmed");
4206
4263
  this.grpcEndpoint = getGrpcEndpoint(config.endpoint);
4207
4264
  this.grpcEnabled = config.enableGrpc !== false;
4208
4265
  }
@@ -4278,7 +4335,7 @@ var init_quicknode = __esm({
4278
4335
  return cached;
4279
4336
  }
4280
4337
  try {
4281
- const mintPubkey = new import_web38.PublicKey(mint);
4338
+ const mintPubkey = new import_web39.PublicKey(mint);
4282
4339
  const mintInfo = await (0, import_spl_token5.getMint)(this.connection, mintPubkey);
4283
4340
  const decimals = mintInfo.decimals;
4284
4341
  this.mintDecimalsCache.set(mint, decimals);
@@ -4326,7 +4383,7 @@ var init_quicknode = __esm({
4326
4383
  try {
4327
4384
  const data = accountData.data;
4328
4385
  if (data && data.length >= 72) {
4329
- const mint = new import_web38.PublicKey(data.slice(0, 32)).toBase58();
4386
+ const mint = new import_web39.PublicKey(data.slice(0, 32)).toBase58();
4330
4387
  const amount = BigInt(
4331
4388
  "0x" + Buffer.from(data.slice(64, 72)).reverse().toString("hex")
4332
4389
  );
@@ -4428,16 +4485,16 @@ var init_quicknode = __esm({
4428
4485
  // src/chains/solana/providers/triton.ts
4429
4486
  function validateSolanaAddress3(address, paramName) {
4430
4487
  try {
4431
- return new import_web39.PublicKey(address);
4488
+ return new import_web310.PublicKey(address);
4432
4489
  } catch {
4433
4490
  throw new ValidationError("invalid Solana address format", paramName, void 0, "SIP_2007" /* INVALID_ADDRESS */);
4434
4491
  }
4435
4492
  }
4436
- var import_web39, import_spl_token6, import_yellowstone_grpc2, import_base2, TRITON_RPC_ENDPOINTS, TRITON_GRPC_ENDPOINTS, TritonProvider;
4493
+ var import_web310, import_spl_token6, import_yellowstone_grpc2, import_base2, TRITON_RPC_ENDPOINTS, TRITON_GRPC_ENDPOINTS, TritonProvider;
4437
4494
  var init_triton = __esm({
4438
4495
  "src/chains/solana/providers/triton.ts"() {
4439
4496
  "use strict";
4440
- import_web39 = require("@solana/web3.js");
4497
+ import_web310 = require("@solana/web3.js");
4441
4498
  import_spl_token6 = require("@solana/spl-token");
4442
4499
  import_yellowstone_grpc2 = __toESM(require("@triton-one/yellowstone-grpc"));
4443
4500
  import_base2 = require("@scure/base");
@@ -4474,7 +4531,7 @@ var init_triton = __esm({
4474
4531
  const rpcEndpoint = config.endpoint ?? TRITON_RPC_ENDPOINTS[cluster];
4475
4532
  const normalizedEndpoint = rpcEndpoint.replace(/\/$/, "");
4476
4533
  const rpcUrl = normalizedEndpoint.includes("?") ? `${normalizedEndpoint}&x-token=${config.xToken}` : `${normalizedEndpoint}/${config.xToken}`;
4477
- this.connection = new import_web39.Connection(rpcUrl, "confirmed");
4534
+ this.connection = new import_web310.Connection(rpcUrl, "confirmed");
4478
4535
  this.grpcEndpoint = config.grpcEndpoint ?? TRITON_GRPC_ENDPOINTS[cluster];
4479
4536
  this.xToken = config.xToken;
4480
4537
  this.grpcEnabled = config.enableGrpc !== false;
@@ -4551,7 +4608,7 @@ var init_triton = __esm({
4551
4608
  return cached;
4552
4609
  }
4553
4610
  try {
4554
- const mintPubkey = new import_web39.PublicKey(mint);
4611
+ const mintPubkey = new import_web310.PublicKey(mint);
4555
4612
  const mintInfo = await (0, import_spl_token6.getMint)(this.connection, mintPubkey);
4556
4613
  const decimals = mintInfo.decimals;
4557
4614
  this.mintDecimalsCache.set(mint, decimals);
@@ -4602,7 +4659,7 @@ var init_triton = __esm({
4602
4659
  try {
4603
4660
  const data = accountData.data;
4604
4661
  if (data && data.length >= 72) {
4605
- const mint = new import_web39.PublicKey(data.slice(0, 32)).toBase58();
4662
+ const mint = new import_web310.PublicKey(data.slice(0, 32)).toBase58();
4606
4663
  const amount = BigInt(
4607
4664
  "0x" + Buffer.from(data.slice(64, 72)).reverse().toString("hex")
4608
4665
  );
@@ -4759,7 +4816,7 @@ function verifyWebhookSignature(rawBody, signature, secret) {
4759
4816
  }
4760
4817
  try {
4761
4818
  const encoder = new TextEncoder();
4762
- const expectedSignature = (0, import_utils23.bytesToHex)(
4819
+ const expectedSignature = (0, import_utils24.bytesToHex)(
4763
4820
  (0, import_hmac2.hmac)(import_sha2567.sha256, encoder.encode(secret), encoder.encode(rawBody))
4764
4821
  );
4765
4822
  if (signature.length !== expectedSignature.length) {
@@ -4938,6 +4995,7 @@ async function processRawTransaction(tx, viewingPrivateKey, spendingPublicKey, o
4938
4995
  const payment = {
4939
4996
  stealthAddress: announcement.stealthAddress || "",
4940
4997
  ephemeralPublicKey: announcement.ephemeralPublicKey,
4998
+ version: announcement.version,
4941
4999
  amount: transferInfo?.amount ?? 0n,
4942
5000
  mint: transferInfo?.mint ?? "",
4943
5001
  tokenSymbol: transferInfo?.mint ? getTokenSymbol(transferInfo.mint) : void 0,
@@ -4977,7 +5035,7 @@ async function processWebhookTransaction(transaction, viewingPrivateKey, spendin
4977
5035
  );
4978
5036
  return result.found ? result.payment ?? null : null;
4979
5037
  }
4980
- var import_hmac2, import_sha2567, import_utils23;
5038
+ var import_hmac2, import_sha2567, import_utils24;
4981
5039
  var init_webhook = __esm({
4982
5040
  "src/chains/solana/providers/webhook.ts"() {
4983
5041
  "use strict";
@@ -4988,7 +5046,7 @@ var init_webhook = __esm({
4988
5046
  init_errors();
4989
5047
  import_hmac2 = require("@noble/hashes/hmac");
4990
5048
  import_sha2567 = require("@noble/hashes/sha256");
4991
- import_utils23 = require("@noble/hashes/utils");
5049
+ import_utils24 = require("@noble/hashes/utils");
4992
5050
  }
4993
5051
  });
4994
5052
 
@@ -5421,11 +5479,11 @@ var init_providers = __esm({
5421
5479
  function createSolanaPrivacyAdapter(config) {
5422
5480
  return new SolanaPrivacyAdapter(config);
5423
5481
  }
5424
- var import_web310, SolanaPrivacyAdapter;
5482
+ var import_web311, SolanaPrivacyAdapter;
5425
5483
  var init_privacy_adapter = __esm({
5426
5484
  "src/chains/solana/privacy-adapter.ts"() {
5427
5485
  "use strict";
5428
- import_web310 = require("@solana/web3.js");
5486
+ import_web311 = require("@solana/web3.js");
5429
5487
  init_stealth2();
5430
5488
  init_transfer();
5431
5489
  init_scan();
@@ -5655,7 +5713,8 @@ var init_privacy_adapter = __esm({
5655
5713
  viewingPrivateKey: params.viewingPrivateKey,
5656
5714
  spendingPrivateKey: params.spendingPrivateKey,
5657
5715
  destinationAddress: params.destinationAddress,
5658
- mint: new import_web310.PublicKey(params.payment.mint)
5716
+ mint: new import_web311.PublicKey(params.payment.mint),
5717
+ version: params.payment.version
5659
5718
  });
5660
5719
  }
5661
5720
  /**
@@ -5894,7 +5953,7 @@ function generateH2() {
5894
5953
  if (!point.equals(import_ed255197.ed25519.ExtendedPoint.ZERO)) {
5895
5954
  const gBytes = G2.toRawBytes();
5896
5955
  const hBytes = point.toRawBytes();
5897
- if ((0, import_utils25.bytesToHex)(gBytes) !== (0, import_utils25.bytesToHex)(hBytes)) {
5956
+ if ((0, import_utils26.bytesToHex)(gBytes) !== (0, import_utils26.bytesToHex)(hBytes)) {
5898
5957
  return point;
5899
5958
  }
5900
5959
  }
@@ -5922,13 +5981,13 @@ function commitSolana(value, blinding) {
5922
5981
  { curveOrder: ED25519_ORDER2.toString(16) }
5923
5982
  );
5924
5983
  }
5925
- const r = blinding ?? (0, import_utils25.randomBytes)(32);
5984
+ const r = blinding ?? (0, import_utils26.randomBytes)(32);
5926
5985
  if (r.length !== 32) {
5927
5986
  throw new ValidationError("must be 32 bytes", "blinding", { received: r.length });
5928
5987
  }
5929
5988
  const rScalar = bytesToBigInt3(r) % ED25519_ORDER2;
5930
5989
  if (rScalar === 0n) {
5931
- return commitSolana(value, (0, import_utils25.randomBytes)(32));
5990
+ return commitSolana(value, (0, import_utils26.randomBytes)(32));
5932
5991
  }
5933
5992
  let C;
5934
5993
  if (value === 0n) {
@@ -5940,8 +5999,8 @@ function commitSolana(value, blinding) {
5940
5999
  }
5941
6000
  const rScalarBytes = bigIntToBytes3(rScalar, 32);
5942
6001
  return {
5943
- commitment: `0x${(0, import_utils25.bytesToHex)(C.toRawBytes())}`,
5944
- blinding: `0x${(0, import_utils25.bytesToHex)(rScalarBytes)}`
6002
+ commitment: `0x${(0, import_utils26.bytesToHex)(C.toRawBytes())}`,
6003
+ blinding: `0x${(0, import_utils26.bytesToHex)(rScalarBytes)}`
5945
6004
  };
5946
6005
  }
5947
6006
  function verifyOpeningSolana(commitment, value, blinding) {
@@ -6027,7 +6086,7 @@ function addCommitmentsSolana(c1, c2) {
6027
6086
  }
6028
6087
  const sum = point1.add(point2);
6029
6088
  return {
6030
- commitment: `0x${(0, import_utils25.bytesToHex)(sum.toRawBytes())}`
6089
+ commitment: `0x${(0, import_utils26.bytesToHex)(sum.toRawBytes())}`
6031
6090
  };
6032
6091
  }
6033
6092
  function subtractCommitmentsSolana(c1, c2) {
@@ -6056,7 +6115,7 @@ function subtractCommitmentsSolana(c1, c2) {
6056
6115
  };
6057
6116
  }
6058
6117
  return {
6059
- commitment: `0x${(0, import_utils25.bytesToHex)(diff.toRawBytes())}`
6118
+ commitment: `0x${(0, import_utils26.bytesToHex)(diff.toRawBytes())}`
6060
6119
  };
6061
6120
  }
6062
6121
  function addBlindingsSolana(b1, b2) {
@@ -6064,23 +6123,23 @@ function addBlindingsSolana(b1, b2) {
6064
6123
  const r2 = bytesToBigInt3(hexToBytes9(b2.slice(2)));
6065
6124
  const sum = (r1 + r2) % ED25519_ORDER2;
6066
6125
  const sumBytes = bigIntToBytes3(sum, 32);
6067
- return `0x${(0, import_utils25.bytesToHex)(sumBytes)}`;
6126
+ return `0x${(0, import_utils26.bytesToHex)(sumBytes)}`;
6068
6127
  }
6069
6128
  function subtractBlindingsSolana(b1, b2) {
6070
6129
  const r1 = bytesToBigInt3(hexToBytes9(b1.slice(2)));
6071
6130
  const r2 = bytesToBigInt3(hexToBytes9(b2.slice(2)));
6072
6131
  const diff = (r1 - r2 + ED25519_ORDER2) % ED25519_ORDER2;
6073
6132
  const diffBytes = bigIntToBytes3(diff, 32);
6074
- return `0x${(0, import_utils25.bytesToHex)(diffBytes)}`;
6133
+ return `0x${(0, import_utils26.bytesToHex)(diffBytes)}`;
6075
6134
  }
6076
6135
  function getGeneratorsSolana() {
6077
6136
  return {
6078
- G: `0x${(0, import_utils25.bytesToHex)(G2.toRawBytes())}`,
6079
- H: `0x${(0, import_utils25.bytesToHex)(H2.toRawBytes())}`
6137
+ G: `0x${(0, import_utils26.bytesToHex)(G2.toRawBytes())}`,
6138
+ H: `0x${(0, import_utils26.bytesToHex)(H2.toRawBytes())}`
6080
6139
  };
6081
6140
  }
6082
6141
  function generateBlindingSolana() {
6083
- return `0x${(0, import_utils25.bytesToHex)((0, import_utils25.randomBytes)(32))}`;
6142
+ return `0x${(0, import_utils26.bytesToHex)((0, import_utils26.randomBytes)(32))}`;
6084
6143
  }
6085
6144
  function bytesToBigInt3(bytes) {
6086
6145
  let result = 0n;
@@ -6105,13 +6164,13 @@ function hexToBytes9(hex) {
6105
6164
  }
6106
6165
  return bytes;
6107
6166
  }
6108
- var import_ed255197, import_sha22, import_utils25, H_DOMAIN2, G2, ED25519_ORDER2, ED25519_COFACTOR, MAX_SPL_AMOUNT, H2;
6167
+ var import_ed255197, import_sha22, import_utils26, H_DOMAIN2, G2, ED25519_ORDER2, ED25519_COFACTOR, MAX_SPL_AMOUNT, H2;
6109
6168
  var init_commitment2 = __esm({
6110
6169
  "src/chains/solana/commitment.ts"() {
6111
6170
  "use strict";
6112
6171
  import_ed255197 = require("@noble/curves/ed25519");
6113
6172
  import_sha22 = require("@noble/hashes/sha2");
6114
- import_utils25 = require("@noble/hashes/utils");
6173
+ import_utils26 = require("@noble/hashes/utils");
6115
6174
  init_errors();
6116
6175
  init_validation();
6117
6176
  H_DOMAIN2 = "SIP-SOLANA-PEDERSEN-GENERATOR-H-v1";
@@ -6131,7 +6190,7 @@ function generateViewingKeyFromSpending(spendingPrivateKey, label) {
6131
6190
  "spendingPrivateKey"
6132
6191
  );
6133
6192
  }
6134
- const spendingBytes = (0, import_utils26.hexToBytes)(spendingPrivateKey.slice(2));
6193
+ const spendingBytes = (0, import_utils27.hexToBytes)(spendingPrivateKey.slice(2));
6135
6194
  if (spendingBytes.length !== 32) {
6136
6195
  throw new ValidationError(
6137
6196
  "spendingPrivateKey must be 32 bytes",
@@ -6142,15 +6201,15 @@ function generateViewingKeyFromSpending(spendingPrivateKey, label) {
6142
6201
  try {
6143
6202
  viewingPrivateBytes = (0, import_hmac4.hmac)(
6144
6203
  import_sha2568.sha256,
6145
- (0, import_utils26.utf8ToBytes)(VIEWING_KEY_CONTEXT2),
6204
+ (0, import_utils27.utf8ToBytes)(VIEWING_KEY_CONTEXT2),
6146
6205
  spendingBytes
6147
6206
  );
6148
6207
  const viewingPublicBytes = import_ed255198.ed25519.getPublicKey(viewingPrivateBytes);
6149
6208
  const hashBytes = (0, import_sha2568.sha256)(viewingPublicBytes);
6150
6209
  return {
6151
- privateKey: `0x${(0, import_utils26.bytesToHex)(viewingPrivateBytes)}`,
6152
- publicKey: `0x${(0, import_utils26.bytesToHex)(viewingPublicBytes)}`,
6153
- hash: `0x${(0, import_utils26.bytesToHex)(hashBytes)}`,
6210
+ privateKey: `0x${(0, import_utils27.bytesToHex)(viewingPrivateBytes)}`,
6211
+ publicKey: `0x${(0, import_utils27.bytesToHex)(viewingPublicBytes)}`,
6212
+ hash: `0x${(0, import_utils27.bytesToHex)(hashBytes)}`,
6154
6213
  label,
6155
6214
  createdAt: Date.now()
6156
6215
  };
@@ -6160,14 +6219,14 @@ function generateViewingKeyFromSpending(spendingPrivateKey, label) {
6160
6219
  }
6161
6220
  }
6162
6221
  function generateRandomViewingKey(label) {
6163
- const privateBytes = (0, import_utils26.randomBytes)(32);
6222
+ const privateBytes = (0, import_utils27.randomBytes)(32);
6164
6223
  try {
6165
6224
  const publicBytes = import_ed255198.ed25519.getPublicKey(privateBytes);
6166
6225
  const hashBytes = (0, import_sha2568.sha256)(publicBytes);
6167
6226
  return {
6168
- privateKey: `0x${(0, import_utils26.bytesToHex)(privateBytes)}`,
6169
- publicKey: `0x${(0, import_utils26.bytesToHex)(publicBytes)}`,
6170
- hash: `0x${(0, import_utils26.bytesToHex)(hashBytes)}`,
6227
+ privateKey: `0x${(0, import_utils27.bytesToHex)(privateBytes)}`,
6228
+ publicKey: `0x${(0, import_utils27.bytesToHex)(publicBytes)}`,
6229
+ hash: `0x${(0, import_utils27.bytesToHex)(hashBytes)}`,
6171
6230
  label,
6172
6231
  createdAt: Date.now()
6173
6232
  };
@@ -6182,7 +6241,7 @@ function computeViewingKeyHash(viewingPublicKey) {
6182
6241
  "viewingPublicKey"
6183
6242
  );
6184
6243
  }
6185
- const publicBytes = (0, import_utils26.hexToBytes)(viewingPublicKey.slice(2));
6244
+ const publicBytes = (0, import_utils27.hexToBytes)(viewingPublicKey.slice(2));
6186
6245
  if (publicBytes.length !== 32) {
6187
6246
  throw new ValidationError(
6188
6247
  "viewingPublicKey must be 32 bytes",
@@ -6190,7 +6249,7 @@ function computeViewingKeyHash(viewingPublicKey) {
6190
6249
  );
6191
6250
  }
6192
6251
  const hashBytes = (0, import_sha2568.sha256)(publicBytes);
6193
- return `0x${(0, import_utils26.bytesToHex)(hashBytes)}`;
6252
+ return `0x${(0, import_utils27.bytesToHex)(hashBytes)}`;
6194
6253
  }
6195
6254
  function computeViewingKeyHashFromPrivate(viewingPrivateKey) {
6196
6255
  if (!viewingPrivateKey || !viewingPrivateKey.startsWith("0x")) {
@@ -6199,7 +6258,7 @@ function computeViewingKeyHashFromPrivate(viewingPrivateKey) {
6199
6258
  "viewingPrivateKey"
6200
6259
  );
6201
6260
  }
6202
- const privateBytes = (0, import_utils26.hexToBytes)(viewingPrivateKey.slice(2));
6261
+ const privateBytes = (0, import_utils27.hexToBytes)(viewingPrivateKey.slice(2));
6203
6262
  if (privateBytes.length !== 32) {
6204
6263
  throw new ValidationError(
6205
6264
  "viewingPrivateKey must be 32 bytes",
@@ -6209,7 +6268,7 @@ function computeViewingKeyHashFromPrivate(viewingPrivateKey) {
6209
6268
  try {
6210
6269
  const publicBytes = import_ed255198.ed25519.getPublicKey(privateBytes);
6211
6270
  const hashBytes = (0, import_sha2568.sha256)(publicBytes);
6212
- return `0x${(0, import_utils26.bytesToHex)(hashBytes)}`;
6271
+ return `0x${(0, import_utils27.bytesToHex)(hashBytes)}`;
6213
6272
  } finally {
6214
6273
  secureWipe(privateBytes);
6215
6274
  }
@@ -6256,9 +6315,9 @@ function importViewingKey(exported) {
6256
6315
  { expected: computedHash, received: exported.hash }
6257
6316
  );
6258
6317
  }
6259
- const privateBytes = (0, import_utils26.hexToBytes)(exported.privateKey.slice(2));
6318
+ const privateBytes = (0, import_utils27.hexToBytes)(exported.privateKey.slice(2));
6260
6319
  try {
6261
- const derivedPublic = `0x${(0, import_utils26.bytesToHex)(import_ed255198.ed25519.getPublicKey(privateBytes))}`;
6320
+ const derivedPublic = `0x${(0, import_utils27.bytesToHex)(import_ed255198.ed25519.getPublicKey(privateBytes))}`;
6262
6321
  if (derivedPublic !== exported.publicKey) {
6263
6322
  throw new ValidationError(
6264
6323
  "Public key does not match private key",
@@ -6277,10 +6336,10 @@ function importViewingKey(exported) {
6277
6336
  };
6278
6337
  }
6279
6338
  function deriveEncryptionKey2(key, salt) {
6280
- const keyBytes = (0, import_utils26.hexToBytes)(key.slice(2));
6339
+ const keyBytes = (0, import_utils27.hexToBytes)(key.slice(2));
6281
6340
  try {
6282
- const hkdfSalt = salt ?? (0, import_utils26.utf8ToBytes)(ENCRYPTION_DOMAIN2);
6283
- return (0, import_hkdf2.hkdf)(import_sha2568.sha256, keyBytes, hkdfSalt, (0, import_utils26.utf8ToBytes)("encryption"), 32);
6341
+ const hkdfSalt = salt ?? (0, import_utils27.utf8ToBytes)(ENCRYPTION_DOMAIN2);
6342
+ return (0, import_hkdf2.hkdf)(import_sha2568.sha256, keyBytes, hkdfSalt, (0, import_utils27.utf8ToBytes)("encryption"), 32);
6284
6343
  } finally {
6285
6344
  secureWipe(keyBytes);
6286
6345
  }
@@ -6288,13 +6347,13 @@ function deriveEncryptionKey2(key, salt) {
6288
6347
  function encryptForViewing2(data, viewingKey) {
6289
6348
  const encKey = deriveEncryptionKey2(viewingKey.privateKey);
6290
6349
  try {
6291
- const nonce = (0, import_utils26.randomBytes)(NONCE_SIZE2);
6292
- const plaintext = (0, import_utils26.utf8ToBytes)(JSON.stringify(data));
6350
+ const nonce = (0, import_utils27.randomBytes)(NONCE_SIZE2);
6351
+ const plaintext = (0, import_utils27.utf8ToBytes)(JSON.stringify(data));
6293
6352
  const cipher = (0, import_chacha2.xchacha20poly1305)(encKey, nonce);
6294
6353
  const ciphertext = cipher.encrypt(plaintext);
6295
6354
  return {
6296
- ciphertext: `0x${(0, import_utils26.bytesToHex)(ciphertext)}`,
6297
- nonce: `0x${(0, import_utils26.bytesToHex)(nonce)}`,
6355
+ ciphertext: `0x${(0, import_utils27.bytesToHex)(ciphertext)}`,
6356
+ nonce: `0x${(0, import_utils27.bytesToHex)(nonce)}`,
6298
6357
  viewingKeyHash: viewingKey.hash
6299
6358
  };
6300
6359
  } finally {
@@ -6311,8 +6370,8 @@ function decryptWithViewing2(encrypted, viewingKey) {
6311
6370
  }
6312
6371
  const encKey = deriveEncryptionKey2(viewingKey.privateKey);
6313
6372
  try {
6314
- const ciphertext = (0, import_utils26.hexToBytes)(encrypted.ciphertext.slice(2));
6315
- const nonce = (0, import_utils26.hexToBytes)(encrypted.nonce.slice(2));
6373
+ const ciphertext = (0, import_utils27.hexToBytes)(encrypted.ciphertext.slice(2));
6374
+ const nonce = (0, import_utils27.hexToBytes)(encrypted.nonce.slice(2));
6316
6375
  if (nonce.length !== NONCE_SIZE2) {
6317
6376
  throw new ValidationError(
6318
6377
  `Invalid nonce length: ${nonce.length}. Expected: ${NONCE_SIZE2}`,
@@ -6362,15 +6421,15 @@ function deriveChildViewingKey(parentKey, childPath, label) {
6362
6421
  if (!childPath || typeof childPath !== "string") {
6363
6422
  throw new ValidationError("childPath must be a non-empty string", "childPath");
6364
6423
  }
6365
- const parentBytes = (0, import_utils26.hexToBytes)(parentKey.privateKey.slice(2));
6424
+ const parentBytes = (0, import_utils27.hexToBytes)(parentKey.privateKey.slice(2));
6366
6425
  try {
6367
- const childBytes = (0, import_hmac4.hmac)(import_sha2568.sha256, (0, import_utils26.utf8ToBytes)(childPath), parentBytes);
6426
+ const childBytes = (0, import_hmac4.hmac)(import_sha2568.sha256, (0, import_utils27.utf8ToBytes)(childPath), parentBytes);
6368
6427
  const publicBytes = import_ed255198.ed25519.getPublicKey(childBytes);
6369
6428
  const hashBytes = (0, import_sha2568.sha256)(publicBytes);
6370
6429
  const result = {
6371
- privateKey: `0x${(0, import_utils26.bytesToHex)(childBytes)}`,
6372
- publicKey: `0x${(0, import_utils26.bytesToHex)(publicBytes)}`,
6373
- hash: `0x${(0, import_utils26.bytesToHex)(hashBytes)}`,
6430
+ privateKey: `0x${(0, import_utils27.bytesToHex)(childBytes)}`,
6431
+ publicKey: `0x${(0, import_utils27.bytesToHex)(publicBytes)}`,
6432
+ hash: `0x${(0, import_utils27.bytesToHex)(hashBytes)}`,
6374
6433
  label: label ?? `${parentKey.label ?? "Key"}/${childPath}`,
6375
6434
  createdAt: Date.now()
6376
6435
  };
@@ -6387,7 +6446,7 @@ function getViewingPublicKey(viewingPrivateKey) {
6387
6446
  "viewingPrivateKey"
6388
6447
  );
6389
6448
  }
6390
- const privateBytes = (0, import_utils26.hexToBytes)(viewingPrivateKey.slice(2));
6449
+ const privateBytes = (0, import_utils27.hexToBytes)(viewingPrivateKey.slice(2));
6391
6450
  if (privateBytes.length !== 32) {
6392
6451
  throw new ValidationError(
6393
6452
  "viewingPrivateKey must be 32 bytes",
@@ -6396,12 +6455,12 @@ function getViewingPublicKey(viewingPrivateKey) {
6396
6455
  }
6397
6456
  try {
6398
6457
  const publicBytes = import_ed255198.ed25519.getPublicKey(privateBytes);
6399
- return `0x${(0, import_utils26.bytesToHex)(publicBytes)}`;
6458
+ return `0x${(0, import_utils27.bytesToHex)(publicBytes)}`;
6400
6459
  } finally {
6401
6460
  secureWipe(privateBytes);
6402
6461
  }
6403
6462
  }
6404
- var import_ed255198, import_sha2568, import_hmac4, import_hkdf2, import_utils26, import_chacha2, VIEWING_KEY_CONTEXT2, ENCRYPTION_DOMAIN2, NONCE_SIZE2, EXPORT_VERSION;
6463
+ var import_ed255198, import_sha2568, import_hmac4, import_hkdf2, import_utils27, import_chacha2, VIEWING_KEY_CONTEXT2, ENCRYPTION_DOMAIN2, NONCE_SIZE2, EXPORT_VERSION;
6405
6464
  var init_viewing_key = __esm({
6406
6465
  "src/chains/solana/viewing-key.ts"() {
6407
6466
  "use strict";
@@ -6409,7 +6468,7 @@ var init_viewing_key = __esm({
6409
6468
  import_sha2568 = require("@noble/hashes/sha256");
6410
6469
  import_hmac4 = require("@noble/hashes/hmac");
6411
6470
  import_hkdf2 = require("@noble/hashes/hkdf");
6412
- import_utils26 = require("@noble/hashes/utils");
6471
+ import_utils27 = require("@noble/hashes/utils");
6413
6472
  import_chacha2 = require("@noble/ciphers/chacha.js");
6414
6473
  init_errors();
6415
6474
  init_validation();
@@ -6429,7 +6488,7 @@ function toAddress(pubkey) {
6429
6488
  return (0, import_compat.fromLegacyPublicKey)(pubkey);
6430
6489
  }
6431
6490
  function toPublicKey(addr) {
6432
- return new import_web311.PublicKey(addr);
6491
+ return new import_web312.PublicKey(addr);
6433
6492
  }
6434
6493
  function createAddress(base583) {
6435
6494
  return (0, import_kit.address)(base583);
@@ -6447,7 +6506,7 @@ function createDualRpcClient(endpoint, wsEndpoint, commitment = "confirmed") {
6447
6506
  const derivedWsEndpoint = wsEndpoint ?? deriveWsEndpoint(endpoint);
6448
6507
  const rpc = (0, import_kit.createSolanaRpc)(endpoint);
6449
6508
  const rpcSubscriptions = (0, import_kit.createSolanaRpcSubscriptions)(derivedWsEndpoint);
6450
- const legacyConnection = new import_web311.Connection(endpoint, {
6509
+ const legacyConnection = new import_web312.Connection(endpoint, {
6451
6510
  commitment,
6452
6511
  wsEndpoint: derivedWsEndpoint
6453
6512
  });
@@ -6486,28 +6545,28 @@ function isAddress(value) {
6486
6545
  return typeof value === "string" && value.length >= 32 && value.length <= 44;
6487
6546
  }
6488
6547
  function isPublicKey(value) {
6489
- return value instanceof import_web311.PublicKey;
6548
+ return value instanceof import_web312.PublicKey;
6490
6549
  }
6491
6550
  function normalizeAddress(input) {
6492
6551
  let base583;
6493
- if (input instanceof import_web311.PublicKey) {
6552
+ if (input instanceof import_web312.PublicKey) {
6494
6553
  base583 = input.toBase58();
6495
6554
  } else {
6496
6555
  base583 = input;
6497
6556
  }
6498
6557
  return {
6499
6558
  address: (0, import_kit.address)(base583),
6500
- publicKey: new import_web311.PublicKey(base583),
6559
+ publicKey: new import_web312.PublicKey(base583),
6501
6560
  base58: base583
6502
6561
  };
6503
6562
  }
6504
- var import_kit, import_compat, import_web311, LAMPORTS_PER_SOL2, RpcHelpers;
6563
+ var import_kit, import_compat, import_web312, LAMPORTS_PER_SOL2, RpcHelpers;
6505
6564
  var init_kit_compat = __esm({
6506
6565
  "src/chains/solana/kit-compat.ts"() {
6507
6566
  "use strict";
6508
6567
  import_kit = require("@solana/kit");
6509
6568
  import_compat = require("@solana/compat");
6510
- import_web311 = require("@solana/web3.js");
6569
+ import_web312 = require("@solana/web3.js");
6511
6570
  LAMPORTS_PER_SOL2 = 1000000000n;
6512
6571
  RpcHelpers = {
6513
6572
  /**
@@ -10787,7 +10846,7 @@ var require_dist = __commonJS({
10787
10846
  var http = __importStar(require("http"));
10788
10847
  var https_1 = require("https");
10789
10848
  __exportStar(require_helpers3(), exports2);
10790
- var INTERNAL = Symbol("AgentBaseInternalState");
10849
+ var INTERNAL = /* @__PURE__ */ Symbol("AgentBaseInternalState");
10791
10850
  var Agent = class extends http.Agent {
10792
10851
  constructor(opts) {
10793
10852
  super(opts);
@@ -12395,12 +12454,12 @@ function createClusterClient(cluster, options = {}) {
12395
12454
  ...options
12396
12455
  });
12397
12456
  }
12398
- var import_kit2, import_web312, RPCErrorType, SolanaRPCClient, RPC_ENDPOINTS;
12457
+ var import_kit2, import_web313, RPCErrorType, SolanaRPCClient, RPC_ENDPOINTS;
12399
12458
  var init_rpc_client = __esm({
12400
12459
  "src/chains/solana/rpc-client.ts"() {
12401
12460
  "use strict";
12402
12461
  import_kit2 = require("@solana/kit");
12403
- import_web312 = require("@solana/web3.js");
12462
+ import_web313 = require("@solana/web3.js");
12404
12463
  init_kit_compat();
12405
12464
  init_proxy();
12406
12465
  RPCErrorType = /* @__PURE__ */ ((RPCErrorType2) => {
@@ -12513,7 +12572,7 @@ var init_rpc_client = __esm({
12513
12572
  return {
12514
12573
  rpc: (0, import_kit2.createSolanaRpc)(endpoint),
12515
12574
  rpcSubscriptions: (0, import_kit2.createSolanaRpcSubscriptions)(wsEndpoint),
12516
- legacyConnection: new import_web312.Connection(endpoint, connectionOptions),
12575
+ legacyConnection: new import_web313.Connection(endpoint, connectionOptions),
12517
12576
  endpoint
12518
12577
  };
12519
12578
  }
@@ -12585,7 +12644,7 @@ var init_rpc_client = __esm({
12585
12644
  ...sendOptions
12586
12645
  } = options;
12587
12646
  let txToSend = transaction;
12588
- if (this.usePriorityFees && !skipPriorityFee && transaction instanceof import_web312.Transaction) {
12647
+ if (this.usePriorityFees && !skipPriorityFee && transaction instanceof import_web313.Transaction) {
12589
12648
  txToSend = await this.addPriorityFee(
12590
12649
  transaction,
12591
12650
  priorityFeeMicroLamports,
@@ -12728,14 +12787,14 @@ var init_rpc_client = __esm({
12728
12787
  const estimate = await this.estimatePriorityFee(transaction);
12729
12788
  feeToUse = estimate.microLamportsPerComputeUnit;
12730
12789
  }
12731
- const modifiedTx = new import_web312.Transaction();
12790
+ const modifiedTx = new import_web313.Transaction();
12732
12791
  modifiedTx.add(
12733
- import_web312.ComputeBudgetProgram.setComputeUnitLimit({
12792
+ import_web313.ComputeBudgetProgram.setComputeUnitLimit({
12734
12793
  units: computeUnitLimit ?? 2e5
12735
12794
  })
12736
12795
  );
12737
12796
  modifiedTx.add(
12738
- import_web312.ComputeBudgetProgram.setComputeUnitPrice({
12797
+ import_web313.ComputeBudgetProgram.setComputeUnitPrice({
12739
12798
  microLamports: feeToUse
12740
12799
  })
12741
12800
  );
@@ -13025,9 +13084,9 @@ function estimateComputeUnits(instructions) {
13025
13084
  units += 3e4;
13026
13085
  } else if (programId === MEMO_PROGRAM_ID) {
13027
13086
  units += 2e3;
13028
- } else if (programId === import_web313.SystemProgram.programId.toBase58()) {
13087
+ } else if (programId === import_web314.SystemProgram.programId.toBase58()) {
13029
13088
  units += 3e3;
13030
- } else if (programId === import_web313.ComputeBudgetProgram.programId.toBase58()) {
13089
+ } else if (programId === import_web314.ComputeBudgetProgram.programId.toBase58()) {
13031
13090
  units += 500;
13032
13091
  }
13033
13092
  }
@@ -13047,11 +13106,11 @@ function calculatePriorityFee(priority) {
13047
13106
  return 1e3;
13048
13107
  }
13049
13108
  }
13050
- var import_web313, import_spl_token7, DEFAULT_COMPUTE_UNITS, DEFAULT_PRIORITY_FEE, MIN_COMPUTE_UNITS, MAX_COMPUTE_UNITS, ShieldedTransactionType, ShieldedTransactionBuilder;
13109
+ var import_web314, import_spl_token7, DEFAULT_COMPUTE_UNITS, DEFAULT_PRIORITY_FEE, MIN_COMPUTE_UNITS, MAX_COMPUTE_UNITS, ShieldedTransactionType, ShieldedTransactionBuilder;
13051
13110
  var init_transaction_builder = __esm({
13052
13111
  "src/chains/solana/transaction-builder.ts"() {
13053
13112
  "use strict";
13054
- import_web313 = require("@solana/web3.js");
13113
+ import_web314 = require("@solana/web3.js");
13055
13114
  import_spl_token7 = require("@solana/spl-token");
13056
13115
  init_stealth2();
13057
13116
  init_types();
@@ -13106,14 +13165,14 @@ var init_transaction_builder = __esm({
13106
13165
  }
13107
13166
  const { stealthAddress } = generateEd25519StealthAddress(recipientMetaAddress);
13108
13167
  const stealthAddressBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.address);
13109
- const stealthPubkey = new import_web313.PublicKey(stealthAddressBase58);
13168
+ const stealthPubkey = new import_web314.PublicKey(stealthAddressBase58);
13110
13169
  const ephemeralPubkeyBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.ephemeralPublicKey);
13111
13170
  const stealthATA = await (0, import_spl_token7.getAssociatedTokenAddress)(mint, stealthPubkey, true);
13112
13171
  const instructions = [];
13113
13172
  if (this.priorityFee > 0) {
13114
13173
  instructions.push(
13115
- import_web313.ComputeBudgetProgram.setComputeUnitLimit({ units: this.computeUnits }),
13116
- import_web313.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.priorityFee })
13174
+ import_web314.ComputeBudgetProgram.setComputeUnitLimit({ units: this.computeUnits }),
13175
+ import_web314.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.priorityFee })
13117
13176
  );
13118
13177
  }
13119
13178
  let needsAtaCreation = false;
@@ -13145,9 +13204,9 @@ var init_transaction_builder = __esm({
13145
13204
  stealthAddressBase58
13146
13205
  );
13147
13206
  instructions.push(
13148
- new import_web313.TransactionInstruction({
13207
+ new import_web314.TransactionInstruction({
13149
13208
  keys: [],
13150
- programId: new import_web313.PublicKey(MEMO_PROGRAM_ID),
13209
+ programId: new import_web314.PublicKey(MEMO_PROGRAM_ID),
13151
13210
  data: Buffer.from(memoContent, "utf-8")
13152
13211
  })
13153
13212
  );
@@ -13179,17 +13238,17 @@ var init_transaction_builder = __esm({
13179
13238
  }
13180
13239
  const { stealthAddress } = generateEd25519StealthAddress(recipientMetaAddress);
13181
13240
  const stealthAddressBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.address);
13182
- const stealthPubkey = new import_web313.PublicKey(stealthAddressBase58);
13241
+ const stealthPubkey = new import_web314.PublicKey(stealthAddressBase58);
13183
13242
  const ephemeralPubkeyBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.ephemeralPublicKey);
13184
13243
  const instructions = [];
13185
13244
  if (this.priorityFee > 0) {
13186
13245
  instructions.push(
13187
- import_web313.ComputeBudgetProgram.setComputeUnitLimit({ units: this.computeUnits }),
13188
- import_web313.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.priorityFee })
13246
+ import_web314.ComputeBudgetProgram.setComputeUnitLimit({ units: this.computeUnits }),
13247
+ import_web314.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.priorityFee })
13189
13248
  );
13190
13249
  }
13191
13250
  instructions.push(
13192
- import_web313.SystemProgram.transfer({
13251
+ import_web314.SystemProgram.transfer({
13193
13252
  fromPubkey: sender,
13194
13253
  toPubkey: stealthPubkey,
13195
13254
  lamports: amount
@@ -13202,9 +13261,9 @@ var init_transaction_builder = __esm({
13202
13261
  stealthAddressBase58
13203
13262
  );
13204
13263
  instructions.push(
13205
- new import_web313.TransactionInstruction({
13264
+ new import_web314.TransactionInstruction({
13206
13265
  keys: [],
13207
- programId: new import_web313.PublicKey(MEMO_PROGRAM_ID),
13266
+ programId: new import_web314.PublicKey(MEMO_PROGRAM_ID),
13208
13267
  data: Buffer.from(memoContent, "utf-8")
13209
13268
  })
13210
13269
  );
@@ -13237,8 +13296,8 @@ var init_transaction_builder = __esm({
13237
13296
  );
13238
13297
  if (this.priorityFee > 0) {
13239
13298
  instructions.push(
13240
- import_web313.ComputeBudgetProgram.setComputeUnitLimit({ units: batchComputeUnits }),
13241
- import_web313.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.priorityFee })
13299
+ import_web314.ComputeBudgetProgram.setComputeUnitLimit({ units: batchComputeUnits }),
13300
+ import_web314.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: this.priorityFee })
13242
13301
  );
13243
13302
  }
13244
13303
  for (const transfer of transfers) {
@@ -13247,7 +13306,7 @@ var init_transaction_builder = __esm({
13247
13306
  }
13248
13307
  const { stealthAddress } = generateEd25519StealthAddress(transfer.recipientMetaAddress);
13249
13308
  const stealthAddressBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.address);
13250
- const stealthPubkey = new import_web313.PublicKey(stealthAddressBase58);
13309
+ const stealthPubkey = new import_web314.PublicKey(stealthAddressBase58);
13251
13310
  const ephemeralPubkeyBase58 = ed25519PublicKeyToSolanaAddress(stealthAddress.ephemeralPublicKey);
13252
13311
  const stealthATA = await (0, import_spl_token7.getAssociatedTokenAddress)(mint, stealthPubkey, true);
13253
13312
  try {
@@ -13286,9 +13345,9 @@ var init_transaction_builder = __esm({
13286
13345
  stealthAddressBase58
13287
13346
  );
13288
13347
  instructions.push(
13289
- new import_web313.TransactionInstruction({
13348
+ new import_web314.TransactionInstruction({
13290
13349
  keys: [],
13291
- programId: new import_web313.PublicKey(MEMO_PROGRAM_ID),
13350
+ programId: new import_web314.PublicKey(MEMO_PROGRAM_ID),
13292
13351
  data: Buffer.from(memoContent, "utf-8")
13293
13352
  })
13294
13353
  );
@@ -13320,12 +13379,12 @@ var init_transaction_builder = __esm({
13320
13379
  const priorityFee = BigInt(Math.ceil(effectiveComputeUnits * this.priorityFee / 1e6));
13321
13380
  const estimatedFee = baseFee + priorityFee;
13322
13381
  if (this.useVersioned) {
13323
- const messageV0 = new import_web313.TransactionMessage({
13382
+ const messageV0 = new import_web314.TransactionMessage({
13324
13383
  payerKey: this.feePayer,
13325
13384
  recentBlockhash: blockhash,
13326
13385
  instructions
13327
13386
  }).compileToV0Message(this.lookupTables.length > 0 ? this.lookupTables : void 0);
13328
- const versionedTransaction = new import_web313.VersionedTransaction(messageV0);
13387
+ const versionedTransaction = new import_web314.VersionedTransaction(messageV0);
13329
13388
  return {
13330
13389
  type,
13331
13390
  versionedTransaction,
@@ -13336,7 +13395,7 @@ var init_transaction_builder = __esm({
13336
13395
  estimatedFee
13337
13396
  };
13338
13397
  } else {
13339
- const transaction = new import_web313.Transaction();
13398
+ const transaction = new import_web314.Transaction();
13340
13399
  transaction.recentBlockhash = blockhash;
13341
13400
  transaction.lastValidBlockHeight = lastValidBlockHeight;
13342
13401
  transaction.feePayer = this.feePayer;
@@ -13381,9 +13440,9 @@ var init_transaction_builder = __esm({
13381
13440
  deserializeSignedTransaction(serialized, isVersioned) {
13382
13441
  const buffer = Buffer.from(serialized, "base64");
13383
13442
  if (isVersioned) {
13384
- return import_web313.VersionedTransaction.deserialize(buffer);
13443
+ return import_web314.VersionedTransaction.deserialize(buffer);
13385
13444
  } else {
13386
- return import_web313.Transaction.from(buffer);
13445
+ return import_web314.Transaction.from(buffer);
13387
13446
  }
13388
13447
  }
13389
13448
  // ─── Configuration ────────────────────────────────────────────────────────────
@@ -13455,9 +13514,9 @@ async function shieldedTransfer(params) {
13455
13514
  const stealthResult = generateEd25519StealthAddress(recipientMeta);
13456
13515
  const stealthAddr = stealthResult.stealthAddress;
13457
13516
  const stealthPubkey = ed25519PublicKeyToSolanaAddress(stealthAddr.address);
13458
- const stealthAccountPubkey = new import_web314.PublicKey(stealthPubkey);
13517
+ const stealthAccountPubkey = new import_web315.PublicKey(stealthPubkey);
13459
13518
  const { commitment, blinding } = commit(amount);
13460
- const commitmentBytes = (0, import_utils27.hexToBytes)(commitment.slice(2));
13519
+ const commitmentBytes = (0, import_utils28.hexToBytes)(commitment.slice(2));
13461
13520
  if (commitmentBytes.length !== 33) {
13462
13521
  throw new ValidationError(
13463
13522
  `Invalid commitment size: ${commitmentBytes.length}, expected 33`,
@@ -13465,21 +13524,21 @@ async function shieldedTransfer(params) {
13465
13524
  );
13466
13525
  }
13467
13526
  const ephemeralPubkeyHex = stealthAddr.ephemeralPublicKey;
13468
- const ephemeralPubkeyBytes = (0, import_utils27.hexToBytes)(ephemeralPubkeyHex.slice(2));
13527
+ const ephemeralPubkeyBytes = (0, import_utils28.hexToBytes)(ephemeralPubkeyHex.slice(2));
13469
13528
  const ephemeralPubkey33 = new Uint8Array(33);
13470
13529
  ephemeralPubkey33[0] = 2;
13471
13530
  ephemeralPubkey33.set(ephemeralPubkeyBytes.slice(0, 32), 1);
13472
- const viewingKeyBytes = (0, import_utils27.hexToBytes)(recipientMeta.viewingKey.slice(2));
13531
+ const viewingKeyBytes = (0, import_utils28.hexToBytes)(recipientMeta.viewingKey.slice(2));
13473
13532
  const viewingKeyHash = (0, import_sha23.sha256)(viewingKeyBytes);
13474
13533
  const encryptedAmount = encryptAmount(amount, recipientMeta.viewingKey);
13475
- const encryptedAmountBytes = (0, import_utils27.hexToBytes)(encryptedAmount.slice(2));
13534
+ const encryptedAmountBytes = (0, import_utils28.hexToBytes)(encryptedAmount.slice(2));
13476
13535
  const mockProof = createMockProof(commitment, amount, blinding);
13477
13536
  const configAccount = await connection.getAccountInfo(CONFIG_PDA);
13478
13537
  if (!configAccount) {
13479
13538
  throw new ValidationError("SIP Privacy program not initialized", "config");
13480
13539
  }
13481
13540
  const totalTransfers = configAccount.data.readBigUInt64LE(43);
13482
- const [transferRecordPda] = import_web314.PublicKey.findProgramAddressSync(
13541
+ const [transferRecordPda] = import_web315.PublicKey.findProgramAddressSync(
13483
13542
  [
13484
13543
  TRANSFER_RECORD_SEED,
13485
13544
  sender.toBuffer(),
@@ -13496,19 +13555,19 @@ async function shieldedTransfer(params) {
13496
13555
  proof: mockProof,
13497
13556
  actualAmount: amount
13498
13557
  });
13499
- const instruction = new import_web314.TransactionInstruction({
13558
+ const instruction = new import_web315.TransactionInstruction({
13500
13559
  keys: [
13501
13560
  { pubkey: CONFIG_PDA, isSigner: false, isWritable: true },
13502
13561
  { pubkey: transferRecordPda, isSigner: false, isWritable: true },
13503
13562
  { pubkey: sender, isSigner: true, isWritable: true },
13504
13563
  { pubkey: stealthAccountPubkey, isSigner: false, isWritable: true },
13505
13564
  { pubkey: FEE_COLLECTOR, isSigner: false, isWritable: true },
13506
- { pubkey: import_web314.SystemProgram.programId, isSigner: false, isWritable: false }
13565
+ { pubkey: import_web315.SystemProgram.programId, isSigner: false, isWritable: false }
13507
13566
  ],
13508
13567
  programId: SIP_PRIVACY_PROGRAM_ID,
13509
13568
  data: instructionData
13510
13569
  });
13511
- const transaction = new import_web314.Transaction();
13570
+ const transaction = new import_web315.Transaction();
13512
13571
  transaction.add(instruction);
13513
13572
  const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
13514
13573
  transaction.recentBlockhash = blockhash;
@@ -13528,7 +13587,7 @@ async function shieldedTransfer(params) {
13528
13587
  ephemeralPublicKey: ephemeralPubkeyHex,
13529
13588
  commitment,
13530
13589
  viewTag: `0x${stealthAddr.viewTag.toString(16).padStart(2, "0")}`,
13531
- viewingKeyHash: `0x${(0, import_utils27.bytesToHex)(viewingKeyHash)}`,
13590
+ viewingKeyHash: `0x${(0, import_utils28.bytesToHex)(viewingKeyHash)}`,
13532
13591
  explorerUrl: `https://solscan.io/tx/${signature}?cluster=${cluster}`
13533
13592
  };
13534
13593
  }
@@ -13575,12 +13634,12 @@ function buildShieldedTransferData(params) {
13575
13634
  }
13576
13635
  function createMockProof(commitment, amount, blinding) {
13577
13636
  const proof = new Uint8Array(128);
13578
- const commitmentBytes = (0, import_utils27.hexToBytes)(commitment.slice(2));
13637
+ const commitmentBytes = (0, import_utils28.hexToBytes)(commitment.slice(2));
13579
13638
  const inputHash = (0, import_sha23.sha256)(
13580
13639
  new Uint8Array([
13581
13640
  ...commitmentBytes,
13582
13641
  ...bigintToLeBytes(amount),
13583
- ...(0, import_utils27.hexToBytes)(blinding.slice(2))
13642
+ ...(0, import_utils28.hexToBytes)(blinding.slice(2))
13584
13643
  ])
13585
13644
  );
13586
13645
  proof.set(inputHash, 0);
@@ -13604,30 +13663,30 @@ async function getCluster(connection) {
13604
13663
  }
13605
13664
  function encryptAmount(amount, viewingKey) {
13606
13665
  const amountBytes = bigintToLeBytes(amount);
13607
- const keyHash = (0, import_sha23.sha256)((0, import_utils27.hexToBytes)(viewingKey.slice(2)));
13666
+ const keyHash = (0, import_sha23.sha256)((0, import_utils28.hexToBytes)(viewingKey.slice(2)));
13608
13667
  const encrypted = new Uint8Array(amountBytes.length);
13609
13668
  for (let i = 0; i < amountBytes.length; i++) {
13610
13669
  encrypted[i] = amountBytes[i] ^ keyHash[i];
13611
13670
  }
13612
- return `0x${(0, import_utils27.bytesToHex)(encrypted)}`;
13671
+ return `0x${(0, import_utils28.bytesToHex)(encrypted)}`;
13613
13672
  }
13614
- var import_web314, import_sha23, import_utils27, SIP_PRIVACY_PROGRAM_ID, CONFIG_PDA, FEE_COLLECTOR, TRANSFER_RECORD_SEED, SHIELDED_TRANSFER_DISCRIMINATOR;
13673
+ var import_web315, import_sha23, import_utils28, SIP_PRIVACY_PROGRAM_ID, CONFIG_PDA, FEE_COLLECTOR, TRANSFER_RECORD_SEED, SHIELDED_TRANSFER_DISCRIMINATOR;
13615
13674
  var init_anchor_transfer = __esm({
13616
13675
  "src/chains/solana/anchor-transfer.ts"() {
13617
13676
  "use strict";
13618
- import_web314 = require("@solana/web3.js");
13677
+ import_web315 = require("@solana/web3.js");
13619
13678
  import_sha23 = require("@noble/hashes/sha2");
13620
- import_utils27 = require("@noble/hashes/utils");
13679
+ import_utils28 = require("@noble/hashes/utils");
13621
13680
  init_errors();
13622
13681
  init_commitment();
13623
13682
  init_stealth2();
13624
- SIP_PRIVACY_PROGRAM_ID = new import_web314.PublicKey(
13683
+ SIP_PRIVACY_PROGRAM_ID = new import_web315.PublicKey(
13625
13684
  "S1PMFspo4W6BYKHWkHNF7kZ3fnqibEXg3LQjxepS9at"
13626
13685
  );
13627
- CONFIG_PDA = new import_web314.PublicKey(
13686
+ CONFIG_PDA = new import_web315.PublicKey(
13628
13687
  "BVawZkppFewygA5nxdrLma4ThKx8Th7bW4KTCkcWTZwZ"
13629
13688
  );
13630
- FEE_COLLECTOR = new import_web314.PublicKey(
13689
+ FEE_COLLECTOR = new import_web315.PublicKey(
13631
13690
  "S1P6j1yeTm6zkewQVeihrTZvmfoHABRkHDhabWTuWMd"
13632
13691
  );
13633
13692
  TRANSFER_RECORD_SEED = Buffer.from("transfer_record");
@@ -13650,24 +13709,24 @@ function createVerifyInstructionData(proof, publicInputs) {
13650
13709
  }
13651
13710
  function formatFundingInputs(params) {
13652
13711
  return [
13653
- (0, import_utils28.hexToBytes)(params.commitmentHash.slice(2)),
13712
+ (0, import_utils29.hexToBytes)(params.commitmentHash.slice(2)),
13654
13713
  bigintToBytes32(params.minimumRequired),
13655
- (0, import_utils28.hexToBytes)(params.assetId.slice(2))
13714
+ (0, import_utils29.hexToBytes)(params.assetId.slice(2))
13656
13715
  ];
13657
13716
  }
13658
13717
  function formatOwnershipInputs(params) {
13659
13718
  return [
13660
- (0, import_utils28.hexToBytes)(params.stealthPubkey.slice(2)),
13661
- (0, import_utils28.hexToBytes)(params.ephemeralPubkey.slice(2)),
13662
- (0, import_utils28.hexToBytes)(params.nullifier.slice(2))
13719
+ (0, import_utils29.hexToBytes)(params.stealthPubkey.slice(2)),
13720
+ (0, import_utils29.hexToBytes)(params.ephemeralPubkey.slice(2)),
13721
+ (0, import_utils29.hexToBytes)(params.nullifier.slice(2))
13663
13722
  ];
13664
13723
  }
13665
13724
  function toPublicKey2(input) {
13666
- return typeof input === "string" ? new import_web315.PublicKey(input) : input;
13725
+ return typeof input === "string" ? new import_web316.PublicKey(input) : input;
13667
13726
  }
13668
13727
  function toBytes(input) {
13669
13728
  if (typeof input === "string") {
13670
- return (0, import_utils28.hexToBytes)(input.startsWith("0x") ? input.slice(2) : input);
13729
+ return (0, import_utils29.hexToBytes)(input.startsWith("0x") ? input.slice(2) : input);
13671
13730
  }
13672
13731
  return input;
13673
13732
  }
@@ -13680,13 +13739,13 @@ function bigintToBytes32(value) {
13680
13739
  }
13681
13740
  return bytes;
13682
13741
  }
13683
- var import_web315, import_utils28, ProofType, DEFAULT_COMPUTE_UNITS2, PROOF_SIZE, SunspotVerifier;
13742
+ var import_web316, import_utils29, ProofType, DEFAULT_COMPUTE_UNITS2, PROOF_SIZE, SunspotVerifier;
13684
13743
  var init_sunspot_verifier = __esm({
13685
13744
  "src/chains/solana/sunspot-verifier.ts"() {
13686
13745
  "use strict";
13687
- import_web315 = require("@solana/web3.js");
13746
+ import_web316 = require("@solana/web3.js");
13688
13747
  init_errors();
13689
- import_utils28 = require("@noble/hashes/utils");
13748
+ import_utils29 = require("@noble/hashes/utils");
13690
13749
  ProofType = /* @__PURE__ */ ((ProofType2) => {
13691
13750
  ProofType2["Funding"] = "funding";
13692
13751
  ProofType2["Ownership"] = "ownership";
@@ -13801,14 +13860,14 @@ var init_sunspot_verifier = __esm({
13801
13860
  proofBytes,
13802
13861
  ...publicInputBytes.map((b) => Buffer.from(b))
13803
13862
  ]);
13804
- const transaction = new import_web315.Transaction();
13863
+ const transaction = new import_web316.Transaction();
13805
13864
  transaction.add(
13806
- import_web315.ComputeBudgetProgram.setComputeUnitLimit({
13865
+ import_web316.ComputeBudgetProgram.setComputeUnitLimit({
13807
13866
  units: this.config.computeUnits
13808
13867
  })
13809
13868
  );
13810
13869
  transaction.add(
13811
- new import_web315.TransactionInstruction({
13870
+ new import_web316.TransactionInstruction({
13812
13871
  keys: [],
13813
13872
  // Verifier programs typically don't need accounts
13814
13873
  programId: verifierProgram,
@@ -13906,6 +13965,202 @@ var init_sunspot_verifier = __esm({
13906
13965
  }
13907
13966
  });
13908
13967
 
13968
+ // src/chains/solana/relayer-fee.ts
13969
+ function computeRelayerFee(amount, config) {
13970
+ if (!Number.isInteger(config.bps) || config.bps < 0) {
13971
+ throw new Error("bps must be a non-negative integer");
13972
+ }
13973
+ if (amount < 0n) {
13974
+ throw new Error("amount must be a non-negative bigint");
13975
+ }
13976
+ if (typeof config.flatFloor !== "bigint" || config.flatFloor < 0n) {
13977
+ throw new Error("flatFloor must be a non-negative bigint");
13978
+ }
13979
+ const bpsFee = amount * BigInt(config.bps) / 10000n;
13980
+ return bpsFee > config.flatFloor ? bpsFee : config.flatFloor;
13981
+ }
13982
+ var init_relayer_fee = __esm({
13983
+ "src/chains/solana/relayer-fee.ts"() {
13984
+ "use strict";
13985
+ }
13986
+ });
13987
+
13988
+ // src/chains/solana/gasless-cashout.ts
13989
+ async function buildGaslessCashout(params) {
13990
+ const {
13991
+ connection,
13992
+ stealthAddress,
13993
+ ephemeralPublicKey,
13994
+ viewingPrivateKey,
13995
+ spendingPrivateKey,
13996
+ destinationAddress,
13997
+ mint,
13998
+ relayerPublicKey,
13999
+ relayerFeeAccount,
14000
+ feeConfig,
14001
+ version = "2"
14002
+ } = params;
14003
+ const stealthSigner = deriveStealthSigner({
14004
+ stealthAddress,
14005
+ ephemeralPublicKey,
14006
+ viewingPrivateKey,
14007
+ spendingPrivateKey,
14008
+ version
14009
+ });
14010
+ const stealthPubkey = stealthSigner.publicKey;
14011
+ const stealthATA = await (0, import_spl_token8.getAssociatedTokenAddress)(mint, stealthPubkey, true);
14012
+ const destinationPubkey = new import_web317.PublicKey(destinationAddress);
14013
+ const destinationATA = await (0, import_spl_token8.getAssociatedTokenAddress)(mint, destinationPubkey);
14014
+ if (destinationATA.equals(stealthATA)) {
14015
+ throw new Error(
14016
+ "destinationAddress resolves to the stealth token account; choose a different destination"
14017
+ );
14018
+ }
14019
+ let feeAccount;
14020
+ try {
14021
+ feeAccount = await (0, import_spl_token8.getAccount)(connection, relayerFeeAccount);
14022
+ } catch {
14023
+ throw new Error("relayerFeeAccount does not exist or is not a token account");
14024
+ }
14025
+ if (!feeAccount.mint.equals(mint)) {
14026
+ throw new Error("relayerFeeAccount is not an associated token account for the given mint");
14027
+ }
14028
+ let balanceResp;
14029
+ try {
14030
+ balanceResp = await connection.getTokenAccountBalance(stealthATA);
14031
+ } catch {
14032
+ throw new Error(
14033
+ `Stealth token account ${stealthATA.toBase58()} for mint ${mint.toBase58()} does not exist or holds no balance; nothing to cash out`
14034
+ );
14035
+ }
14036
+ const grossAmount = BigInt(balanceResp.value.amount);
14037
+ const relayerFee = computeRelayerFee(grossAmount, feeConfig);
14038
+ if (relayerFee >= grossAmount) {
14039
+ throw new Error(
14040
+ `Relayer fee (${relayerFee}) equals or exceeds the claim amount (${grossAmount}); nothing left to forward`
14041
+ );
14042
+ }
14043
+ const netAmount = grossAmount - relayerFee;
14044
+ const transaction = new import_web317.Transaction();
14045
+ transaction.add(
14046
+ (0, import_spl_token8.createAssociatedTokenAccountIdempotentInstruction)(
14047
+ relayerPublicKey,
14048
+ // payer (relayer pays rent)
14049
+ destinationATA,
14050
+ destinationPubkey,
14051
+ mint
14052
+ )
14053
+ );
14054
+ transaction.add(
14055
+ (0, import_spl_token8.createTransferInstruction)(stealthATA, relayerFeeAccount, stealthPubkey, relayerFee)
14056
+ );
14057
+ transaction.add(
14058
+ (0, import_spl_token8.createTransferInstruction)(stealthATA, destinationATA, stealthPubkey, netAmount)
14059
+ );
14060
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
14061
+ transaction.recentBlockhash = blockhash;
14062
+ transaction.lastValidBlockHeight = lastValidBlockHeight;
14063
+ transaction.feePayer = relayerPublicKey;
14064
+ stealthSigner.signTransaction(transaction);
14065
+ return {
14066
+ transaction,
14067
+ stealthAddress,
14068
+ destinationAddress,
14069
+ grossAmount,
14070
+ relayerFee,
14071
+ netAmount,
14072
+ blockhash,
14073
+ lastValidBlockHeight
14074
+ };
14075
+ }
14076
+ function detectCluster5(endpoint) {
14077
+ if (endpoint.includes("devnet")) {
14078
+ return "devnet";
14079
+ }
14080
+ if (endpoint.includes("testnet")) {
14081
+ return "testnet";
14082
+ }
14083
+ if (endpoint.includes("localhost") || endpoint.includes("127.0.0.1")) {
14084
+ return "localnet";
14085
+ }
14086
+ return "mainnet-beta";
14087
+ }
14088
+ async function submitGaslessCashout(params) {
14089
+ const { connection, build, relayerKeypair, jitoRelayer, tipLamports } = params;
14090
+ const { transaction, netAmount, relayerFee, destinationAddress } = build;
14091
+ if (!transaction.feePayer || !transaction.feePayer.equals(relayerKeypair.publicKey)) {
14092
+ throw new Error("relayerKeypair does not match the transaction fee-payer");
14093
+ }
14094
+ const relayerAlreadySigned = transaction.signatures.some(
14095
+ (s) => s.publicKey.equals(relayerKeypair.publicKey) && s.signature !== null
14096
+ );
14097
+ if (!relayerAlreadySigned) {
14098
+ transaction.partialSign(relayerKeypair);
14099
+ }
14100
+ const cluster = detectCluster5(connection.rpcEndpoint);
14101
+ if (jitoRelayer) {
14102
+ const relayed = await jitoRelayer.relayTransaction({
14103
+ transaction,
14104
+ tipLamports,
14105
+ tipPayer: relayerKeypair,
14106
+ waitForConfirmation: true
14107
+ });
14108
+ if (relayed.status !== "confirmed") {
14109
+ throw new Error(
14110
+ `Gasless cash-out via Jito did not confirm (status: ${relayed.status})` + (relayed.error ? `: ${relayed.error}` : "")
14111
+ );
14112
+ }
14113
+ if (!relayed.signature) {
14114
+ throw new Error("Gasless cash-out via Jito returned an empty transaction signature");
14115
+ }
14116
+ return {
14117
+ txSignature: relayed.signature,
14118
+ destinationAddress,
14119
+ amount: netAmount,
14120
+ relayerFee,
14121
+ explorerUrl: getExplorerUrl(relayed.signature, cluster),
14122
+ // Report the TRUE path: the relayer may have fallen back to direct submission.
14123
+ viaJito: relayed.relayed
14124
+ };
14125
+ }
14126
+ const txSignature = await connection.sendRawTransaction(transaction.serialize(), {
14127
+ skipPreflight: false,
14128
+ preflightCommitment: "confirmed"
14129
+ });
14130
+ const confirmation = await connection.confirmTransaction(
14131
+ {
14132
+ signature: txSignature,
14133
+ blockhash: build.blockhash,
14134
+ lastValidBlockHeight: build.lastValidBlockHeight
14135
+ },
14136
+ "confirmed"
14137
+ );
14138
+ if (confirmation.value.err) {
14139
+ throw new Error(
14140
+ `Gasless cash-out landed but failed on-chain: ${JSON.stringify(confirmation.value.err)}`
14141
+ );
14142
+ }
14143
+ return {
14144
+ txSignature,
14145
+ destinationAddress,
14146
+ amount: netAmount,
14147
+ relayerFee,
14148
+ explorerUrl: getExplorerUrl(txSignature, cluster),
14149
+ viaJito: false
14150
+ };
14151
+ }
14152
+ var import_web317, import_spl_token8;
14153
+ var init_gasless_cashout = __esm({
14154
+ "src/chains/solana/gasless-cashout.ts"() {
14155
+ "use strict";
14156
+ import_web317 = require("@solana/web3.js");
14157
+ import_spl_token8 = require("@solana/spl-token");
14158
+ init_stealth_signer();
14159
+ init_relayer_fee();
14160
+ init_constants();
14161
+ }
14162
+ });
14163
+
13909
14164
  // src/chains/solana/index.ts
13910
14165
  var solana_exports = {};
13911
14166
  __export(solana_exports, {
@@ -13952,10 +14207,12 @@ __export(solana_exports, {
13952
14207
  batchGetTokenBalances: () => batchGetTokenBalances,
13953
14208
  batchResolveTokenMetadata: () => batchResolveTokenMetadata,
13954
14209
  batchScanForRecipients: () => batchScanForRecipients,
14210
+ buildGaslessCashout: () => buildGaslessCashout,
13955
14211
  calculatePriorityFee: () => calculatePriorityFee,
13956
14212
  claimStealthPayment: () => claimStealthPayment,
13957
14213
  commitSPLToken: () => commitSPLToken,
13958
14214
  commitSolana: () => commitSolana,
14215
+ computeRelayerFee: () => computeRelayerFee,
13959
14216
  computeViewingKeyHash: () => computeViewingKeyHash,
13960
14217
  computeViewingKeyHashFromPrivate: () => computeViewingKeyHashFromPrivate,
13961
14218
  createAddress: () => createAddress,
@@ -13976,6 +14233,7 @@ __export(solana_exports, {
13976
14233
  decryptWithViewing: () => decryptWithViewing2,
13977
14234
  deriveChildViewingKey: () => deriveChildViewingKey,
13978
14235
  deriveSolanaStealthKeys: () => deriveSolanaStealthKeys,
14236
+ deriveStealthSigner: () => deriveStealthSigner,
13979
14237
  deriveViewingKeyFromSpending: () => deriveViewingKeyFromSpending,
13980
14238
  disposeEphemeralKeypairs: () => disposeEphemeralKeypairs,
13981
14239
  encryptForViewing: () => encryptForViewing2,
@@ -14025,7 +14283,9 @@ __export(solana_exports, {
14025
14283
  sendPrivateSPLTransfer: () => sendPrivateSPLTransfer,
14026
14284
  sendSOLTransfer: () => sendSOLTransfer,
14027
14285
  shieldedTransfer: () => shieldedTransfer,
14286
+ signEd25519WithScalar: () => signEd25519WithScalar,
14028
14287
  solToLamports: () => solToLamports,
14288
+ submitGaslessCashout: () => submitGaslessCashout,
14029
14289
  subtractBlindingsSolana: () => subtractBlindingsSolana,
14030
14290
  subtractCommitmentsSolana: () => subtractCommitmentsSolana,
14031
14291
  toAddress: () => toAddress,
@@ -14069,6 +14329,9 @@ var init_solana = __esm({
14069
14329
  init_anchor_transfer();
14070
14330
  init_kit_compat();
14071
14331
  init_sunspot_verifier();
14332
+ init_gasless_cashout();
14333
+ init_relayer_fee();
14334
+ init_stealth_signer();
14072
14335
  }
14073
14336
  });
14074
14337
 
@@ -14519,10 +14782,10 @@ var init_lib_es2 = __esm({
14519
14782
  }
14520
14783
  });
14521
14784
 
14522
- // ../../node_modules/.pnpm/@ledgerhq+hw-transport@6.35.2/node_modules/@ledgerhq/hw-transport/lib-es/Transport.js
14785
+ // ../../node_modules/.pnpm/@ledgerhq+hw-transport@6.35.3/node_modules/@ledgerhq/hw-transport/lib-es/Transport.js
14523
14786
  var import_events, DEFAULT_LOG_TYPE, Transport;
14524
14787
  var init_Transport = __esm({
14525
- "../../node_modules/.pnpm/@ledgerhq+hw-transport@6.35.2/node_modules/@ledgerhq/hw-transport/lib-es/Transport.js"() {
14788
+ "../../node_modules/.pnpm/@ledgerhq+hw-transport@6.35.3/node_modules/@ledgerhq/hw-transport/lib-es/Transport.js"() {
14526
14789
  "use strict";
14527
14790
  import_events = __toESM(require("events"));
14528
14791
  init_lib_es();
@@ -14851,7 +15114,7 @@ var init_Transport = __esm({
14851
15114
  }
14852
15115
  });
14853
15116
 
14854
- // ../../node_modules/.pnpm/@ledgerhq+devices@8.14.2/node_modules/@ledgerhq/devices/lib-es/hid-framing.js
15117
+ // ../../node_modules/.pnpm/@ledgerhq+devices@8.15.0/node_modules/@ledgerhq/devices/lib-es/hid-framing.js
14855
15118
  function asUInt16BE(value) {
14856
15119
  const b = Buffer.alloc(2);
14857
15120
  b.writeUInt16BE(value, 0);
@@ -14859,7 +15122,7 @@ function asUInt16BE(value) {
14859
15122
  }
14860
15123
  var Tag, initialAcc, createHIDframing, hid_framing_default;
14861
15124
  var init_hid_framing = __esm({
14862
- "../../node_modules/.pnpm/@ledgerhq+devices@8.14.2/node_modules/@ledgerhq/devices/lib-es/hid-framing.js"() {
15125
+ "../../node_modules/.pnpm/@ledgerhq+devices@8.15.0/node_modules/@ledgerhq/devices/lib-es/hid-framing.js"() {
14863
15126
  "use strict";
14864
15127
  init_lib_es();
14865
15128
  Tag = 5;
@@ -16195,7 +16458,7 @@ var require_range = __commonJS({
16195
16458
  var require_comparator = __commonJS({
16196
16459
  "../../node_modules/.pnpm/semver@7.7.3/node_modules/semver/classes/comparator.js"(exports2, module2) {
16197
16460
  "use strict";
16198
- var ANY = Symbol("SemVer ANY");
16461
+ var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
16199
16462
  var Comparator = class _Comparator {
16200
16463
  static get ANY() {
16201
16464
  return ANY;
@@ -16874,10 +17137,10 @@ var require_semver2 = __commonJS({
16874
17137
  }
16875
17138
  });
16876
17139
 
16877
- // ../../node_modules/.pnpm/@ledgerhq+devices@8.14.2/node_modules/@ledgerhq/devices/lib-es/index.js
17140
+ // ../../node_modules/.pnpm/@ledgerhq+devices@8.15.0/node_modules/@ledgerhq/devices/lib-es/index.js
16878
17141
  var import_semver, DeviceModelId, devices, productMap, devicesList, ledgerUSBVendorId, identifyUSBProductId, bluetoothServices, serviceUuidToInfos;
16879
17142
  var init_lib_es3 = __esm({
16880
- "../../node_modules/.pnpm/@ledgerhq+devices@8.14.2/node_modules/@ledgerhq/devices/lib-es/index.js"() {
17143
+ "../../node_modules/.pnpm/@ledgerhq+devices@8.15.0/node_modules/@ledgerhq/devices/lib-es/index.js"() {
16881
17144
  "use strict";
16882
17145
  import_semver = __toESM(require_semver2());
16883
17146
  (function(DeviceModelId2) {
@@ -16936,7 +17199,7 @@ var init_lib_es3 = __esm({
16936
17199
  usbOnly: true,
16937
17200
  memorySize: 1533 * 1024,
16938
17201
  masks: [856686592],
16939
- getBlockSize: (_firmwareVersion) => 32
17202
+ getBlockSize: (_firmwareVersion) => 512
16940
17203
  },
16941
17204
  [DeviceModelId.apex]: {
16942
17205
  id: DeviceModelId.apex,
@@ -16946,7 +17209,7 @@ var init_lib_es3 = __esm({
16946
17209
  usbOnly: false,
16947
17210
  memorySize: 1533 * 1024,
16948
17211
  masks: [859832320],
16949
- getBlockSize: (_firmwareVersion) => 32,
17212
+ getBlockSize: (_firmwareVersion) => 512,
16950
17213
  bluetoothSpec: [
16951
17214
  {
16952
17215
  serviceUuid: "13d63400-2c97-8004-0000-4c6564676572",
@@ -16964,7 +17227,7 @@ var init_lib_es3 = __esm({
16964
17227
  usbOnly: false,
16965
17228
  memorySize: 1533 * 1024,
16966
17229
  masks: [857735168],
16967
- getBlockSize: (_firmwareVersion) => 32,
17230
+ getBlockSize: (_firmwareVersion) => 512,
16968
17231
  bluetoothSpec: [
16969
17232
  {
16970
17233
  serviceUuid: "13d63400-2c97-6004-0000-4c6564676572",
@@ -16982,7 +17245,7 @@ var init_lib_es3 = __esm({
16982
17245
  usbOnly: false,
16983
17246
  memorySize: 1533 * 1024,
16984
17247
  masks: [858783744],
16985
- getBlockSize: (_firmwareVersion) => 32,
17248
+ getBlockSize: (_firmwareVersion) => 512,
16986
17249
  bluetoothSpec: [
16987
17250
  {
16988
17251
  serviceUuid: "13d63400-2c97-3004-0000-4c6564676572",
@@ -17030,7 +17293,7 @@ var init_lib_es3 = __esm({
17030
17293
  }
17031
17294
  });
17032
17295
 
17033
- // ../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.2/node_modules/@ledgerhq/hw-transport-webusb/lib-es/webusb.js
17296
+ // ../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.3/node_modules/@ledgerhq/hw-transport-webusb/lib-es/webusb.js
17034
17297
  async function requestLedgerDevice() {
17035
17298
  const device = await navigator.usb.requestDevice({
17036
17299
  filters: ledgerDevices
@@ -17049,7 +17312,7 @@ async function getFirstLedgerDevice() {
17049
17312
  }
17050
17313
  var ledgerDevices, isSupported;
17051
17314
  var init_webusb = __esm({
17052
- "../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.2/node_modules/@ledgerhq/hw-transport-webusb/lib-es/webusb.js"() {
17315
+ "../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.3/node_modules/@ledgerhq/hw-transport-webusb/lib-es/webusb.js"() {
17053
17316
  "use strict";
17054
17317
  init_lib_es3();
17055
17318
  ledgerDevices = [
@@ -17061,7 +17324,7 @@ var init_webusb = __esm({
17061
17324
  }
17062
17325
  });
17063
17326
 
17064
- // ../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.2/node_modules/@ledgerhq/hw-transport-webusb/lib-es/TransportWebUSB.js
17327
+ // ../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.3/node_modules/@ledgerhq/hw-transport-webusb/lib-es/TransportWebUSB.js
17065
17328
  var TransportWebUSB_exports = {};
17066
17329
  __export(TransportWebUSB_exports, {
17067
17330
  default: () => TransportWebUSB
@@ -17075,7 +17338,7 @@ async function gracefullyResetDevice(device) {
17075
17338
  }
17076
17339
  var configurationValue, endpointNumber, TransportWebUSB;
17077
17340
  var init_TransportWebUSB = __esm({
17078
- "../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.2/node_modules/@ledgerhq/hw-transport-webusb/lib-es/TransportWebUSB.js"() {
17341
+ "../../node_modules/.pnpm/@ledgerhq+hw-transport-webusb@6.34.3/node_modules/@ledgerhq/hw-transport-webusb/lib-es/TransportWebUSB.js"() {
17079
17342
  "use strict";
17080
17343
  init_Transport();
17081
17344
  init_hid_framing();
@@ -18236,7 +18499,7 @@ __export(index_exports, {
18236
18499
  NEARIntentsAdapter: () => NEARIntentsAdapter,
18237
18500
  NEARIntentsBackend: () => NEARIntentsBackend,
18238
18501
  NEAR_DEFAULT_GAS: () => DEFAULT_GAS,
18239
- NEAR_ED25519_ORDER: () => ED25519_ORDER5,
18502
+ NEAR_ED25519_ORDER: () => ED25519_ORDER4,
18240
18503
  NEAR_EXPLORER_URLS: () => NEAR_EXPLORER_URLS,
18241
18504
  NEAR_FEE_CONTRACTS: () => NEAR_FEE_CONTRACTS,
18242
18505
  NEAR_IMPLICIT_ACCOUNT_LENGTH: () => NEAR_IMPLICIT_ACCOUNT_LENGTH,
@@ -18285,6 +18548,8 @@ __export(index_exports, {
18285
18548
  SIPError: () => SIPError,
18286
18549
  SIPNativeBackend: () => SIPNativeBackend,
18287
18550
  SIP_MEMO_PREFIX: () => SIP_MEMO_PREFIX,
18551
+ SIP_MEMO_PREFIX_ANY: () => SIP_MEMO_PREFIX_ANY,
18552
+ SIP_MEMO_PREFIX_V2: () => SIP_MEMO_PREFIX_V2,
18288
18553
  SIP_VERSION: () => import_types84.SIP_VERSION,
18289
18554
  SOLANA_EXPLORER_URLS: () => SOLANA_EXPLORER_URLS,
18290
18555
  SOLANA_RPC_ENDPOINTS: () => SOLANA_RPC_ENDPOINTS3,
@@ -18344,6 +18609,7 @@ __export(index_exports, {
18344
18609
  bpsToPercent: () => bpsToPercent,
18345
18610
  browserBytesToHex: () => bytesToHex18,
18346
18611
  browserHexToBytes: () => hexToBytes15,
18612
+ buildGaslessCashout: () => buildGaslessCashout,
18347
18613
  cacheKeyGenerator: () => cacheKeyGenerator,
18348
18614
  calculateFeeForSwap: () => calculateFeeForSwap,
18349
18615
  calculatePrivacyScore: () => calculatePrivacyScore,
@@ -18365,6 +18631,7 @@ __export(index_exports, {
18365
18631
  computeAttestationHash: () => computeAttestationHash,
18366
18632
  computeNEARViewingKeyHash: () => computeNEARViewingKeyHash,
18367
18633
  computeNEARViewingKeyHashFromPrivate: () => computeNEARViewingKeyHashFromPrivate,
18634
+ computeRelayerFee: () => computeRelayerFee,
18368
18635
  computeTweakedKey: () => computeTweakedKey,
18369
18636
  configureLogger: () => configureLogger,
18370
18637
  convertFromSIP: () => convertFromSIP,
@@ -18468,6 +18735,7 @@ __export(index_exports, {
18468
18735
  deriveSecp256k1StealthPrivateKeyV1: () => deriveSecp256k1StealthPrivateKeyV1,
18469
18736
  deriveStealthPrivateKey: () => deriveStealthPrivateKey,
18470
18737
  deriveStealthPrivateKeyV1: () => deriveStealthPrivateKeyV1,
18738
+ deriveStealthSigner: () => deriveStealthSigner,
18471
18739
  deriveSuiStealthPrivateKey: () => deriveSuiStealthPrivateKey,
18472
18740
  deriveTraditionalNullifier: () => deriveTraditionalNullifier,
18473
18741
  deriveViewingKey: () => deriveViewingKey,
@@ -18659,11 +18927,13 @@ __export(index_exports, {
18659
18927
  serializePayment: () => serializePayment,
18660
18928
  setLogLevel: () => setLogLevel,
18661
18929
  signAttestationMessage: () => signAttestationMessage,
18930
+ signEd25519WithScalar: () => signEd25519WithScalar,
18662
18931
  silenceLogger: () => silenceLogger,
18663
18932
  solanaAddressToEd25519PublicKey: () => solanaAddressToEd25519PublicKey,
18664
18933
  solanaOptimizations: () => optimizations_exports,
18665
18934
  solanaPublicKeyToHex: () => solanaPublicKeyToHex,
18666
18935
  stealthKeyToCosmosAddress: () => stealthKeyToCosmosAddress,
18936
+ submitGaslessCashout: () => submitGaslessCashout,
18667
18937
  subtractBlindings: () => subtractBlindings,
18668
18938
  subtractBlindingsNEAR: () => subtractBlindingsNEAR,
18669
18939
  subtractCommitments: () => subtractCommitments,
@@ -21340,7 +21610,7 @@ var SIP = class {
21340
21610
  }
21341
21611
  const { sendPrivateSPLTransfer: sendPrivateSPLTransfer2 } = await Promise.resolve().then(() => (init_solana(), solana_exports));
21342
21612
  const { PublicKey: SolanaPublicKey } = await import("@solana/web3.js");
21343
- const { getAssociatedTokenAddress: getAssociatedTokenAddress8 } = await import("@solana/spl-token");
21613
+ const { getAssociatedTokenAddress: getAssociatedTokenAddress9 } = await import("@solana/spl-token");
21344
21614
  const { SOLANA_TOKEN_MINTS: SOLANA_TOKEN_MINTS3 } = await Promise.resolve().then(() => (init_constants(), constants_exports));
21345
21615
  let mint;
21346
21616
  if (params.token in SOLANA_TOKEN_MINTS3) {
@@ -21348,7 +21618,7 @@ var SIP = class {
21348
21618
  } else {
21349
21619
  mint = new SolanaPublicKey(params.token);
21350
21620
  }
21351
- const senderTokenAccount = await getAssociatedTokenAddress8(
21621
+ const senderTokenAccount = await getAssociatedTokenAddress9(
21352
21622
  mint,
21353
21623
  params.sender
21354
21624
  );
@@ -21397,7 +21667,7 @@ init_stealth2();
21397
21667
  // src/cosmos/stealth.ts
21398
21668
  var import_sha2569 = require("@noble/hashes/sha256");
21399
21669
  var import_ripemd160 = require("@noble/hashes/ripemd160");
21400
- var import_utils29 = require("@noble/hashes/utils");
21670
+ var import_utils30 = require("@noble/hashes/utils");
21401
21671
  var import_base3 = require("@scure/base");
21402
21672
  init_stealth2();
21403
21673
  init_errors();
@@ -21481,14 +21751,14 @@ var CosmosStealthService = class {
21481
21751
  );
21482
21752
  }
21483
21753
  const metaAddress = {
21484
- spendingKey: `0x${(0, import_utils29.bytesToHex)(spendingPubKey)}`,
21485
- viewingKey: `0x${(0, import_utils29.bytesToHex)(viewingPubKey)}`,
21754
+ spendingKey: `0x${(0, import_utils30.bytesToHex)(spendingPubKey)}`,
21755
+ viewingKey: `0x${(0, import_utils30.bytesToHex)(viewingPubKey)}`,
21486
21756
  chain: "ethereum"
21487
21757
  // Use ethereum for secp256k1 generation
21488
21758
  };
21489
21759
  const { stealthAddress, sharedSecret } = generateStealthAddress(metaAddress);
21490
21760
  const cosmosAddress = this.stealthKeyToCosmosAddress(
21491
- (0, import_utils29.hexToBytes)(stealthAddress.address.slice(2)),
21761
+ (0, import_utils30.hexToBytes)(stealthAddress.address.slice(2)),
21492
21762
  CHAIN_PREFIXES[chain]
21493
21763
  );
21494
21764
  return {
@@ -21516,8 +21786,8 @@ var CosmosStealthService = class {
21516
21786
  * ```
21517
21787
  */
21518
21788
  generateStealthAddressFromMeta(recipientMetaAddress, chain) {
21519
- const spendingPubKey = (0, import_utils29.hexToBytes)(recipientMetaAddress.spendingKey.slice(2));
21520
- const viewingPubKey = (0, import_utils29.hexToBytes)(recipientMetaAddress.viewingKey.slice(2));
21789
+ const spendingPubKey = (0, import_utils30.hexToBytes)(recipientMetaAddress.spendingKey.slice(2));
21790
+ const viewingPubKey = (0, import_utils30.hexToBytes)(recipientMetaAddress.viewingKey.slice(2));
21521
21791
  return this.generateStealthAddress(spendingPubKey, viewingPubKey, chain);
21522
21792
  }
21523
21793
  /**
@@ -21695,7 +21965,7 @@ function isValidCosmosAddress(address, expectedChain) {
21695
21965
  }
21696
21966
 
21697
21967
  // src/cosmos/ibc-stealth.ts
21698
- var import_utils30 = require("@noble/hashes/utils");
21968
+ var import_utils31 = require("@noble/hashes/utils");
21699
21969
  var import_secp256k14 = require("@noble/curves/secp256k1");
21700
21970
  var import_sha25610 = require("@noble/hashes/sha256");
21701
21971
  init_errors();
@@ -21719,7 +21989,7 @@ var ProofGenerationError = class extends Error {
21719
21989
 
21720
21990
  // src/proofs/mock.ts
21721
21991
  var import_sha25611 = require("@noble/hashes/sha256");
21722
- var import_utils31 = require("@noble/hashes/utils");
21992
+ var import_utils32 = require("@noble/hashes/utils");
21723
21993
  init_errors();
21724
21994
  var log3 = createLogger("proofs/mock");
21725
21995
  var MOCK_PROOF_PREFIX = "0x4d4f434b";
@@ -21896,16 +22166,16 @@ var MockProofProvider = class {
21896
22166
  (_, v) => typeof v === "bigint" ? v.toString() : v
21897
22167
  );
21898
22168
  const hash2 = (0, import_sha25611.sha256)(new TextEncoder().encode(input));
21899
- const random = (0, import_utils31.randomBytes)(16);
22169
+ const random = (0, import_utils32.randomBytes)(16);
21900
22170
  const combined = new Uint8Array(4 + hash2.length + random.length);
21901
22171
  combined.set(new TextEncoder().encode("MOCK"), 0);
21902
22172
  combined.set(hash2, 4);
21903
22173
  combined.set(random, 4 + hash2.length);
21904
- return `${MOCK_PROOF_PREFIX}${(0, import_utils31.bytesToHex)(combined.slice(4))}`;
22174
+ return `${MOCK_PROOF_PREFIX}${(0, import_utils32.bytesToHex)(combined.slice(4))}`;
21905
22175
  }
21906
22176
  hashToHex(data) {
21907
22177
  const hash2 = (0, import_sha25611.sha256)(new TextEncoder().encode(data));
21908
- return `0x${(0, import_utils31.bytesToHex)(hash2)}`;
22178
+ return `0x${(0, import_utils32.bytesToHex)(hash2)}`;
21909
22179
  }
21910
22180
  };
21911
22181
 
@@ -22372,46 +22642,46 @@ var ComplianceProofProvider = class {
22372
22642
  }
22373
22643
  async hashViewingKey(viewingKey) {
22374
22644
  const { sha256: sha25642 } = await import("@noble/hashes/sha256");
22375
- const { bytesToHex: bytesToHex65 } = await import("@noble/hashes/utils");
22645
+ const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
22376
22646
  const keyString = typeof viewingKey === "string" ? viewingKey : JSON.stringify(viewingKey);
22377
22647
  const encoder = new TextEncoder();
22378
22648
  const keyBytes = encoder.encode(keyString);
22379
- return bytesToHex65(sha25642(keyBytes));
22649
+ return bytesToHex64(sha25642(keyBytes));
22380
22650
  }
22381
22651
  async computeDecryptionCommitment(viewingKey, encryptedData) {
22382
22652
  const { sha256: sha25642 } = await import("@noble/hashes/sha256");
22383
- const { bytesToHex: bytesToHex65 } = await import("@noble/hashes/utils");
22653
+ const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
22384
22654
  const keyHash = await this.hashViewingKey(viewingKey);
22385
22655
  const keyBytes = this.hexToBytes(keyHash);
22386
22656
  const preimage = new Uint8Array([...keyBytes, ...encryptedData.slice(0, 32)]);
22387
- return bytesToHex65(sha25642(preimage));
22657
+ return bytesToHex64(sha25642(preimage));
22388
22658
  }
22389
22659
  async computeAuditorHash(auditorPublicKey, transactionHash) {
22390
22660
  const { sha256: sha25642 } = await import("@noble/hashes/sha256");
22391
- const { bytesToHex: bytesToHex65 } = await import("@noble/hashes/utils");
22661
+ const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
22392
22662
  const auditorBytes = this.hexToBytes(auditorPublicKey.replace("0x", "").padStart(64, "0"));
22393
22663
  const txBytes = this.hexToBytes(transactionHash.replace("0x", "").padStart(64, "0"));
22394
22664
  const preimage = new Uint8Array([...auditorBytes, ...txBytes]);
22395
- return bytesToHex65(sha25642(preimage));
22665
+ return bytesToHex64(sha25642(preimage));
22396
22666
  }
22397
22667
  async computeAddressCommitment(address, blinding) {
22398
22668
  const { sha256: sha25642 } = await import("@noble/hashes/sha256");
22399
- const { bytesToHex: bytesToHex65 } = await import("@noble/hashes/utils");
22669
+ const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
22400
22670
  const addressBytes = this.hexToBytes(address.replace("0x", "").padStart(64, "0"));
22401
22671
  const preimage = new Uint8Array([...addressBytes, ...blinding.slice(0, 32)]);
22402
- return bytesToHex65(sha25642(preimage));
22672
+ return bytesToHex64(sha25642(preimage));
22403
22673
  }
22404
22674
  async computeNonMembershipProof(senderAddress, recipientAddress, _sanctionsListRoot) {
22405
22675
  const { sha256: sha25642 } = await import("@noble/hashes/sha256");
22406
- const { bytesToHex: bytesToHex65 } = await import("@noble/hashes/utils");
22676
+ const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
22407
22677
  const senderBytes = this.hexToBytes(senderAddress.replace("0x", "").padStart(64, "0"));
22408
22678
  const recipientBytes = this.hexToBytes(recipientAddress.replace("0x", "").padStart(64, "0"));
22409
22679
  const preimage = new Uint8Array([...senderBytes, ...recipientBytes]);
22410
- return bytesToHex65(sha25642(preimage));
22680
+ return bytesToHex64(sha25642(preimage));
22411
22681
  }
22412
22682
  async computeBalanceCommitment(balance, blinding) {
22413
22683
  const { sha256: sha25642 } = await import("@noble/hashes/sha256");
22414
- const { bytesToHex: bytesToHex65 } = await import("@noble/hashes/utils");
22684
+ const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
22415
22685
  const balanceBytes = new Uint8Array(8);
22416
22686
  let v = balance;
22417
22687
  for (let i = 7; i >= 0; i--) {
@@ -22419,11 +22689,11 @@ var ComplianceProofProvider = class {
22419
22689
  v = v >> 8n;
22420
22690
  }
22421
22691
  const preimage = new Uint8Array([...balanceBytes, ...blinding.slice(0, 32)]);
22422
- return bytesToHex65(sha25642(preimage));
22692
+ return bytesToHex64(sha25642(preimage));
22423
22693
  }
22424
22694
  async generateComplianceProofBytes(type, publicInputs) {
22425
22695
  const { sha256: sha25642 } = await import("@noble/hashes/sha256");
22426
- const { bytesToHex: bytesToHex65 } = await import("@noble/hashes/utils");
22696
+ const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
22427
22697
  const circuitId = COMPLIANCE_CIRCUIT_IDS[type];
22428
22698
  const encoder = new TextEncoder();
22429
22699
  const inputBytes = publicInputs.flatMap((pi) => Array.from(this.hexToBytes(pi.replace("0x", ""))));
@@ -22434,7 +22704,7 @@ var ComplianceProofProvider = class {
22434
22704
  const hash2 = sha25642(preimage);
22435
22705
  let proofBytes = "";
22436
22706
  for (let i = 0; i < 8; i++) {
22437
- proofBytes += bytesToHex65(sha25642(new Uint8Array([...hash2, i])));
22707
+ proofBytes += bytesToHex64(sha25642(new Uint8Array([...hash2, i])));
22438
22708
  }
22439
22709
  return proofBytes;
22440
22710
  }
@@ -22462,7 +22732,7 @@ var ComplianceProofProvider = class {
22462
22732
  };
22463
22733
 
22464
22734
  // src/proofs/aggregator.ts
22465
- var import_utils32 = require("@noble/hashes/utils");
22735
+ var import_utils33 = require("@noble/hashes/utils");
22466
22736
  var import_types13 = require("@sip-protocol/types");
22467
22737
  var DEFAULT_AGGREGATOR_CONFIG = {
22468
22738
  maxProofs: 100,
@@ -22480,8 +22750,8 @@ var DEFAULT_AGGREGATOR_CONFIG = {
22480
22750
  verbose: false
22481
22751
  };
22482
22752
  function generateId(prefix) {
22483
- const bytes = (0, import_utils32.randomBytes)(8);
22484
- return `${prefix}-${(0, import_utils32.bytesToHex)(bytes)}`;
22753
+ const bytes = (0, import_utils33.randomBytes)(8);
22754
+ return `${prefix}-${(0, import_utils33.bytesToHex)(bytes)}`;
22485
22755
  }
22486
22756
  function computeProofHash(proofs) {
22487
22757
  const data = proofs.map((p) => p.proof).join("");
@@ -22881,10 +23151,10 @@ var ProofAggregator = class {
22881
23151
  async simulateRecursiveMerge(proofs, targetSystem, depth) {
22882
23152
  await delay(proofs.length * 50);
22883
23153
  const combinedInputs = proofs.flatMap((p) => p.publicInputs);
22884
- const proofBytes = (0, import_utils32.randomBytes)(256);
23154
+ const proofBytes = (0, import_utils33.randomBytes)(256);
22885
23155
  return {
22886
23156
  id: generateId(`recursive-${depth}`),
22887
- proof: `0x${(0, import_utils32.bytesToHex)(proofBytes)}`,
23157
+ proof: `0x${(0, import_utils33.bytesToHex)(proofBytes)}`,
22888
23158
  publicInputs: combinedInputs.slice(0, 10),
22889
23159
  metadata: {
22890
23160
  system: targetSystem,
@@ -23099,7 +23369,7 @@ function createProofAggregator(config) {
23099
23369
  }
23100
23370
 
23101
23371
  // src/proofs/verifier.ts
23102
- var import_utils33 = require("@noble/hashes/utils");
23372
+ var import_utils34 = require("@noble/hashes/utils");
23103
23373
  var DEFAULT_PIPELINE_CONFIG = {
23104
23374
  enableParallel: true,
23105
23375
  maxConcurrent: 4,
@@ -23113,7 +23383,7 @@ var DEFAULT_PIPELINE_CONFIG = {
23113
23383
  generateVerificationProof: false
23114
23384
  };
23115
23385
  function generateId2(prefix) {
23116
- return `${prefix}-${(0, import_utils33.bytesToHex)((0, import_utils33.randomBytes)(8))}`;
23386
+ return `${prefix}-${(0, import_utils34.bytesToHex)((0, import_utils34.randomBytes)(8))}`;
23117
23387
  }
23118
23388
  function computeLinkHash(sourceProof, targetProof) {
23119
23389
  const combinedData = sourceProof.proof + targetProof.proof;
@@ -24093,7 +24363,7 @@ function createCrossSystemValidator(options) {
24093
24363
  }
24094
24364
 
24095
24365
  // src/proofs/orchestrator.ts
24096
- var import_utils34 = require("@noble/hashes/utils");
24366
+ var import_utils35 = require("@noble/hashes/utils");
24097
24367
  var import_types14 = require("@sip-protocol/types");
24098
24368
  var DEFAULT_ORCHESTRATOR_CONFIG = {
24099
24369
  maxRetries: 3,
@@ -24149,7 +24419,7 @@ var BUILTIN_TEMPLATES = [
24149
24419
  }
24150
24420
  ];
24151
24421
  function generateId3(prefix) {
24152
- return `${prefix}-${(0, import_utils34.bytesToHex)((0, import_utils34.randomBytes)(8))}`;
24422
+ return `${prefix}-${(0, import_utils35.bytesToHex)((0, import_utils35.randomBytes)(8))}`;
24153
24423
  }
24154
24424
  function delay2(ms) {
24155
24425
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -24700,12 +24970,12 @@ var IncompatibleSystemsError = class extends ProofCompositionError {
24700
24970
  };
24701
24971
 
24702
24972
  // src/proofs/composer/base.ts
24703
- var import_utils35 = require("@noble/hashes/utils");
24704
24973
  var import_utils36 = require("@noble/hashes/utils");
24974
+ var import_utils37 = require("@noble/hashes/utils");
24705
24975
  var import_types16 = require("@sip-protocol/types");
24706
24976
  function generateId4(prefix) {
24707
- const bytes = (0, import_utils35.randomBytes)(8);
24708
- return `${prefix}-${(0, import_utils36.bytesToHex)(bytes)}`;
24977
+ const bytes = (0, import_utils36.randomBytes)(8);
24978
+ return `${prefix}-${(0, import_utils37.bytesToHex)(bytes)}`;
24709
24979
  }
24710
24980
  function computeProofHash2(proofs) {
24711
24981
  const data = proofs.map((p) => p.proof).join("");
@@ -25350,7 +25620,7 @@ var BaseProofComposer = class {
25350
25620
  };
25351
25621
 
25352
25622
  // src/proofs/providers/halo2.ts
25353
- var import_utils37 = require("@noble/hashes/utils");
25623
+ var import_utils38 = require("@noble/hashes/utils");
25354
25624
  var import_types17 = require("@sip-protocol/types");
25355
25625
  var DEFAULT_HALO2_CONFIG = {
25356
25626
  artifactsPath: "",
@@ -25551,8 +25821,8 @@ var Halo2Provider = class {
25551
25821
  async generateMockProof(request, circuit) {
25552
25822
  const simulatedTimeMs = Math.min(100 + circuit.k * 10, 2e3);
25553
25823
  await this.delay(simulatedTimeMs);
25554
- const proofBytes = (0, import_utils37.randomBytes)(256);
25555
- const proofHex = `0x${(0, import_utils37.bytesToHex)(proofBytes)}`;
25824
+ const proofBytes = (0, import_utils38.randomBytes)(256);
25825
+ const proofHex = `0x${(0, import_utils38.bytesToHex)(proofBytes)}`;
25556
25826
  const publicInputs = Object.values(request.publicInputs).map((v) => {
25557
25827
  if (typeof v === "string" && v.startsWith("0x")) {
25558
25828
  return v;
@@ -25563,7 +25833,7 @@ var Halo2Provider = class {
25563
25833
  return `0x${Buffer.from(String(v)).toString("hex")}`;
25564
25834
  });
25565
25835
  return {
25566
- id: `halo2-proof-${Date.now()}-${(0, import_utils37.randomBytes)(4).reduce((a, b) => a + b.toString(16), "")}`,
25836
+ id: `halo2-proof-${Date.now()}-${(0, import_utils38.randomBytes)(4).reduce((a, b) => a + b.toString(16), "")}`,
25567
25837
  proof: proofHex,
25568
25838
  publicInputs,
25569
25839
  metadata: {
@@ -25631,7 +25901,7 @@ var Halo2Provider = class {
25631
25901
  return new Promise((resolve) => setTimeout(resolve, ms));
25632
25902
  }
25633
25903
  generateProviderId() {
25634
- return (0, import_utils37.bytesToHex)((0, import_utils37.randomBytes)(4));
25904
+ return (0, import_utils38.bytesToHex)((0, import_utils38.randomBytes)(4));
25635
25905
  }
25636
25906
  };
25637
25907
  function createHalo2Provider(config) {
@@ -25662,7 +25932,7 @@ function createOrchardProvider() {
25662
25932
  }
25663
25933
 
25664
25934
  // src/proofs/providers/kimchi.ts
25665
- var import_utils38 = require("@noble/hashes/utils");
25935
+ var import_utils39 = require("@noble/hashes/utils");
25666
25936
  var import_types18 = require("@sip-protocol/types");
25667
25937
  var DEFAULT_KIMCHI_CONFIG = {
25668
25938
  circuits: [],
@@ -25811,7 +26081,7 @@ var KimchiProvider = class {
25811
26081
  console.log(`[KimchiProvider] Compiling circuit: ${circuitId}`);
25812
26082
  }
25813
26083
  await this.delay(100 + circuit.gateCount * 0.1);
25814
- const vkHash = `0x${(0, import_utils38.bytesToHex)((0, import_utils38.randomBytes)(32))}`;
26084
+ const vkHash = `0x${(0, import_utils39.bytesToHex)((0, import_utils39.randomBytes)(32))}`;
25815
26085
  this._compiledCircuits.set(circuitId, {
25816
26086
  compiled: true,
25817
26087
  vkHash
@@ -25877,8 +26147,8 @@ var KimchiProvider = class {
25877
26147
  async generateMockProof(request, circuit) {
25878
26148
  const simulatedTimeMs = Math.min(200 + circuit.gateCount * 0.5, 5e3);
25879
26149
  await this.delay(simulatedTimeMs);
25880
- const proofBytes = (0, import_utils38.randomBytes)(KIMCHI_PROOF_SIZE);
25881
- const proofHex = `0x${(0, import_utils38.bytesToHex)(proofBytes)}`;
26150
+ const proofBytes = (0, import_utils39.randomBytes)(KIMCHI_PROOF_SIZE);
26151
+ const proofHex = `0x${(0, import_utils39.bytesToHex)(proofBytes)}`;
25882
26152
  const publicInputs = Object.values(request.publicInputs).map((v) => {
25883
26153
  if (typeof v === "string" && v.startsWith("0x")) {
25884
26154
  return v;
@@ -25890,7 +26160,7 @@ var KimchiProvider = class {
25890
26160
  });
25891
26161
  const vkHash = this._compiledCircuits.get(request.circuitId)?.vkHash;
25892
26162
  return {
25893
- id: `kimchi-proof-${Date.now()}-${(0, import_utils38.randomBytes)(4).reduce((a, b) => a + b.toString(16), "")}`,
26163
+ id: `kimchi-proof-${Date.now()}-${(0, import_utils39.randomBytes)(4).reduce((a, b) => a + b.toString(16), "")}`,
25894
26164
  proof: proofHex,
25895
26165
  publicInputs,
25896
26166
  verificationKey: vkHash,
@@ -25983,11 +26253,11 @@ var KimchiProvider = class {
25983
26253
  console.log(`[KimchiProvider] Merging ${proofs.length} proofs recursively`);
25984
26254
  }
25985
26255
  await this.delay(proofs.length * 100);
25986
- const mergedProofBytes = (0, import_utils38.randomBytes)(KIMCHI_PROOF_SIZE);
26256
+ const mergedProofBytes = (0, import_utils39.randomBytes)(KIMCHI_PROOF_SIZE);
25987
26257
  const combinedInputs = proofs.flatMap((p) => p.publicInputs);
25988
26258
  return {
25989
26259
  id: `kimchi-merged-${Date.now()}`,
25990
- proof: `0x${(0, import_utils38.bytesToHex)(mergedProofBytes)}`,
26260
+ proof: `0x${(0, import_utils39.bytesToHex)(mergedProofBytes)}`,
25991
26261
  publicInputs: combinedInputs.slice(0, 10),
25992
26262
  // Limit public inputs
25993
26263
  metadata: {
@@ -26008,7 +26278,7 @@ var KimchiProvider = class {
26008
26278
  return new Promise((resolve) => setTimeout(resolve, ms));
26009
26279
  }
26010
26280
  generateProviderId() {
26011
- return (0, import_utils38.bytesToHex)((0, import_utils38.randomBytes)(4));
26281
+ return (0, import_utils39.bytesToHex)((0, import_utils39.randomBytes)(4));
26012
26282
  }
26013
26283
  };
26014
26284
  function createKimchiProvider(config) {
@@ -27119,7 +27389,7 @@ var DEFAULT_WARMING_CONFIG = {
27119
27389
 
27120
27390
  // src/proofs/cache/key-generator.ts
27121
27391
  var import_sha25612 = require("@noble/hashes/sha256");
27122
- var import_utils39 = require("@noble/hashes/utils");
27392
+ var import_utils40 = require("@noble/hashes/utils");
27123
27393
  var KEY_SEPARATOR = ":";
27124
27394
  var KEY_PREFIX = "sip-proof";
27125
27395
  var KEY_VERSION = "v1";
@@ -27141,7 +27411,7 @@ function canonicalize(value) {
27141
27411
  return value.toString();
27142
27412
  }
27143
27413
  if (value instanceof Uint8Array) {
27144
- return `bytes:${(0, import_utils39.bytesToHex)(value)}`;
27414
+ return `bytes:${(0, import_utils40.bytesToHex)(value)}`;
27145
27415
  }
27146
27416
  if (Array.isArray(value)) {
27147
27417
  return `[${value.map(canonicalize).join(",")}]`;
@@ -27204,7 +27474,7 @@ var CacheKeyGenerator = class {
27204
27474
  hashInputs(inputs) {
27205
27475
  const canonical = canonicalize(inputs);
27206
27476
  const hash2 = (0, import_sha25612.sha256)(new TextEncoder().encode(canonical));
27207
- return (0, import_utils39.bytesToHex)(hash2);
27477
+ return (0, import_utils40.bytesToHex)(hash2);
27208
27478
  }
27209
27479
  /**
27210
27480
  * Generate a cache key from raw inputs
@@ -28649,11 +28919,11 @@ var CHAIN_NUMERIC_IDS = {
28649
28919
  // src/oracle/verification.ts
28650
28920
  var import_ed255199 = require("@noble/curves/ed25519");
28651
28921
  var import_sha25614 = require("@noble/hashes/sha256");
28652
- var import_utils41 = require("@noble/hashes/utils");
28922
+ var import_utils42 = require("@noble/hashes/utils");
28653
28923
 
28654
28924
  // src/oracle/serialization.ts
28655
28925
  var import_sha25613 = require("@noble/hashes/sha256");
28656
- var import_utils40 = require("@noble/hashes/utils");
28926
+ var import_utils41 = require("@noble/hashes/utils");
28657
28927
  init_errors();
28658
28928
  function serializeAttestationMessage(message) {
28659
28929
  const buffer = new Uint8Array(197);
@@ -28697,19 +28967,19 @@ function deserializeAttestationMessage(bytes) {
28697
28967
  const version = bytes[offset++];
28698
28968
  const chainId = view.getUint32(offset, false);
28699
28969
  offset += 4;
28700
- const intentHash = `0x${(0, import_utils40.bytesToHex)(bytes.slice(offset, offset + 32))}`;
28970
+ const intentHash = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
28701
28971
  offset += 32;
28702
- const recipient = `0x${(0, import_utils40.bytesToHex)(bytes.slice(offset, offset + 32))}`;
28972
+ const recipient = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
28703
28973
  offset += 32;
28704
28974
  const amount = bytesToBigint(bytes.slice(offset, offset + 16));
28705
28975
  offset += 16;
28706
- const assetId = `0x${(0, import_utils40.bytesToHex)(bytes.slice(offset, offset + 32))}`;
28976
+ const assetId = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
28707
28977
  offset += 32;
28708
- const txHash = `0x${(0, import_utils40.bytesToHex)(bytes.slice(offset, offset + 32))}`;
28978
+ const txHash = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
28709
28979
  offset += 32;
28710
28980
  const blockNumber = view.getBigUint64(offset, false);
28711
28981
  offset += 8;
28712
- const blockHash = `0x${(0, import_utils40.bytesToHex)(bytes.slice(offset, offset + 32))}`;
28982
+ const blockHash = `0x${(0, import_utils41.bytesToHex)(bytes.slice(offset, offset + 32))}`;
28713
28983
  offset += 32;
28714
28984
  const timestamp = Number(view.getBigUint64(offset, false));
28715
28985
  return {
@@ -28726,7 +28996,7 @@ function deserializeAttestationMessage(bytes) {
28726
28996
  };
28727
28997
  }
28728
28998
  function computeAttestationHash(message) {
28729
- const domain = (0, import_utils40.utf8ToBytes)(ORACLE_DOMAIN);
28999
+ const domain = (0, import_utils41.utf8ToBytes)(ORACLE_DOMAIN);
28730
29000
  const messageBytes = serializeAttestationMessage(message);
28731
29001
  const toHash = new Uint8Array(domain.length + messageBytes.length);
28732
29002
  toHash.set(domain, 0);
@@ -28742,7 +29012,7 @@ function getChainNumericId(chain) {
28742
29012
  }
28743
29013
  function normalizeToBytes(hex, length, field) {
28744
29014
  const stripped = hex.startsWith("0x") ? hex.slice(2) : hex;
28745
- const bytes = (0, import_utils40.hexToBytes)(stripped);
29015
+ const bytes = (0, import_utils41.hexToBytes)(stripped);
28746
29016
  if (bytes.length === length) {
28747
29017
  return bytes;
28748
29018
  }
@@ -28775,9 +29045,9 @@ function bytesToBigint(bytes) {
28775
29045
 
28776
29046
  // src/oracle/verification.ts
28777
29047
  function deriveOracleId(publicKey) {
28778
- const keyBytes = typeof publicKey === "string" ? (0, import_utils41.hexToBytes)(publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey) : publicKey;
29048
+ const keyBytes = typeof publicKey === "string" ? (0, import_utils42.hexToBytes)(publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey) : publicKey;
28779
29049
  const hash2 = (0, import_sha25614.sha256)(keyBytes);
28780
- return `0x${(0, import_utils41.bytesToHex)(hash2)}`;
29050
+ return `0x${(0, import_utils42.bytesToHex)(hash2)}`;
28781
29051
  }
28782
29052
  function verifyAttestation(attestation, registry) {
28783
29053
  const { message, signatures } = attestation;
@@ -28807,10 +29077,10 @@ function verifyAttestation(attestation, registry) {
28807
29077
  continue;
28808
29078
  }
28809
29079
  try {
28810
- const publicKeyBytes = (0, import_utils41.hexToBytes)(
29080
+ const publicKeyBytes = (0, import_utils42.hexToBytes)(
28811
29081
  oracle.publicKey.startsWith("0x") ? oracle.publicKey.slice(2) : oracle.publicKey
28812
29082
  );
28813
- const signatureBytes = (0, import_utils41.hexToBytes)(
29083
+ const signatureBytes = (0, import_utils42.hexToBytes)(
28814
29084
  sig.signature.startsWith("0x") ? sig.signature.slice(2) : sig.signature
28815
29085
  );
28816
29086
  const isValid = import_ed255199.ed25519.verify(signatureBytes, messageHash, publicKeyBytes);
@@ -28835,10 +29105,10 @@ function verifyAttestation(attestation, registry) {
28835
29105
  }
28836
29106
  function verifyOracleSignature(signature, messageHash, oracle) {
28837
29107
  try {
28838
- const publicKeyBytes = (0, import_utils41.hexToBytes)(
29108
+ const publicKeyBytes = (0, import_utils42.hexToBytes)(
28839
29109
  oracle.publicKey.startsWith("0x") ? oracle.publicKey.slice(2) : oracle.publicKey
28840
29110
  );
28841
- const signatureBytes = (0, import_utils41.hexToBytes)(
29111
+ const signatureBytes = (0, import_utils42.hexToBytes)(
28842
29112
  signature.signature.startsWith("0x") ? signature.signature.slice(2) : signature.signature
28843
29113
  );
28844
29114
  return import_ed255199.ed25519.verify(signatureBytes, messageHash, publicKeyBytes);
@@ -28852,7 +29122,7 @@ function signAttestationMessage(messageHash, privateKey) {
28852
29122
  const oracleId = deriveOracleId(publicKey);
28853
29123
  return {
28854
29124
  oracleId,
28855
- signature: `0x${(0, import_utils41.bytesToHex)(signature)}`
29125
+ signature: `0x${(0, import_utils42.bytesToHex)(signature)}`
28856
29126
  };
28857
29127
  }
28858
29128
  function createOracleRegistry(config = {}) {
@@ -29094,7 +29364,7 @@ var import_types87 = require("@sip-protocol/types");
29094
29364
 
29095
29365
  // src/solver/mock-solver.ts
29096
29366
  var import_types24 = require("@sip-protocol/types");
29097
- var import_utils42 = require("@noble/hashes/utils");
29367
+ var import_utils43 = require("@noble/hashes/utils");
29098
29368
  var MockSolver = class {
29099
29369
  info;
29100
29370
  capabilities;
@@ -29176,7 +29446,7 @@ var MockSolver = class {
29176
29446
  const spreadAmount = baseOutput * BigInt(Math.floor(this.spreadPercent * 1e4)) / 10000n;
29177
29447
  const outputAmount = baseOutput + spreadAmount;
29178
29448
  const feeAmount = outputAmount * BigInt(Math.floor(this.feePercent * 1e4)) / 10000n;
29179
- const quoteId = `quote-${(0, import_utils42.bytesToHex)((0, import_utils42.randomBytes)(8))}`;
29449
+ const quoteId = `quote-${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(8))}`;
29180
29450
  const now = Math.floor(Date.now() / 1e3);
29181
29451
  const quote = {
29182
29452
  quoteId,
@@ -29187,7 +29457,7 @@ var MockSolver = class {
29187
29457
  expiry: now + 60,
29188
29458
  // Quote valid for 1 minute
29189
29459
  fee: feeAmount,
29190
- signature: `0x${(0, import_utils42.bytesToHex)((0, import_utils42.randomBytes)(64))}`,
29460
+ signature: `0x${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(64))}`,
29191
29461
  // Mock signature
29192
29462
  validUntil: now + 60,
29193
29463
  estimatedGas: 200000n
@@ -29224,7 +29494,7 @@ var MockSolver = class {
29224
29494
  error: status.error
29225
29495
  };
29226
29496
  }
29227
- const txHash = `0x${(0, import_utils42.bytesToHex)((0, import_utils42.randomBytes)(32))}`;
29497
+ const txHash = `0x${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(32))}`;
29228
29498
  status.status = "completed";
29229
29499
  status.txHash = txHash;
29230
29500
  return {
@@ -29234,10 +29504,10 @@ var MockSolver = class {
29234
29504
  txHash: intent.privacyLevel === "transparent" ? txHash : void 0,
29235
29505
  fulfillmentProof: {
29236
29506
  type: "fulfillment",
29237
- proof: `0x${(0, import_utils42.bytesToHex)((0, import_utils42.randomBytes)(128))}`,
29507
+ proof: `0x${(0, import_utils43.bytesToHex)((0, import_utils43.randomBytes)(128))}`,
29238
29508
  publicInputs: [
29239
- `0x${(0, import_utils42.bytesToHex)(new TextEncoder().encode(intent.intentId))}`,
29240
- `0x${(0, import_utils42.bytesToHex)(new TextEncoder().encode(quote.quoteId))}`
29509
+ `0x${(0, import_utils43.bytesToHex)(new TextEncoder().encode(intent.intentId))}`,
29510
+ `0x${(0, import_utils43.bytesToHex)(new TextEncoder().encode(quote.quoteId))}`
29241
29511
  ]
29242
29512
  },
29243
29513
  fulfilledAt: Math.floor(Date.now() / 1e3)
@@ -29796,6 +30066,7 @@ var SmartRouter = class {
29796
30066
  log4.warn({ backend, error }, "Backend failed");
29797
30067
  });
29798
30068
  }
30069
+ registry;
29799
30070
  cache;
29800
30071
  tracker;
29801
30072
  backendTimeoutMs;
@@ -30802,7 +31073,7 @@ function createZcashNativeBackend(config) {
30802
31073
  var import_types27 = require("@sip-protocol/types");
30803
31074
  init_stealth2();
30804
31075
  init_errors();
30805
- var import_utils43 = require("@noble/hashes/utils");
31076
+ var import_utils44 = require("@noble/hashes/utils");
30806
31077
  var DEFAULT_GAS_FEES = {
30807
31078
  ethereum: 21000n * 50n * 1000000000n,
30808
31079
  // 21k gas * 50 gwei = 0.00105 ETH
@@ -30861,6 +31132,8 @@ var ZcashRPCError = class extends Error {
30861
31132
  this.data = data;
30862
31133
  this.name = "ZcashRPCError";
30863
31134
  }
31135
+ code;
31136
+ data;
30864
31137
  /**
30865
31138
  * Check if error is due to insufficient funds
30866
31139
  */
@@ -32138,7 +32411,7 @@ var import_types89 = require("@sip-protocol/types");
32138
32411
  // src/bitcoin/taproot.ts
32139
32412
  var import_secp256k15 = require("@noble/curves/secp256k1");
32140
32413
  var import_sha25615 = require("@noble/hashes/sha256");
32141
- var import_utils45 = require("@noble/hashes/utils");
32414
+ var import_utils46 = require("@noble/hashes/utils");
32142
32415
  init_errors();
32143
32416
  init_validation();
32144
32417
  var BECH32_CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
@@ -32195,16 +32468,16 @@ function computeTweakedKey(internalKey, merkleRoot) {
32195
32468
  }
32196
32469
  const tweakData = merkleRoot ? new Uint8Array([...internalKey, ...merkleRoot]) : internalKey;
32197
32470
  const tweak = taggedHash("TapTweak", tweakData);
32198
- const tweakScalar = BigInt("0x" + (0, import_utils45.bytesToHex)(tweak)) % import_secp256k15.secp256k1.CURVE.n;
32471
+ const tweakScalar = BigInt("0x" + (0, import_utils46.bytesToHex)(tweak)) % import_secp256k15.secp256k1.CURVE.n;
32199
32472
  const internalPoint = import_secp256k15.secp256k1.ProjectivePoint.fromHex(
32200
- "02" + (0, import_utils45.bytesToHex)(internalKey)
32473
+ "02" + (0, import_utils46.bytesToHex)(internalKey)
32201
32474
  );
32202
32475
  const tweakPoint = import_secp256k15.secp256k1.ProjectivePoint.BASE.multiply(tweakScalar);
32203
32476
  const tweakedPoint = internalPoint.add(tweakPoint);
32204
32477
  const tweakedKeyBytes = tweakedPoint.toRawBytes(false);
32205
32478
  const xOnly = tweakedKeyBytes.slice(1, 33);
32206
32479
  const yCoord = tweakedKeyBytes.slice(33, 65);
32207
- const yBigInt = BigInt("0x" + (0, import_utils45.bytesToHex)(yCoord));
32480
+ const yBigInt = BigInt("0x" + (0, import_utils46.bytesToHex)(yCoord));
32208
32481
  const parity = Number(yBigInt & 1n);
32209
32482
  return {
32210
32483
  tweakedKey: xOnly,
@@ -32234,9 +32507,9 @@ function createTaprootOutput(internalKey, scripts) {
32234
32507
  }
32235
32508
  const { tweakedKey, parity } = computeTweakedKey(internalKey, merkleRoot);
32236
32509
  return {
32237
- tweakedKey: `0x${(0, import_utils45.bytesToHex)(tweakedKey)}`,
32238
- internalKey: `0x${(0, import_utils45.bytesToHex)(internalKey)}`,
32239
- merkleRoot: merkleRoot ? `0x${(0, import_utils45.bytesToHex)(merkleRoot)}` : void 0,
32510
+ tweakedKey: `0x${(0, import_utils46.bytesToHex)(tweakedKey)}`,
32511
+ internalKey: `0x${(0, import_utils46.bytesToHex)(internalKey)}`,
32512
+ merkleRoot: merkleRoot ? `0x${(0, import_utils46.bytesToHex)(merkleRoot)}` : void 0,
32240
32513
  parity
32241
32514
  };
32242
32515
  }
@@ -32369,10 +32642,10 @@ function createKeySpendOnlyOutput(privateKey, network = "mainnet") {
32369
32642
  if (!isValidPrivateKey(privateKey)) {
32370
32643
  throw new ValidationError("privateKey must be a valid 32-byte hex string", "privateKey");
32371
32644
  }
32372
- const privKeyBytes = (0, import_utils45.hexToBytes)(privateKey.slice(2));
32645
+ const privKeyBytes = (0, import_utils46.hexToBytes)(privateKey.slice(2));
32373
32646
  const internalKey = getXOnlyPublicKey(privKeyBytes);
32374
32647
  const output = createTaprootOutput(internalKey);
32375
- const tweakedKeyBytes = (0, import_utils45.hexToBytes)(output.tweakedKey.slice(2));
32648
+ const tweakedKeyBytes = (0, import_utils46.hexToBytes)(output.tweakedKey.slice(2));
32376
32649
  const address = taprootAddress(tweakedKeyBytes, network);
32377
32650
  return {
32378
32651
  output,
@@ -32398,11 +32671,11 @@ function schnorrSignHex(message, privateKey, auxRand) {
32398
32671
  if (auxRand && !isValidHex(auxRand)) {
32399
32672
  throw new ValidationError("auxRand must be a hex string", "auxRand");
32400
32673
  }
32401
- const messageBytes = (0, import_utils45.hexToBytes)(message.slice(2));
32402
- const privateKeyBytes = (0, import_utils45.hexToBytes)(privateKey.slice(2));
32403
- const auxRandBytes = auxRand ? (0, import_utils45.hexToBytes)(auxRand.slice(2)) : void 0;
32674
+ const messageBytes = (0, import_utils46.hexToBytes)(message.slice(2));
32675
+ const privateKeyBytes = (0, import_utils46.hexToBytes)(privateKey.slice(2));
32676
+ const auxRandBytes = auxRand ? (0, import_utils46.hexToBytes)(auxRand.slice(2)) : void 0;
32404
32677
  const signature = schnorrSign(messageBytes, privateKeyBytes, auxRandBytes);
32405
- return `0x${(0, import_utils45.bytesToHex)(signature)}`;
32678
+ return `0x${(0, import_utils46.bytesToHex)(signature)}`;
32406
32679
  }
32407
32680
  function schnorrVerifyHex(signature, message, publicKey) {
32408
32681
  if (!isValidHex(signature)) {
@@ -32414,23 +32687,23 @@ function schnorrVerifyHex(signature, message, publicKey) {
32414
32687
  if (!isValidHex(publicKey)) {
32415
32688
  throw new ValidationError("publicKey must be a hex string", "publicKey");
32416
32689
  }
32417
- const signatureBytes = (0, import_utils45.hexToBytes)(signature.slice(2));
32418
- const messageBytes = (0, import_utils45.hexToBytes)(message.slice(2));
32419
- const publicKeyBytes = (0, import_utils45.hexToBytes)(publicKey.slice(2));
32690
+ const signatureBytes = (0, import_utils46.hexToBytes)(signature.slice(2));
32691
+ const messageBytes = (0, import_utils46.hexToBytes)(message.slice(2));
32692
+ const publicKeyBytes = (0, import_utils46.hexToBytes)(publicKey.slice(2));
32420
32693
  return schnorrVerify(signatureBytes, messageBytes, publicKeyBytes);
32421
32694
  }
32422
32695
 
32423
32696
  // src/bitcoin/silent-payments.ts
32424
32697
  var import_secp256k16 = require("@noble/curves/secp256k1");
32425
32698
  var import_sha25616 = require("@noble/hashes/sha256");
32426
- var import_utils46 = require("@noble/hashes/utils");
32699
+ var import_utils47 = require("@noble/hashes/utils");
32427
32700
  init_errors();
32428
32701
  init_validation();
32429
32702
 
32430
32703
  // src/payment/payment.ts
32431
32704
  var import_types32 = require("@sip-protocol/types");
32432
32705
  var import_sha25617 = require("@noble/hashes/sha256");
32433
- var import_utils47 = require("@noble/hashes/utils");
32706
+ var import_utils48 = require("@noble/hashes/utils");
32434
32707
  var import_chacha3 = require("@noble/ciphers/chacha.js");
32435
32708
  var import_hkdf3 = require("@noble/hashes/hkdf");
32436
32709
  init_stealth2();
@@ -32930,8 +33203,8 @@ async function createShieldedPayment(params, options) {
32930
33203
  let viewingKeyHash;
32931
33204
  if (viewingKey) {
32932
33205
  const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
32933
- const keyBytes = (0, import_utils47.hexToBytes)(keyHex);
32934
- viewingKeyHash = `0x${(0, import_utils47.bytesToHex)((0, import_sha25617.sha256)(keyBytes))}`;
33206
+ const keyBytes = (0, import_utils48.hexToBytes)(keyHex);
33207
+ viewingKeyHash = `0x${(0, import_utils48.bytesToHex)((0, import_sha25617.sha256)(keyBytes))}`;
32935
33208
  }
32936
33209
  const privacyConfig = getPrivacyConfig(
32937
33210
  privacy,
@@ -32971,7 +33244,7 @@ async function createShieldedPayment(params, options) {
32971
33244
  if (privacy !== import_types32.PrivacyLevel.TRANSPARENT && proofProvider?.isReady) {
32972
33245
  const hexToUint8 = (hex) => {
32973
33246
  const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
32974
- return (0, import_utils47.hexToBytes)(cleanHex);
33247
+ return (0, import_utils48.hexToBytes)(cleanHex);
32975
33248
  };
32976
33249
  const fundingResult = await proofProvider.generateFundingProof({
32977
33250
  balance: amount,
@@ -32998,17 +33271,17 @@ async function createShieldedPayment(params, options) {
32998
33271
  }
32999
33272
  function encryptMemo(memo, viewingKey) {
33000
33273
  const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
33001
- const keyBytes = (0, import_utils47.hexToBytes)(keyHex);
33274
+ const keyBytes = (0, import_utils48.hexToBytes)(keyHex);
33002
33275
  const encKey = (0, import_hkdf3.hkdf)(import_sha25617.sha256, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
33003
33276
  try {
33004
- const nonce = (0, import_utils47.randomBytes)(24);
33277
+ const nonce = (0, import_utils48.randomBytes)(24);
33005
33278
  const cipher = (0, import_chacha3.xchacha20poly1305)(encKey, nonce);
33006
33279
  const plaintext = new TextEncoder().encode(memo);
33007
33280
  const ciphertext = cipher.encrypt(plaintext);
33008
33281
  const result = new Uint8Array(nonce.length + ciphertext.length);
33009
33282
  result.set(nonce);
33010
33283
  result.set(ciphertext, nonce.length);
33011
- return `0x${(0, import_utils47.bytesToHex)(result)}`;
33284
+ return `0x${(0, import_utils48.bytesToHex)(result)}`;
33012
33285
  } finally {
33013
33286
  secureWipe(keyBytes);
33014
33287
  secureWipe(encKey);
@@ -33016,11 +33289,11 @@ function encryptMemo(memo, viewingKey) {
33016
33289
  }
33017
33290
  function decryptMemo(encryptedMemo, viewingKey) {
33018
33291
  const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
33019
- const keyBytes = (0, import_utils47.hexToBytes)(keyHex);
33292
+ const keyBytes = (0, import_utils48.hexToBytes)(keyHex);
33020
33293
  const encKey = (0, import_hkdf3.hkdf)(import_sha25617.sha256, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
33021
33294
  try {
33022
33295
  const dataHex = encryptedMemo.startsWith("0x") ? encryptedMemo.slice(2) : encryptedMemo;
33023
- const data = (0, import_utils47.hexToBytes)(dataHex);
33296
+ const data = (0, import_utils48.hexToBytes)(dataHex);
33024
33297
  const nonce = data.slice(0, 24);
33025
33298
  const ciphertext = data.slice(24);
33026
33299
  const cipher = (0, import_chacha3.xchacha20poly1305)(encKey, nonce);
@@ -33070,7 +33343,7 @@ function getPaymentSummary(payment) {
33070
33343
  var import_types33 = require("@sip-protocol/types");
33071
33344
  var import_secp256k17 = require("@noble/curves/secp256k1");
33072
33345
  var import_sha25618 = require("@noble/hashes/sha256");
33073
- var import_utils48 = require("@noble/hashes/utils");
33346
+ var import_utils49 = require("@noble/hashes/utils");
33074
33347
  init_errors();
33075
33348
  init_validation();
33076
33349
  init_secure_memory();
@@ -33564,12 +33837,12 @@ var Treasury = class _Treasury {
33564
33837
  }
33565
33838
  };
33566
33839
  function generateTreasuryId() {
33567
- const bytes = (0, import_utils48.randomBytes)(16);
33568
- return `treasury_${(0, import_utils48.bytesToHex)(bytes)}`;
33840
+ const bytes = (0, import_utils49.randomBytes)(16);
33841
+ return `treasury_${(0, import_utils49.bytesToHex)(bytes)}`;
33569
33842
  }
33570
33843
  function generateProposalId() {
33571
- const bytes = (0, import_utils48.randomBytes)(16);
33572
- return `prop_${(0, import_utils48.bytesToHex)(bytes)}`;
33844
+ const bytes = (0, import_utils49.randomBytes)(16);
33845
+ return `prop_${(0, import_utils49.bytesToHex)(bytes)}`;
33573
33846
  }
33574
33847
  function computeProposalHash(proposal) {
33575
33848
  const data = JSON.stringify({
@@ -33585,7 +33858,7 @@ function computeProposalHash(proposal) {
33585
33858
  }
33586
33859
  function signMessage(messageHash, privateKey) {
33587
33860
  const keyHex = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
33588
- const keyBytes = (0, import_utils48.hexToBytes)(keyHex);
33861
+ const keyBytes = (0, import_utils49.hexToBytes)(keyHex);
33589
33862
  try {
33590
33863
  const signature = import_secp256k17.secp256k1.sign(messageHash, keyBytes);
33591
33864
  return `0x${signature.toCompactHex()}`;
@@ -33597,8 +33870,8 @@ function verifySignature(messageHash, signature, publicKey) {
33597
33870
  const sigHex = signature.startsWith("0x") ? signature.slice(2) : signature;
33598
33871
  const pubKeyHex = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
33599
33872
  try {
33600
- const sigBytes = (0, import_utils48.hexToBytes)(sigHex);
33601
- const pubKeyBytes = (0, import_utils48.hexToBytes)(pubKeyHex);
33873
+ const sigBytes = (0, import_utils49.hexToBytes)(sigHex);
33874
+ const pubKeyBytes = (0, import_utils49.hexToBytes)(pubKeyHex);
33602
33875
  return import_secp256k17.secp256k1.verify(sigBytes, messageHash, pubKeyBytes);
33603
33876
  } catch {
33604
33877
  return false;
@@ -33757,7 +34030,7 @@ function validateBatchProposalParams(params, config) {
33757
34030
 
33758
34031
  // src/compliance/compliance-manager.ts
33759
34032
  var import_types34 = require("@sip-protocol/types");
33760
- var import_utils49 = require("@noble/hashes/utils");
34033
+ var import_utils50 = require("@noble/hashes/utils");
33761
34034
  init_errors();
33762
34035
  var DEFAULTS2 = {
33763
34036
  riskThreshold: 70,
@@ -34505,7 +34778,7 @@ var ComplianceManager = class _ComplianceManager {
34505
34778
  }
34506
34779
  };
34507
34780
  function generateId5(prefix) {
34508
- return `${prefix}_${(0, import_utils49.bytesToHex)((0, import_utils49.randomBytes)(12))}`;
34781
+ return `${prefix}_${(0, import_utils50.bytesToHex)((0, import_utils50.randomBytes)(12))}`;
34509
34782
  }
34510
34783
  function validateRegisterAuditorParams(params) {
34511
34784
  if (!params.organization?.trim()) {
@@ -34594,7 +34867,7 @@ function validateReportParams(params) {
34594
34867
 
34595
34868
  // src/compliance/reports.ts
34596
34869
  var import_sha25619 = require("@noble/hashes/sha256");
34597
- var import_utils50 = require("@noble/hashes/utils");
34870
+ var import_utils51 = require("@noble/hashes/utils");
34598
34871
  init_errors();
34599
34872
 
34600
34873
  // src/compliance/pdf.ts
@@ -34896,12 +35169,12 @@ var ComplianceReporter = class {
34896
35169
  normalizeViewingKey(viewingKey) {
34897
35170
  if (typeof viewingKey === "string") {
34898
35171
  const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
34899
- const keyBytes = (0, import_utils50.hexToBytes)(keyHex);
35172
+ const keyBytes = (0, import_utils51.hexToBytes)(keyHex);
34900
35173
  const hashBytes = (0, import_sha25619.sha256)(keyBytes);
34901
35174
  return {
34902
35175
  key: `0x${keyHex}`,
34903
35176
  path: "m/0",
34904
- hash: `0x${(0, import_utils50.bytesToHex)(hashBytes)}`
35177
+ hash: `0x${(0, import_utils51.bytesToHex)(hashBytes)}`
34905
35178
  };
34906
35179
  }
34907
35180
  return viewingKey;
@@ -35283,7 +35556,7 @@ var ComplianceReporter = class {
35283
35556
 
35284
35557
  // src/compliance/conditional.ts
35285
35558
  var import_sha25620 = require("@noble/hashes/sha256");
35286
- var import_utils51 = require("@noble/hashes/utils");
35559
+ var import_utils52 = require("@noble/hashes/utils");
35287
35560
  var import_chacha4 = require("@noble/ciphers/chacha.js");
35288
35561
  init_errors();
35289
35562
  var ConditionalDisclosure = class {
@@ -35350,8 +35623,8 @@ var ConditionalDisclosure = class {
35350
35623
  params.commitment,
35351
35624
  revealAfterSeconds
35352
35625
  );
35353
- const nonce = (0, import_utils51.randomBytes)(24);
35354
- const viewingKeyBytes = (0, import_utils51.hexToBytes)(params.viewingKey.slice(2));
35626
+ const nonce = (0, import_utils52.randomBytes)(24);
35627
+ const viewingKeyBytes = (0, import_utils52.hexToBytes)(params.viewingKey.slice(2));
35355
35628
  const cipher = (0, import_chacha4.xchacha20poly1305)(encryptionKey, nonce);
35356
35629
  const encryptedKey = cipher.encrypt(viewingKeyBytes);
35357
35630
  const commitmentData = new Uint8Array([
@@ -35360,10 +35633,10 @@ var ConditionalDisclosure = class {
35360
35633
  ]);
35361
35634
  const commitmentHash = (0, import_sha25620.sha256)(commitmentData);
35362
35635
  return {
35363
- encryptedKey: "0x" + (0, import_utils51.bytesToHex)(encryptedKey),
35364
- nonce: "0x" + (0, import_utils51.bytesToHex)(nonce),
35636
+ encryptedKey: "0x" + (0, import_utils52.bytesToHex)(encryptedKey),
35637
+ nonce: "0x" + (0, import_utils52.bytesToHex)(nonce),
35365
35638
  revealAfter: revealAfterSeconds,
35366
- verificationCommitment: "0x" + (0, import_utils51.bytesToHex)(commitmentHash),
35639
+ verificationCommitment: "0x" + (0, import_utils52.bytesToHex)(commitmentHash),
35367
35640
  encryptionCommitment: params.commitment,
35368
35641
  type
35369
35642
  };
@@ -35440,11 +35713,11 @@ var ConditionalDisclosure = class {
35440
35713
  timeLock.encryptionCommitment,
35441
35714
  timeLock.revealAfter
35442
35715
  );
35443
- const nonce = (0, import_utils51.hexToBytes)(timeLock.nonce.slice(2));
35444
- const encryptedData = (0, import_utils51.hexToBytes)(timeLock.encryptedKey.slice(2));
35716
+ const nonce = (0, import_utils52.hexToBytes)(timeLock.nonce.slice(2));
35717
+ const encryptedData = (0, import_utils52.hexToBytes)(timeLock.encryptedKey.slice(2));
35445
35718
  const cipher = (0, import_chacha4.xchacha20poly1305)(encryptionKey, nonce);
35446
35719
  const decryptedBytes = cipher.decrypt(encryptedData);
35447
- const viewingKey = "0x" + (0, import_utils51.bytesToHex)(decryptedBytes);
35720
+ const viewingKey = "0x" + (0, import_utils52.bytesToHex)(decryptedBytes);
35448
35721
  return {
35449
35722
  unlocked: true,
35450
35723
  viewingKey
@@ -35475,13 +35748,13 @@ var ConditionalDisclosure = class {
35475
35748
  */
35476
35749
  verifyCommitment(timeLock, viewingKey) {
35477
35750
  try {
35478
- const viewingKeyBytes = (0, import_utils51.hexToBytes)(viewingKey.slice(2));
35751
+ const viewingKeyBytes = (0, import_utils52.hexToBytes)(viewingKey.slice(2));
35479
35752
  const commitmentData = new Uint8Array([
35480
35753
  ...viewingKeyBytes,
35481
35754
  ...this._numberToBytes(timeLock.revealAfter)
35482
35755
  ]);
35483
35756
  const expectedCommitment = (0, import_sha25620.sha256)(commitmentData);
35484
- const actualCommitment = (0, import_utils51.hexToBytes)(timeLock.verificationCommitment.slice(2));
35757
+ const actualCommitment = (0, import_utils52.hexToBytes)(timeLock.verificationCommitment.slice(2));
35485
35758
  if (expectedCommitment.length !== actualCommitment.length) {
35486
35759
  return false;
35487
35760
  }
@@ -35500,7 +35773,7 @@ var ConditionalDisclosure = class {
35500
35773
  * @private
35501
35774
  */
35502
35775
  _deriveEncryptionKey(commitment, revealAfter) {
35503
- const commitmentBytes = (0, import_utils51.hexToBytes)(commitment.slice(2));
35776
+ const commitmentBytes = (0, import_utils52.hexToBytes)(commitment.slice(2));
35504
35777
  const timeBytes = this._numberToBytes(revealAfter);
35505
35778
  const combined = new Uint8Array([...commitmentBytes, ...timeBytes]);
35506
35779
  const key = (0, import_sha25620.sha256)(combined);
@@ -35532,14 +35805,14 @@ var ConditionalDisclosure = class {
35532
35805
  // src/compliance/conditional-threshold.ts
35533
35806
  var import_secp256k18 = require("@noble/curves/secp256k1");
35534
35807
  var import_sha25621 = require("@noble/hashes/sha256");
35535
- var import_utils52 = require("@noble/hashes/utils");
35808
+ var import_utils53 = require("@noble/hashes/utils");
35536
35809
  init_commitment();
35537
35810
  init_errors();
35538
35811
  var CURVE_ORDER2 = import_secp256k18.secp256k1.CURVE.n;
35539
35812
 
35540
35813
  // src/compliance/threshold.ts
35541
35814
  var import_sha25622 = require("@noble/hashes/sha256");
35542
- var import_utils53 = require("@noble/hashes/utils");
35815
+ var import_utils54 = require("@noble/hashes/utils");
35543
35816
  init_errors();
35544
35817
  var FIELD_PRIME = 2n ** 256n - 189n;
35545
35818
  var ThresholdViewingKey = class {
@@ -35723,7 +35996,7 @@ var ThresholdViewingKey = class {
35723
35996
  * Convert viewing key to secret (bigint)
35724
35997
  */
35725
35998
  static viewingKeyToSecret(viewingKey) {
35726
- const bytes = (0, import_utils53.hexToBytes)(viewingKey.slice(2));
35999
+ const bytes = (0, import_utils54.hexToBytes)(viewingKey.slice(2));
35727
36000
  let secret = 0n;
35728
36001
  for (let i = 0; i < bytes.length; i++) {
35729
36002
  secret = secret << 8n | BigInt(bytes[i]);
@@ -35757,7 +36030,7 @@ var ThresholdViewingKey = class {
35757
36030
  * Generate a random field element
35758
36031
  */
35759
36032
  static randomFieldElement() {
35760
- const bytes = (0, import_utils53.randomBytes)(32);
36033
+ const bytes = (0, import_utils54.randomBytes)(32);
35761
36034
  let value = 0n;
35762
36035
  for (let i = 0; i < bytes.length; i++) {
35763
36036
  value = value << 8n | BigInt(bytes[i]);
@@ -35782,8 +36055,8 @@ var ThresholdViewingKey = class {
35782
36055
  */
35783
36056
  static createCommitment(secret, coefficients) {
35784
36057
  const data = [secret, ...coefficients].map((c) => c.toString(16).padStart(64, "0")).join("");
35785
- const hash2 = (0, import_sha25622.sha256)((0, import_utils53.hexToBytes)(data));
35786
- return (0, import_utils53.bytesToHex)(hash2);
36058
+ const hash2 = (0, import_sha25622.sha256)((0, import_utils54.hexToBytes)(data));
36059
+ return (0, import_utils54.bytesToHex)(hash2);
35787
36060
  }
35788
36061
  /**
35789
36062
  * Encode share as string: "x:y:len:commitment"
@@ -35907,9 +36180,9 @@ var ThresholdViewingKey = class {
35907
36180
 
35908
36181
  // src/compliance/derivation.ts
35909
36182
  var import_sha25623 = require("@noble/hashes/sha256");
35910
- var import_sha5123 = require("@noble/hashes/sha512");
36183
+ var import_sha5124 = require("@noble/hashes/sha512");
35911
36184
  var import_hmac5 = require("@noble/hashes/hmac");
35912
- var import_utils54 = require("@noble/hashes/utils");
36185
+ var import_utils55 = require("@noble/hashes/utils");
35913
36186
  init_errors();
35914
36187
  init_secure_memory();
35915
36188
  var AuditorType = /* @__PURE__ */ ((AuditorType2) => {
@@ -36008,7 +36281,7 @@ var AuditorKeyDerivation = class {
36008
36281
  auditorType
36009
36282
  // auditorType (non-hardened)
36010
36283
  ];
36011
- const masterData = (0, import_hmac5.hmac)(import_sha5123.sha512, (0, import_utils54.utf8ToBytes)("SIP-MASTER-SEED"), masterSeed);
36284
+ const masterData = (0, import_hmac5.hmac)(import_sha5124.sha512, (0, import_utils55.utf8ToBytes)("SIP-MASTER-SEED"), masterSeed);
36012
36285
  let currentKey = new Uint8Array(masterData.slice(0, 32));
36013
36286
  let chainCode = new Uint8Array(masterData.slice(32, 64));
36014
36287
  try {
@@ -36021,9 +36294,9 @@ var AuditorKeyDerivation = class {
36021
36294
  currentKey = new Uint8Array(derived.key);
36022
36295
  chainCode = new Uint8Array(derived.chainCode);
36023
36296
  }
36024
- const keyHex = `0x${(0, import_utils54.bytesToHex)(currentKey)}`;
36297
+ const keyHex = `0x${(0, import_utils55.bytesToHex)(currentKey)}`;
36025
36298
  const hashBytes = (0, import_sha25623.sha256)(currentKey);
36026
- const hash2 = `0x${(0, import_utils54.bytesToHex)(hashBytes)}`;
36299
+ const hash2 = `0x${(0, import_utils55.bytesToHex)(hashBytes)}`;
36027
36300
  const viewingKey = {
36028
36301
  key: keyHex,
36029
36302
  path,
@@ -36090,7 +36363,7 @@ var AuditorKeyDerivation = class {
36090
36363
  account | this.HARDENED
36091
36364
  // account' (hardened)
36092
36365
  ];
36093
- const masterData = (0, import_hmac5.hmac)(import_sha5123.sha512, (0, import_utils54.utf8ToBytes)("SIP-MASTER-SEED"), masterSeed);
36366
+ const masterData = (0, import_hmac5.hmac)(import_sha5124.sha512, (0, import_utils55.utf8ToBytes)("SIP-MASTER-SEED"), masterSeed);
36094
36367
  let commonKey = new Uint8Array(masterData.slice(0, 32));
36095
36368
  let commonChainCode = new Uint8Array(masterData.slice(32, 64));
36096
36369
  try {
@@ -36107,9 +36380,9 @@ var AuditorKeyDerivation = class {
36107
36380
  for (const auditorType of uniqueTypes) {
36108
36381
  const derived = this.deriveChildKey(commonKey, commonChainCode, auditorType);
36109
36382
  try {
36110
- const keyHex = `0x${(0, import_utils54.bytesToHex)(derived.key)}`;
36383
+ const keyHex = `0x${(0, import_utils55.bytesToHex)(derived.key)}`;
36111
36384
  const hashBytes = (0, import_sha25623.sha256)(derived.key);
36112
- const hash2 = `0x${(0, import_utils54.bytesToHex)(hashBytes)}`;
36385
+ const hash2 = `0x${(0, import_utils55.bytesToHex)(hashBytes)}`;
36113
36386
  const path = this.derivePath(auditorType, account);
36114
36387
  const viewingKey = {
36115
36388
  key: keyHex,
@@ -36174,7 +36447,7 @@ var AuditorKeyDerivation = class {
36174
36447
  }
36175
36448
  const indexView = new DataView(data.buffer, 33, 4);
36176
36449
  indexView.setUint32(0, index, false);
36177
- const hmacResult = (0, import_hmac5.hmac)(import_sha5123.sha512, chainCode, data);
36450
+ const hmacResult = (0, import_hmac5.hmac)(import_sha5124.sha512, chainCode, data);
36178
36451
  const childKey = new Uint8Array(hmacResult.slice(0, 32));
36179
36452
  const childChainCode = new Uint8Array(hmacResult.slice(32, 64));
36180
36453
  return {
@@ -36232,8 +36505,8 @@ var AuditorKeyDerivation = class {
36232
36505
  // src/compliance/range-sas.ts
36233
36506
  var import_sha25624 = require("@noble/hashes/sha256");
36234
36507
  var import_hmac6 = require("@noble/hashes/hmac");
36235
- var import_sha5124 = require("@noble/hashes/sha512");
36236
- var import_utils55 = require("@noble/hashes/utils");
36508
+ var import_sha5125 = require("@noble/hashes/sha512");
36509
+ var import_utils56 = require("@noble/hashes/utils");
36237
36510
  init_errors();
36238
36511
  init_secure_memory();
36239
36512
  var AttestationSchema = /* @__PURE__ */ ((AttestationSchema2) => {
@@ -36469,16 +36742,16 @@ var AttestationGatedDisclosure = class {
36469
36742
  */
36470
36743
  deriveKeyFromAttestation(attestation) {
36471
36744
  const masterKeyHex = this.config.masterViewingKey.key.startsWith("0x") ? this.config.masterViewingKey.key.slice(2) : this.config.masterViewingKey.key;
36472
- const masterKeyBytes = (0, import_utils55.hexToBytes)(masterKeyHex);
36473
- const derivationData = (0, import_utils55.utf8ToBytes)(
36745
+ const masterKeyBytes = (0, import_utils56.hexToBytes)(masterKeyHex);
36746
+ const derivationData = (0, import_utils56.utf8ToBytes)(
36474
36747
  `SIP-RANGE-SAS:${attestation.uid}:${attestation.subject}:${attestation.schema}:${attestation.signature}`
36475
36748
  );
36476
- const derived = (0, import_hmac6.hmac)(import_sha5124.sha512, masterKeyBytes, derivationData);
36749
+ const derived = (0, import_hmac6.hmac)(import_sha5125.sha512, masterKeyBytes, derivationData);
36477
36750
  const keyBytes = derived.slice(0, 32);
36478
36751
  try {
36479
- const key = `0x${(0, import_utils55.bytesToHex)(keyBytes)}`;
36752
+ const key = `0x${(0, import_utils56.bytesToHex)(keyBytes)}`;
36480
36753
  const hashBytes = (0, import_sha25624.sha256)(keyBytes);
36481
- const hash2 = `0x${(0, import_utils55.bytesToHex)(hashBytes)}`;
36754
+ const hash2 = `0x${(0, import_utils56.bytesToHex)(hashBytes)}`;
36482
36755
  return {
36483
36756
  key,
36484
36757
  path: `${this.config.masterViewingKey.path}/sas/${attestation.uid.slice(0, 8)}`,
@@ -36570,13 +36843,13 @@ async function verifyAttestationSignature(attestation, options = {}) {
36570
36843
  const signedMessage = constructAttestationMessage(attestation);
36571
36844
  try {
36572
36845
  const { ed25519: ed2551918 } = await import("@noble/curves/ed25519");
36573
- const signatureBytes = (0, import_utils55.hexToBytes)(
36846
+ const signatureBytes = (0, import_utils56.hexToBytes)(
36574
36847
  attestation.signature.startsWith("0x") ? attestation.signature.slice(2) : attestation.signature
36575
36848
  );
36576
- const publicKeyBytes = (0, import_utils55.hexToBytes)(
36849
+ const publicKeyBytes = (0, import_utils56.hexToBytes)(
36577
36850
  issuerPublicKey.startsWith("0x") ? issuerPublicKey.slice(2) : issuerPublicKey
36578
36851
  );
36579
- const messageBytes = (0, import_utils55.utf8ToBytes)(signedMessage);
36852
+ const messageBytes = (0, import_utils56.utf8ToBytes)(signedMessage);
36580
36853
  return ed2551918.verify(signatureBytes, messageBytes, publicKeyBytes);
36581
36854
  } catch (error) {
36582
36855
  console.warn(`[Range SAS] Signature verification error: ${error}`);
@@ -36733,11 +37006,11 @@ async function fetchWalletAttestations(walletAddress, options = {}) {
36733
37006
 
36734
37007
  // src/compliance/fireblocks.ts
36735
37008
  var import_sha25625 = require("@noble/hashes/sha256");
36736
- var import_utils56 = require("@noble/hashes/utils");
37009
+ var import_utils57 = require("@noble/hashes/utils");
36737
37010
 
36738
37011
  // src/auction/sealed-bid.ts
36739
37012
  init_commitment();
36740
- var import_utils57 = require("@noble/hashes/utils");
37013
+ var import_utils58 = require("@noble/hashes/utils");
36741
37014
  init_errors();
36742
37015
  var SealedBidAuction = class {
36743
37016
  /**
@@ -36815,7 +37088,7 @@ var SealedBidAuction = class {
36815
37088
  );
36816
37089
  }
36817
37090
  }
36818
- const salt = params.salt ?? (0, import_utils57.randomBytes)(32);
37091
+ const salt = params.salt ?? (0, import_utils58.randomBytes)(32);
36819
37092
  const { commitment, blinding } = commit(params.amount, salt);
36820
37093
  const sealedBid = {
36821
37094
  auctionId: params.auctionId,
@@ -36959,7 +37232,7 @@ var SealedBidAuction = class {
36959
37232
  * ```
36960
37233
  */
36961
37234
  revealBid(bid, amount, salt) {
36962
- const saltHex = `0x${(0, import_utils57.bytesToHex)(salt)}`;
37235
+ const saltHex = `0x${(0, import_utils58.bytesToHex)(salt)}`;
36963
37236
  const isValid = this.verifyBid({
36964
37237
  commitment: bid.commitment,
36965
37238
  amount,
@@ -37446,7 +37719,7 @@ function createSealedBidAuction() {
37446
37719
  // src/governance/private-vote.ts
37447
37720
  var import_sha25626 = require("@noble/hashes/sha256");
37448
37721
  var import_hkdf4 = require("@noble/hashes/hkdf");
37449
- var import_utils58 = require("@noble/hashes/utils");
37722
+ var import_utils59 = require("@noble/hashes/utils");
37450
37723
  var import_chacha5 = require("@noble/ciphers/chacha.js");
37451
37724
  init_errors();
37452
37725
  init_secure_memory();
@@ -37487,7 +37760,7 @@ var PrivateVoting = class {
37487
37760
  const { proposalId, choice, weight, encryptionKey, voter = "anonymous" } = params;
37488
37761
  const derivedKey = this.deriveEncryptionKey(encryptionKey, proposalId);
37489
37762
  try {
37490
- const nonce = (0, import_utils58.randomBytes)(NONCE_SIZE3);
37763
+ const nonce = (0, import_utils59.randomBytes)(NONCE_SIZE3);
37491
37764
  const voteData = {
37492
37765
  proposalId,
37493
37766
  choice,
@@ -37495,14 +37768,14 @@ var PrivateVoting = class {
37495
37768
  voter,
37496
37769
  timestamp: Date.now()
37497
37770
  };
37498
- const plaintext = (0, import_utils58.utf8ToBytes)(JSON.stringify(voteData));
37771
+ const plaintext = (0, import_utils59.utf8ToBytes)(JSON.stringify(voteData));
37499
37772
  const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonce);
37500
37773
  const ciphertext = cipher.encrypt(plaintext);
37501
- const keyHash = (0, import_sha25626.sha256)((0, import_utils58.hexToBytes)(encryptionKey.slice(2)));
37774
+ const keyHash = (0, import_sha25626.sha256)((0, import_utils59.hexToBytes)(encryptionKey.slice(2)));
37502
37775
  return {
37503
- ciphertext: `0x${(0, import_utils58.bytesToHex)(ciphertext)}`,
37504
- nonce: `0x${(0, import_utils58.bytesToHex)(nonce)}`,
37505
- encryptionKeyHash: `0x${(0, import_utils58.bytesToHex)(keyHash)}`,
37776
+ ciphertext: `0x${(0, import_utils59.bytesToHex)(ciphertext)}`,
37777
+ nonce: `0x${(0, import_utils59.bytesToHex)(nonce)}`,
37778
+ encryptionKeyHash: `0x${(0, import_utils59.bytesToHex)(keyHash)}`,
37506
37779
  proposalId,
37507
37780
  voter,
37508
37781
  timestamp: voteData.timestamp
@@ -37548,8 +37821,8 @@ var PrivateVoting = class {
37548
37821
  }
37549
37822
  const derivedKey = this.deriveEncryptionKey(decryptionKey, vote.proposalId);
37550
37823
  try {
37551
- const keyHash = (0, import_sha25626.sha256)((0, import_utils58.hexToBytes)(decryptionKey.slice(2)));
37552
- const expectedKeyHash = `0x${(0, import_utils58.bytesToHex)(keyHash)}`;
37824
+ const keyHash = (0, import_sha25626.sha256)((0, import_utils59.hexToBytes)(decryptionKey.slice(2)));
37825
+ const expectedKeyHash = `0x${(0, import_utils59.bytesToHex)(keyHash)}`;
37553
37826
  if (vote.encryptionKeyHash !== expectedKeyHash) {
37554
37827
  throw new CryptoError(
37555
37828
  "Decryption key hash mismatch - this key cannot decrypt this vote",
@@ -37558,9 +37831,9 @@ var PrivateVoting = class {
37558
37831
  );
37559
37832
  }
37560
37833
  const nonceHex = vote.nonce.startsWith("0x") ? vote.nonce.slice(2) : vote.nonce;
37561
- const nonce = (0, import_utils58.hexToBytes)(nonceHex);
37834
+ const nonce = (0, import_utils59.hexToBytes)(nonceHex);
37562
37835
  const ciphertextHex = vote.ciphertext.startsWith("0x") ? vote.ciphertext.slice(2) : vote.ciphertext;
37563
- const ciphertext = (0, import_utils58.hexToBytes)(ciphertextHex);
37836
+ const ciphertext = (0, import_utils59.hexToBytes)(ciphertextHex);
37564
37837
  const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonce);
37565
37838
  let plaintext;
37566
37839
  try {
@@ -37649,10 +37922,10 @@ var PrivateVoting = class {
37649
37922
  */
37650
37923
  deriveEncryptionKey(key, proposalId) {
37651
37924
  const keyHex = key.startsWith("0x") ? key.slice(2) : key;
37652
- const keyBytes = (0, import_utils58.hexToBytes)(keyHex);
37925
+ const keyBytes = (0, import_utils59.hexToBytes)(keyHex);
37653
37926
  try {
37654
- const salt = (0, import_utils58.utf8ToBytes)(VOTE_ENCRYPTION_DOMAIN);
37655
- const info = (0, import_utils58.utf8ToBytes)(proposalId);
37927
+ const salt = (0, import_utils59.utf8ToBytes)(VOTE_ENCRYPTION_DOMAIN);
37928
+ const info = (0, import_utils59.utf8ToBytes)(proposalId);
37656
37929
  return (0, import_hkdf4.hkdf)(import_sha25626.sha256, keyBytes, salt, info, 32);
37657
37930
  } finally {
37658
37931
  secureWipe(keyBytes);
@@ -37798,21 +38071,21 @@ var PrivateVoting = class {
37798
38071
  const blindings = {};
37799
38072
  for (const [choice, weights] of Object.entries(votesByChoice)) {
37800
38073
  const totalWeight = weights.reduce((sum, w) => sum + w, 0n);
37801
- const { commitment, blinding } = commit(totalWeight, (0, import_utils58.hexToBytes)(generateBlinding().slice(2)));
38074
+ const { commitment, blinding } = commit(totalWeight, (0, import_utils59.hexToBytes)(generateBlinding().slice(2)));
37802
38075
  tallies[choice] = commitment;
37803
38076
  blindings[choice] = blinding;
37804
38077
  }
37805
38078
  const encryptedBlindings = {};
37806
38079
  for (const [choice, blinding] of Object.entries(blindings)) {
37807
- const nonce = (0, import_utils58.randomBytes)(NONCE_SIZE3);
38080
+ const nonce = (0, import_utils59.randomBytes)(NONCE_SIZE3);
37808
38081
  const derivedKey = this.deriveEncryptionKey(decryptionKey, `${proposalId}-tally-${choice}`);
37809
38082
  try {
37810
38083
  const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonce);
37811
- const blindingBytes = (0, import_utils58.hexToBytes)(blinding.slice(2));
38084
+ const blindingBytes = (0, import_utils59.hexToBytes)(blinding.slice(2));
37812
38085
  const ciphertext = cipher.encrypt(blindingBytes);
37813
38086
  encryptedBlindings[choice] = {
37814
- ciphertext: `0x${(0, import_utils58.bytesToHex)(ciphertext)}`,
37815
- nonce: `0x${(0, import_utils58.bytesToHex)(nonce)}`
38087
+ ciphertext: `0x${(0, import_utils59.bytesToHex)(ciphertext)}`,
38088
+ nonce: `0x${(0, import_utils59.bytesToHex)(nonce)}`
37816
38089
  };
37817
38090
  } finally {
37818
38091
  secureWipe(derivedKey);
@@ -37905,9 +38178,9 @@ var PrivateVoting = class {
37905
38178
  }
37906
38179
  let reconstructedKey = null;
37907
38180
  try {
37908
- reconstructedKey = (0, import_utils58.hexToBytes)(decryptionShares[0].share.slice(2));
38181
+ reconstructedKey = (0, import_utils59.hexToBytes)(decryptionShares[0].share.slice(2));
37909
38182
  for (let i = 1; i < decryptionShares.length; i++) {
37910
- const shareBytes = (0, import_utils58.hexToBytes)(decryptionShares[i].share.slice(2));
38183
+ const shareBytes = (0, import_utils59.hexToBytes)(decryptionShares[i].share.slice(2));
37911
38184
  if (shareBytes.length !== reconstructedKey.length) {
37912
38185
  throw new ValidationError(
37913
38186
  "all decryption shares must have the same length",
@@ -37920,7 +38193,7 @@ var PrivateVoting = class {
37920
38193
  reconstructedKey[j] ^= shareBytes[j];
37921
38194
  }
37922
38195
  }
37923
- const reconstructedKeyHex = `0x${(0, import_utils58.bytesToHex)(reconstructedKey)}`;
38196
+ const reconstructedKeyHex = `0x${(0, import_utils59.bytesToHex)(reconstructedKey)}`;
37924
38197
  const results = {};
37925
38198
  for (const [choice, commitmentPoint] of Object.entries(tally.tallies)) {
37926
38199
  const encBlinding = tally.encryptedBlindings[choice];
@@ -37937,11 +38210,11 @@ var PrivateVoting = class {
37937
38210
  );
37938
38211
  let blindingFactor;
37939
38212
  try {
37940
- const nonceBytes = (0, import_utils58.hexToBytes)(encBlinding.nonce.slice(2));
37941
- const ciphertextBytes = (0, import_utils58.hexToBytes)(encBlinding.ciphertext.slice(2));
38213
+ const nonceBytes = (0, import_utils59.hexToBytes)(encBlinding.nonce.slice(2));
38214
+ const ciphertextBytes = (0, import_utils59.hexToBytes)(encBlinding.ciphertext.slice(2));
37942
38215
  const cipher = (0, import_chacha5.xchacha20poly1305)(derivedKey, nonceBytes);
37943
38216
  const blindingBytes = cipher.decrypt(ciphertextBytes);
37944
- blindingFactor = `0x${(0, import_utils58.bytesToHex)(blindingBytes)}`;
38217
+ blindingFactor = `0x${(0, import_utils59.bytesToHex)(blindingBytes)}`;
37945
38218
  } catch (e) {
37946
38219
  throw new CryptoError(
37947
38220
  "failed to decrypt blinding factor",
@@ -37961,7 +38234,7 @@ var PrivateVoting = class {
37961
38234
  try {
37962
38235
  const { commitment: testCommit } = commit(
37963
38236
  value,
37964
- (0, import_utils58.hexToBytes)(blindingFactor.slice(2))
38237
+ (0, import_utils59.hexToBytes)(blindingFactor.slice(2))
37965
38238
  );
37966
38239
  if (testCommit === commitmentPoint) {
37967
38240
  results[choice] = value;
@@ -38164,7 +38437,7 @@ function createPrivateVoting() {
38164
38437
  var import_sha25627 = require("@noble/hashes/sha256");
38165
38438
  var import_ed2551910 = require("@noble/curves/ed25519");
38166
38439
  var import_secp256k19 = require("@noble/curves/secp256k1");
38167
- var import_utils59 = require("@noble/hashes/utils");
38440
+ var import_utils60 = require("@noble/hashes/utils");
38168
38441
  init_stealth2();
38169
38442
  init_errors();
38170
38443
  init_validation();
@@ -38254,22 +38527,22 @@ var PrivateNFT = class {
38254
38527
  try {
38255
38528
  const message = this.createProofMessage(ownership, challenge);
38256
38529
  const messageHash = (0, import_sha25627.sha256)(new TextEncoder().encode(message));
38257
- const privateKeyBytes = (0, import_utils59.hexToBytes)(stealthPrivateKey.slice(2));
38530
+ const privateKeyBytes = (0, import_utils60.hexToBytes)(stealthPrivateKey.slice(2));
38258
38531
  const signature = import_secp256k19.secp256k1.sign(messageHash, privateKeyBytes);
38259
38532
  const zkProof = {
38260
38533
  type: "ownership",
38261
- proof: `0x${(0, import_utils59.bytesToHex)(signature.toCompactRawBytes())}`,
38534
+ proof: `0x${(0, import_utils60.bytesToHex)(signature.toCompactRawBytes())}`,
38262
38535
  publicInputs: [
38263
- `0x${(0, import_utils59.bytesToHex)(messageHash)}`
38536
+ `0x${(0, import_utils60.bytesToHex)(messageHash)}`
38264
38537
  ]
38265
38538
  };
38266
- const stealthHashBytes = (0, import_sha25627.sha256)((0, import_utils59.hexToBytes)(ownership.ownerStealth.address.slice(2)));
38539
+ const stealthHashBytes = (0, import_sha25627.sha256)((0, import_utils60.hexToBytes)(ownership.ownerStealth.address.slice(2)));
38267
38540
  return {
38268
38541
  nftContract: ownership.nftContract,
38269
38542
  tokenId: ownership.tokenId,
38270
38543
  challenge,
38271
38544
  proof: zkProof,
38272
- stealthHash: `0x${(0, import_utils59.bytesToHex)(stealthHashBytes)}`,
38545
+ stealthHash: `0x${(0, import_utils60.bytesToHex)(stealthHashBytes)}`,
38273
38546
  timestamp: Date.now()
38274
38547
  };
38275
38548
  } catch (e) {
@@ -38311,9 +38584,9 @@ var PrivateNFT = class {
38311
38584
  verifyOwnership(proof) {
38312
38585
  try {
38313
38586
  this.validateOwnershipProof(proof);
38314
- const signatureBytes = (0, import_utils59.hexToBytes)(proof.proof.proof.slice(2));
38587
+ const signatureBytes = (0, import_utils60.hexToBytes)(proof.proof.proof.slice(2));
38315
38588
  const signature = import_secp256k19.secp256k1.Signature.fromCompact(signatureBytes);
38316
- const messageHash = (0, import_utils59.hexToBytes)(proof.proof.publicInputs[0].slice(2));
38589
+ const messageHash = (0, import_utils60.hexToBytes)(proof.proof.publicInputs[0].slice(2));
38317
38590
  if (signatureBytes.length !== 64) {
38318
38591
  return {
38319
38592
  valid: false,
@@ -38410,12 +38683,12 @@ var PrivateNFT = class {
38410
38683
  chain: nft.chain,
38411
38684
  timestamp: Date.now()
38412
38685
  };
38413
- const previousOwnerHashBytes = (0, import_sha25627.sha256)((0, import_utils59.hexToBytes)(nft.ownerStealth.address.slice(2)));
38686
+ const previousOwnerHashBytes = (0, import_sha25627.sha256)((0, import_utils60.hexToBytes)(nft.ownerStealth.address.slice(2)));
38414
38687
  const transfer = {
38415
38688
  nftContract: nft.nftContract,
38416
38689
  tokenId: nft.tokenId,
38417
38690
  newOwnerStealth,
38418
- previousOwnerHash: `0x${(0, import_utils59.bytesToHex)(previousOwnerHashBytes)}`,
38691
+ previousOwnerHash: `0x${(0, import_utils60.bytesToHex)(previousOwnerHashBytes)}`,
38419
38692
  chain: nft.chain,
38420
38693
  timestamp: Date.now()
38421
38694
  };
@@ -38482,9 +38755,9 @@ var PrivateNFT = class {
38482
38755
  );
38483
38756
  }
38484
38757
  const ownedNFTs = [];
38485
- const viewingKeyHex = `0x${(0, import_utils59.bytesToHex)(viewingKey)}`;
38486
- const ed25519SpendingPubHex = `0x${(0, import_utils59.bytesToHex)(import_ed2551910.ed25519.getPublicKey(scanKey))}`;
38487
- const secp256k1SpendingPubHex = `0x${(0, import_utils59.bytesToHex)(import_secp256k19.secp256k1.getPublicKey(scanKey, true))}`;
38758
+ const viewingKeyHex = `0x${(0, import_utils60.bytesToHex)(viewingKey)}`;
38759
+ const ed25519SpendingPubHex = `0x${(0, import_utils60.bytesToHex)(import_ed2551910.ed25519.getPublicKey(scanKey))}`;
38760
+ const secp256k1SpendingPubHex = `0x${(0, import_utils60.bytesToHex)(import_secp256k19.secp256k1.getPublicKey(scanKey, true))}`;
38488
38761
  for (const transfer of transfers) {
38489
38762
  try {
38490
38763
  if (!transfer || typeof transfer !== "object") {
@@ -39926,7 +40199,7 @@ function createMockSolanaAdapter(config = {}) {
39926
40199
  var import_sha24 = require("@noble/hashes/sha2");
39927
40200
  var import_ed2551911 = require("@noble/curves/ed25519");
39928
40201
  init_stealth2();
39929
- var ED25519_ORDER3 = BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed");
40202
+ init_utils();
39930
40203
 
39931
40204
  // src/wallet/ethereum/adapter.ts
39932
40205
  var import_types41 = require("@sip-protocol/types");
@@ -41031,7 +41304,7 @@ var import_types64 = require("@sip-protocol/types");
41031
41304
  // src/wallet/near/adapter.ts
41032
41305
  var import_ed2551913 = require("@noble/curves/ed25519");
41033
41306
  var import_sha26 = require("@noble/hashes/sha2");
41034
- var import_utils61 = require("@noble/hashes/utils");
41307
+ var import_utils63 = require("@noble/hashes/utils");
41035
41308
  var import_types66 = require("@sip-protocol/types");
41036
41309
 
41037
41310
  // src/chains/near/stealth.ts
@@ -41238,16 +41511,16 @@ function validateNEARStealthAddress(stealthAddress) {
41238
41511
  }
41239
41512
 
41240
41513
  // src/wallet/near/adapter.ts
41241
- var ED25519_ORDER4 = 2n ** 252n + 27742317777372353535851937790883648493n;
41514
+ var ED25519_ORDER3 = 2n ** 252n + 27742317777372353535851937790883648493n;
41242
41515
 
41243
41516
  // src/wallet/near/wallet-selector.ts
41244
41517
  var import_sha27 = require("@noble/hashes/sha2");
41245
- var import_utils63 = require("@noble/hashes/utils");
41518
+ var import_utils65 = require("@noble/hashes/utils");
41246
41519
  var import_ed2551915 = require("@noble/curves/ed25519");
41247
41520
 
41248
41521
  // src/chains/near/implicit-account.ts
41249
41522
  var import_ed2551914 = require("@noble/curves/ed25519");
41250
- var import_utils62 = require("@noble/hashes/utils");
41523
+ var import_utils64 = require("@noble/hashes/utils");
41251
41524
  init_errors();
41252
41525
  init_validation();
41253
41526
 
@@ -41291,12 +41564,12 @@ function createAnnouncementMemo2(ephemeralPublicKey, viewTag) {
41291
41564
 
41292
41565
  // src/wallet/near/my-near-wallet.ts
41293
41566
  var import_sha28 = require("@noble/hashes/sha2");
41294
- var import_utils64 = require("@noble/hashes/utils");
41567
+ var import_utils66 = require("@noble/hashes/utils");
41295
41568
  var import_ed2551916 = require("@noble/curves/ed25519");
41296
41569
 
41297
41570
  // src/wallet/near/meteor-wallet.ts
41298
41571
  var import_sha29 = require("@noble/hashes/sha2");
41299
- var import_utils65 = require("@noble/hashes/utils");
41572
+ var import_utils67 = require("@noble/hashes/utils");
41300
41573
  var import_ed2551917 = require("@noble/curves/ed25519");
41301
41574
 
41302
41575
  // src/wallet/hardware/types.ts
@@ -41909,7 +42182,7 @@ function createLedgerAdapter(config) {
41909
42182
  // src/wallet/hardware/ledger-privacy.ts
41910
42183
  var import_secp256k113 = require("@noble/curves/secp256k1");
41911
42184
  var import_sha25628 = require("@noble/hashes/sha256");
41912
- var import_utils66 = require("@noble/hashes/utils");
42185
+ var import_utils68 = require("@noble/hashes/utils");
41913
42186
  var import_types70 = require("@sip-protocol/types");
41914
42187
 
41915
42188
  // src/wallet/hardware/trezor.ts
@@ -42352,7 +42625,7 @@ function createTrezorAdapter(config) {
42352
42625
 
42353
42626
  // src/wallet/hardware/mock.ts
42354
42627
  var import_types74 = require("@sip-protocol/types");
42355
- var import_utils67 = require("@noble/hashes/utils");
42628
+ var import_utils69 = require("@noble/hashes/utils");
42356
42629
  var MockLedgerAdapter = class extends BaseWalletAdapter {
42357
42630
  chain;
42358
42631
  name = "mock-ledger";
@@ -42597,15 +42870,15 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
42597
42870
  }
42598
42871
  }
42599
42872
  generateMockAddress(index) {
42600
- const bytes = (0, import_utils67.randomBytes)(20);
42873
+ const bytes = (0, import_utils69.randomBytes)(20);
42601
42874
  bytes[0] = index;
42602
- return `0x${(0, import_utils67.bytesToHex)(bytes)}`;
42875
+ return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
42603
42876
  }
42604
42877
  generateMockPublicKey(index) {
42605
- const bytes = (0, import_utils67.randomBytes)(33);
42878
+ const bytes = (0, import_utils69.randomBytes)(33);
42606
42879
  bytes[0] = 2;
42607
42880
  bytes[1] = index;
42608
- return `0x${(0, import_utils67.bytesToHex)(bytes)}`;
42881
+ return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
42609
42882
  }
42610
42883
  generateMockSignature(data) {
42611
42884
  const sig = new Uint8Array(65);
@@ -42614,7 +42887,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
42614
42887
  sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 11;
42615
42888
  }
42616
42889
  sig[64] = 27;
42617
- return `0x${(0, import_utils67.bytesToHex)(sig)}`;
42890
+ return `0x${(0, import_utils69.bytesToHex)(sig)}`;
42618
42891
  }
42619
42892
  delay(ms) {
42620
42893
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -42803,15 +43076,15 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
42803
43076
  }
42804
43077
  }
42805
43078
  generateMockAddress(index) {
42806
- const bytes = (0, import_utils67.randomBytes)(20);
43079
+ const bytes = (0, import_utils69.randomBytes)(20);
42807
43080
  bytes[0] = index + 100;
42808
- return `0x${(0, import_utils67.bytesToHex)(bytes)}`;
43081
+ return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
42809
43082
  }
42810
43083
  generateMockPublicKey(index) {
42811
- const bytes = (0, import_utils67.randomBytes)(33);
43084
+ const bytes = (0, import_utils69.randomBytes)(33);
42812
43085
  bytes[0] = 3;
42813
43086
  bytes[1] = index + 100;
42814
- return `0x${(0, import_utils67.bytesToHex)(bytes)}`;
43087
+ return `0x${(0, import_utils69.bytesToHex)(bytes)}`;
42815
43088
  }
42816
43089
  generateMockSignature(data) {
42817
43090
  const sig = new Uint8Array(65);
@@ -42820,7 +43093,7 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
42820
43093
  sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 17;
42821
43094
  }
42822
43095
  sig[64] = 28;
42823
- return `0x${(0, import_utils67.bytesToHex)(sig)}`;
43096
+ return `0x${(0, import_utils69.bytesToHex)(sig)}`;
42824
43097
  }
42825
43098
  delay(ms) {
42826
43099
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -42840,7 +43113,7 @@ var import_types77 = require("@sip-protocol/types");
42840
43113
  init_solana();
42841
43114
 
42842
43115
  // src/solana/noir-verifier.ts
42843
- var import_web316 = require("@solana/web3.js");
43116
+ var import_web318 = require("@solana/web3.js");
42844
43117
 
42845
43118
  // src/solana/noir-verifier-types.ts
42846
43119
  init_endpoints();
@@ -42931,6 +43204,8 @@ var SolanaNoirError = class extends Error {
42931
43204
  this.details = details;
42932
43205
  this.name = "SolanaNoirError";
42933
43206
  }
43207
+ code;
43208
+ details;
42934
43209
  };
42935
43210
  var MAX_PROOF_SIZE_BYTES = 4096;
42936
43211
  var MAX_PUBLIC_INPUTS = 32;
@@ -42965,7 +43240,7 @@ var SolanaNoirVerifier = class {
42965
43240
  commitment: config.commitment ?? "confirmed",
42966
43241
  maxComputeUnits: config.maxComputeUnits ?? 4e5
42967
43242
  };
42968
- this.connection = new import_web316.Connection(this.config.rpcUrl, this.config.commitment);
43243
+ this.connection = new import_web318.Connection(this.config.rpcUrl, this.config.commitment);
42969
43244
  }
42970
43245
  /**
42971
43246
  * Get the Solana connection
@@ -43217,16 +43492,16 @@ var SolanaNoirVerifier = class {
43217
43492
  error: `Proof requires ${computeUnits} CU, max is ${this.config.maxComputeUnits}`
43218
43493
  };
43219
43494
  }
43220
- const transaction = new import_web316.Transaction();
43495
+ const transaction = new import_web318.Transaction();
43221
43496
  transaction.add(
43222
- import_web316.ComputeBudgetProgram.setComputeUnitLimit({ units: this.config.maxComputeUnits })
43497
+ import_web318.ComputeBudgetProgram.setComputeUnitLimit({ units: this.config.maxComputeUnits })
43223
43498
  );
43224
43499
  transaction.add(instruction);
43225
43500
  const { blockhash, lastValidBlockHeight } = await this.connection.getLatestBlockhash(
43226
43501
  this.config.commitment
43227
43502
  );
43228
43503
  transaction.recentBlockhash = blockhash;
43229
- transaction.feePayer = new import_web316.PublicKey(wallet.publicKey.toBase58());
43504
+ transaction.feePayer = new import_web318.PublicKey(wallet.publicKey.toBase58());
43230
43505
  const signedTransaction = await wallet.signTransaction(transaction);
43231
43506
  const signature = await this.connection.sendRawTransaction(signedTransaction.serialize());
43232
43507
  const confirmation = await this.connection.confirmTransaction(
@@ -43268,8 +43543,8 @@ var SolanaNoirVerifier = class {
43268
43543
  */
43269
43544
  createSunspotVerifyInstruction(proof, programId) {
43270
43545
  const serialized = this.serializeProofForSunspot(proof);
43271
- return new import_web316.TransactionInstruction({
43272
- programId: new import_web316.PublicKey(programId),
43546
+ return new import_web318.TransactionInstruction({
43547
+ programId: new import_web318.PublicKey(programId),
43273
43548
  keys: [],
43274
43549
  // Sunspot verifiers don't require any accounts
43275
43550
  data: serialized
@@ -43443,8 +43718,8 @@ var SolanaNoirVerifier = class {
43443
43718
  }
43444
43719
  async hashBytes(bytes) {
43445
43720
  const { sha256: sha25642 } = await import("@noble/hashes/sha256");
43446
- const { bytesToHex: bytesToHex65 } = await import("@noble/hashes/utils");
43447
- return bytesToHex65(sha25642(bytes));
43721
+ const { bytesToHex: bytesToHex64 } = await import("@noble/hashes/utils");
43722
+ return bytesToHex64(sha25642(bytes));
43448
43723
  }
43449
43724
  hexToBytes(hex) {
43450
43725
  const h = hex.startsWith("0x") ? hex.slice(2) : hex;
@@ -43481,8 +43756,8 @@ function createMainnetVerifier(config = {}) {
43481
43756
  }
43482
43757
 
43483
43758
  // src/solana/jito-relayer.ts
43484
- var import_web317 = require("@solana/web3.js");
43485
- var import_utils68 = require("@noble/hashes/utils");
43759
+ var import_web319 = require("@solana/web3.js");
43760
+ var import_bs58 = __toESM(require("bs58"));
43486
43761
  var JITO_BLOCK_ENGINES = {
43487
43762
  mainnet: {
43488
43763
  amsterdam: "https://amsterdam.mainnet.block-engine.jito.wtf/api/v1",
@@ -43531,8 +43806,10 @@ var JitoRelayerError = class extends Error {
43531
43806
  this.details = details;
43532
43807
  this.name = "JitoRelayerError";
43533
43808
  }
43809
+ code;
43810
+ details;
43534
43811
  };
43535
- var JitoRelayer = class {
43812
+ var JitoRelayer = class _JitoRelayer {
43536
43813
  connection;
43537
43814
  blockEngineUrl;
43538
43815
  defaultTipLamports;
@@ -43541,7 +43818,7 @@ var JitoRelayer = class {
43541
43818
  submissionTimeout;
43542
43819
  constructor(config = {}) {
43543
43820
  this.blockEngineUrl = config.blockEngineUrl ?? JITO_BLOCK_ENGINES.mainnet.ny;
43544
- this.connection = new import_web317.Connection(
43821
+ this.connection = new import_web319.Connection(
43545
43822
  config.rpcUrl ?? "https://api.mainnet-beta.solana.com",
43546
43823
  "confirmed"
43547
43824
  );
@@ -43550,6 +43827,11 @@ var JitoRelayer = class {
43550
43827
  this.maxRetries = config.maxRetries ?? JITO_DEFAULTS.maxRetries;
43551
43828
  this.submissionTimeout = config.submissionTimeout ?? JITO_DEFAULTS.submissionTimeout;
43552
43829
  }
43830
+ // ─── Static Helpers ─────────────────────────────────────────────────────────
43831
+ /** Encode a 64-byte ed25519 signature as a base58 string (Solana canonical form). */
43832
+ static encodeSignature(sig) {
43833
+ return import_bs58.default.encode(sig);
43834
+ }
43553
43835
  // ─── Public Methods ─────────────────────────────────────────────────────────
43554
43836
  /**
43555
43837
  * Submit a bundle of transactions to Jito
@@ -43601,11 +43883,11 @@ var JitoRelayer = class {
43601
43883
  }
43602
43884
  }
43603
43885
  const signatures = bundleTransactions.map((tx) => {
43604
- if (tx instanceof import_web317.VersionedTransaction) {
43605
- return (0, import_utils68.bytesToHex)(tx.signatures[0]);
43606
- } else {
43607
- return tx.signature?.toString() ?? "";
43886
+ if (tx instanceof import_web319.VersionedTransaction) {
43887
+ return _JitoRelayer.encodeSignature(tx.signatures[0]);
43608
43888
  }
43889
+ const sig = tx.signature;
43890
+ return sig ? _JitoRelayer.encodeSignature(sig) : "";
43609
43891
  });
43610
43892
  if (request.waitForConfirmation) {
43611
43893
  const status = await this.waitForBundleConfirmation(bundleId, lastValidBlockHeight);
@@ -43637,13 +43919,30 @@ var JitoRelayer = class {
43637
43919
  async relayTransaction(request) {
43638
43920
  this.log("Relaying transaction");
43639
43921
  try {
43922
+ if (request.tipPayer) {
43923
+ const bundle = await this.submitBundle({
43924
+ transactions: [request.transaction],
43925
+ tipLamports: request.tipLamports,
43926
+ tipPayer: request.tipPayer,
43927
+ waitForConfirmation: request.waitForConfirmation
43928
+ });
43929
+ return {
43930
+ signature: bundle.signatures[bundle.signatures.length - 1] ?? "",
43931
+ bundleId: bundle.bundleId,
43932
+ status: bundle.status === "landed" ? "confirmed" : bundle.status === "submitted" ? "submitted" : "failed",
43933
+ slot: bundle.slot,
43934
+ error: bundle.error,
43935
+ relayed: true
43936
+ };
43937
+ }
43640
43938
  const serializedTx = Buffer.from(request.transaction.serialize()).toString("base64");
43641
43939
  const bundleId = await this.sendBundle([serializedTx]);
43642
43940
  let signature;
43643
- if (request.transaction instanceof import_web317.VersionedTransaction) {
43644
- signature = (0, import_utils68.bytesToHex)(request.transaction.signatures[0]);
43941
+ if (request.transaction instanceof import_web319.VersionedTransaction) {
43942
+ signature = _JitoRelayer.encodeSignature(request.transaction.signatures[0]);
43645
43943
  } else {
43646
- signature = request.transaction.signature?.toString() ?? "";
43944
+ const sig = request.transaction.signature;
43945
+ signature = sig ? _JitoRelayer.encodeSignature(sig) : "";
43647
43946
  }
43648
43947
  if (request.waitForConfirmation) {
43649
43948
  const { lastValidBlockHeight } = await this.connection.getLatestBlockhash();
@@ -43693,7 +43992,7 @@ var JitoRelayer = class {
43693
43992
  */
43694
43993
  getRandomTipAccount() {
43695
43994
  const index = Math.floor(Math.random() * JITO_TIP_ACCOUNTS.length);
43696
- return new import_web317.PublicKey(JITO_TIP_ACCOUNTS[index]);
43995
+ return new import_web319.PublicKey(JITO_TIP_ACCOUNTS[index]);
43697
43996
  }
43698
43997
  // ─── Private Methods ────────────────────────────────────────────────────────
43699
43998
  /**
@@ -43701,7 +44000,7 @@ var JitoRelayer = class {
43701
44000
  */
43702
44001
  createTipInstruction(payer, tipLamports) {
43703
44002
  const tipAccount = this.getRandomTipAccount();
43704
- return import_web317.SystemProgram.transfer({
44003
+ return import_web319.SystemProgram.transfer({
43705
44004
  fromPubkey: payer,
43706
44005
  toPubkey: tipAccount,
43707
44006
  lamports: tipLamports
@@ -43711,7 +44010,7 @@ var JitoRelayer = class {
43711
44010
  * Prepare transactions for bundle submission
43712
44011
  */
43713
44012
  async prepareBundleTransactions(transactions, tipInstruction, tipPayer, blockhash) {
43714
- const tipTx = new import_web317.Transaction();
44013
+ const tipTx = new import_web319.Transaction();
43715
44014
  tipTx.add(tipInstruction);
43716
44015
  tipTx.recentBlockhash = blockhash;
43717
44016
  tipTx.feePayer = tipPayer.publicKey;
@@ -43866,15 +44165,15 @@ function createMainnetRelayer(rpcUrl) {
43866
44165
  // src/chains/near/commitment.ts
43867
44166
  var import_ed2551918 = require("@noble/curves/ed25519");
43868
44167
  var import_sha210 = require("@noble/hashes/sha2");
43869
- var import_utils69 = require("@noble/hashes/utils");
44168
+ var import_utils70 = require("@noble/hashes/utils");
43870
44169
  init_errors();
43871
44170
  init_validation();
43872
44171
  var H_DOMAIN3 = "SIP-NEAR-PEDERSEN-GENERATOR-H-v1";
43873
44172
  var G3 = import_ed2551918.ed25519.ExtendedPoint.BASE;
43874
- var ED25519_ORDER5 = 2n ** 252n + 27742317777372353535851937790883648493n;
44173
+ var ED25519_ORDER4 = 2n ** 252n + 27742317777372353535851937790883648493n;
43875
44174
  var ED25519_COFACTOR2 = 8n;
43876
44175
  var MAX_NEAR_AMOUNT = 2n ** 128n - 1n;
43877
- var MAX_COMMITMENT_VALUE = ED25519_ORDER5 - 1n;
44176
+ var MAX_COMMITMENT_VALUE = ED25519_ORDER4 - 1n;
43878
44177
  var H3 = generateH3();
43879
44178
  function generateH3() {
43880
44179
  let counter = 0;
@@ -43887,7 +44186,7 @@ function generateH3() {
43887
44186
  if (!point.equals(import_ed2551918.ed25519.ExtendedPoint.ZERO)) {
43888
44187
  const gBytes = G3.toRawBytes();
43889
44188
  const hBytes = point.toRawBytes();
43890
- if ((0, import_utils69.bytesToHex)(gBytes) !== (0, import_utils69.bytesToHex)(hBytes)) {
44189
+ if ((0, import_utils70.bytesToHex)(gBytes) !== (0, import_utils70.bytesToHex)(hBytes)) {
43891
44190
  return point;
43892
44191
  }
43893
44192
  }
@@ -43931,20 +44230,20 @@ function commitNEAR(value, blinding) {
43931
44230
  if (value < 0n) {
43932
44231
  throw new ValidationError("must be non-negative", "value");
43933
44232
  }
43934
- if (value >= ED25519_ORDER5) {
44233
+ if (value >= ED25519_ORDER4) {
43935
44234
  throw new ValidationError(
43936
44235
  "must be less than curve order",
43937
44236
  "value",
43938
- { curveOrder: ED25519_ORDER5.toString(16) }
44237
+ { curveOrder: ED25519_ORDER4.toString(16) }
43939
44238
  );
43940
44239
  }
43941
- const r = blinding ?? (0, import_utils69.randomBytes)(32);
44240
+ const r = blinding ?? (0, import_utils70.randomBytes)(32);
43942
44241
  if (r.length !== 32) {
43943
44242
  throw new ValidationError("must be 32 bytes", "blinding", { received: r.length });
43944
44243
  }
43945
- const rScalar = bytesToBigInt4(r) % ED25519_ORDER5;
44244
+ const rScalar = bytesToBigInt4(r) % ED25519_ORDER4;
43946
44245
  if (rScalar === 0n) {
43947
- return commitNEAR(value, (0, import_utils69.randomBytes)(32));
44246
+ return commitNEAR(value, (0, import_utils70.randomBytes)(32));
43948
44247
  }
43949
44248
  let C;
43950
44249
  if (value === 0n) {
@@ -43956,8 +44255,8 @@ function commitNEAR(value, blinding) {
43956
44255
  }
43957
44256
  const rScalarBytes = bigIntToBytes4(rScalar, 32);
43958
44257
  return {
43959
- commitment: `0x${(0, import_utils69.bytesToHex)(C.toRawBytes())}`,
43960
- blinding: `0x${(0, import_utils69.bytesToHex)(rScalarBytes)}`
44258
+ commitment: `0x${(0, import_utils70.bytesToHex)(C.toRawBytes())}`,
44259
+ blinding: `0x${(0, import_utils70.bytesToHex)(rScalarBytes)}`
43961
44260
  };
43962
44261
  }
43963
44262
  function verifyOpeningNEAR(commitment, value, blinding) {
@@ -43965,7 +44264,7 @@ function verifyOpeningNEAR(commitment, value, blinding) {
43965
44264
  const commitmentBytes = hexToBytes38(commitment.slice(2));
43966
44265
  const C = import_ed2551918.ed25519.ExtendedPoint.fromHex(commitmentBytes);
43967
44266
  const blindingBytes = hexToBytes38(blinding.slice(2));
43968
- const rScalar = bytesToBigInt4(blindingBytes) % ED25519_ORDER5;
44267
+ const rScalar = bytesToBigInt4(blindingBytes) % ED25519_ORDER4;
43969
44268
  let expected;
43970
44269
  if (value === 0n) {
43971
44270
  expected = H3.multiply(rScalar);
@@ -43989,7 +44288,7 @@ function commitNEP141Token(amount, tokenContract, decimals, blinding) {
43989
44288
  { max: MAX_NEAR_AMOUNT.toString() }
43990
44289
  );
43991
44290
  }
43992
- if (amount >= ED25519_ORDER5) {
44291
+ if (amount >= ED25519_ORDER4) {
43993
44292
  throw new ValidationError(
43994
44293
  "Amount exceeds maximum committable value (curve order)",
43995
44294
  "amount",
@@ -44050,7 +44349,7 @@ function addCommitmentsNEAR(c1, c2) {
44050
44349
  }
44051
44350
  const sum = point1.add(point2);
44052
44351
  return {
44053
- commitment: `0x${(0, import_utils69.bytesToHex)(sum.toRawBytes())}`
44352
+ commitment: `0x${(0, import_utils70.bytesToHex)(sum.toRawBytes())}`
44054
44353
  };
44055
44354
  }
44056
44355
  function subtractCommitmentsNEAR(c1, c2) {
@@ -44079,7 +44378,7 @@ function subtractCommitmentsNEAR(c1, c2) {
44079
44378
  };
44080
44379
  }
44081
44380
  return {
44082
- commitment: `0x${(0, import_utils69.bytesToHex)(diff.toRawBytes())}`
44381
+ commitment: `0x${(0, import_utils70.bytesToHex)(diff.toRawBytes())}`
44083
44382
  };
44084
44383
  }
44085
44384
  function addBlindingsNEAR(b1, b2) {
@@ -44093,9 +44392,9 @@ function addBlindingsNEAR(b1, b2) {
44093
44392
  const b2Bytes = hexToBytes38(b2.slice(2));
44094
44393
  const b1Scalar = bytesToBigInt4(b1Bytes);
44095
44394
  const b2Scalar = bytesToBigInt4(b2Bytes);
44096
- const sum = (b1Scalar + b2Scalar) % ED25519_ORDER5;
44395
+ const sum = (b1Scalar + b2Scalar) % ED25519_ORDER4;
44097
44396
  const sumBytes = bigIntToBytes4(sum, 32);
44098
- return `0x${(0, import_utils69.bytesToHex)(sumBytes)}`;
44397
+ return `0x${(0, import_utils70.bytesToHex)(sumBytes)}`;
44099
44398
  }
44100
44399
  function subtractBlindingsNEAR(b1, b2) {
44101
44400
  if (!isValidHex(b1)) {
@@ -44108,24 +44407,24 @@ function subtractBlindingsNEAR(b1, b2) {
44108
44407
  const b2Bytes = hexToBytes38(b2.slice(2));
44109
44408
  const b1Scalar = bytesToBigInt4(b1Bytes);
44110
44409
  const b2Scalar = bytesToBigInt4(b2Bytes);
44111
- const diff = (b1Scalar - b2Scalar + ED25519_ORDER5) % ED25519_ORDER5;
44410
+ const diff = (b1Scalar - b2Scalar + ED25519_ORDER4) % ED25519_ORDER4;
44112
44411
  const diffBytes = bigIntToBytes4(diff, 32);
44113
- return `0x${(0, import_utils69.bytesToHex)(diffBytes)}`;
44412
+ return `0x${(0, import_utils70.bytesToHex)(diffBytes)}`;
44114
44413
  }
44115
44414
  function getGeneratorsNEAR() {
44116
44415
  return {
44117
- G: `0x${(0, import_utils69.bytesToHex)(G3.toRawBytes())}`,
44118
- H: `0x${(0, import_utils69.bytesToHex)(H3.toRawBytes())}`
44416
+ G: `0x${(0, import_utils70.bytesToHex)(G3.toRawBytes())}`,
44417
+ H: `0x${(0, import_utils70.bytesToHex)(H3.toRawBytes())}`
44119
44418
  };
44120
44419
  }
44121
44420
  function generateBlindingNEAR() {
44122
- const bytes = (0, import_utils69.randomBytes)(32);
44123
- const scalar = bytesToBigInt4(bytes) % ED25519_ORDER5;
44421
+ const bytes = (0, import_utils70.randomBytes)(32);
44422
+ const scalar = bytesToBigInt4(bytes) % ED25519_ORDER4;
44124
44423
  if (scalar === 0n) {
44125
44424
  return generateBlindingNEAR();
44126
44425
  }
44127
44426
  const scalarBytes = bigIntToBytes4(scalar, 32);
44128
- return `0x${(0, import_utils69.bytesToHex)(scalarBytes)}`;
44427
+ return `0x${(0, import_utils70.bytesToHex)(scalarBytes)}`;
44129
44428
  }
44130
44429
 
44131
44430
  // src/chains/near/viewing-key.ts
@@ -44133,7 +44432,7 @@ var import_ed2551919 = require("@noble/curves/ed25519");
44133
44432
  var import_sha25629 = require("@noble/hashes/sha256");
44134
44433
  var import_hmac7 = require("@noble/hashes/hmac");
44135
44434
  var import_hkdf5 = require("@noble/hashes/hkdf");
44136
- var import_utils70 = require("@noble/hashes/utils");
44435
+ var import_utils71 = require("@noble/hashes/utils");
44137
44436
  var import_chacha6 = require("@noble/ciphers/chacha.js");
44138
44437
  init_errors();
44139
44438
  init_validation();
@@ -44149,7 +44448,7 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
44149
44448
  "spendingPrivateKey"
44150
44449
  );
44151
44450
  }
44152
- const spendingBytes = (0, import_utils70.hexToBytes)(spendingPrivateKey.slice(2));
44451
+ const spendingBytes = (0, import_utils71.hexToBytes)(spendingPrivateKey.slice(2));
44153
44452
  if (spendingBytes.length !== 32) {
44154
44453
  throw new ValidationError(
44155
44454
  "spendingPrivateKey must be 32 bytes",
@@ -44160,15 +44459,15 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
44160
44459
  try {
44161
44460
  viewingPrivateBytes = (0, import_hmac7.hmac)(
44162
44461
  import_sha25629.sha256,
44163
- (0, import_utils70.utf8ToBytes)(VIEWING_KEY_CONTEXT3),
44462
+ (0, import_utils71.utf8ToBytes)(VIEWING_KEY_CONTEXT3),
44164
44463
  spendingBytes
44165
44464
  );
44166
44465
  const viewingPublicBytes = import_ed2551919.ed25519.getPublicKey(viewingPrivateBytes);
44167
44466
  const hashBytes = (0, import_sha25629.sha256)(viewingPublicBytes);
44168
44467
  return {
44169
- privateKey: `0x${(0, import_utils70.bytesToHex)(viewingPrivateBytes)}`,
44170
- publicKey: `0x${(0, import_utils70.bytesToHex)(viewingPublicBytes)}`,
44171
- hash: `0x${(0, import_utils70.bytesToHex)(hashBytes)}`,
44468
+ privateKey: `0x${(0, import_utils71.bytesToHex)(viewingPrivateBytes)}`,
44469
+ publicKey: `0x${(0, import_utils71.bytesToHex)(viewingPublicBytes)}`,
44470
+ hash: `0x${(0, import_utils71.bytesToHex)(hashBytes)}`,
44172
44471
  label,
44173
44472
  createdAt: Date.now()
44174
44473
  };
@@ -44178,14 +44477,14 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
44178
44477
  }
44179
44478
  }
44180
44479
  function generateRandomNEARViewingKey(label) {
44181
- const privateBytes = (0, import_utils70.randomBytes)(32);
44480
+ const privateBytes = (0, import_utils71.randomBytes)(32);
44182
44481
  try {
44183
44482
  const publicBytes = import_ed2551919.ed25519.getPublicKey(privateBytes);
44184
44483
  const hashBytes = (0, import_sha25629.sha256)(publicBytes);
44185
44484
  return {
44186
- privateKey: `0x${(0, import_utils70.bytesToHex)(privateBytes)}`,
44187
- publicKey: `0x${(0, import_utils70.bytesToHex)(publicBytes)}`,
44188
- hash: `0x${(0, import_utils70.bytesToHex)(hashBytes)}`,
44485
+ privateKey: `0x${(0, import_utils71.bytesToHex)(privateBytes)}`,
44486
+ publicKey: `0x${(0, import_utils71.bytesToHex)(publicBytes)}`,
44487
+ hash: `0x${(0, import_utils71.bytesToHex)(hashBytes)}`,
44189
44488
  label,
44190
44489
  createdAt: Date.now()
44191
44490
  };
@@ -44200,7 +44499,7 @@ function computeNEARViewingKeyHash(viewingPublicKey) {
44200
44499
  "viewingPublicKey"
44201
44500
  );
44202
44501
  }
44203
- const publicBytes = (0, import_utils70.hexToBytes)(viewingPublicKey.slice(2));
44502
+ const publicBytes = (0, import_utils71.hexToBytes)(viewingPublicKey.slice(2));
44204
44503
  if (publicBytes.length !== 32) {
44205
44504
  throw new ValidationError(
44206
44505
  "viewingPublicKey must be 32 bytes",
@@ -44208,7 +44507,7 @@ function computeNEARViewingKeyHash(viewingPublicKey) {
44208
44507
  );
44209
44508
  }
44210
44509
  const hashBytes = (0, import_sha25629.sha256)(publicBytes);
44211
- return `0x${(0, import_utils70.bytesToHex)(hashBytes)}`;
44510
+ return `0x${(0, import_utils71.bytesToHex)(hashBytes)}`;
44212
44511
  }
44213
44512
  function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
44214
44513
  if (!viewingPrivateKey || !viewingPrivateKey.startsWith("0x")) {
@@ -44217,7 +44516,7 @@ function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
44217
44516
  "viewingPrivateKey"
44218
44517
  );
44219
44518
  }
44220
- const privateBytes = (0, import_utils70.hexToBytes)(viewingPrivateKey.slice(2));
44519
+ const privateBytes = (0, import_utils71.hexToBytes)(viewingPrivateKey.slice(2));
44221
44520
  if (privateBytes.length !== 32) {
44222
44521
  throw new ValidationError(
44223
44522
  "viewingPrivateKey must be 32 bytes",
@@ -44227,7 +44526,7 @@ function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
44227
44526
  try {
44228
44527
  const publicBytes = import_ed2551919.ed25519.getPublicKey(privateBytes);
44229
44528
  const hashBytes = (0, import_sha25629.sha256)(publicBytes);
44230
- return `0x${(0, import_utils70.bytesToHex)(hashBytes)}`;
44529
+ return `0x${(0, import_utils71.bytesToHex)(hashBytes)}`;
44231
44530
  } finally {
44232
44531
  secureWipe(privateBytes);
44233
44532
  }
@@ -44274,9 +44573,9 @@ function importNEARViewingKey(exported) {
44274
44573
  { expected: computedHash, received: exported.hash }
44275
44574
  );
44276
44575
  }
44277
- const privateBytes = (0, import_utils70.hexToBytes)(exported.privateKey.slice(2));
44576
+ const privateBytes = (0, import_utils71.hexToBytes)(exported.privateKey.slice(2));
44278
44577
  try {
44279
- const derivedPublic = `0x${(0, import_utils70.bytesToHex)(import_ed2551919.ed25519.getPublicKey(privateBytes))}`;
44578
+ const derivedPublic = `0x${(0, import_utils71.bytesToHex)(import_ed2551919.ed25519.getPublicKey(privateBytes))}`;
44280
44579
  if (derivedPublic !== exported.publicKey) {
44281
44580
  throw new ValidationError(
44282
44581
  "Public key does not match private key",
@@ -44295,10 +44594,10 @@ function importNEARViewingKey(exported) {
44295
44594
  };
44296
44595
  }
44297
44596
  function deriveEncryptionKey3(key, salt) {
44298
- const keyBytes = (0, import_utils70.hexToBytes)(key.slice(2));
44597
+ const keyBytes = (0, import_utils71.hexToBytes)(key.slice(2));
44299
44598
  try {
44300
- const hkdfSalt = salt ?? (0, import_utils70.utf8ToBytes)(ENCRYPTION_DOMAIN3);
44301
- return (0, import_hkdf5.hkdf)(import_sha25629.sha256, keyBytes, hkdfSalt, (0, import_utils70.utf8ToBytes)("encryption"), 32);
44599
+ const hkdfSalt = salt ?? (0, import_utils71.utf8ToBytes)(ENCRYPTION_DOMAIN3);
44600
+ return (0, import_hkdf5.hkdf)(import_sha25629.sha256, keyBytes, hkdfSalt, (0, import_utils71.utf8ToBytes)("encryption"), 32);
44302
44601
  } finally {
44303
44602
  secureWipe(keyBytes);
44304
44603
  }
@@ -44306,13 +44605,13 @@ function deriveEncryptionKey3(key, salt) {
44306
44605
  function encryptForNEARViewing(data, viewingKey) {
44307
44606
  const encKey = deriveEncryptionKey3(viewingKey.privateKey);
44308
44607
  try {
44309
- const nonce = (0, import_utils70.randomBytes)(NONCE_SIZE4);
44310
- const plaintext = (0, import_utils70.utf8ToBytes)(JSON.stringify(data));
44608
+ const nonce = (0, import_utils71.randomBytes)(NONCE_SIZE4);
44609
+ const plaintext = (0, import_utils71.utf8ToBytes)(JSON.stringify(data));
44311
44610
  const cipher = (0, import_chacha6.xchacha20poly1305)(encKey, nonce);
44312
44611
  const ciphertext = cipher.encrypt(plaintext);
44313
44612
  return {
44314
- ciphertext: `0x${(0, import_utils70.bytesToHex)(ciphertext)}`,
44315
- nonce: `0x${(0, import_utils70.bytesToHex)(nonce)}`,
44613
+ ciphertext: `0x${(0, import_utils71.bytesToHex)(ciphertext)}`,
44614
+ nonce: `0x${(0, import_utils71.bytesToHex)(nonce)}`,
44316
44615
  viewingKeyHash: viewingKey.hash
44317
44616
  };
44318
44617
  } finally {
@@ -44329,8 +44628,8 @@ function decryptWithNEARViewing(encrypted, viewingKey) {
44329
44628
  }
44330
44629
  const encKey = deriveEncryptionKey3(viewingKey.privateKey);
44331
44630
  try {
44332
- const ciphertext = (0, import_utils70.hexToBytes)(encrypted.ciphertext.slice(2));
44333
- const nonce = (0, import_utils70.hexToBytes)(encrypted.nonce.slice(2));
44631
+ const ciphertext = (0, import_utils71.hexToBytes)(encrypted.ciphertext.slice(2));
44632
+ const nonce = (0, import_utils71.hexToBytes)(encrypted.nonce.slice(2));
44334
44633
  if (nonce.length !== NONCE_SIZE4) {
44335
44634
  throw new ValidationError(
44336
44635
  `Invalid nonce length: ${nonce.length}. Expected: ${NONCE_SIZE4}`,
@@ -44380,15 +44679,15 @@ function deriveNEARChildViewingKey(parentKey, childPath, label) {
44380
44679
  if (!childPath || typeof childPath !== "string") {
44381
44680
  throw new ValidationError("childPath must be a non-empty string", "childPath");
44382
44681
  }
44383
- const parentBytes = (0, import_utils70.hexToBytes)(parentKey.privateKey.slice(2));
44682
+ const parentBytes = (0, import_utils71.hexToBytes)(parentKey.privateKey.slice(2));
44384
44683
  try {
44385
- const childBytes = (0, import_hmac7.hmac)(import_sha25629.sha256, (0, import_utils70.utf8ToBytes)(childPath), parentBytes);
44684
+ const childBytes = (0, import_hmac7.hmac)(import_sha25629.sha256, (0, import_utils71.utf8ToBytes)(childPath), parentBytes);
44386
44685
  const publicBytes = import_ed2551919.ed25519.getPublicKey(childBytes);
44387
44686
  const hashBytes = (0, import_sha25629.sha256)(publicBytes);
44388
44687
  const result = {
44389
- privateKey: `0x${(0, import_utils70.bytesToHex)(childBytes)}`,
44390
- publicKey: `0x${(0, import_utils70.bytesToHex)(publicBytes)}`,
44391
- hash: `0x${(0, import_utils70.bytesToHex)(hashBytes)}`,
44688
+ privateKey: `0x${(0, import_utils71.bytesToHex)(childBytes)}`,
44689
+ publicKey: `0x${(0, import_utils71.bytesToHex)(publicBytes)}`,
44690
+ hash: `0x${(0, import_utils71.bytesToHex)(hashBytes)}`,
44392
44691
  label: label ?? `${parentKey.label ?? "Key"}/${childPath}`,
44393
44692
  createdAt: Date.now()
44394
44693
  };
@@ -44405,7 +44704,7 @@ function getNEARViewingPublicKey(viewingPrivateKey) {
44405
44704
  "viewingPrivateKey"
44406
44705
  );
44407
44706
  }
44408
- const privateBytes = (0, import_utils70.hexToBytes)(viewingPrivateKey.slice(2));
44707
+ const privateBytes = (0, import_utils71.hexToBytes)(viewingPrivateKey.slice(2));
44409
44708
  if (privateBytes.length !== 32) {
44410
44709
  throw new ValidationError(
44411
44710
  "viewingPrivateKey must be 32 bytes",
@@ -44414,7 +44713,7 @@ function getNEARViewingPublicKey(viewingPrivateKey) {
44414
44713
  }
44415
44714
  try {
44416
44715
  const publicBytes = import_ed2551919.ed25519.getPublicKey(privateBytes);
44417
- return `0x${(0, import_utils70.bytesToHex)(publicBytes)}`;
44716
+ return `0x${(0, import_utils71.bytesToHex)(publicBytes)}`;
44418
44717
  } finally {
44419
44718
  secureWipe(privateBytes);
44420
44719
  }
@@ -44449,9 +44748,9 @@ function validateNEARViewingKey(viewingKey) {
44449
44748
  { expected: computedHash, received: viewingKey.hash }
44450
44749
  );
44451
44750
  }
44452
- const privateBytes = (0, import_utils70.hexToBytes)(viewingKey.privateKey.slice(2));
44751
+ const privateBytes = (0, import_utils71.hexToBytes)(viewingKey.privateKey.slice(2));
44453
44752
  try {
44454
- const derivedPublic = `0x${(0, import_utils70.bytesToHex)(import_ed2551919.ed25519.getPublicKey(privateBytes))}`;
44753
+ const derivedPublic = `0x${(0, import_utils71.bytesToHex)(import_ed2551919.ed25519.getPublicKey(privateBytes))}`;
44455
44754
  if (derivedPublic !== viewingKey.publicKey) {
44456
44755
  throw new ValidationError(
44457
44756
  "publicKey does not match privateKey",
@@ -44466,11 +44765,11 @@ function validateNEARViewingKey(viewingKey) {
44466
44765
 
44467
44766
  // src/chains/near/resolver.ts
44468
44767
  var import_ed2551920 = require("@noble/curves/ed25519");
44469
- var import_utils71 = require("@noble/hashes/utils");
44768
+ var import_utils72 = require("@noble/hashes/utils");
44470
44769
  init_errors();
44471
44770
  init_validation();
44472
44771
  function nearSpendingPublicFromPrivate(spendingPrivateKey) {
44473
- return `0x${(0, import_utils71.bytesToHex)(import_ed2551920.ed25519.getPublicKey((0, import_utils71.hexToBytes)(spendingPrivateKey.slice(2))))}`;
44772
+ return `0x${(0, import_utils72.bytesToHex)(import_ed2551920.ed25519.getPublicKey((0, import_utils72.hexToBytes)(spendingPrivateKey.slice(2))))}`;
44474
44773
  }
44475
44774
  function createNEARAnnouncementCache() {
44476
44775
  const entries = [];
@@ -44511,6 +44810,8 @@ var NEARRpcClient = class {
44511
44810
  this.rpcUrl = rpcUrl;
44512
44811
  this.timeout = timeout;
44513
44812
  }
44813
+ rpcUrl;
44814
+ timeout;
44514
44815
  async call(method, params) {
44515
44816
  const controller = new AbortController();
44516
44817
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
@@ -44721,7 +45022,7 @@ var NEARStealthScanner = class {
44721
45022
  nearSpendingPublicFromPrivate(recipient.spendingPrivateKey)
44722
45023
  );
44723
45024
  if (isMatch) {
44724
- const stealthAddress = isImplicitAccount(announcement.stealthAddress) ? announcement.stealthAddress : (0, import_utils71.bytesToHex)((0, import_utils71.hexToBytes)(stealthPublicKey.slice(2)));
45025
+ const stealthAddress = isImplicitAccount(announcement.stealthAddress) ? announcement.stealthAddress : (0, import_utils72.bytesToHex)((0, import_utils72.hexToBytes)(stealthPublicKey.slice(2)));
44725
45026
  let amount = metadata?.amount ?? 0n;
44726
45027
  if (amount === 0n && isImplicitAccount(stealthAddress)) {
44727
45028
  try {
@@ -45171,6 +45472,9 @@ var AllBackendsFailedError = class _AllBackendsFailedError extends Error {
45171
45472
  this.params = params;
45172
45473
  Object.setPrototypeOf(this, _AllBackendsFailedError.prototype);
45173
45474
  }
45475
+ attemptedBackends;
45476
+ errors;
45477
+ params;
45174
45478
  name = "AllBackendsFailedError";
45175
45479
  /**
45176
45480
  * Get formatted error summary
@@ -45826,6 +46130,10 @@ var RateLimitExceededError = class extends Error {
45826
46130
  this.requestedTokens = requestedTokens;
45827
46131
  this.retryAfterMs = retryAfterMs;
45828
46132
  }
46133
+ backend;
46134
+ availableTokens;
46135
+ requestedTokens;
46136
+ retryAfterMs;
45829
46137
  name = "RateLimitExceededError";
45830
46138
  };
45831
46139
  var QueueFullError = class extends Error {
@@ -45837,6 +46145,9 @@ var QueueFullError = class extends Error {
45837
46145
  this.queueSize = queueSize;
45838
46146
  this.maxQueueSize = maxQueueSize;
45839
46147
  }
46148
+ backend;
46149
+ queueSize;
46150
+ maxQueueSize;
45840
46151
  name = "QueueFullError";
45841
46152
  };
45842
46153
  var AcquireTimeoutError = class extends Error {
@@ -45845,6 +46156,8 @@ var AcquireTimeoutError = class extends Error {
45845
46156
  this.backend = backend;
45846
46157
  this.timeoutMs = timeoutMs;
45847
46158
  }
46159
+ backend;
46160
+ timeoutMs;
45848
46161
  name = "AcquireTimeoutError";
45849
46162
  };
45850
46163
  var RateLimiter = class {
@@ -47096,7 +47409,7 @@ function createPrivacyLogger(moduleName, config = {}) {
47096
47409
  }
47097
47410
 
47098
47411
  // src/privacy-backends/privacycash.ts
47099
- var import_utils72 = require("@noble/hashes/utils");
47412
+ var import_utils73 = require("@noble/hashes/utils");
47100
47413
  var privacyCashLogger = createPrivacyLogger("PrivacyCash");
47101
47414
  var DEFAULT_ANONYMITY_SET = 50;
47102
47415
  var BASE_COST_LAMPORTS = BigInt(1e7);
@@ -47126,7 +47439,7 @@ var PRIVACYCASH_CAPABILITIES = {
47126
47439
 
47127
47440
  // src/privacy-backends/shadowwire.ts
47128
47441
  var import_shadowwire = require("@radr/shadowwire");
47129
- var import_utils73 = require("@noble/hashes/utils");
47442
+ var import_utils74 = require("@noble/hashes/utils");
47130
47443
  var SHADOWWIRE_TOKEN_MINTS = {
47131
47444
  SOL: "So11111111111111111111111111111111111111112",
47132
47445
  USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
@@ -47185,8 +47498,8 @@ var COST_PER_ENCRYPTED_INPUT_WEI = BigInt("1000000000000000");
47185
47498
 
47186
47499
  // src/privacy-backends/magicblock.ts
47187
47500
  var import_ephemeral_rollups_sdk = require("@magicblock-labs/ephemeral-rollups-sdk");
47188
- var import_web318 = require("@solana/web3.js");
47189
- var import_utils74 = require("@noble/hashes/utils");
47501
+ var import_web320 = require("@solana/web3.js");
47502
+ var import_utils75 = require("@noble/hashes/utils");
47190
47503
  var magicBlockLogger = createPrivacyLogger("MagicBlock");
47191
47504
 
47192
47505
  // src/privacy-backends/cspl-types.ts
@@ -47876,7 +48189,7 @@ var CSPLClient = class {
47876
48189
 
47877
48190
  // src/privacy-backends/private-swap.ts
47878
48191
  var import_sha25630 = require("@noble/hashes/sha256");
47879
- var import_utils75 = require("@noble/hashes/utils");
48192
+ var import_utils76 = require("@noble/hashes/utils");
47880
48193
 
47881
48194
  // src/privacy-backends/cspl-token.ts
47882
48195
  var CSPLTokenService = class {
@@ -50483,6 +50796,7 @@ var ProductionSafetyError = class extends Error {
50483
50796
  this.errors = errors;
50484
50797
  this.name = "ProductionSafetyError";
50485
50798
  }
50799
+ errors;
50486
50800
  };
50487
50801
  function validateProductionConfig(config, options = {}) {
50488
50802
  const isProduction = isProductionEnvironment();
@@ -50587,7 +50901,7 @@ init_proxy();
50587
50901
  // src/sync/oblivious.ts
50588
50902
  var import_sha211 = require("@noble/hashes/sha2");
50589
50903
  var import_hmac8 = require("@noble/hashes/hmac");
50590
- var import_utils76 = require("@noble/hashes/utils");
50904
+ var import_utils77 = require("@noble/hashes/utils");
50591
50905
  init_secure_memory();
50592
50906
  var DEFAULT_SYNC_CONFIG = {
50593
50907
  maxBatchSize: 1e3,
@@ -50598,7 +50912,7 @@ var DEFAULT_SYNC_CONFIG = {
50598
50912
  parallelSync: true
50599
50913
  };
50600
50914
  function generateSyncRandomness(epoch, durationSeconds = DEFAULT_SYNC_CONFIG.epochDurationSeconds) {
50601
- const value = (0, import_utils76.randomBytes)(32);
50915
+ const value = (0, import_utils77.randomBytes)(32);
50602
50916
  const expiresAt = Date.now() + durationSeconds * 1e3;
50603
50917
  return {
50604
50918
  value,
@@ -50614,21 +50928,21 @@ function getCurrentEpoch(epochDurationSeconds = DEFAULT_SYNC_CONFIG.epochDuratio
50614
50928
  }
50615
50929
  var OBLIVIOUS_NULLIFIER_DOMAIN = "SIP-OBLIVIOUS-NULLIFIER-V1";
50616
50930
  function deriveObliviousNullifier(noteCommitment, spendingKey, syncRandomness) {
50617
- const commitmentBytes = (0, import_utils76.hexToBytes)(
50931
+ const commitmentBytes = (0, import_utils77.hexToBytes)(
50618
50932
  noteCommitment.startsWith("0x") ? noteCommitment.slice(2) : noteCommitment
50619
50933
  );
50620
- const keyBytes = (0, import_utils76.hexToBytes)(
50934
+ const keyBytes = (0, import_utils77.hexToBytes)(
50621
50935
  spendingKey.startsWith("0x") ? spendingKey.slice(2) : spendingKey
50622
50936
  );
50623
50937
  try {
50624
- const domain = (0, import_utils76.utf8ToBytes)(OBLIVIOUS_NULLIFIER_DOMAIN);
50938
+ const domain = (0, import_utils77.utf8ToBytes)(OBLIVIOUS_NULLIFIER_DOMAIN);
50625
50939
  const message = new Uint8Array(domain.length + commitmentBytes.length + syncRandomness.value.length);
50626
50940
  message.set(domain, 0);
50627
50941
  message.set(commitmentBytes, domain.length);
50628
50942
  message.set(syncRandomness.value, domain.length + commitmentBytes.length);
50629
50943
  const nullifierBytes = (0, import_hmac8.hmac)(import_sha211.sha256, keyBytes, message);
50630
50944
  return {
50631
- nullifier: `0x${(0, import_utils76.bytesToHex)(nullifierBytes)}`,
50945
+ nullifier: `0x${(0, import_utils77.bytesToHex)(nullifierBytes)}`,
50632
50946
  epoch: syncRandomness.epoch,
50633
50947
  chainId: "default"
50634
50948
  // Will be set by caller
@@ -50638,15 +50952,15 @@ function deriveObliviousNullifier(noteCommitment, spendingKey, syncRandomness) {
50638
50952
  }
50639
50953
  }
50640
50954
  function deriveTraditionalNullifier(noteCommitment, spendingKey) {
50641
- const commitmentBytes = (0, import_utils76.hexToBytes)(
50955
+ const commitmentBytes = (0, import_utils77.hexToBytes)(
50642
50956
  noteCommitment.startsWith("0x") ? noteCommitment.slice(2) : noteCommitment
50643
50957
  );
50644
- const keyBytes = (0, import_utils76.hexToBytes)(
50958
+ const keyBytes = (0, import_utils77.hexToBytes)(
50645
50959
  spendingKey.startsWith("0x") ? spendingKey.slice(2) : spendingKey
50646
50960
  );
50647
50961
  try {
50648
50962
  const nullifierBytes = (0, import_hmac8.hmac)(import_sha211.sha256, keyBytes, commitmentBytes);
50649
- return `0x${(0, import_utils76.bytesToHex)(nullifierBytes)}`;
50963
+ return `0x${(0, import_utils77.bytesToHex)(nullifierBytes)}`;
50650
50964
  } finally {
50651
50965
  secureWipe(keyBytes);
50652
50966
  }
@@ -50691,7 +51005,7 @@ function createTimeWindowedKey(masterViewingKey, startTime, endTime, epochDurati
50691
51005
  for (let e = startEpoch; e <= endEpoch; e++) {
50692
51006
  epochs.push(e);
50693
51007
  }
50694
- const keyBytes = (0, import_utils76.hexToBytes)(
51008
+ const keyBytes = (0, import_utils77.hexToBytes)(
50695
51009
  masterViewingKey.startsWith("0x") ? masterViewingKey.slice(2) : masterViewingKey
50696
51010
  );
50697
51011
  const windowData = new Uint8Array(16);
@@ -50702,11 +51016,11 @@ function createTimeWindowedKey(masterViewingKey, startTime, endTime, epochDurati
50702
51016
  const keyHash = (0, import_sha211.sha256)(derivedKey);
50703
51017
  secureWipe(keyBytes);
50704
51018
  return {
50705
- viewingKey: `0x${(0, import_utils76.bytesToHex)(derivedKey)}`,
51019
+ viewingKey: `0x${(0, import_utils77.bytesToHex)(derivedKey)}`,
50706
51020
  windowStart: startTime,
50707
51021
  windowEnd: endTime,
50708
51022
  epochs,
50709
- hash: `0x${(0, import_utils76.bytesToHex)(keyHash)}`
51023
+ hash: `0x${(0, import_utils77.bytesToHex)(keyHash)}`
50710
51024
  };
50711
51025
  }
50712
51026
  function isNoteInWindow(_note, _windowedKey) {
@@ -50729,10 +51043,12 @@ var ObliviousSyncError = class extends Error {
50729
51043
  this.context = context;
50730
51044
  this.name = "ObliviousSyncError";
50731
51045
  }
51046
+ code;
51047
+ context;
50732
51048
  };
50733
51049
 
50734
51050
  // src/sync/mock-provider.ts
50735
- var import_utils77 = require("@noble/hashes/utils");
51051
+ var import_utils78 = require("@noble/hashes/utils");
50736
51052
  var DEFAULT_MOCK_CONFIG = {
50737
51053
  chains: ["ethereum", "solana", "near"],
50738
51054
  latencyMs: 100,
@@ -50829,7 +51145,7 @@ var MockObliviousSyncProvider = class {
50829
51145
  merkleProofs,
50830
51146
  syncHeight: this.config.blockHeight,
50831
51147
  timestamp: Date.now(),
50832
- queryHash: `0x${(0, import_utils77.bytesToHex)((0, import_utils77.randomBytes)(32))}`
51148
+ queryHash: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`
50833
51149
  };
50834
51150
  }
50835
51151
  async getCurrentHeight(chainId) {
@@ -50910,23 +51226,23 @@ var MockObliviousSyncProvider = class {
50910
51226
  generateMockNote(blockRange) {
50911
51227
  const blockNumber = blockRange.startBlock + BigInt(Math.floor(Math.random() * Number(blockRange.endBlock - blockRange.startBlock)));
50912
51228
  return {
50913
- commitment: `0x${(0, import_utils77.bytesToHex)((0, import_utils77.randomBytes)(32))}`,
50914
- encryptedData: `0x${(0, import_utils77.bytesToHex)((0, import_utils77.randomBytes)(128))}`,
51229
+ commitment: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`,
51230
+ encryptedData: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(128))}`,
50915
51231
  blockNumber,
50916
- txHash: `0x${(0, import_utils77.bytesToHex)((0, import_utils77.randomBytes)(32))}`,
51232
+ txHash: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`,
50917
51233
  chainId: blockRange.chainId
50918
51234
  };
50919
51235
  }
50920
51236
  generateMockMerkleProof(leaf) {
50921
51237
  const siblings = [];
50922
51238
  for (let i = 0; i < 20; i++) {
50923
- siblings.push(`0x${(0, import_utils77.bytesToHex)((0, import_utils77.randomBytes)(32))}`);
51239
+ siblings.push(`0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`);
50924
51240
  }
50925
51241
  return {
50926
51242
  leaf,
50927
51243
  siblings,
50928
51244
  index: BigInt(Math.floor(Math.random() * 1e6)),
50929
- root: `0x${(0, import_utils77.bytesToHex)((0, import_utils77.randomBytes)(32))}`
51245
+ root: `0x${(0, import_utils78.bytesToHex)((0, import_utils78.randomBytes)(32))}`
50930
51246
  };
50931
51247
  }
50932
51248
  };
@@ -52655,6 +52971,8 @@ async function calculateFeeForSwap(contract, swapAmount, swapAmountUsd, sourceCh
52655
52971
  SIPError,
52656
52972
  SIPNativeBackend,
52657
52973
  SIP_MEMO_PREFIX,
52974
+ SIP_MEMO_PREFIX_ANY,
52975
+ SIP_MEMO_PREFIX_V2,
52658
52976
  SIP_VERSION,
52659
52977
  SOLANA_EXPLORER_URLS,
52660
52978
  SOLANA_RPC_ENDPOINTS,
@@ -52714,6 +53032,7 @@ async function calculateFeeForSwap(contract, swapAmount, swapAmountUsd, sourceCh
52714
53032
  bpsToPercent,
52715
53033
  browserBytesToHex,
52716
53034
  browserHexToBytes,
53035
+ buildGaslessCashout,
52717
53036
  cacheKeyGenerator,
52718
53037
  calculateFeeForSwap,
52719
53038
  calculatePrivacyScore,
@@ -52735,6 +53054,7 @@ async function calculateFeeForSwap(contract, swapAmount, swapAmountUsd, sourceCh
52735
53054
  computeAttestationHash,
52736
53055
  computeNEARViewingKeyHash,
52737
53056
  computeNEARViewingKeyHashFromPrivate,
53057
+ computeRelayerFee,
52738
53058
  computeTweakedKey,
52739
53059
  configureLogger,
52740
53060
  convertFromSIP,
@@ -52838,6 +53158,7 @@ async function calculateFeeForSwap(contract, swapAmount, swapAmountUsd, sourceCh
52838
53158
  deriveSecp256k1StealthPrivateKeyV1,
52839
53159
  deriveStealthPrivateKey,
52840
53160
  deriveStealthPrivateKeyV1,
53161
+ deriveStealthSigner,
52841
53162
  deriveSuiStealthPrivateKey,
52842
53163
  deriveTraditionalNullifier,
52843
53164
  deriveViewingKey,
@@ -53029,11 +53350,13 @@ async function calculateFeeForSwap(contract, swapAmount, swapAmountUsd, sourceCh
53029
53350
  serializePayment,
53030
53351
  setLogLevel,
53031
53352
  signAttestationMessage,
53353
+ signEd25519WithScalar,
53032
53354
  silenceLogger,
53033
53355
  solanaAddressToEd25519PublicKey,
53034
53356
  solanaOptimizations,
53035
53357
  solanaPublicKeyToHex,
53036
53358
  stealthKeyToCosmosAddress,
53359
+ submitGaslessCashout,
53037
53360
  subtractBlindings,
53038
53361
  subtractBlindingsNEAR,
53039
53362
  subtractCommitments,