@sip-protocol/sdk 0.11.1 → 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 +864 -545
  5. package/dist/browser.mjs +13 -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-DH5XRHYV.d.mts → index-B_fGN4Fk.d.mts} +796 -597
  16. package/dist/{index-mw7KGX5M.d.ts → index-rqQpCeVM.d.ts} +796 -597
  17. package/dist/index.d.mts +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +864 -545
  20. package/dist/index.mjs +13 -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 +14 -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
@@ -34,7 +34,7 @@ import {
34
34
  validateEd25519StealthAddress,
35
35
  validateEd25519StealthMetaAddress,
36
36
  verifyOpening
37
- } from "./chunk-7IUKXWDN.mjs";
37
+ } from "./chunk-MKTCJPFH.mjs";
38
38
  import {
39
39
  ProofGenerationError
40
40
  } from "./chunk-HOR7PM3M.mjs";
@@ -54,7 +54,7 @@ import {
54
54
  } from "./chunk-KXETSSKP.mjs";
55
55
  import {
56
56
  __export
57
- } from "./chunk-XGB3TDIC.mjs";
57
+ } from "./chunk-S3F4CPQ5.mjs";
58
58
 
59
59
  // src/sip.ts
60
60
  import {
@@ -2682,10 +2682,10 @@ var SIP = class {
2682
2682
  "chain"
2683
2683
  );
2684
2684
  }
2685
- const { sendPrivateSPLTransfer: sendPrivateSPLTransfer2 } = await import("./solana-7QOA3HBZ.mjs");
2685
+ const { sendPrivateSPLTransfer: sendPrivateSPLTransfer2 } = await import("./solana-VKZI66MK.mjs");
2686
2686
  const { PublicKey: SolanaPublicKey } = await import("@solana/web3.js");
2687
2687
  const { getAssociatedTokenAddress } = await import("@solana/spl-token");
2688
- const { SOLANA_TOKEN_MINTS: SOLANA_TOKEN_MINTS3 } = await import("./constants-DCJYTIU3.mjs");
2688
+ const { SOLANA_TOKEN_MINTS: SOLANA_TOKEN_MINTS3 } = await import("./constants-NCGOQF7S.mjs");
2689
2689
  let mint;
2690
2690
  if (params.token in SOLANA_TOKEN_MINTS3) {
2691
2691
  mint = new SolanaPublicKey(SOLANA_TOKEN_MINTS3[params.token]);
@@ -3959,46 +3959,46 @@ var ComplianceProofProvider = class {
3959
3959
  }
3960
3960
  async hashViewingKey(viewingKey) {
3961
3961
  const { sha256: sha25635 } = await import("@noble/hashes/sha256");
3962
- const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
3962
+ const { bytesToHex: bytesToHex56 } = await import("@noble/hashes/utils");
3963
3963
  const keyString = typeof viewingKey === "string" ? viewingKey : JSON.stringify(viewingKey);
3964
3964
  const encoder = new TextEncoder();
3965
3965
  const keyBytes = encoder.encode(keyString);
3966
- return bytesToHex57(sha25635(keyBytes));
3966
+ return bytesToHex56(sha25635(keyBytes));
3967
3967
  }
3968
3968
  async computeDecryptionCommitment(viewingKey, encryptedData) {
3969
3969
  const { sha256: sha25635 } = await import("@noble/hashes/sha256");
3970
- const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
3970
+ const { bytesToHex: bytesToHex56 } = await import("@noble/hashes/utils");
3971
3971
  const keyHash = await this.hashViewingKey(viewingKey);
3972
3972
  const keyBytes = this.hexToBytes(keyHash);
3973
3973
  const preimage = new Uint8Array([...keyBytes, ...encryptedData.slice(0, 32)]);
3974
- return bytesToHex57(sha25635(preimage));
3974
+ return bytesToHex56(sha25635(preimage));
3975
3975
  }
3976
3976
  async computeAuditorHash(auditorPublicKey, transactionHash) {
3977
3977
  const { sha256: sha25635 } = await import("@noble/hashes/sha256");
3978
- const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
3978
+ const { bytesToHex: bytesToHex56 } = await import("@noble/hashes/utils");
3979
3979
  const auditorBytes = this.hexToBytes(auditorPublicKey.replace("0x", "").padStart(64, "0"));
3980
3980
  const txBytes = this.hexToBytes(transactionHash.replace("0x", "").padStart(64, "0"));
3981
3981
  const preimage = new Uint8Array([...auditorBytes, ...txBytes]);
3982
- return bytesToHex57(sha25635(preimage));
3982
+ return bytesToHex56(sha25635(preimage));
3983
3983
  }
3984
3984
  async computeAddressCommitment(address, blinding) {
3985
3985
  const { sha256: sha25635 } = await import("@noble/hashes/sha256");
3986
- const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
3986
+ const { bytesToHex: bytesToHex56 } = await import("@noble/hashes/utils");
3987
3987
  const addressBytes = this.hexToBytes(address.replace("0x", "").padStart(64, "0"));
3988
3988
  const preimage = new Uint8Array([...addressBytes, ...blinding.slice(0, 32)]);
3989
- return bytesToHex57(sha25635(preimage));
3989
+ return bytesToHex56(sha25635(preimage));
3990
3990
  }
3991
3991
  async computeNonMembershipProof(senderAddress, recipientAddress, _sanctionsListRoot) {
3992
3992
  const { sha256: sha25635 } = await import("@noble/hashes/sha256");
3993
- const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
3993
+ const { bytesToHex: bytesToHex56 } = await import("@noble/hashes/utils");
3994
3994
  const senderBytes = this.hexToBytes(senderAddress.replace("0x", "").padStart(64, "0"));
3995
3995
  const recipientBytes = this.hexToBytes(recipientAddress.replace("0x", "").padStart(64, "0"));
3996
3996
  const preimage = new Uint8Array([...senderBytes, ...recipientBytes]);
3997
- return bytesToHex57(sha25635(preimage));
3997
+ return bytesToHex56(sha25635(preimage));
3998
3998
  }
3999
3999
  async computeBalanceCommitment(balance, blinding) {
4000
4000
  const { sha256: sha25635 } = await import("@noble/hashes/sha256");
4001
- const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
4001
+ const { bytesToHex: bytesToHex56 } = await import("@noble/hashes/utils");
4002
4002
  const balanceBytes = new Uint8Array(8);
4003
4003
  let v = balance;
4004
4004
  for (let i = 7; i >= 0; i--) {
@@ -4006,11 +4006,11 @@ var ComplianceProofProvider = class {
4006
4006
  v = v >> 8n;
4007
4007
  }
4008
4008
  const preimage = new Uint8Array([...balanceBytes, ...blinding.slice(0, 32)]);
4009
- return bytesToHex57(sha25635(preimage));
4009
+ return bytesToHex56(sha25635(preimage));
4010
4010
  }
4011
4011
  async generateComplianceProofBytes(type, publicInputs) {
4012
4012
  const { sha256: sha25635 } = await import("@noble/hashes/sha256");
4013
- const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
4013
+ const { bytesToHex: bytesToHex56 } = await import("@noble/hashes/utils");
4014
4014
  const circuitId = COMPLIANCE_CIRCUIT_IDS[type];
4015
4015
  const encoder = new TextEncoder();
4016
4016
  const inputBytes = publicInputs.flatMap((pi) => Array.from(this.hexToBytes(pi.replace("0x", ""))));
@@ -4021,7 +4021,7 @@ var ComplianceProofProvider = class {
4021
4021
  const hash2 = sha25635(preimage);
4022
4022
  let proofBytes = "";
4023
4023
  for (let i = 0; i < 8; i++) {
4024
- proofBytes += bytesToHex57(sha25635(new Uint8Array([...hash2, i])));
4024
+ proofBytes += bytesToHex56(sha25635(new Uint8Array([...hash2, i])));
4025
4025
  }
4026
4026
  return proofBytes;
4027
4027
  }
@@ -10715,6 +10715,7 @@ var SmartRouter = class {
10715
10715
  log4.warn({ backend, error }, "Backend failed");
10716
10716
  });
10717
10717
  }
10718
+ registry;
10718
10719
  cache;
10719
10720
  tracker;
10720
10721
  backendTimeoutMs;
@@ -11779,6 +11780,8 @@ var ZcashRPCError = class extends Error {
11779
11780
  this.data = data;
11780
11781
  this.name = "ZcashRPCError";
11781
11782
  }
11783
+ code;
11784
+ data;
11782
11785
  /**
11783
11786
  * Check if error is due to insufficient funds
11784
11787
  */
@@ -20817,7 +20820,6 @@ function createMockSolanaAdapter(config = {}) {
20817
20820
  // src/wallet/solana/privacy-adapter.ts
20818
20821
  import { sha256 as sha25623 } from "@noble/hashes/sha2";
20819
20822
  import { ed25519 as ed255193 } from "@noble/curves/ed25519";
20820
- var ED25519_ORDER = BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed");
20821
20823
 
20822
20824
  // src/wallet/ethereum/adapter.ts
20823
20825
  import { WalletErrorCode as WalletErrorCode5 } from "@sip-protocol/types";
@@ -22457,7 +22459,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
22457
22459
  */
22458
22460
  async loadTransport() {
22459
22461
  try {
22460
- const module = await import("./TransportWebUSB-2KITI5HD.mjs");
22462
+ const module = await import("./TransportWebUSB-TXDZJBGS.mjs");
22461
22463
  return module.default;
22462
22464
  } catch {
22463
22465
  throw new HardwareWalletError(
@@ -23812,6 +23814,8 @@ var SolanaNoirError = class extends Error {
23812
23814
  this.details = details;
23813
23815
  this.name = "SolanaNoirError";
23814
23816
  }
23817
+ code;
23818
+ details;
23815
23819
  };
23816
23820
  var MAX_PROOF_SIZE_BYTES = 4096;
23817
23821
  var MAX_PUBLIC_INPUTS = 32;
@@ -24291,11 +24295,11 @@ var SolanaNoirVerifier = class {
24291
24295
  try {
24292
24296
  switch (circuitType) {
24293
24297
  case "funding":
24294
- return await import("./funding_proof-ICFZ5LHY.mjs");
24298
+ return await import("./funding_proof-X5IP4SG5.mjs");
24295
24299
  case "validity":
24296
- return await import("./validity_proof-3POXLPNY.mjs");
24300
+ return await import("./validity_proof-2GVV6GA6.mjs");
24297
24301
  case "fulfillment":
24298
- return await import("./fulfillment_proof-ANHVPKTB.mjs");
24302
+ return await import("./fulfillment_proof-WCEE5GGO.mjs");
24299
24303
  default:
24300
24304
  throw new SolanaNoirError(
24301
24305
  `Unknown circuit type: ${circuitType}`,
@@ -24324,8 +24328,8 @@ var SolanaNoirVerifier = class {
24324
24328
  }
24325
24329
  async hashBytes(bytes) {
24326
24330
  const { sha256: sha25635 } = await import("@noble/hashes/sha256");
24327
- const { bytesToHex: bytesToHex57 } = await import("@noble/hashes/utils");
24328
- return bytesToHex57(sha25635(bytes));
24331
+ const { bytesToHex: bytesToHex56 } = await import("@noble/hashes/utils");
24332
+ return bytesToHex56(sha25635(bytes));
24329
24333
  }
24330
24334
  hexToBytes(hex) {
24331
24335
  const h = hex.startsWith("0x") ? hex.slice(2) : hex;
@@ -24369,7 +24373,7 @@ import {
24369
24373
  Transaction as Transaction2,
24370
24374
  SystemProgram
24371
24375
  } from "@solana/web3.js";
24372
- import { bytesToHex as bytesToHex47 } from "@noble/hashes/utils";
24376
+ import bs58 from "bs58";
24373
24377
  var JITO_BLOCK_ENGINES = {
24374
24378
  mainnet: {
24375
24379
  amsterdam: "https://amsterdam.mainnet.block-engine.jito.wtf/api/v1",
@@ -24418,8 +24422,10 @@ var JitoRelayerError = class extends Error {
24418
24422
  this.details = details;
24419
24423
  this.name = "JitoRelayerError";
24420
24424
  }
24425
+ code;
24426
+ details;
24421
24427
  };
24422
- var JitoRelayer = class {
24428
+ var JitoRelayer = class _JitoRelayer {
24423
24429
  connection;
24424
24430
  blockEngineUrl;
24425
24431
  defaultTipLamports;
@@ -24437,6 +24443,11 @@ var JitoRelayer = class {
24437
24443
  this.maxRetries = config.maxRetries ?? JITO_DEFAULTS.maxRetries;
24438
24444
  this.submissionTimeout = config.submissionTimeout ?? JITO_DEFAULTS.submissionTimeout;
24439
24445
  }
24446
+ // ─── Static Helpers ─────────────────────────────────────────────────────────
24447
+ /** Encode a 64-byte ed25519 signature as a base58 string (Solana canonical form). */
24448
+ static encodeSignature(sig) {
24449
+ return bs58.encode(sig);
24450
+ }
24440
24451
  // ─── Public Methods ─────────────────────────────────────────────────────────
24441
24452
  /**
24442
24453
  * Submit a bundle of transactions to Jito
@@ -24489,10 +24500,10 @@ var JitoRelayer = class {
24489
24500
  }
24490
24501
  const signatures = bundleTransactions.map((tx) => {
24491
24502
  if (tx instanceof VersionedTransaction2) {
24492
- return bytesToHex47(tx.signatures[0]);
24493
- } else {
24494
- return tx.signature?.toString() ?? "";
24503
+ return _JitoRelayer.encodeSignature(tx.signatures[0]);
24495
24504
  }
24505
+ const sig = tx.signature;
24506
+ return sig ? _JitoRelayer.encodeSignature(sig) : "";
24496
24507
  });
24497
24508
  if (request.waitForConfirmation) {
24498
24509
  const status = await this.waitForBundleConfirmation(bundleId, lastValidBlockHeight);
@@ -24524,13 +24535,30 @@ var JitoRelayer = class {
24524
24535
  async relayTransaction(request) {
24525
24536
  this.log("Relaying transaction");
24526
24537
  try {
24538
+ if (request.tipPayer) {
24539
+ const bundle = await this.submitBundle({
24540
+ transactions: [request.transaction],
24541
+ tipLamports: request.tipLamports,
24542
+ tipPayer: request.tipPayer,
24543
+ waitForConfirmation: request.waitForConfirmation
24544
+ });
24545
+ return {
24546
+ signature: bundle.signatures[bundle.signatures.length - 1] ?? "",
24547
+ bundleId: bundle.bundleId,
24548
+ status: bundle.status === "landed" ? "confirmed" : bundle.status === "submitted" ? "submitted" : "failed",
24549
+ slot: bundle.slot,
24550
+ error: bundle.error,
24551
+ relayed: true
24552
+ };
24553
+ }
24527
24554
  const serializedTx = Buffer.from(request.transaction.serialize()).toString("base64");
24528
24555
  const bundleId = await this.sendBundle([serializedTx]);
24529
24556
  let signature;
24530
24557
  if (request.transaction instanceof VersionedTransaction2) {
24531
- signature = bytesToHex47(request.transaction.signatures[0]);
24558
+ signature = _JitoRelayer.encodeSignature(request.transaction.signatures[0]);
24532
24559
  } else {
24533
- signature = request.transaction.signature?.toString() ?? "";
24560
+ const sig = request.transaction.signature;
24561
+ signature = sig ? _JitoRelayer.encodeSignature(sig) : "";
24534
24562
  }
24535
24563
  if (request.waitForConfirmation) {
24536
24564
  const { lastValidBlockHeight } = await this.connection.getLatestBlockhash();
@@ -24753,7 +24781,7 @@ function createMainnetRelayer(rpcUrl) {
24753
24781
  // src/chains/near/commitment.ts
24754
24782
  import { ed25519 as ed255199 } from "@noble/curves/ed25519";
24755
24783
  import { sha256 as sha25631 } from "@noble/hashes/sha2";
24756
- import { bytesToHex as bytesToHex48, randomBytes as randomBytes19 } from "@noble/hashes/utils";
24784
+ import { bytesToHex as bytesToHex47, randomBytes as randomBytes19 } from "@noble/hashes/utils";
24757
24785
  var H_DOMAIN = "SIP-NEAR-PEDERSEN-GENERATOR-H-v1";
24758
24786
  var G = ed255199.ExtendedPoint.BASE;
24759
24787
  var ED25519_ORDER3 = 2n ** 252n + 27742317777372353535851937790883648493n;
@@ -24772,7 +24800,7 @@ function generateH() {
24772
24800
  if (!point.equals(ed255199.ExtendedPoint.ZERO)) {
24773
24801
  const gBytes = G.toRawBytes();
24774
24802
  const hBytes = point.toRawBytes();
24775
- if (bytesToHex48(gBytes) !== bytesToHex48(hBytes)) {
24803
+ if (bytesToHex47(gBytes) !== bytesToHex47(hBytes)) {
24776
24804
  return point;
24777
24805
  }
24778
24806
  }
@@ -24786,7 +24814,7 @@ function generateH() {
24786
24814
  { context: { domain: H_DOMAIN } }
24787
24815
  );
24788
24816
  }
24789
- function bytesToBigInt(bytes) {
24817
+ function bytesToBigInt2(bytes) {
24790
24818
  let result = 0n;
24791
24819
  for (let i = bytes.length - 1; i >= 0; i--) {
24792
24820
  result = result * 256n + BigInt(bytes[i]);
@@ -24827,7 +24855,7 @@ function commitNEAR(value, blinding) {
24827
24855
  if (r.length !== 32) {
24828
24856
  throw new ValidationError("must be 32 bytes", "blinding", { received: r.length });
24829
24857
  }
24830
- const rScalar = bytesToBigInt(r) % ED25519_ORDER3;
24858
+ const rScalar = bytesToBigInt2(r) % ED25519_ORDER3;
24831
24859
  if (rScalar === 0n) {
24832
24860
  return commitNEAR(value, randomBytes19(32));
24833
24861
  }
@@ -24841,8 +24869,8 @@ function commitNEAR(value, blinding) {
24841
24869
  }
24842
24870
  const rScalarBytes = bigIntToBytes(rScalar, 32);
24843
24871
  return {
24844
- commitment: `0x${bytesToHex48(C.toRawBytes())}`,
24845
- blinding: `0x${bytesToHex48(rScalarBytes)}`
24872
+ commitment: `0x${bytesToHex47(C.toRawBytes())}`,
24873
+ blinding: `0x${bytesToHex47(rScalarBytes)}`
24846
24874
  };
24847
24875
  }
24848
24876
  function verifyOpeningNEAR(commitment, value, blinding) {
@@ -24850,7 +24878,7 @@ function verifyOpeningNEAR(commitment, value, blinding) {
24850
24878
  const commitmentBytes = hexToBytes31(commitment.slice(2));
24851
24879
  const C = ed255199.ExtendedPoint.fromHex(commitmentBytes);
24852
24880
  const blindingBytes = hexToBytes31(blinding.slice(2));
24853
- const rScalar = bytesToBigInt(blindingBytes) % ED25519_ORDER3;
24881
+ const rScalar = bytesToBigInt2(blindingBytes) % ED25519_ORDER3;
24854
24882
  let expected;
24855
24883
  if (value === 0n) {
24856
24884
  expected = H.multiply(rScalar);
@@ -24935,7 +24963,7 @@ function addCommitmentsNEAR(c1, c2) {
24935
24963
  }
24936
24964
  const sum = point1.add(point2);
24937
24965
  return {
24938
- commitment: `0x${bytesToHex48(sum.toRawBytes())}`
24966
+ commitment: `0x${bytesToHex47(sum.toRawBytes())}`
24939
24967
  };
24940
24968
  }
24941
24969
  function subtractCommitmentsNEAR(c1, c2) {
@@ -24964,7 +24992,7 @@ function subtractCommitmentsNEAR(c1, c2) {
24964
24992
  };
24965
24993
  }
24966
24994
  return {
24967
- commitment: `0x${bytesToHex48(diff.toRawBytes())}`
24995
+ commitment: `0x${bytesToHex47(diff.toRawBytes())}`
24968
24996
  };
24969
24997
  }
24970
24998
  function addBlindingsNEAR(b1, b2) {
@@ -24976,11 +25004,11 @@ function addBlindingsNEAR(b1, b2) {
24976
25004
  }
24977
25005
  const b1Bytes = hexToBytes31(b1.slice(2));
24978
25006
  const b2Bytes = hexToBytes31(b2.slice(2));
24979
- const b1Scalar = bytesToBigInt(b1Bytes);
24980
- const b2Scalar = bytesToBigInt(b2Bytes);
25007
+ const b1Scalar = bytesToBigInt2(b1Bytes);
25008
+ const b2Scalar = bytesToBigInt2(b2Bytes);
24981
25009
  const sum = (b1Scalar + b2Scalar) % ED25519_ORDER3;
24982
25010
  const sumBytes = bigIntToBytes(sum, 32);
24983
- return `0x${bytesToHex48(sumBytes)}`;
25011
+ return `0x${bytesToHex47(sumBytes)}`;
24984
25012
  }
24985
25013
  function subtractBlindingsNEAR(b1, b2) {
24986
25014
  if (!isValidHex(b1)) {
@@ -24991,26 +25019,26 @@ function subtractBlindingsNEAR(b1, b2) {
24991
25019
  }
24992
25020
  const b1Bytes = hexToBytes31(b1.slice(2));
24993
25021
  const b2Bytes = hexToBytes31(b2.slice(2));
24994
- const b1Scalar = bytesToBigInt(b1Bytes);
24995
- const b2Scalar = bytesToBigInt(b2Bytes);
25022
+ const b1Scalar = bytesToBigInt2(b1Bytes);
25023
+ const b2Scalar = bytesToBigInt2(b2Bytes);
24996
25024
  const diff = (b1Scalar - b2Scalar + ED25519_ORDER3) % ED25519_ORDER3;
24997
25025
  const diffBytes = bigIntToBytes(diff, 32);
24998
- return `0x${bytesToHex48(diffBytes)}`;
25026
+ return `0x${bytesToHex47(diffBytes)}`;
24999
25027
  }
25000
25028
  function getGeneratorsNEAR() {
25001
25029
  return {
25002
- G: `0x${bytesToHex48(G.toRawBytes())}`,
25003
- H: `0x${bytesToHex48(H.toRawBytes())}`
25030
+ G: `0x${bytesToHex47(G.toRawBytes())}`,
25031
+ H: `0x${bytesToHex47(H.toRawBytes())}`
25004
25032
  };
25005
25033
  }
25006
25034
  function generateBlindingNEAR() {
25007
25035
  const bytes = randomBytes19(32);
25008
- const scalar = bytesToBigInt(bytes) % ED25519_ORDER3;
25036
+ const scalar = bytesToBigInt2(bytes) % ED25519_ORDER3;
25009
25037
  if (scalar === 0n) {
25010
25038
  return generateBlindingNEAR();
25011
25039
  }
25012
25040
  const scalarBytes = bigIntToBytes(scalar, 32);
25013
- return `0x${bytesToHex48(scalarBytes)}`;
25041
+ return `0x${bytesToHex47(scalarBytes)}`;
25014
25042
  }
25015
25043
 
25016
25044
  // src/chains/near/viewing-key.ts
@@ -25018,7 +25046,7 @@ import { ed25519 as ed2551910 } from "@noble/curves/ed25519";
25018
25046
  import { sha256 as sha25632 } from "@noble/hashes/sha256";
25019
25047
  import { hmac as hmac4 } from "@noble/hashes/hmac";
25020
25048
  import { hkdf as hkdf4 } from "@noble/hashes/hkdf";
25021
- import { bytesToHex as bytesToHex49, hexToBytes as hexToBytes32, randomBytes as randomBytes20, utf8ToBytes as utf8ToBytes7 } from "@noble/hashes/utils";
25049
+ import { bytesToHex as bytesToHex48, hexToBytes as hexToBytes32, randomBytes as randomBytes20, utf8ToBytes as utf8ToBytes7 } from "@noble/hashes/utils";
25022
25050
  import { xchacha20poly1305 as xchacha20poly13055 } from "@noble/ciphers/chacha.js";
25023
25051
  var VIEWING_KEY_CONTEXT = "SIP-NEAR-viewing-key-v1";
25024
25052
  var ENCRYPTION_DOMAIN2 = "SIP-NEAR-VIEWING-KEY-ENCRYPTION-V1";
@@ -25048,9 +25076,9 @@ function generateNEARViewingKeyFromSpending(spendingPrivateKey, label) {
25048
25076
  const viewingPublicBytes = ed2551910.getPublicKey(viewingPrivateBytes);
25049
25077
  const hashBytes = sha25632(viewingPublicBytes);
25050
25078
  return {
25051
- privateKey: `0x${bytesToHex49(viewingPrivateBytes)}`,
25052
- publicKey: `0x${bytesToHex49(viewingPublicBytes)}`,
25053
- hash: `0x${bytesToHex49(hashBytes)}`,
25079
+ privateKey: `0x${bytesToHex48(viewingPrivateBytes)}`,
25080
+ publicKey: `0x${bytesToHex48(viewingPublicBytes)}`,
25081
+ hash: `0x${bytesToHex48(hashBytes)}`,
25054
25082
  label,
25055
25083
  createdAt: Date.now()
25056
25084
  };
@@ -25065,9 +25093,9 @@ function generateRandomNEARViewingKey(label) {
25065
25093
  const publicBytes = ed2551910.getPublicKey(privateBytes);
25066
25094
  const hashBytes = sha25632(publicBytes);
25067
25095
  return {
25068
- privateKey: `0x${bytesToHex49(privateBytes)}`,
25069
- publicKey: `0x${bytesToHex49(publicBytes)}`,
25070
- hash: `0x${bytesToHex49(hashBytes)}`,
25096
+ privateKey: `0x${bytesToHex48(privateBytes)}`,
25097
+ publicKey: `0x${bytesToHex48(publicBytes)}`,
25098
+ hash: `0x${bytesToHex48(hashBytes)}`,
25071
25099
  label,
25072
25100
  createdAt: Date.now()
25073
25101
  };
@@ -25090,7 +25118,7 @@ function computeNEARViewingKeyHash(viewingPublicKey) {
25090
25118
  );
25091
25119
  }
25092
25120
  const hashBytes = sha25632(publicBytes);
25093
- return `0x${bytesToHex49(hashBytes)}`;
25121
+ return `0x${bytesToHex48(hashBytes)}`;
25094
25122
  }
25095
25123
  function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
25096
25124
  if (!viewingPrivateKey || !viewingPrivateKey.startsWith("0x")) {
@@ -25109,7 +25137,7 @@ function computeNEARViewingKeyHashFromPrivate(viewingPrivateKey) {
25109
25137
  try {
25110
25138
  const publicBytes = ed2551910.getPublicKey(privateBytes);
25111
25139
  const hashBytes = sha25632(publicBytes);
25112
- return `0x${bytesToHex49(hashBytes)}`;
25140
+ return `0x${bytesToHex48(hashBytes)}`;
25113
25141
  } finally {
25114
25142
  secureWipe(privateBytes);
25115
25143
  }
@@ -25158,7 +25186,7 @@ function importNEARViewingKey(exported) {
25158
25186
  }
25159
25187
  const privateBytes = hexToBytes32(exported.privateKey.slice(2));
25160
25188
  try {
25161
- const derivedPublic = `0x${bytesToHex49(ed2551910.getPublicKey(privateBytes))}`;
25189
+ const derivedPublic = `0x${bytesToHex48(ed2551910.getPublicKey(privateBytes))}`;
25162
25190
  if (derivedPublic !== exported.publicKey) {
25163
25191
  throw new ValidationError(
25164
25192
  "Public key does not match private key",
@@ -25193,8 +25221,8 @@ function encryptForNEARViewing(data, viewingKey) {
25193
25221
  const cipher = xchacha20poly13055(encKey, nonce);
25194
25222
  const ciphertext = cipher.encrypt(plaintext);
25195
25223
  return {
25196
- ciphertext: `0x${bytesToHex49(ciphertext)}`,
25197
- nonce: `0x${bytesToHex49(nonce)}`,
25224
+ ciphertext: `0x${bytesToHex48(ciphertext)}`,
25225
+ nonce: `0x${bytesToHex48(nonce)}`,
25198
25226
  viewingKeyHash: viewingKey.hash
25199
25227
  };
25200
25228
  } finally {
@@ -25268,9 +25296,9 @@ function deriveNEARChildViewingKey(parentKey, childPath, label) {
25268
25296
  const publicBytes = ed2551910.getPublicKey(childBytes);
25269
25297
  const hashBytes = sha25632(publicBytes);
25270
25298
  const result = {
25271
- privateKey: `0x${bytesToHex49(childBytes)}`,
25272
- publicKey: `0x${bytesToHex49(publicBytes)}`,
25273
- hash: `0x${bytesToHex49(hashBytes)}`,
25299
+ privateKey: `0x${bytesToHex48(childBytes)}`,
25300
+ publicKey: `0x${bytesToHex48(publicBytes)}`,
25301
+ hash: `0x${bytesToHex48(hashBytes)}`,
25274
25302
  label: label ?? `${parentKey.label ?? "Key"}/${childPath}`,
25275
25303
  createdAt: Date.now()
25276
25304
  };
@@ -25296,7 +25324,7 @@ function getNEARViewingPublicKey(viewingPrivateKey) {
25296
25324
  }
25297
25325
  try {
25298
25326
  const publicBytes = ed2551910.getPublicKey(privateBytes);
25299
- return `0x${bytesToHex49(publicBytes)}`;
25327
+ return `0x${bytesToHex48(publicBytes)}`;
25300
25328
  } finally {
25301
25329
  secureWipe(privateBytes);
25302
25330
  }
@@ -25333,7 +25361,7 @@ function validateNEARViewingKey(viewingKey) {
25333
25361
  }
25334
25362
  const privateBytes = hexToBytes32(viewingKey.privateKey.slice(2));
25335
25363
  try {
25336
- const derivedPublic = `0x${bytesToHex49(ed2551910.getPublicKey(privateBytes))}`;
25364
+ const derivedPublic = `0x${bytesToHex48(ed2551910.getPublicKey(privateBytes))}`;
25337
25365
  if (derivedPublic !== viewingKey.publicKey) {
25338
25366
  throw new ValidationError(
25339
25367
  "publicKey does not match privateKey",
@@ -25348,9 +25376,9 @@ function validateNEARViewingKey(viewingKey) {
25348
25376
 
25349
25377
  // src/chains/near/resolver.ts
25350
25378
  import { ed25519 as ed2551911 } from "@noble/curves/ed25519";
25351
- import { bytesToHex as bytesToHex50, hexToBytes as hexToBytes33 } from "@noble/hashes/utils";
25379
+ import { bytesToHex as bytesToHex49, hexToBytes as hexToBytes33 } from "@noble/hashes/utils";
25352
25380
  function nearSpendingPublicFromPrivate(spendingPrivateKey) {
25353
- return `0x${bytesToHex50(ed2551911.getPublicKey(hexToBytes33(spendingPrivateKey.slice(2))))}`;
25381
+ return `0x${bytesToHex49(ed2551911.getPublicKey(hexToBytes33(spendingPrivateKey.slice(2))))}`;
25354
25382
  }
25355
25383
  function createNEARAnnouncementCache() {
25356
25384
  const entries = [];
@@ -25391,6 +25419,8 @@ var NEARRpcClient = class {
25391
25419
  this.rpcUrl = rpcUrl;
25392
25420
  this.timeout = timeout;
25393
25421
  }
25422
+ rpcUrl;
25423
+ timeout;
25394
25424
  async call(method, params) {
25395
25425
  const controller = new AbortController();
25396
25426
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
@@ -25601,7 +25631,7 @@ var NEARStealthScanner = class {
25601
25631
  nearSpendingPublicFromPrivate(recipient.spendingPrivateKey)
25602
25632
  );
25603
25633
  if (isMatch) {
25604
- const stealthAddress = isImplicitAccount(announcement.stealthAddress) ? announcement.stealthAddress : bytesToHex50(hexToBytes33(stealthPublicKey.slice(2)));
25634
+ const stealthAddress = isImplicitAccount(announcement.stealthAddress) ? announcement.stealthAddress : bytesToHex49(hexToBytes33(stealthPublicKey.slice(2)));
25605
25635
  let amount = metadata?.amount ?? 0n;
25606
25636
  if (amount === 0n && isImplicitAccount(stealthAddress)) {
25607
25637
  try {
@@ -26036,6 +26066,9 @@ var AllBackendsFailedError = class _AllBackendsFailedError extends Error {
26036
26066
  this.params = params;
26037
26067
  Object.setPrototypeOf(this, _AllBackendsFailedError.prototype);
26038
26068
  }
26069
+ attemptedBackends;
26070
+ errors;
26071
+ params;
26039
26072
  name = "AllBackendsFailedError";
26040
26073
  /**
26041
26074
  * Get formatted error summary
@@ -26691,6 +26724,10 @@ var RateLimitExceededError = class extends Error {
26691
26724
  this.requestedTokens = requestedTokens;
26692
26725
  this.retryAfterMs = retryAfterMs;
26693
26726
  }
26727
+ backend;
26728
+ availableTokens;
26729
+ requestedTokens;
26730
+ retryAfterMs;
26694
26731
  name = "RateLimitExceededError";
26695
26732
  };
26696
26733
  var QueueFullError = class extends Error {
@@ -26702,6 +26739,9 @@ var QueueFullError = class extends Error {
26702
26739
  this.queueSize = queueSize;
26703
26740
  this.maxQueueSize = maxQueueSize;
26704
26741
  }
26742
+ backend;
26743
+ queueSize;
26744
+ maxQueueSize;
26705
26745
  name = "QueueFullError";
26706
26746
  };
26707
26747
  var AcquireTimeoutError = class extends Error {
@@ -26710,6 +26750,8 @@ var AcquireTimeoutError = class extends Error {
26710
26750
  this.backend = backend;
26711
26751
  this.timeoutMs = timeoutMs;
26712
26752
  }
26753
+ backend;
26754
+ timeoutMs;
26713
26755
  name = "AcquireTimeoutError";
26714
26756
  };
26715
26757
  var RateLimiter = class {
@@ -27961,7 +28003,7 @@ function createPrivacyLogger(moduleName, config = {}) {
27961
28003
  }
27962
28004
 
27963
28005
  // src/privacy-backends/privacycash.ts
27964
- import { randomBytes as randomBytes21, bytesToHex as bytesToHex51 } from "@noble/hashes/utils";
28006
+ import { randomBytes as randomBytes21, bytesToHex as bytesToHex50 } from "@noble/hashes/utils";
27965
28007
  var privacyCashLogger = createPrivacyLogger("PrivacyCash");
27966
28008
  var DEFAULT_ANONYMITY_SET = 50;
27967
28009
  var BASE_COST_LAMPORTS = BigInt(1e7);
@@ -27997,7 +28039,7 @@ import {
27997
28039
  InvalidAmountError,
27998
28040
  InvalidAddressError
27999
28041
  } from "@radr/shadowwire";
28000
- import { bytesToHex as bytesToHex52 } from "@noble/hashes/utils";
28042
+ import { bytesToHex as bytesToHex51 } from "@noble/hashes/utils";
28001
28043
  var SHADOWWIRE_TOKEN_MINTS = {
28002
28044
  SOL: "So11111111111111111111111111111111111111112",
28003
28045
  USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
@@ -28067,7 +28109,7 @@ import {
28067
28109
  PublicKey as PublicKey4,
28068
28110
  Transaction as Transaction3
28069
28111
  } from "@solana/web3.js";
28070
- import { bytesToHex as bytesToHex53 } from "@noble/hashes/utils";
28112
+ import { bytesToHex as bytesToHex52 } from "@noble/hashes/utils";
28071
28113
  var magicBlockLogger = createPrivacyLogger("MagicBlock");
28072
28114
 
28073
28115
  // src/privacy-backends/cspl-types.ts
@@ -28756,7 +28798,7 @@ var CSPLClient = class {
28756
28798
 
28757
28799
  // src/privacy-backends/private-swap.ts
28758
28800
  import { sha256 as sha25633 } from "@noble/hashes/sha256";
28759
- import { bytesToHex as bytesToHex54 } from "@noble/hashes/utils";
28801
+ import { bytesToHex as bytesToHex53 } from "@noble/hashes/utils";
28760
28802
 
28761
28803
  // src/privacy-backends/cspl-token.ts
28762
28804
  var CSPLTokenService = class {
@@ -31363,6 +31405,7 @@ var ProductionSafetyError = class extends Error {
31363
31405
  this.errors = errors;
31364
31406
  this.name = "ProductionSafetyError";
31365
31407
  }
31408
+ errors;
31366
31409
  };
31367
31410
  function validateProductionConfig(config, options = {}) {
31368
31411
  const isProduction = isProductionEnvironment();
@@ -31461,7 +31504,7 @@ function createProductionConfig(defaults) {
31461
31504
  // src/sync/oblivious.ts
31462
31505
  import { sha256 as sha25634 } from "@noble/hashes/sha2";
31463
31506
  import { hmac as hmac5 } from "@noble/hashes/hmac";
31464
- import { bytesToHex as bytesToHex55, hexToBytes as hexToBytes34, randomBytes as randomBytes22, utf8ToBytes as utf8ToBytes8 } from "@noble/hashes/utils";
31507
+ import { bytesToHex as bytesToHex54, hexToBytes as hexToBytes34, randomBytes as randomBytes22, utf8ToBytes as utf8ToBytes8 } from "@noble/hashes/utils";
31465
31508
  var DEFAULT_SYNC_CONFIG = {
31466
31509
  maxBatchSize: 1e3,
31467
31510
  timeoutMs: 3e4,
@@ -31501,7 +31544,7 @@ function deriveObliviousNullifier(noteCommitment, spendingKey, syncRandomness) {
31501
31544
  message.set(syncRandomness.value, domain.length + commitmentBytes.length);
31502
31545
  const nullifierBytes = hmac5(sha25634, keyBytes, message);
31503
31546
  return {
31504
- nullifier: `0x${bytesToHex55(nullifierBytes)}`,
31547
+ nullifier: `0x${bytesToHex54(nullifierBytes)}`,
31505
31548
  epoch: syncRandomness.epoch,
31506
31549
  chainId: "default"
31507
31550
  // Will be set by caller
@@ -31519,7 +31562,7 @@ function deriveTraditionalNullifier(noteCommitment, spendingKey) {
31519
31562
  );
31520
31563
  try {
31521
31564
  const nullifierBytes = hmac5(sha25634, keyBytes, commitmentBytes);
31522
- return `0x${bytesToHex55(nullifierBytes)}`;
31565
+ return `0x${bytesToHex54(nullifierBytes)}`;
31523
31566
  } finally {
31524
31567
  secureWipe(keyBytes);
31525
31568
  }
@@ -31575,11 +31618,11 @@ function createTimeWindowedKey(masterViewingKey, startTime, endTime, epochDurati
31575
31618
  const keyHash = sha25634(derivedKey);
31576
31619
  secureWipe(keyBytes);
31577
31620
  return {
31578
- viewingKey: `0x${bytesToHex55(derivedKey)}`,
31621
+ viewingKey: `0x${bytesToHex54(derivedKey)}`,
31579
31622
  windowStart: startTime,
31580
31623
  windowEnd: endTime,
31581
31624
  epochs,
31582
- hash: `0x${bytesToHex55(keyHash)}`
31625
+ hash: `0x${bytesToHex54(keyHash)}`
31583
31626
  };
31584
31627
  }
31585
31628
  function isNoteInWindow(_note, _windowedKey) {
@@ -31602,10 +31645,12 @@ var ObliviousSyncError = class extends Error {
31602
31645
  this.context = context;
31603
31646
  this.name = "ObliviousSyncError";
31604
31647
  }
31648
+ code;
31649
+ context;
31605
31650
  };
31606
31651
 
31607
31652
  // src/sync/mock-provider.ts
31608
- import { bytesToHex as bytesToHex56, randomBytes as randomBytes23 } from "@noble/hashes/utils";
31653
+ import { bytesToHex as bytesToHex55, randomBytes as randomBytes23 } from "@noble/hashes/utils";
31609
31654
  var DEFAULT_MOCK_CONFIG = {
31610
31655
  chains: ["ethereum", "solana", "near"],
31611
31656
  latencyMs: 100,
@@ -31702,7 +31747,7 @@ var MockObliviousSyncProvider = class {
31702
31747
  merkleProofs,
31703
31748
  syncHeight: this.config.blockHeight,
31704
31749
  timestamp: Date.now(),
31705
- queryHash: `0x${bytesToHex56(randomBytes23(32))}`
31750
+ queryHash: `0x${bytesToHex55(randomBytes23(32))}`
31706
31751
  };
31707
31752
  }
31708
31753
  async getCurrentHeight(chainId) {
@@ -31783,23 +31828,23 @@ var MockObliviousSyncProvider = class {
31783
31828
  generateMockNote(blockRange) {
31784
31829
  const blockNumber = blockRange.startBlock + BigInt(Math.floor(Math.random() * Number(blockRange.endBlock - blockRange.startBlock)));
31785
31830
  return {
31786
- commitment: `0x${bytesToHex56(randomBytes23(32))}`,
31787
- encryptedData: `0x${bytesToHex56(randomBytes23(128))}`,
31831
+ commitment: `0x${bytesToHex55(randomBytes23(32))}`,
31832
+ encryptedData: `0x${bytesToHex55(randomBytes23(128))}`,
31788
31833
  blockNumber,
31789
- txHash: `0x${bytesToHex56(randomBytes23(32))}`,
31834
+ txHash: `0x${bytesToHex55(randomBytes23(32))}`,
31790
31835
  chainId: blockRange.chainId
31791
31836
  };
31792
31837
  }
31793
31838
  generateMockMerkleProof(leaf) {
31794
31839
  const siblings = [];
31795
31840
  for (let i = 0; i < 20; i++) {
31796
- siblings.push(`0x${bytesToHex56(randomBytes23(32))}`);
31841
+ siblings.push(`0x${bytesToHex55(randomBytes23(32))}`);
31797
31842
  }
31798
31843
  return {
31799
31844
  leaf,
31800
31845
  siblings,
31801
31846
  index: BigInt(Math.floor(Math.random() * 1e6)),
31802
- root: `0x${bytesToHex56(randomBytes23(32))}`
31847
+ root: `0x${bytesToHex55(randomBytes23(32))}`
31803
31848
  };
31804
31849
  }
31805
31850
  };