@buildonspark/spark-sdk 0.2.0 → 0.2.2

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 (57) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{chunk-UDK3EBE5.js → chunk-2TUM3R6C.js} +132 -24
  3. package/dist/{chunk-XYTKKLCV.js → chunk-S2AL73MZ.js} +1 -1
  4. package/dist/{client-DKbwpcnl.d.ts → client-CGTRS23n.d.ts} +21 -4
  5. package/dist/{client-Drs5Lapg.d.cts → client-CcYzmpmj.d.cts} +21 -4
  6. package/dist/debug.cjs +73 -24
  7. package/dist/debug.d.cts +3 -3
  8. package/dist/debug.d.ts +3 -3
  9. package/dist/debug.js +1 -1
  10. package/dist/graphql/objects/index.d.cts +2 -2
  11. package/dist/graphql/objects/index.d.ts +2 -2
  12. package/dist/index.cjs +133 -24
  13. package/dist/index.d.cts +3 -3
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +4 -2
  16. package/dist/index.node.cjs +135 -28
  17. package/dist/index.node.d.cts +4 -4
  18. package/dist/index.node.d.ts +4 -4
  19. package/dist/index.node.js +3 -1
  20. package/dist/native/index.cjs +77 -27
  21. package/dist/native/index.d.cts +10 -6
  22. package/dist/native/index.d.ts +10 -6
  23. package/dist/native/index.js +77 -27
  24. package/dist/{spark-wallet-CF8Oxjqs.d.ts → spark-wallet-B_96y9BS.d.ts} +4 -4
  25. package/dist/{spark-wallet-DOLSa3oF.d.cts → spark-wallet-CHwKQYJu.d.cts} +4 -4
  26. package/dist/tests/test-utils.cjs +76 -9
  27. package/dist/tests/test-utils.d.cts +7 -3
  28. package/dist/tests/test-utils.d.ts +7 -3
  29. package/dist/tests/test-utils.js +10 -3
  30. package/dist/types/index.d.cts +1 -1
  31. package/dist/types/index.d.ts +1 -1
  32. package/dist/{xchain-address-C2xMs9nz.d.cts → xchain-address-D5MIHCDL.d.cts} +2 -2
  33. package/dist/{xchain-address-Ckto9oEz.d.ts → xchain-address-DLbW1iDh.d.ts} +2 -2
  34. package/package.json +2 -2
  35. package/src/index.node.ts +6 -6
  36. package/src/index.ts +5 -5
  37. package/src/services/connection.ts +3 -3
  38. package/src/services/coop-exit.ts +1 -1
  39. package/src/services/deposit.ts +2 -2
  40. package/src/services/signing.ts +1 -1
  41. package/src/services/token-transactions.ts +48 -0
  42. package/src/services/transfer.ts +25 -9
  43. package/src/services/tree-creation.ts +10 -7
  44. package/src/signer/signer.react-native.ts +4 -3
  45. package/src/signer/signer.ts +84 -6
  46. package/src/signer/types.ts +7 -1
  47. package/src/spark-wallet/spark-wallet.ts +1 -1
  48. package/src/tests/integration/coop-exit.test.ts +5 -3
  49. package/src/tests/integration/deposit.test.ts +20 -10
  50. package/src/tests/integration/lightning.test.ts +13 -7
  51. package/src/tests/integration/message-signing.test.ts +10 -7
  52. package/src/tests/integration/swap.test.ts +8 -4
  53. package/src/tests/integration/transfer.test.ts +25 -11
  54. package/src/tests/integration/wallet.test.ts +9 -4
  55. package/src/tests/test-utils.ts +10 -1
  56. package/src/tests/token-identifier.test.ts +5 -5
  57. package/src/utils/token-identifier.ts +10 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @buildonspark/spark-sdk
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Export stateless signer from signer.ts
8
+
9
+ ## 0.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - tokens changes
14
+ - Bech32mTokenIdentifier prefix change from "btk" -> "btkn"
15
+
16
+ - Updated dependencies
17
+ - @buildonspark/lrc20-sdk@0.0.60
18
+
3
19
  ## 0.2.0
4
20
 
5
21
  ### Minor Changes
@@ -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.0" : "unknown";
580
+ var packageVersion = true ? "0.2.2" : "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) {
@@ -3425,11 +3486,11 @@ function collectResponses(responses) {
3425
3486
  // src/utils/token-identifier.ts
3426
3487
  import { bech32m as bech32m2 } from "@scure/base";
3427
3488
  var Bech32mTokenIdentifierTokenIdentifierNetworkPrefix = {
3428
- MAINNET: "btk",
3429
- REGTEST: "btkrt",
3430
- TESTNET: "btkt",
3431
- SIGNET: "btks",
3432
- LOCAL: "btkl"
3489
+ MAINNET: "btkn",
3490
+ REGTEST: "btknrt",
3491
+ TESTNET: "btknt",
3492
+ SIGNET: "btkns",
3493
+ LOCAL: "btknl"
3433
3494
  };
3434
3495
  function encodeBech32mTokenIdentifier(payload) {
3435
3496
  try {
@@ -5348,6 +5409,23 @@ var TokenTransactionService = class {
5348
5409
  signature: ownerSignature,
5349
5410
  inputIndex: 0
5350
5411
  });
5412
+ } else if (tokenTransaction.tokenInputs.$case === "createInput") {
5413
+ const issuerPublicKey = tokenTransaction.tokenInputs.createInput.issuerPublicKey;
5414
+ if (!issuerPublicKey) {
5415
+ throw new ValidationError("Invalid create input", {
5416
+ field: "issuerPublicKey",
5417
+ value: null,
5418
+ expected: "Non-null issuer public key"
5419
+ });
5420
+ }
5421
+ const ownerSignature = await this.signMessageWithKey(
5422
+ partialTokenTransactionHash,
5423
+ issuerPublicKey
5424
+ );
5425
+ ownerSignaturesWithIndex.push({
5426
+ signature: ownerSignature,
5427
+ inputIndex: 0
5428
+ });
5351
5429
  } else if (tokenTransaction.tokenInputs.$case === "transferInput") {
5352
5430
  if (!outputsToSpendSigningPublicKeys || !outputsToSpendCommitments) {
5353
5431
  throw new ValidationError("Invalid transfer input", {
@@ -5848,6 +5926,28 @@ var TokenTransactionService = class {
5848
5926
  signature: ownerSignature,
5849
5927
  inputIndex: 0
5850
5928
  });
5929
+ } else if (finalTokenTransaction.tokenInputs.$case === "createInput") {
5930
+ const issuerPublicKey = finalTokenTransaction.tokenInputs.createInput.issuerPublicKey;
5931
+ if (!issuerPublicKey) {
5932
+ throw new ValidationError("Invalid create input", {
5933
+ field: "issuerPublicKey",
5934
+ value: null,
5935
+ expected: "Non-null issuer public key"
5936
+ });
5937
+ }
5938
+ const payload = {
5939
+ finalTokenTransactionHash,
5940
+ operatorIdentityPublicKey: hexToBytes6(operator.identityPublicKey)
5941
+ };
5942
+ const payloadHash = await hashOperatorSpecificTokenTransactionSignablePayload(payload);
5943
+ const ownerSignature = await this.signMessageWithKey(
5944
+ payloadHash,
5945
+ issuerPublicKey
5946
+ );
5947
+ ttxoSignatures.push({
5948
+ signature: ownerSignature,
5949
+ inputIndex: 0
5950
+ });
5851
5951
  } else if (finalTokenTransaction.tokenInputs.$case === "transferInput") {
5852
5952
  const transferInput = finalTokenTransaction.tokenInputs.transferInput;
5853
5953
  for (let i = 0; i < transferInput.outputsToSpend.length; i++) {
@@ -7400,6 +7500,13 @@ var DEFAULT_EXPIRY_TIME = 10 * 60 * 1e3;
7400
7500
  function initialSequence() {
7401
7501
  return 1 << 30 | INITIAL_TIME_LOCK2;
7402
7502
  }
7503
+ function getSigningJobProto(signingJob) {
7504
+ return {
7505
+ signingPublicKey: signingJob.signingPublicKey,
7506
+ rawTx: signingJob.rawTx,
7507
+ signingNonceCommitment: signingJob.signingNonceCommitment.commitment
7508
+ };
7509
+ }
7403
7510
  var BaseTransferService = class {
7404
7511
  config;
7405
7512
  connectionManager;
@@ -8026,7 +8133,7 @@ var TransferService = class extends BaseTransferService {
8026
8133
  refundSigningData.keyDerivation
8027
8134
  ),
8028
8135
  rawTx: refundTx.toBytes(),
8029
- signingNonceCommitment: refundNonceCommitmentProto
8136
+ signingNonceCommitment: refundNonceCommitmentProto.commitment
8030
8137
  },
8031
8138
  // TODO: Add direct refund signature
8032
8139
  directRefundTxSigningJob: void 0,
@@ -8338,7 +8445,7 @@ var TransferService = class extends BaseTransferService {
8338
8445
  const response = await sparkClient.refresh_timelock({
8339
8446
  leafId: leaf.id,
8340
8447
  ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
8341
- signingJobs
8448
+ signingJobs: signingJobs.map(getSigningJobProto)
8342
8449
  });
8343
8450
  if (signingJobs.length !== response.signingResults.length) {
8344
8451
  throw Error(
@@ -8504,8 +8611,8 @@ var TransferService = class extends BaseTransferService {
8504
8611
  const response = await sparkClient.extend_leaf({
8505
8612
  leafId: node.id,
8506
8613
  ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
8507
- nodeTxSigningJob: newNodeSigningJob,
8508
- refundTxSigningJob: newRefundSigningJob
8614
+ nodeTxSigningJob: getSigningJobProto(newNodeSigningJob),
8615
+ refundTxSigningJob: getSigningJobProto(newRefundSigningJob)
8509
8616
  });
8510
8617
  if (!response.nodeTxSigningResult || !response.refundTxSigningResult) {
8511
8618
  throw new Error("Signing result does not exist");
@@ -8613,7 +8720,7 @@ var TransferService = class extends BaseTransferService {
8613
8720
  const response = await sparkClient.refresh_timelock({
8614
8721
  leafId: node.id,
8615
8722
  ownerIdentityPublicKey: await this.config.signer.getIdentityPublicKey(),
8616
- signingJobs: [refundSigningJob]
8723
+ signingJobs: [getSigningJobProto(refundSigningJob)]
8617
8724
  });
8618
8725
  if (response.signingResults.length !== 1) {
8619
8726
  throw Error(
@@ -8765,7 +8872,7 @@ var CoopExitService = class extends BaseTransferService {
8765
8872
  leaf.keyDerivation
8766
8873
  ),
8767
8874
  rawTx: refundTx.toBytes(),
8768
- signingNonceCommitment
8875
+ signingNonceCommitment: signingNonceCommitment.commitment
8769
8876
  },
8770
8877
  // TODO: Add direct refund signature
8771
8878
  directRefundTxSigningJob: void 0,
@@ -9398,7 +9505,7 @@ var TreeCreationService = class {
9398
9505
  const signingJob = {
9399
9506
  signingPublicKey: node.signingPublicKey,
9400
9507
  rawTx: tx.toBytes(),
9401
- signingNonceCommitment
9508
+ signingNonceCommitment: signingNonceCommitment.commitment
9402
9509
  };
9403
9510
  internalCreationNode.nodeTxSigningCommitment = signingNonceCommitment;
9404
9511
  internalCreationNode.nodeTxSigningJob = signingJob;
@@ -9427,7 +9534,7 @@ var TreeCreationService = class {
9427
9534
  const childSigningJob = {
9428
9535
  signingPublicKey: node.signingPublicKey,
9429
9536
  rawTx: childTx.toBytes(),
9430
- signingNonceCommitment: childSigningNonceCommitment
9537
+ signingNonceCommitment: childSigningNonceCommitment.commitment
9431
9538
  };
9432
9539
  childCreationNode.nodeTxSigningCommitment = childSigningNonceCommitment;
9433
9540
  childCreationNode.nodeTxSigningJob = childSigningJob;
@@ -9454,7 +9561,7 @@ var TreeCreationService = class {
9454
9561
  const refundSigningJob = {
9455
9562
  signingPublicKey: node.signingPublicKey,
9456
9563
  rawTx: refundTx.toBytes(),
9457
- signingNonceCommitment: refundSigningNonceCommitment
9564
+ signingNonceCommitment: refundSigningNonceCommitment.commitment
9458
9565
  };
9459
9566
  childCreationNode.refundTxSigningCommitment = refundSigningNonceCommitment;
9460
9567
  childCreationNode.refundTxSigningJob = refundSigningJob;
@@ -9489,7 +9596,7 @@ var TreeCreationService = class {
9489
9596
  const rootNodeSigningJob = {
9490
9597
  signingPublicKey: root.signingPublicKey,
9491
9598
  rawTx: rootNodeTx.toBytes(),
9492
- signingNonceCommitment: rootNodeSigningCommitment
9599
+ signingNonceCommitment: rootNodeSigningCommitment.commitment
9493
9600
  };
9494
9601
  const rootCreationNode = {
9495
9602
  nodeTxSigningJob: rootNodeSigningJob,
@@ -9721,7 +9828,7 @@ var SigningService = class {
9721
9828
  leaf.keyDerivation
9722
9829
  ),
9723
9830
  rawTx: refundTx.toBytes(),
9724
- signingNonceCommitment: signingCommitment,
9831
+ signingNonceCommitment: signingCommitment.commitment,
9725
9832
  userSignature: signingResult,
9726
9833
  signingCommitments: {
9727
9834
  signingCommitments: signingNonceCommitments
@@ -10864,7 +10971,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
10864
10971
  const signingJob = {
10865
10972
  rawTx: tx.toBytes(),
10866
10973
  signingPublicKey: await this.config.signer.getStaticDepositSigningKey(0),
10867
- signingNonceCommitment
10974
+ signingNonceCommitment: signingNonceCommitment.commitment
10868
10975
  };
10869
10976
  const message = await this.getStaticDepositSigningPayload(
10870
10977
  depositTransactionId,
@@ -13453,6 +13560,7 @@ export {
13453
13560
  MultisigReceiptInput,
13454
13561
  TaprootOutputKeysGenerator,
13455
13562
  DefaultSparkSigner,
13563
+ UnsafeStatelessSparkSigner,
13456
13564
  TaprootSparkSigner,
13457
13565
  Network2 as Network,
13458
13566
  NetworkToProto,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  setCrypto
3
- } from "./chunk-UDK3EBE5.js";
3
+ } from "./chunk-2TUM3R6C.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 };