@buildonspark/spark-sdk 0.2.1 → 0.2.3

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 (77) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/{chunk-TM6CHQXC.js → chunk-3SEOTO43.js} +1 -1
  3. package/dist/{chunk-2ENZX6LT.js → chunk-AAZWSPUK.js} +84 -8
  4. package/dist/{chunk-4JD4HIAN.js → chunk-G4MSZ6DE.js} +299 -1
  5. package/dist/{chunk-KFDVDUIS.js → chunk-PLLJIZC3.js} +138 -35
  6. package/dist/{chunk-N4JAOOIN.js → chunk-PTRXJS7Q.js} +1 -1
  7. package/dist/{client-DKbwpcnl.d.ts → client-CGTRS23n.d.ts} +21 -4
  8. package/dist/{client-Drs5Lapg.d.cts → client-CcYzmpmj.d.cts} +21 -4
  9. package/dist/debug.cjs +455 -40
  10. package/dist/debug.d.cts +5 -5
  11. package/dist/debug.d.ts +5 -5
  12. package/dist/debug.js +4 -4
  13. package/dist/graphql/objects/index.d.cts +2 -2
  14. package/dist/graphql/objects/index.d.ts +2 -2
  15. package/dist/index.cjs +515 -40
  16. package/dist/index.d.cts +5 -5
  17. package/dist/index.d.ts +5 -5
  18. package/dist/index.js +7 -5
  19. package/dist/index.node.cjs +517 -44
  20. package/dist/index.node.d.cts +8 -6
  21. package/dist/index.node.d.ts +8 -6
  22. package/dist/index.node.js +6 -4
  23. package/dist/native/index.cjs +459 -43
  24. package/dist/native/index.d.cts +62 -15
  25. package/dist/native/index.d.ts +62 -15
  26. package/dist/native/index.js +459 -43
  27. package/dist/proto/lrc20.d.cts +1 -1
  28. package/dist/proto/lrc20.d.ts +1 -1
  29. package/dist/proto/lrc20.js +1 -1
  30. package/dist/proto/spark.cjs +84 -8
  31. package/dist/proto/spark.d.cts +1 -1
  32. package/dist/proto/spark.d.ts +1 -1
  33. package/dist/proto/spark.js +1 -1
  34. package/dist/proto/spark_token.cjs +301 -0
  35. package/dist/proto/spark_token.d.cts +35 -2
  36. package/dist/proto/spark_token.d.ts +35 -2
  37. package/dist/proto/spark_token.js +8 -2
  38. package/dist/{sdk-types-DJ2ve9YY.d.cts → sdk-types-CB9HrW5O.d.cts} +1 -1
  39. package/dist/{sdk-types-DCIVdKUT.d.ts → sdk-types-CkRNraXT.d.ts} +1 -1
  40. package/dist/{spark-BUOx3U7Q.d.cts → spark-B_7nZx6T.d.cts} +112 -10
  41. package/dist/{spark-BUOx3U7Q.d.ts → spark-B_7nZx6T.d.ts} +112 -10
  42. package/dist/{spark-wallet-DbCjWOfP.d.ts → spark-wallet-CxcGPXRB.d.ts} +10 -6
  43. package/dist/{spark-wallet-BslnB-4H.d.cts → spark-wallet-DJJm19BP.d.cts} +10 -6
  44. package/dist/tests/test-utils.cjs +455 -17
  45. package/dist/tests/test-utils.d.cts +9 -5
  46. package/dist/tests/test-utils.d.ts +9 -5
  47. package/dist/tests/test-utils.js +13 -6
  48. package/dist/types/index.cjs +84 -8
  49. package/dist/types/index.d.cts +3 -3
  50. package/dist/types/index.d.ts +3 -3
  51. package/dist/types/index.js +2 -2
  52. package/dist/{xchain-address-BIcYZU3K.d.ts → xchain-address-Bh9w1SeC.d.ts} +3 -3
  53. package/dist/{xchain-address-C3B-Jfk5.d.cts → xchain-address-SZ7dkVUE.d.cts} +3 -3
  54. package/package.json +1 -1
  55. package/src/index.node.ts +6 -6
  56. package/src/index.ts +5 -5
  57. package/src/proto/spark.ts +172 -16
  58. package/src/proto/spark_token.ts +369 -0
  59. package/src/services/connection.ts +3 -3
  60. package/src/services/coop-exit.ts +1 -1
  61. package/src/services/deposit.ts +2 -2
  62. package/src/services/signing.ts +1 -1
  63. package/src/services/token-transactions.ts +6 -2
  64. package/src/services/transfer.ts +25 -9
  65. package/src/services/tree-creation.ts +10 -7
  66. package/src/signer/signer.react-native.ts +4 -3
  67. package/src/signer/signer.ts +84 -6
  68. package/src/signer/types.ts +7 -1
  69. package/src/spark-wallet/spark-wallet.ts +56 -15
  70. package/src/tests/integration/coop-exit.test.ts +5 -3
  71. package/src/tests/integration/deposit.test.ts +20 -10
  72. package/src/tests/integration/lightning.test.ts +13 -7
  73. package/src/tests/integration/message-signing.test.ts +10 -7
  74. package/src/tests/integration/swap.test.ts +8 -4
  75. package/src/tests/integration/transfer.test.ts +25 -11
  76. package/src/tests/integration/wallet.test.ts +9 -4
  77. package/src/tests/test-utils.ts +10 -1
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  SparkTokenServiceDefinition
3
- } from "./chunk-4JD4HIAN.js";
3
+ } from "./chunk-G4MSZ6DE.js";
4
4
  import {
5
5
  mapTransferToWalletTransfer,
6
6
  mapTreeNodeToWalletLeaf
7
- } from "./chunk-TM6CHQXC.js";
7
+ } from "./chunk-3SEOTO43.js";
8
8
  import {
9
9
  BitcoinNetwork_default,
10
10
  ClaimStaticDepositRequestType_default,
@@ -30,7 +30,7 @@ import {
30
30
  SparkServiceDefinition,
31
31
  TreeNode,
32
32
  networkToJSON
33
- } from "./chunk-2ENZX6LT.js";
33
+ } from "./chunk-AAZWSPUK.js";
34
34
  import {
35
35
  Buffer,
36
36
  __export
@@ -577,7 +577,7 @@ import * as ecies from "eciesjs";
577
577
  import { isNode } from "@lightsparkdev/core";
578
578
  var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
579
579
  var isBun = globalThis.Bun !== void 0;
580
- var packageVersion = true ? "0.2.1" : "unknown";
580
+ var packageVersion = true ? "0.2.3" : "unknown";
581
581
  var baseEnvStr = "unknown";
582
582
  if (isBun) {
583
583
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -897,7 +897,8 @@ var DefaultSparkSigner = class {
897
897
  field: "privateKey"
898
898
  });
899
899
  }
900
- const nonce = this.commitmentToNonceMap.get(selfCommitment);
900
+ const commitment = selfCommitment.commitment;
901
+ const nonce = this.commitmentToNonceMap.get(commitment);
901
902
  if (!nonce) {
902
903
  throw new ValidationError("Nonce not found for commitment", {
903
904
  field: "nonce"
@@ -912,7 +913,7 @@ var DefaultSparkSigner = class {
912
913
  message,
913
914
  keyPackage,
914
915
  nonce,
915
- selfCommitment,
916
+ selfCommitment: commitment,
916
917
  statechainCommitments,
917
918
  adaptorPubKey
918
919
  });
@@ -940,7 +941,7 @@ var DefaultSparkSigner = class {
940
941
  statechainPublicKeys,
941
942
  verifyingKey,
942
943
  statechainCommitments,
943
- selfCommitment,
944
+ selfCommitment: selfCommitment.commitment,
944
945
  selfPublicKey: publicKey,
945
946
  selfSignature,
946
947
  adaptorPubKey
@@ -991,7 +992,9 @@ var DefaultSparkSigner = class {
991
992
  const nonce = getRandomSigningNonce();
992
993
  const commitment = getSigningCommitmentFromNonce(nonce);
993
994
  this.commitmentToNonceMap.set(commitment, nonce);
994
- return commitment;
995
+ return {
996
+ commitment
997
+ };
995
998
  }
996
999
  async validateMessageWithIdentityKey(message, signature) {
997
1000
  if (!this.identityKey?.publicKey) {
@@ -1045,6 +1048,64 @@ var DefaultSparkSigner = class {
1045
1048
  tx.signIdx(privateKey, index);
1046
1049
  }
1047
1050
  };
1051
+ var UnsafeStatelessSparkSigner = class extends DefaultSparkSigner {
1052
+ constructor({
1053
+ sparkKeysGenerator
1054
+ } = {}) {
1055
+ super({
1056
+ sparkKeysGenerator
1057
+ });
1058
+ }
1059
+ async getRandomSigningCommitment() {
1060
+ const nonce = getRandomSigningNonce();
1061
+ const commitment = getSigningCommitmentFromNonce(nonce);
1062
+ return {
1063
+ commitment,
1064
+ nonce
1065
+ };
1066
+ }
1067
+ async signFrost({
1068
+ message,
1069
+ keyDerivation,
1070
+ publicKey,
1071
+ verifyingKey,
1072
+ selfCommitment,
1073
+ statechainCommitments,
1074
+ adaptorPubKey
1075
+ }) {
1076
+ const SparkFrost = await getSparkFrostModule();
1077
+ if (!SparkFrost) {
1078
+ throw new ValidationError("SparkFrost module not found", {
1079
+ field: "SparkFrost"
1080
+ });
1081
+ }
1082
+ const signingPrivateKey = await this.getSigningPrivateKeyFromDerivation(keyDerivation);
1083
+ if (!signingPrivateKey) {
1084
+ throw new ValidationError("Private key not found for public key", {
1085
+ field: "privateKey"
1086
+ });
1087
+ }
1088
+ const { commitment, nonce } = selfCommitment;
1089
+ if (!nonce) {
1090
+ throw new ValidationError("Nonce not found for commitment", {
1091
+ field: "nonce"
1092
+ });
1093
+ }
1094
+ const keyPackage = {
1095
+ secretKey: signingPrivateKey,
1096
+ publicKey,
1097
+ verifyingKey
1098
+ };
1099
+ return SparkFrost.signFrost({
1100
+ message,
1101
+ keyPackage,
1102
+ nonce,
1103
+ selfCommitment: commitment,
1104
+ statechainCommitments,
1105
+ adaptorPubKey
1106
+ });
1107
+ }
1108
+ };
1048
1109
  var TaprootSparkSigner = class extends DefaultSparkSigner {
1049
1110
  constructor(useAddressIndex = false) {
1050
1111
  super({
@@ -3159,12 +3220,12 @@ var DepositService = class {
3159
3220
  rootTxSigningJob: {
3160
3221
  rawTx: rootTx.toBytes(),
3161
3222
  signingPublicKey: signingPubKey,
3162
- signingNonceCommitment: rootNonceCommitment
3223
+ signingNonceCommitment: rootNonceCommitment.commitment
3163
3224
  },
3164
3225
  refundTxSigningJob: {
3165
3226
  rawTx: refundTx.toBytes(),
3166
3227
  signingPublicKey: signingPubKey,
3167
- signingNonceCommitment: refundNonceCommitment
3228
+ signingNonceCommitment: refundNonceCommitment.commitment
3168
3229
  }
3169
3230
  });
3170
3231
  } catch (error) {
@@ -5702,7 +5763,9 @@ var TokenTransactionService = class {
5702
5763
  issuerPublicKeys,
5703
5764
  tokenTransactionHashes,
5704
5765
  tokenIdentifiers,
5705
- outputIds
5766
+ outputIds,
5767
+ pageSize,
5768
+ offset
5706
5769
  } = params;
5707
5770
  const tokenClient = await this.connectionManager.createSparkTokenClient(
5708
5771
  this.config.getCoordinatorAddress()
@@ -5713,8 +5776,8 @@ var TokenTransactionService = class {
5713
5776
  tokenIdentifiers: tokenIdentifiers?.map(hexToBytes6),
5714
5777
  tokenTransactionHashes: tokenTransactionHashes?.map(hexToBytes6),
5715
5778
  outputIds: outputIds || [],
5716
- limit: 100,
5717
- offset: 0
5779
+ limit: pageSize,
5780
+ offset
5718
5781
  };
5719
5782
  try {
5720
5783
  const response = await tokenClient.query_token_transactions(queryParams);
@@ -7439,6 +7502,13 @@ var DEFAULT_EXPIRY_TIME = 10 * 60 * 1e3;
7439
7502
  function initialSequence() {
7440
7503
  return 1 << 30 | INITIAL_TIME_LOCK2;
7441
7504
  }
7505
+ function getSigningJobProto(signingJob) {
7506
+ return {
7507
+ signingPublicKey: signingJob.signingPublicKey,
7508
+ rawTx: signingJob.rawTx,
7509
+ signingNonceCommitment: signingJob.signingNonceCommitment.commitment
7510
+ };
7511
+ }
7442
7512
  var BaseTransferService = class {
7443
7513
  config;
7444
7514
  connectionManager;
@@ -8065,7 +8135,7 @@ var TransferService = class extends BaseTransferService {
8065
8135
  refundSigningData.keyDerivation
8066
8136
  ),
8067
8137
  rawTx: refundTx.toBytes(),
8068
- signingNonceCommitment: refundNonceCommitmentProto
8138
+ signingNonceCommitment: refundNonceCommitmentProto.commitment
8069
8139
  },
8070
8140
  // TODO: Add direct refund signature
8071
8141
  directRefundTxSigningJob: void 0,
@@ -8377,7 +8447,7 @@ var TransferService = class extends BaseTransferService {
8377
8447
  const response = await sparkClient.refresh_timelock({
8378
8448
  leafId: leaf.id,
8379
8449
  ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
8380
- signingJobs
8450
+ signingJobs: signingJobs.map(getSigningJobProto)
8381
8451
  });
8382
8452
  if (signingJobs.length !== response.signingResults.length) {
8383
8453
  throw Error(
@@ -8543,8 +8613,8 @@ var TransferService = class extends BaseTransferService {
8543
8613
  const response = await sparkClient.extend_leaf({
8544
8614
  leafId: node.id,
8545
8615
  ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
8546
- nodeTxSigningJob: newNodeSigningJob,
8547
- refundTxSigningJob: newRefundSigningJob
8616
+ nodeTxSigningJob: getSigningJobProto(newNodeSigningJob),
8617
+ refundTxSigningJob: getSigningJobProto(newRefundSigningJob)
8548
8618
  });
8549
8619
  if (!response.nodeTxSigningResult || !response.refundTxSigningResult) {
8550
8620
  throw new Error("Signing result does not exist");
@@ -8652,7 +8722,7 @@ var TransferService = class extends BaseTransferService {
8652
8722
  const response = await sparkClient.refresh_timelock({
8653
8723
  leafId: node.id,
8654
8724
  ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
8655
- signingJobs: [refundSigningJob]
8725
+ signingJobs: [getSigningJobProto(refundSigningJob)]
8656
8726
  });
8657
8727
  if (response.signingResults.length !== 1) {
8658
8728
  throw Error(
@@ -8804,7 +8874,7 @@ var CoopExitService = class extends BaseTransferService {
8804
8874
  leaf.keyDerivation
8805
8875
  ),
8806
8876
  rawTx: refundTx.toBytes(),
8807
- signingNonceCommitment
8877
+ signingNonceCommitment: signingNonceCommitment.commitment
8808
8878
  },
8809
8879
  // TODO: Add direct refund signature
8810
8880
  directRefundTxSigningJob: void 0,
@@ -9437,7 +9507,7 @@ var TreeCreationService = class {
9437
9507
  const signingJob = {
9438
9508
  signingPublicKey: node.signingPublicKey,
9439
9509
  rawTx: tx.toBytes(),
9440
- signingNonceCommitment
9510
+ signingNonceCommitment: signingNonceCommitment.commitment
9441
9511
  };
9442
9512
  internalCreationNode.nodeTxSigningCommitment = signingNonceCommitment;
9443
9513
  internalCreationNode.nodeTxSigningJob = signingJob;
@@ -9466,7 +9536,7 @@ var TreeCreationService = class {
9466
9536
  const childSigningJob = {
9467
9537
  signingPublicKey: node.signingPublicKey,
9468
9538
  rawTx: childTx.toBytes(),
9469
- signingNonceCommitment: childSigningNonceCommitment
9539
+ signingNonceCommitment: childSigningNonceCommitment.commitment
9470
9540
  };
9471
9541
  childCreationNode.nodeTxSigningCommitment = childSigningNonceCommitment;
9472
9542
  childCreationNode.nodeTxSigningJob = childSigningJob;
@@ -9493,7 +9563,7 @@ var TreeCreationService = class {
9493
9563
  const refundSigningJob = {
9494
9564
  signingPublicKey: node.signingPublicKey,
9495
9565
  rawTx: refundTx.toBytes(),
9496
- signingNonceCommitment: refundSigningNonceCommitment
9566
+ signingNonceCommitment: refundSigningNonceCommitment.commitment
9497
9567
  };
9498
9568
  childCreationNode.refundTxSigningCommitment = refundSigningNonceCommitment;
9499
9569
  childCreationNode.refundTxSigningJob = refundSigningJob;
@@ -9528,7 +9598,7 @@ var TreeCreationService = class {
9528
9598
  const rootNodeSigningJob = {
9529
9599
  signingPublicKey: root.signingPublicKey,
9530
9600
  rawTx: rootNodeTx.toBytes(),
9531
- signingNonceCommitment: rootNodeSigningCommitment
9601
+ signingNonceCommitment: rootNodeSigningCommitment.commitment
9532
9602
  };
9533
9603
  const rootCreationNode = {
9534
9604
  nodeTxSigningJob: rootNodeSigningJob,
@@ -9760,7 +9830,7 @@ var SigningService = class {
9760
9830
  leaf.keyDerivation
9761
9831
  ),
9762
9832
  rawTx: refundTx.toBytes(),
9763
- signingNonceCommitment: signingCommitment,
9833
+ signingNonceCommitment: signingCommitment.commitment,
9764
9834
  userSignature: signingResult,
9765
9835
  signingCommitments: {
9766
9836
  signingCommitments: signingNonceCommitments
@@ -10048,11 +10118,24 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
10048
10118
  }
10049
10119
  }
10050
10120
  }
10051
- const verifyKey = (pubkey1, pubkey2, verifyingKey) => {
10052
- return equalBytes5(addPublicKeys(pubkey1, pubkey2), verifyingKey);
10053
- };
10054
- for (const [id, leaf] of Object.entries(leaves.nodes)) {
10055
- if (!verifyKey(
10121
+ const availableLeaves = Object.entries(leaves.nodes).filter(
10122
+ ([_, node]) => node.status === "AVAILABLE"
10123
+ );
10124
+ for (const [id, leaf] of availableLeaves) {
10125
+ if (leaf.parentNodeId && leaf.status === "AVAILABLE" && this.verifyKey(
10126
+ await this.config.signer.getPublicKeyFromDerivation({
10127
+ type: "leaf" /* LEAF */,
10128
+ path: leaf.parentNodeId
10129
+ }),
10130
+ leaf.signingKeyshare?.publicKey ?? new Uint8Array(),
10131
+ leaf.verifyingPublicKey
10132
+ )) {
10133
+ this.transferLeavesToSelf([leaf], {
10134
+ type: "leaf" /* LEAF */,
10135
+ path: leaf.parentNodeId
10136
+ });
10137
+ leavesToIgnore.add(id);
10138
+ } else if (!this.verifyKey(
10056
10139
  await this.config.signer.getPublicKeyFromDerivation({
10057
10140
  type: "leaf" /* LEAF */,
10058
10141
  path: leaf.id
@@ -10063,9 +10146,23 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
10063
10146
  leavesToIgnore.add(id);
10064
10147
  }
10065
10148
  }
10066
- return Object.entries(leaves.nodes).filter(
10067
- ([_, node]) => node.status === "AVAILABLE" && !leavesToIgnore.has(node.id)
10068
- ).map(([_, node]) => node);
10149
+ return availableLeaves.filter(([_, node]) => !leavesToIgnore.has(node.id)).map(([_, node]) => node);
10150
+ }
10151
+ async checkExtendLeaves(leaves) {
10152
+ await this.withLeaves(async () => {
10153
+ for (const leaf of leaves) {
10154
+ if (!leaf.parentNodeId && leaf.status === "AVAILABLE") {
10155
+ const res = await this.transferService.extendTimelock(leaf);
10156
+ await this.transferLeavesToSelf(res.nodes, {
10157
+ type: "leaf" /* LEAF */,
10158
+ path: leaf.id
10159
+ });
10160
+ }
10161
+ }
10162
+ });
10163
+ }
10164
+ verifyKey(pubkey1, pubkey2, verifyingKey) {
10165
+ return equalBytes5(addPublicKeys(pubkey1, pubkey2), verifyingKey);
10069
10166
  }
10070
10167
  async selectLeaves(targetAmounts) {
10071
10168
  if (targetAmounts.length === 0) {
@@ -10204,6 +10301,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
10204
10301
  leaves = await this.checkRefreshTimelockNodes(leaves);
10205
10302
  leaves = await this.checkExtendTimeLockNodes(leaves);
10206
10303
  this.leaves = leaves;
10304
+ this.checkExtendLeaves(leaves);
10207
10305
  this.optimizeLeaves().catch((e) => {
10208
10306
  console.error("Failed to optimize leaves", e);
10209
10307
  });
@@ -10903,7 +11001,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
10903
11001
  const signingJob = {
10904
11002
  rawTx: tx.toBytes(),
10905
11003
  signingPublicKey: await this.config.signer.getStaticDepositSigningKey(0),
10906
- signingNonceCommitment
11004
+ signingNonceCommitment: signingNonceCommitment.commitment
10907
11005
  };
10908
11006
  const message = await this.getStaticDepositSigningPayload(
10909
11007
  depositTransactionId,
@@ -12364,14 +12462,18 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12364
12462
  issuerPublicKeys,
12365
12463
  tokenTransactionHashes,
12366
12464
  tokenIdentifiers,
12367
- outputIds
12465
+ outputIds,
12466
+ pageSize = 100,
12467
+ offset = 0
12368
12468
  }) {
12369
12469
  return this.tokenTransactionService.queryTokenTransactions({
12370
12470
  ownerPublicKeys,
12371
12471
  issuerPublicKeys,
12372
12472
  tokenTransactionHashes,
12373
12473
  tokenIdentifiers,
12374
- outputIds
12474
+ outputIds,
12475
+ pageSize,
12476
+ offset
12375
12477
  });
12376
12478
  }
12377
12479
  async getTokenL1Address() {
@@ -13492,6 +13594,7 @@ export {
13492
13594
  MultisigReceiptInput,
13493
13595
  TaprootOutputKeysGenerator,
13494
13596
  DefaultSparkSigner,
13597
+ UnsafeStatelessSparkSigner,
13495
13598
  TaprootSparkSigner,
13496
13599
  Network2 as Network,
13497
13600
  NetworkToProto,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  setCrypto
3
- } from "./chunk-KFDVDUIS.js";
3
+ } from "./chunk-PLLJIZC3.js";
4
4
 
5
5
  // src/index.ts
6
6
  var cryptoImpl = typeof window !== "undefined" && window.crypto ? window.crypto : typeof global !== "undefined" && global.crypto ? global.crypto : null;
@@ -31,6 +31,10 @@ declare function recoverSecret(shares: VerifiableSecretShare[]): bigint;
31
31
  declare function validateShare(share: VerifiableSecretShare): void;
32
32
  declare function bigIntToPrivateKey(value: bigint): Uint8Array;
33
33
 
34
+ type SigningCommitmentWithOptionalNonce = {
35
+ commitment: SigningCommitment;
36
+ nonce?: SigningNonce;
37
+ };
34
38
  type SigningNonce = {
35
39
  binding: Uint8Array;
36
40
  hiding: Uint8Array;
@@ -65,7 +69,7 @@ type SignFrostParams = {
65
69
  keyDerivation: KeyDerivation;
66
70
  publicKey: Uint8Array;
67
71
  verifyingKey: Uint8Array;
68
- selfCommitment: ISigningCommitment;
72
+ selfCommitment: SigningCommitmentWithOptionalNonce;
69
73
  statechainCommitments?: {
70
74
  [key: string]: ISigningCommitment;
71
75
  } | undefined;
@@ -144,7 +148,7 @@ interface SparkSigner extends TokenSigner {
144
148
  validateMessageWithIdentityKey(message: Uint8Array, signature: Uint8Array): Promise<boolean>;
145
149
  signTransactionIndex(tx: Transaction, index: number, publicKey: Uint8Array): void;
146
150
  decryptEcies(ciphertext: Uint8Array): Promise<Uint8Array>;
147
- getRandomSigningCommitment(): Promise<SigningCommitment>;
151
+ getRandomSigningCommitment(): Promise<SigningCommitmentWithOptionalNonce>;
148
152
  getDepositSigningKey(): Promise<Uint8Array>;
149
153
  }
150
154
  declare class DefaultSparkSigner implements SparkSigner {
@@ -187,12 +191,25 @@ declare class DefaultSparkSigner implements SparkSigner {
187
191
  createSparkWalletFromSeed(seed: Uint8Array | string, accountNumber?: number): Promise<string>;
188
192
  signMessageWithIdentityKey(message: Uint8Array, compact?: boolean): Promise<Uint8Array>;
189
193
  decryptEcies(ciphertext: Uint8Array): Promise<Uint8Array>;
190
- getRandomSigningCommitment(): Promise<SigningCommitment>;
194
+ getRandomSigningCommitment(): Promise<SigningCommitmentWithOptionalNonce>;
191
195
  validateMessageWithIdentityKey(message: Uint8Array, signature: Uint8Array): Promise<boolean>;
192
196
  signPsbt(psbt: Psbt, input: number, sighashTypes?: number[], receipt?: Receipt): Promise<Psbt>;
193
197
  private getReceiptPrivateKey;
194
198
  signTransactionIndex(tx: Transaction, index: number, publicKey: Uint8Array): void;
195
199
  }
200
+ /**
201
+ * StatelessSparkSigner is different from DefaultSparkSigner in that it does not store
202
+ * nonces in internal state. StatelessSparkSigner should only be used in a secure environment.
203
+ *
204
+ * @extends DefaultSparkSigner
205
+ */
206
+ declare class UnsafeStatelessSparkSigner extends DefaultSparkSigner {
207
+ constructor({ sparkKeysGenerator, }?: {
208
+ sparkKeysGenerator?: SparkKeysGenerator;
209
+ });
210
+ getRandomSigningCommitment(): Promise<SigningCommitmentWithOptionalNonce>;
211
+ signFrost({ message, keyDerivation, publicKey, verifyingKey, selfCommitment, statechainCommitments, adaptorPubKey, }: SignFrostParams): Promise<Uint8Array>;
212
+ }
196
213
  declare class TaprootSparkSigner extends DefaultSparkSigner {
197
214
  constructor(useAddressIndex?: boolean);
198
215
  }
@@ -773,4 +790,4 @@ declare class SspClient {
773
790
  getCoopExitFeeQuote({ leafExternalIds, withdrawalAddress, }: CoopExitFeeQuoteInput): Promise<CoopExitFeeQuote | null>;
774
791
  }
775
792
 
776
- export { splitSecretWithProofs as $, SparkLeavesSwapRequestStatus as A, BitcoinNetwork as B, type ClaimStaticDepositOutput as C, type SparkTransferToLeavesConnection as D, ExitSpeed as E, type StaticDepositQuoteInput as F, type GetChallengeOutput as G, type StaticDepositQuoteOutput as H, type Invoice as I, type SwapLeaf as J, type VerifiableSecretShare as K, type Leaf as L, bigIntToPrivateKey as M, computerLagrangeCoefficients as N, evaluatePolynomial as O, type PageInfo as P, fieldDiv as Q, type RequestCoopExitInput as R, SparkCoopExitRequestStatus as S, Transfer as T, type UserLeafInput as U, type VerifyChallengeOutput as V, generatePolynomialForSecretSharing as W, getRandomBigInt as X, modInverse as Y, recoverSecret as Z, splitSecret as _, type CompleteCoopExitInput as a, validateShare as a0, type SparkSigner as a1, type MayHaveSspClientOptions as a2, type SspClientOptions as a3, type HasSspClientOptions as a4, type KeyDerivation as a5, type SigningCommitment as a6, type SigningNonce as a7, SspClient as a8, DefaultSparkSigner as a9, TaprootSparkSigner as aa, TaprootOutputKeysGenerator as ab, KeyDerivationType as ac, type SignFrostParams as ad, type AggregateFrostParams as ae, type SplitSecretWithProofsParams as af, type DerivedHDKey as ag, type KeyPair as ah, type CompleteLeavesSwapInput as b, type CoopExitFeeEstimate as c, type CoopExitFeeEstimatesInput as d, type CoopExitFeeEstimatesOutput as e, type CoopExitFeeQuote as f, getCoopExitFeeQuoteQuery as g, type CoopExitFeeQuoteInput as h, type CoopExitRequest as i, getCoopExitRequestQuery as j, type CurrencyAmount as k, CurrencyUnit as l, type LeavesSwapFeeEstimateOutput as m, getLeavesSwapRequestQuery as n, type LeavesSwapRequest as o, getLightningReceiveRequestQuery as p, type LightningReceiveRequest as q, LightningReceiveRequestStatus as r, type LightningSendFeeEstimateInput as s, type LightningSendFeeEstimateOutput as t, getLightningSendRequestQuery as u, type LightningSendRequest as v, LightningSendRequestStatus as w, type RequestLeavesSwapInput as x, type RequestLightningReceiveInput as y, type RequestLightningSendInput as z };
793
+ export { splitSecretWithProofs as $, SparkLeavesSwapRequestStatus as A, BitcoinNetwork as B, type ClaimStaticDepositOutput as C, type SparkTransferToLeavesConnection as D, ExitSpeed as E, type StaticDepositQuoteInput as F, type GetChallengeOutput as G, type StaticDepositQuoteOutput as H, type Invoice as I, type SwapLeaf as J, type VerifiableSecretShare as K, type Leaf as L, bigIntToPrivateKey as M, computerLagrangeCoefficients as N, evaluatePolynomial as O, type PageInfo as P, fieldDiv as Q, type RequestCoopExitInput as R, SparkCoopExitRequestStatus as S, Transfer as T, type UserLeafInput as U, type VerifyChallengeOutput as V, generatePolynomialForSecretSharing as W, getRandomBigInt as X, modInverse as Y, recoverSecret as Z, splitSecret as _, type CompleteCoopExitInput as a, validateShare as a0, type SparkSigner as a1, DefaultSparkSigner as a2, type MayHaveSspClientOptions as a3, type SspClientOptions as a4, type HasSspClientOptions as a5, type KeyDerivation as a6, type SigningCommitmentWithOptionalNonce as a7, type SigningNonce as a8, type SigningCommitment as a9, SspClient as aa, TaprootOutputKeysGenerator as ab, TaprootSparkSigner as ac, UnsafeStatelessSparkSigner as ad, KeyDerivationType as ae, type SignFrostParams as af, type AggregateFrostParams as ag, type SplitSecretWithProofsParams as ah, type DerivedHDKey as ai, type KeyPair as aj, type CompleteLeavesSwapInput as b, type CoopExitFeeEstimate as c, type CoopExitFeeEstimatesInput as d, type CoopExitFeeEstimatesOutput as e, type CoopExitFeeQuote as f, getCoopExitFeeQuoteQuery as g, type CoopExitFeeQuoteInput as h, type CoopExitRequest as i, getCoopExitRequestQuery as j, type CurrencyAmount as k, CurrencyUnit as l, type LeavesSwapFeeEstimateOutput as m, getLeavesSwapRequestQuery as n, type LeavesSwapRequest as o, getLightningReceiveRequestQuery as p, type LightningReceiveRequest as q, LightningReceiveRequestStatus as r, type LightningSendFeeEstimateInput as s, type LightningSendFeeEstimateOutput as t, getLightningSendRequestQuery as u, type LightningSendRequest as v, LightningSendRequestStatus as w, type RequestLeavesSwapInput as x, type RequestLightningReceiveInput as y, type RequestLightningSendInput as z };
@@ -31,6 +31,10 @@ declare function recoverSecret(shares: VerifiableSecretShare[]): bigint;
31
31
  declare function validateShare(share: VerifiableSecretShare): void;
32
32
  declare function bigIntToPrivateKey(value: bigint): Uint8Array;
33
33
 
34
+ type SigningCommitmentWithOptionalNonce = {
35
+ commitment: SigningCommitment;
36
+ nonce?: SigningNonce;
37
+ };
34
38
  type SigningNonce = {
35
39
  binding: Uint8Array;
36
40
  hiding: Uint8Array;
@@ -65,7 +69,7 @@ type SignFrostParams = {
65
69
  keyDerivation: KeyDerivation;
66
70
  publicKey: Uint8Array;
67
71
  verifyingKey: Uint8Array;
68
- selfCommitment: ISigningCommitment;
72
+ selfCommitment: SigningCommitmentWithOptionalNonce;
69
73
  statechainCommitments?: {
70
74
  [key: string]: ISigningCommitment;
71
75
  } | undefined;
@@ -144,7 +148,7 @@ interface SparkSigner extends TokenSigner {
144
148
  validateMessageWithIdentityKey(message: Uint8Array, signature: Uint8Array): Promise<boolean>;
145
149
  signTransactionIndex(tx: Transaction, index: number, publicKey: Uint8Array): void;
146
150
  decryptEcies(ciphertext: Uint8Array): Promise<Uint8Array>;
147
- getRandomSigningCommitment(): Promise<SigningCommitment>;
151
+ getRandomSigningCommitment(): Promise<SigningCommitmentWithOptionalNonce>;
148
152
  getDepositSigningKey(): Promise<Uint8Array>;
149
153
  }
150
154
  declare class DefaultSparkSigner implements SparkSigner {
@@ -187,12 +191,25 @@ declare class DefaultSparkSigner implements SparkSigner {
187
191
  createSparkWalletFromSeed(seed: Uint8Array | string, accountNumber?: number): Promise<string>;
188
192
  signMessageWithIdentityKey(message: Uint8Array, compact?: boolean): Promise<Uint8Array>;
189
193
  decryptEcies(ciphertext: Uint8Array): Promise<Uint8Array>;
190
- getRandomSigningCommitment(): Promise<SigningCommitment>;
194
+ getRandomSigningCommitment(): Promise<SigningCommitmentWithOptionalNonce>;
191
195
  validateMessageWithIdentityKey(message: Uint8Array, signature: Uint8Array): Promise<boolean>;
192
196
  signPsbt(psbt: Psbt, input: number, sighashTypes?: number[], receipt?: Receipt): Promise<Psbt>;
193
197
  private getReceiptPrivateKey;
194
198
  signTransactionIndex(tx: Transaction, index: number, publicKey: Uint8Array): void;
195
199
  }
200
+ /**
201
+ * StatelessSparkSigner is different from DefaultSparkSigner in that it does not store
202
+ * nonces in internal state. StatelessSparkSigner should only be used in a secure environment.
203
+ *
204
+ * @extends DefaultSparkSigner
205
+ */
206
+ declare class UnsafeStatelessSparkSigner extends DefaultSparkSigner {
207
+ constructor({ sparkKeysGenerator, }?: {
208
+ sparkKeysGenerator?: SparkKeysGenerator;
209
+ });
210
+ getRandomSigningCommitment(): Promise<SigningCommitmentWithOptionalNonce>;
211
+ signFrost({ message, keyDerivation, publicKey, verifyingKey, selfCommitment, statechainCommitments, adaptorPubKey, }: SignFrostParams): Promise<Uint8Array>;
212
+ }
196
213
  declare class TaprootSparkSigner extends DefaultSparkSigner {
197
214
  constructor(useAddressIndex?: boolean);
198
215
  }
@@ -773,4 +790,4 @@ declare class SspClient {
773
790
  getCoopExitFeeQuote({ leafExternalIds, withdrawalAddress, }: CoopExitFeeQuoteInput): Promise<CoopExitFeeQuote | null>;
774
791
  }
775
792
 
776
- export { splitSecretWithProofs as $, SparkLeavesSwapRequestStatus as A, BitcoinNetwork as B, type ClaimStaticDepositOutput as C, type SparkTransferToLeavesConnection as D, ExitSpeed as E, type StaticDepositQuoteInput as F, type GetChallengeOutput as G, type StaticDepositQuoteOutput as H, type Invoice as I, type SwapLeaf as J, type VerifiableSecretShare as K, type Leaf as L, bigIntToPrivateKey as M, computerLagrangeCoefficients as N, evaluatePolynomial as O, type PageInfo as P, fieldDiv as Q, type RequestCoopExitInput as R, SparkCoopExitRequestStatus as S, Transfer as T, type UserLeafInput as U, type VerifyChallengeOutput as V, generatePolynomialForSecretSharing as W, getRandomBigInt as X, modInverse as Y, recoverSecret as Z, splitSecret as _, type CompleteCoopExitInput as a, validateShare as a0, type SparkSigner as a1, type MayHaveSspClientOptions as a2, type SspClientOptions as a3, type HasSspClientOptions as a4, type KeyDerivation as a5, type SigningCommitment as a6, type SigningNonce as a7, SspClient as a8, DefaultSparkSigner as a9, TaprootSparkSigner as aa, TaprootOutputKeysGenerator as ab, KeyDerivationType as ac, type SignFrostParams as ad, type AggregateFrostParams as ae, type SplitSecretWithProofsParams as af, type DerivedHDKey as ag, type KeyPair as ah, type CompleteLeavesSwapInput as b, type CoopExitFeeEstimate as c, type CoopExitFeeEstimatesInput as d, type CoopExitFeeEstimatesOutput as e, type CoopExitFeeQuote as f, getCoopExitFeeQuoteQuery as g, type CoopExitFeeQuoteInput as h, type CoopExitRequest as i, getCoopExitRequestQuery as j, type CurrencyAmount as k, CurrencyUnit as l, type LeavesSwapFeeEstimateOutput as m, getLeavesSwapRequestQuery as n, type LeavesSwapRequest as o, getLightningReceiveRequestQuery as p, type LightningReceiveRequest as q, LightningReceiveRequestStatus as r, type LightningSendFeeEstimateInput as s, type LightningSendFeeEstimateOutput as t, getLightningSendRequestQuery as u, type LightningSendRequest as v, LightningSendRequestStatus as w, type RequestLeavesSwapInput as x, type RequestLightningReceiveInput as y, type RequestLightningSendInput as z };
793
+ export { splitSecretWithProofs as $, SparkLeavesSwapRequestStatus as A, BitcoinNetwork as B, type ClaimStaticDepositOutput as C, type SparkTransferToLeavesConnection as D, ExitSpeed as E, type StaticDepositQuoteInput as F, type GetChallengeOutput as G, type StaticDepositQuoteOutput as H, type Invoice as I, type SwapLeaf as J, type VerifiableSecretShare as K, type Leaf as L, bigIntToPrivateKey as M, computerLagrangeCoefficients as N, evaluatePolynomial as O, type PageInfo as P, fieldDiv as Q, type RequestCoopExitInput as R, SparkCoopExitRequestStatus as S, Transfer as T, type UserLeafInput as U, type VerifyChallengeOutput as V, generatePolynomialForSecretSharing as W, getRandomBigInt as X, modInverse as Y, recoverSecret as Z, splitSecret as _, type CompleteCoopExitInput as a, validateShare as a0, type SparkSigner as a1, DefaultSparkSigner as a2, type MayHaveSspClientOptions as a3, type SspClientOptions as a4, type HasSspClientOptions as a5, type KeyDerivation as a6, type SigningCommitmentWithOptionalNonce as a7, type SigningNonce as a8, type SigningCommitment as a9, SspClient as aa, TaprootOutputKeysGenerator as ab, TaprootSparkSigner as ac, UnsafeStatelessSparkSigner as ad, KeyDerivationType as ae, type SignFrostParams as af, type AggregateFrostParams as ag, type SplitSecretWithProofsParams as ah, type DerivedHDKey as ai, type KeyPair as aj, type CompleteLeavesSwapInput as b, type CoopExitFeeEstimate as c, type CoopExitFeeEstimatesInput as d, type CoopExitFeeEstimatesOutput as e, type CoopExitFeeQuote as f, getCoopExitFeeQuoteQuery as g, type CoopExitFeeQuoteInput as h, type CoopExitRequest as i, getCoopExitRequestQuery as j, type CurrencyAmount as k, CurrencyUnit as l, type LeavesSwapFeeEstimateOutput as m, getLeavesSwapRequestQuery as n, type LeavesSwapRequest as o, getLightningReceiveRequestQuery as p, type LightningReceiveRequest as q, LightningReceiveRequestStatus as r, type LightningSendFeeEstimateInput as s, type LightningSendFeeEstimateOutput as t, getLightningSendRequestQuery as u, type LightningSendRequest as v, LightningSendRequestStatus as w, type RequestLeavesSwapInput as x, type RequestLightningReceiveInput as y, type RequestLightningSendInput as z };