@babylonlabs-io/ts-sdk 0.73.0 → 0.74.1

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 (145) hide show
  1. package/dist/{PeginManager-E-UHA1un.cjs → PeginManager-DEByBX5R.cjs} +2 -2
  2. package/dist/{PeginManager-E-UHA1un.cjs.map → PeginManager-DEByBX5R.cjs.map} +1 -1
  3. package/dist/{PeginManager-C9RPOd0L.js → PeginManager-DNimKlmw.js} +11 -11
  4. package/dist/{PeginManager-C9RPOd0L.js.map → PeginManager-DNimKlmw.js.map} +1 -1
  5. package/dist/{bip322Verify-D6sBBUHE.js → bip322Verify-DSco3Yhl.js} +2 -2
  6. package/dist/{bip322Verify-D6sBBUHE.js.map → bip322Verify-DSco3Yhl.js.map} +1 -1
  7. package/dist/buildAndBroadcastReclaim-Cqc6Jiqk.cjs +2 -0
  8. package/dist/{buildAndBroadcastReclaim-U-PyFfDg.cjs.map → buildAndBroadcastReclaim-Cqc6Jiqk.cjs.map} +1 -1
  9. package/dist/{buildAndBroadcastReclaim-BXclIcu_.js → buildAndBroadcastReclaim-DCGcupg7.js} +6 -6
  10. package/dist/{buildAndBroadcastReclaim-BXclIcu_.js.map → buildAndBroadcastReclaim-DCGcupg7.js.map} +1 -1
  11. package/dist/constants-BTZdyOuk.cjs +2 -0
  12. package/dist/constants-BTZdyOuk.cjs.map +1 -0
  13. package/dist/constants-D5vORbQE.js +29 -0
  14. package/dist/constants-D5vORbQE.js.map +1 -0
  15. package/dist/fundPeginTransaction-54-Rwb2k.cjs +2 -0
  16. package/dist/fundPeginTransaction-54-Rwb2k.cjs.map +1 -0
  17. package/dist/fundPeginTransaction-CwhRbCQC.js +88 -0
  18. package/dist/fundPeginTransaction-CwhRbCQC.js.map +1 -0
  19. package/dist/{index-Cs7_Evtk.cjs → index-CK1Xvq4K.cjs} +2 -2
  20. package/dist/{index-Cs7_Evtk.cjs.map → index-CK1Xvq4K.cjs.map} +1 -1
  21. package/dist/{index-LgmJhdEN.js → index-DQ5bfoT3.js} +2 -2
  22. package/dist/{index-LgmJhdEN.js.map → index-DQ5bfoT3.js.map} +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +166 -161
  25. package/dist/noPayout-4RZB2g1e.cjs +2 -0
  26. package/dist/noPayout-4RZB2g1e.cjs.map +1 -0
  27. package/dist/noPayout-DiGr4eas.js +361 -0
  28. package/dist/noPayout-DiGr4eas.js.map +1 -0
  29. package/dist/{parseFundingOutpoints-B67CoXpF.js → parseFundingOutpoints-BQWvINfm.js} +2 -2
  30. package/dist/{parseFundingOutpoints-B67CoXpF.js.map → parseFundingOutpoints-BQWvINfm.js.map} +1 -1
  31. package/dist/pegin-registration-client-CXK3B_D1.js +882 -0
  32. package/dist/pegin-registration-client-CXK3B_D1.js.map +1 -0
  33. package/dist/pegin-registration-client-DLsMNm8Z.cjs +2 -0
  34. package/dist/pegin-registration-client-DLsMNm8Z.cjs.map +1 -0
  35. package/dist/{primeVpAuth-DBHohVKM.cjs → primeVpAuth-BOGKniTl.cjs} +2 -2
  36. package/dist/{primeVpAuth-DBHohVKM.cjs.map → primeVpAuth-BOGKniTl.cjs.map} +1 -1
  37. package/dist/{primeVpAuth-DvaD45q_.js → primeVpAuth-DdfHSC53.js} +4 -4
  38. package/dist/{primeVpAuth-DvaD45q_.js.map → primeVpAuth-DdfHSC53.js.map} +1 -1
  39. package/dist/{psbtInputFields-BIxBpPj2.cjs → psbtInputFields-BrV_ZfL_.cjs} +2 -2
  40. package/dist/{psbtInputFields-BIxBpPj2.cjs.map → psbtInputFields-BrV_ZfL_.cjs.map} +1 -1
  41. package/dist/{psbtInputFields-B3e05Xe6.js → psbtInputFields-CCVyaQMi.js} +2 -2
  42. package/dist/{psbtInputFields-B3e05Xe6.js.map → psbtInputFields-CCVyaQMi.js.map} +1 -1
  43. package/dist/secp256k1-D-H9jmd7.js +1766 -0
  44. package/dist/secp256k1-D-H9jmd7.js.map +1 -0
  45. package/dist/secp256k1-DDHQ1_za.cjs +2 -0
  46. package/dist/secp256k1-DDHQ1_za.cjs.map +1 -0
  47. package/dist/{sha2-CrlWM5S8.js → sha2-CLpQd0Rd.js} +8 -8
  48. package/dist/{sha2-CrlWM5S8.js.map → sha2-CLpQd0Rd.js.map} +1 -1
  49. package/dist/{signPsbtsWithFallback-DMSpIQWH.cjs → signPsbtsWithFallback-DtwzL5AA.cjs} +2 -2
  50. package/dist/{signPsbtsWithFallback-DMSpIQWH.cjs.map → signPsbtsWithFallback-DtwzL5AA.cjs.map} +1 -1
  51. package/dist/{signPsbtsWithFallback-0VBALhjS.js → signPsbtsWithFallback-f7QLp0q8.js} +4 -4
  52. package/dist/{signPsbtsWithFallback-0VBALhjS.js.map → signPsbtsWithFallback-f7QLp0q8.js.map} +1 -1
  53. package/dist/tbv/core/clients/eth/index.cjs +1 -1
  54. package/dist/tbv/core/clients/eth/index.js +3 -3
  55. package/dist/tbv/core/clients/index.cjs +1 -1
  56. package/dist/tbv/core/clients/index.js +5 -5
  57. package/dist/tbv/core/clients/vault-provider/status/index.cjs +1 -1
  58. package/dist/tbv/core/clients/vault-provider/status/index.js +1 -1
  59. package/dist/tbv/core/index.cjs +1 -1
  60. package/dist/tbv/core/index.d.ts +3 -0
  61. package/dist/tbv/core/index.d.ts.map +1 -1
  62. package/dist/tbv/core/index.js +159 -154
  63. package/dist/tbv/core/managers/index.cjs +1 -1
  64. package/dist/tbv/core/managers/index.js +2 -2
  65. package/dist/tbv/core/pegin-fingerprint/__tests__/peginFingerprint.golden.test.d.ts +62 -0
  66. package/dist/tbv/core/pegin-fingerprint/__tests__/peginFingerprint.golden.test.d.ts.map +1 -0
  67. package/dist/tbv/core/pegin-fingerprint/__tests__/peginFingerprint.test.d.ts +15 -0
  68. package/dist/tbv/core/pegin-fingerprint/__tests__/peginFingerprint.test.d.ts.map +1 -0
  69. package/dist/tbv/core/pegin-fingerprint/index.d.ts +14 -0
  70. package/dist/tbv/core/pegin-fingerprint/index.d.ts.map +1 -0
  71. package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts +141 -0
  72. package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts.map +1 -0
  73. package/dist/tbv/core/primitives/index.cjs +1 -1
  74. package/dist/tbv/core/primitives/index.js +4 -4
  75. package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts +5 -6
  76. package/dist/tbv/core/primitives/psbt/__tests__/assertPeginTxShape.test.d.ts.map +1 -1
  77. package/dist/tbv/core/primitives/psbt/__tests__/assertWasmPeginSizing.test.d.ts +2 -2
  78. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts +36 -14
  79. package/dist/tbv/core/primitives/psbt/assertWasmPeginSizing.d.ts.map +1 -1
  80. package/dist/tbv/core/primitives/psbt/constants.d.ts +39 -0
  81. package/dist/tbv/core/primitives/psbt/constants.d.ts.map +1 -1
  82. package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
  83. package/dist/tbv/core/primitives/psbt/peginInput.d.ts.map +1 -1
  84. package/dist/tbv/core/primitives/psbt/refund.d.ts.map +1 -1
  85. package/dist/tbv/core/services/index.cjs +1 -1
  86. package/dist/tbv/core/services/index.js +2 -2
  87. package/dist/tbv/core/utils/fee/constants.d.ts +4 -4
  88. package/dist/tbv/core/utils/index.cjs +1 -1
  89. package/dist/tbv/core/utils/index.js +2 -2
  90. package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts.map +1 -1
  91. package/dist/tbv/core/vault-secrets/index.js +1 -1
  92. package/dist/tbv/index.cjs +1 -1
  93. package/dist/tbv/index.js +159 -154
  94. package/dist/test/setup.browser.d.ts +2 -0
  95. package/dist/test/setup.browser.d.ts.map +1 -0
  96. package/dist/testing/index.js +1 -1
  97. package/dist/{toRefundInputs-BkcFhvDp.js → toRefundInputs-BNSXIymn.js} +238 -140
  98. package/dist/toRefundInputs-BNSXIymn.js.map +1 -0
  99. package/dist/toRefundInputs-meTyor7r.cjs +2 -0
  100. package/dist/toRefundInputs-meTyor7r.cjs.map +1 -0
  101. package/dist/{types-DSlcXtog.cjs → types-BzSOthHH.cjs} +2 -2
  102. package/dist/{types-DSlcXtog.cjs.map → types-BzSOthHH.cjs.map} +1 -1
  103. package/dist/{types-CPDLZm3l.js → types-C5DyrC8F.js} +2 -2
  104. package/dist/{types-CPDLZm3l.js.map → types-C5DyrC8F.js.map} +1 -1
  105. package/dist/verifyKeyPathSchnorrSignature-BVtNwgK6.js +360 -0
  106. package/dist/verifyKeyPathSchnorrSignature-BVtNwgK6.js.map +1 -0
  107. package/dist/verifyKeyPathSchnorrSignature-BjB8Znly.cjs +2 -0
  108. package/dist/verifyKeyPathSchnorrSignature-BjB8Znly.cjs.map +1 -0
  109. package/dist/verifyScriptPathSchnorrSignature-D_epga4j.js +1140 -0
  110. package/dist/verifyScriptPathSchnorrSignature-D_epga4j.js.map +1 -0
  111. package/dist/verifyScriptPathSchnorrSignature-DaRqvEgW.cjs +2 -0
  112. package/dist/verifyScriptPathSchnorrSignature-DaRqvEgW.cjs.map +1 -0
  113. package/package.json +5 -2
  114. package/dist/buildAndBroadcastReclaim-U-PyFfDg.cjs +0 -2
  115. package/dist/constants-Bh38W9mq.cjs +0 -2
  116. package/dist/constants-Bh38W9mq.cjs.map +0 -1
  117. package/dist/constants-CPzppOdq.js +0 -17
  118. package/dist/constants-CPzppOdq.js.map +0 -1
  119. package/dist/fundPeginTransaction-B2wyjqp0.js +0 -83
  120. package/dist/fundPeginTransaction-B2wyjqp0.js.map +0 -1
  121. package/dist/fundPeginTransaction-BLD8FRL9.cjs +0 -2
  122. package/dist/fundPeginTransaction-BLD8FRL9.cjs.map +0 -1
  123. package/dist/noPayout-DpGRzidi.js +0 -353
  124. package/dist/noPayout-DpGRzidi.js.map +0 -1
  125. package/dist/noPayout-zEifyecV.cjs +0 -2
  126. package/dist/noPayout-zEifyecV.cjs.map +0 -1
  127. package/dist/pegin-registration-client-6vLk2itL.cjs +0 -2
  128. package/dist/pegin-registration-client-6vLk2itL.cjs.map +0 -1
  129. package/dist/pegin-registration-client-BdRiR8br.js +0 -2635
  130. package/dist/pegin-registration-client-BdRiR8br.js.map +0 -1
  131. package/dist/toRefundInputs-BkcFhvDp.js.map +0 -1
  132. package/dist/toRefundInputs-CatCKniS.cjs +0 -2
  133. package/dist/toRefundInputs-CatCKniS.cjs.map +0 -1
  134. package/dist/vaultCoreVersion-DYfw3qed.cjs +0 -2
  135. package/dist/vaultCoreVersion-DYfw3qed.cjs.map +0 -1
  136. package/dist/vaultCoreVersion-D_fP9P3C.js +0 -10
  137. package/dist/vaultCoreVersion-D_fP9P3C.js.map +0 -1
  138. package/dist/verifyKeyPathSchnorrSignature-BedSbH2D.cjs +0 -2
  139. package/dist/verifyKeyPathSchnorrSignature-BedSbH2D.cjs.map +0 -1
  140. package/dist/verifyKeyPathSchnorrSignature-BrgUJmV0.js +0 -372
  141. package/dist/verifyKeyPathSchnorrSignature-BrgUJmV0.js.map +0 -1
  142. package/dist/verifyScriptPathSchnorrSignature-BfNUSgA7.cjs +0 -2
  143. package/dist/verifyScriptPathSchnorrSignature-BfNUSgA7.cjs.map +0 -1
  144. package/dist/verifyScriptPathSchnorrSignature-Ciq_xZhw.js +0 -951
  145. package/dist/verifyScriptPathSchnorrSignature-Ciq_xZhw.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";function je(t,e){if(!Number.isInteger(t)||t<1||t>65535)throw new Error(`Invalid vaultCoreVersion ${t} from ${e}: expected an integer in [1, 65535].`)}const ct=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Ut(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Kt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ot(t,...e){if(!Ut(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function he(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Kt(t.outputLen),Kt(t.blockLen)}function vt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ye(t,e){ot(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function St(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function qt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Y(t,e){return t<<32-e|t>>>e}const ge=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ze=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ft(t){if(ot(t),ge)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=ze[t[r]];return e}const D={_0:48,_9:57,A:65,F:70,a:97,f:102};function ne(t){if(t>=D._0&&t<=D._9)return t-D._0;if(t>=D.A&&t<=D.F)return t-(D.A-10);if(t>=D.a&&t<=D.f)return t-(D.a-10)}function At(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(ge)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){const i=ne(t.charCodeAt(s)),c=ne(t.charCodeAt(s+1));if(i===void 0||c===void 0){const f=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+s)}n[o]=i*16+c}return n}function we(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Xt(t){return typeof t=="string"&&(t=we(t)),ot(t),t}function z(...t){let e=0;for(let n=0;n<t.length;n++){const o=t[n];ot(o),e+=o.length}const r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){const s=t[n];r.set(s,o),o+=s.length}return r}class ye{}function De(t){const e=n=>t().update(Xt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ht(t=32){if(ct&&typeof ct.getRandomValues=="function")return ct.getRandomValues(new Uint8Array(t));if(ct&&typeof ct.randomBytes=="function")return Uint8Array.from(ct.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}function Xe(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),c=Number(r&s),f=n?4:0,g=n?0:4;t.setUint32(e+f,i,n),t.setUint32(e+g,c,n)}function Ge(t,e,r){return t&e^~t&r}function Fe(t,e,r){return t&e^t&r^e&r}class Pe extends ye{constructor(e,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=qt(this.buffer)}update(e){vt(this),e=Xt(e),ot(e);const{view:r,buffer:n,blockLen:o}=this,s=e.length;for(let i=0;i<s;){const c=Math.min(o-this.pos,s-i);if(c===o){const f=qt(e);for(;o<=s-i;i+=o)this.process(f,i);continue}n.set(e.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){vt(this),Ye(e,this),this.finished=!0;const{buffer:r,view:n,blockLen:o,isLE:s}=this;let{pos:i}=this;r[i++]=128,St(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let b=i;b<o;b++)r[b]=0;Xe(n,o-8,BigInt(this.length*8),s),this.process(n,0);const c=qt(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=f/4,y=this.get();if(g>y.length)throw new Error("_sha2: outputLen bigger than state");for(let b=0;b<g;b++)c.setUint32(4*b,y[b],s)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return e.destroyed=i,e.finished=s,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const P=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),We=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),W=new Uint32Array(64);class Qe extends Pe{constructor(e=32){super(64,e,8,!1),this.A=P[0]|0,this.B=P[1]|0,this.C=P[2]|0,this.D=P[3]|0,this.E=P[4]|0,this.F=P[5]|0,this.G=P[6]|0,this.H=P[7]|0}get(){const{A:e,B:r,C:n,D:o,E:s,F:i,G:c,H:f}=this;return[e,r,n,o,s,i,c,f]}set(e,r,n,o,s,i,c,f){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=f|0}process(e,r){for(let b=0;b<16;b++,r+=4)W[b]=e.getUint32(r,!1);for(let b=16;b<64;b++){const u=W[b-15],l=W[b-2],p=Y(u,7)^Y(u,18)^u>>>3,B=Y(l,17)^Y(l,19)^l>>>10;W[b]=B+W[b-7]+p+W[b-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:f,G:g,H:y}=this;for(let b=0;b<64;b++){const u=Y(c,6)^Y(c,11)^Y(c,25),l=y+u+Ge(c,f,g)+We[b]+W[b]|0,B=(Y(n,2)^Y(n,13)^Y(n,22))+Fe(n,o,s)|0;y=g,g=f,f=c,c=i+l|0,i=s,s=o,o=n,n=l+B|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,f=f+this.F|0,g=g+this.G|0,y=y+this.H|0,this.set(n,o,s,i,c,f,g,y)}roundClean(){St(W)}destroy(){this.set(0,0,0,0,0,0,0,0),St(this.buffer)}}const $t=De(()=>new Qe);class be extends ye{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,he(e);const n=Xt(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),St(s)}update(e){return vt(this),this.iHash.update(e),this}digestInto(e){vt(this),ot(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const me=(t,e,r)=>new be(t,e).update(r).digest();me.create=(t,e)=>new be(t,e);const Gt=BigInt(0),Mt=BigInt(1);function It(t,e=""){if(typeof t!="boolean"){const r=e&&`"${e}"`;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function tt(t,e,r=""){const n=Ut(t),o=t==null?void 0:t.length,s=e!==void 0;if(!n||s&&o!==e){const i=r&&`"${r}" `,c=s?` of length ${e}`:"",f=n?`length=${o}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+c+", got "+f)}return t}function xt(t){const e=t.toString(16);return e.length&1?"0"+e:e}function pe(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Gt:BigInt("0x"+t)}function dt(t){return pe(ft(t))}function Ee(t){return ot(t),pe(ft(Uint8Array.from(t).reverse()))}function Ot(t,e){return At(t.toString(16).padStart(e*2,"0"))}function xe(t,e){return Ot(t,e).reverse()}function T(t,e,r){let n;if(typeof e=="string")try{n=At(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Ut(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}const Vt=t=>typeof t=="bigint"&&Gt<=t;function jt(t,e,r){return Vt(t)&&Vt(e)&&Vt(r)&&e<=t&&t<r}function Je(t,e,r,n){if(!jt(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Be(t){let e;for(e=0;t>Gt;t>>=Mt,e+=1);return e}const yt=t=>(Mt<<BigInt(t))-Mt;function tn(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");const n=l=>new Uint8Array(l),o=l=>Uint8Array.of(l);let s=n(t),i=n(t),c=0;const f=()=>{s.fill(1),i.fill(0),c=0},g=(...l)=>r(i,s,...l),y=(l=n(0))=>{i=g(o(0),l),s=g(),l.length!==0&&(i=g(o(1),l),s=g())},b=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let l=0;const p=[];for(;l<e;){s=g();const B=s.slice();p.push(B),l+=s.length}return z(...p)};return(l,p)=>{f(),y(l);let B;for(;!(B=p(b()));)y();return f(),B}}function Ft(t,e,r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(o,s,i){const c=t[o];if(i&&c===void 0)return;const f=typeof c;if(f!==s||c===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${f}`)}Object.entries(e).forEach(([o,s])=>n(o,s,!1)),Object.entries(r).forEach(([o,s])=>n(o,s,!0))}function re(t){const e=new WeakMap;return(r,...n)=>{const o=e.get(r);if(o!==void 0)return o;const s=t(r,...n);return e.set(r,s),s}}const $=BigInt(0),C=BigInt(1),et=BigInt(2),ve=BigInt(3),Se=BigInt(4),Ae=BigInt(5),en=BigInt(7),Ie=BigInt(8),nn=BigInt(9),_e=BigInt(16);function j(t,e){const r=t%e;return r>=$?r:e+r}function M(t,e,r){let n=t;for(;e-- >$;)n*=n,n%=r;return n}function oe(t,e){if(t===$)throw new Error("invert: expected non-zero number");if(e<=$)throw new Error("invert: expected positive modulus, got "+e);let r=j(t,e),n=e,o=$,s=C;for(;r!==$;){const c=n/r,f=n%r,g=o-s*c;n=r,r=f,o=s,s=g}if(n!==C)throw new Error("invert: does not exist");return j(o,e)}function Pt(t,e,r){if(!t.eql(t.sqr(e),r))throw new Error("Cannot find square root")}function Ne(t,e){const r=(t.ORDER+C)/Se,n=t.pow(e,r);return Pt(t,n,e),n}function rn(t,e){const r=(t.ORDER-Ae)/Ie,n=t.mul(e,et),o=t.pow(n,r),s=t.mul(e,o),i=t.mul(t.mul(s,et),o),c=t.mul(s,t.sub(i,t.ONE));return Pt(t,c,e),c}function on(t){const e=bt(t),r=Re(t),n=r(e,e.neg(e.ONE)),o=r(e,n),s=r(e,e.neg(n)),i=(t+en)/_e;return(c,f)=>{let g=c.pow(f,i),y=c.mul(g,n);const b=c.mul(g,o),u=c.mul(g,s),l=c.eql(c.sqr(y),f),p=c.eql(c.sqr(b),f);g=c.cmov(g,y,l),y=c.cmov(u,b,p);const B=c.eql(c.sqr(y),f),R=c.cmov(g,y,B);return Pt(c,R,f),R}}function Re(t){if(t<ve)throw new Error("sqrt is not defined for small field");let e=t-C,r=0;for(;e%et===$;)e/=et,r++;let n=et;const o=bt(t);for(;se(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ne;let s=o.pow(n,e);const i=(e+C)/et;return function(f,g){if(f.is0(g))return g;if(se(f,g)!==1)throw new Error("Cannot find square root");let y=r,b=f.mul(f.ONE,s),u=f.pow(g,e),l=f.pow(g,i);for(;!f.eql(u,f.ONE);){if(f.is0(u))return f.ZERO;let p=1,B=f.sqr(u);for(;!f.eql(B,f.ONE);)if(p++,B=f.sqr(B),p===y)throw new Error("Cannot find square root");const R=C<<BigInt(y-p-1),q=f.pow(b,R);y=p,b=f.sqr(q),u=f.mul(u,b),l=f.mul(l,q)}return l}}function sn(t){return t%Se===ve?Ne:t%Ie===Ae?rn:t%_e===nn?on(t):Re(t)}const cn=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function fn(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=cn.reduce((n,o)=>(n[o]="function",n),e);return Ft(t,r),t}function un(t,e,r){if(r<$)throw new Error("invalid exponent, negatives unsupported");if(r===$)return t.ONE;if(r===C)return e;let n=t.ONE,o=e;for(;r>$;)r&C&&(n=t.mul(n,o)),o=t.sqr(o),r>>=C;return n}function Ue(t,e,r=!1){const n=new Array(e.length).fill(r?t.ZERO:void 0),o=e.reduce((i,c,f)=>t.is0(c)?i:(n[f]=i,t.mul(i,c)),t.ONE),s=t.inv(o);return e.reduceRight((i,c,f)=>t.is0(c)?i:(n[f]=t.mul(i,n[f]),t.mul(i,c)),s),n}function se(t,e){const r=(t.ORDER-C)/et,n=t.pow(e,r),o=t.eql(n,t.ONE),s=t.eql(n,t.ZERO),i=t.eql(n,t.neg(t.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function He(t,e){e!==void 0&&Kt(e);const r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function bt(t,e,r=!1,n={}){if(t<=$)throw new Error("invalid field: expected ORDER > 0, got "+t);let o,s,i=!1,c;if(typeof e=="object"&&e!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");const u=e;u.BITS&&(o=u.BITS),u.sqrt&&(s=u.sqrt),typeof u.isLE=="boolean"&&(r=u.isLE),typeof u.modFromBytes=="boolean"&&(i=u.modFromBytes),c=u.allowedLengths}else typeof e=="number"&&(o=e),n.sqrt&&(s=n.sqrt);const{nBitLength:f,nByteLength:g}=He(t,o);if(g>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let y;const b=Object.freeze({ORDER:t,isLE:r,BITS:f,BYTES:g,MASK:yt(f),ZERO:$,ONE:C,allowedLengths:c,create:u=>j(u,t),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return $<=u&&u<t},is0:u=>u===$,isValidNot0:u=>!b.is0(u)&&b.isValid(u),isOdd:u=>(u&C)===C,neg:u=>j(-u,t),eql:(u,l)=>u===l,sqr:u=>j(u*u,t),add:(u,l)=>j(u+l,t),sub:(u,l)=>j(u-l,t),mul:(u,l)=>j(u*l,t),pow:(u,l)=>un(b,u,l),div:(u,l)=>j(u*oe(l,t),t),sqrN:u=>u*u,addN:(u,l)=>u+l,subN:(u,l)=>u-l,mulN:(u,l)=>u*l,inv:u=>oe(u,t),sqrt:s||(u=>(y||(y=sn(t)),y(b,u))),toBytes:u=>r?xe(u,g):Ot(u,g),fromBytes:(u,l=!0)=>{if(c){if(!c.includes(u.length)||u.length>g)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+u.length);const B=new Uint8Array(g);B.set(u,r?0:B.length-u.length),u=B}if(u.length!==g)throw new Error("Field.fromBytes: expected "+g+" bytes, got "+u.length);let p=r?Ee(u):dt(u);if(i&&(p=j(p,t)),!l&&!b.isValid(p))throw new Error("invalid field element: outside of range 0..ORDER");return p},invertBatch:u=>Ue(b,u),cmov:(u,l,p)=>p?l:u});return Object.freeze(b)}function Oe(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function qe(t){const e=Oe(t);return e+Math.ceil(e/2)}function Ve(t,e,r=!1){const n=t.length,o=Oe(e),s=qe(e);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);const i=r?Ee(t):dt(t),c=j(i,e-C)+C;return r?xe(c,o):Ot(c,o)}const at=BigInt(0),nt=BigInt(1);function _t(t,e){const r=e.negate();return t?r:e}function Lt(t,e){const r=Ue(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function Le(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Zt(t,e){Le(t,e);const r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,s=yt(t),i=BigInt(t);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function ie(t,e,r){const{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r;let c=Number(t&o),f=t>>i;c>n&&(c-=s,f+=nt);const g=e*n,y=g+Math.abs(c)-1,b=c===0,u=c<0,l=e%2!==0;return{nextN:f,offset:y,isZero:b,isNeg:u,isNegF:l,offsetF:g}}function an(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function ln(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}const Tt=new WeakMap,Ze=new WeakMap;function kt(t){return Ze.get(t)||1}function ce(t){if(t!==at)throw new Error("invalid wNAF")}class dn{constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>at;)r&nt&&(n=n.add(o)),o=o.double(),r>>=nt;return n}precomputeWindow(e,r){const{windows:n,windowSize:o}=Zt(r,this.bits),s=[];let i=e,c=i;for(let f=0;f<n;f++){c=i,s.push(c);for(let g=1;g<o;g++)c=c.add(i),s.push(c);i=c.double()}return s}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE;const i=Zt(e,this.bits);for(let c=0;c<i.windows;c++){const{nextN:f,offset:g,isZero:y,isNeg:b,isNegF:u,offsetF:l}=ie(n,c,i);n=f,y?s=s.add(_t(u,r[l])):o=o.add(_t(b,r[g]))}return ce(n),{p:o,f:s}}wNAFUnsafe(e,r,n,o=this.ZERO){const s=Zt(e,this.bits);for(let i=0;i<s.windows&&n!==at;i++){const{nextN:c,offset:f,isZero:g,isNeg:y}=ie(n,i,s);if(n=c,!g){const b=r[f];o=o.add(y?b.negate():b)}}return ce(n),o}getPrecomputes(e,r,n){let o=Tt.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Tt.set(r,o))),o}cached(e,r,n){const o=kt(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){const s=kt(e);return s===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),r,o)}createCache(e,r){Le(r,this.bits),Ze.set(e,r),Tt.delete(e)}hasCache(e){return kt(e)!==1}}function hn(t,e,r,n){let o=e,s=t.ZERO,i=t.ZERO;for(;r>at||n>at;)r&nt&&(s=s.add(o)),n&nt&&(i=i.add(o)),o=o.double(),r>>=nt,n>>=nt;return{p1:s,p2:i}}function gn(t,e,r,n){an(r,t),ln(n,e);const o=r.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,c=Be(BigInt(o));let f=1;c>12?f=c-3:c>4?f=c-2:c>0&&(f=2);const g=yt(f),y=new Array(Number(g)+1).fill(i),b=Math.floor((e.BITS-1)/f)*f;let u=i;for(let l=b;l>=0;l-=f){y.fill(i);for(let B=0;B<s;B++){const R=n[B],q=Number(R>>BigInt(l)&g);y[q]=y[q].add(r[B])}let p=i;for(let B=y.length-1,R=i;B>0;B--)R=R.add(y[B]),p=p.add(R);if(u=u.add(p),l!==0)for(let B=0;B<f;B++)u=u.double()}return u}function fe(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return fn(e),e}else return bt(t,{isLE:r})}function wn(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const f of["p","n","h"]){const g=e[f];if(!(typeof g=="bigint"&&g>at))throw new Error(`CURVE.${f} must be positive bigint`)}const o=fe(e.p,r.Fp,n),s=fe(e.n,r.Fn,n),c=["Gx","Gy","a","b"];for(const f of c)if(!o.isValid(e[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:s}}const ue=(t,e)=>(t+(t>=0?e:-e)/Te)/e;function yn(t,e,r){const[[n,o],[s,i]]=e,c=ue(i*t,r),f=ue(-o*t,r);let g=t-c*n-f*s,y=-c*o-f*i;const b=g<G,u=y<G;b&&(g=-g),u&&(y=-y);const l=yt(Math.ceil(Be(r)/2))+ut;if(g<G||g>=l||y<G||y>=l)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:b,k1:g,k2neg:u,k2:y}}function Yt(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Ct(t,e){const r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return It(r.lowS,"lowS"),It(r.prehash,"prehash"),r.format!==void 0&&Yt(r.format),r}class bn extends Error{constructor(e=""){super(e)}}const X={Err:bn,_tlv:{encode:(t,e)=>{const{Err:r}=X;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");const n=e.length/2,o=xt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");const s=n>127?xt(o.length/2|128):"";return xt(t)+s+o+e},decode(t,e){const{Err:r}=X;let n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const o=e[n++],s=!!(o&128);let i=0;if(!s)i=o;else{const f=o&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");const g=e.subarray(n,n+f);if(g.length!==f)throw new r("tlv.decode: length bytes not complete");if(g[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const y of g)i=i<<8|y;if(n+=f,i<128)throw new r("tlv.decode(long): not minimal encoding")}const c=e.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+i)}}},_int:{encode(t){const{Err:e}=X;if(t<G)throw new e("integer: negative integers are not allowed");let r=xt(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=X;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return dt(t)}},toSig(t){const{Err:e,_int:r,_tlv:n}=X,o=T("signature",t),{v:s,l:i}=n.decode(48,o);if(i.length)throw new e("invalid signature: left bytes after parsing");const{v:c,l:f}=n.decode(2,s),{v:g,l:y}=n.decode(2,f);if(y.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(g)}},hexFromSig(t){const{_tlv:e,_int:r}=X,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),s=n+o;return e.encode(48,s)}},G=BigInt(0),ut=BigInt(1),Te=BigInt(2),Bt=BigInt(3),mn=BigInt(4);function rt(t,e){const{BYTES:r}=t;let n;if(typeof e=="bigint")n=e;else{let o=T("private key",e);try{n=t.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function pn(t,e={}){const r=wn("weierstrass",t,e),{Fp:n,Fn:o}=r;let s=r.CURVE;const{h:i,n:c}=s;Ft(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=e;if(f&&(!n.is0(s.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const g=Ce(n,o);function y(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function b(N,h,d){const{x:a,y:w}=h.toAffine(),m=n.toBytes(a);if(It(d,"isCompressed"),d){y();const v=!n.isOdd(w);return z(ke(v),m)}else return z(Uint8Array.of(4),m,n.toBytes(w))}function u(N){tt(N,void 0,"Point");const{publicKey:h,publicKeyUncompressed:d}=g,a=N.length,w=N[0],m=N.subarray(1);if(a===h&&(w===2||w===3)){const v=n.fromBytes(m);if(!n.isValid(v))throw new Error("bad point: is not on curve, wrong x");const x=B(v);let E;try{E=n.sqrt(x)}catch(L){const U=L instanceof Error?": "+L.message:"";throw new Error("bad point: is not on curve, sqrt error"+U)}y();const S=n.isOdd(E);return(w&1)===1!==S&&(E=n.neg(E)),{x:v,y:E}}else if(a===d&&w===4){const v=n.BYTES,x=n.fromBytes(m.subarray(0,v)),E=n.fromBytes(m.subarray(v,v*2));if(!R(x,E))throw new Error("bad point: is not on curve");return{x,y:E}}else throw new Error(`bad point: got length ${a}, expected compressed=${h} or uncompressed=${d}`)}const l=e.toBytes||b,p=e.fromBytes||u;function B(N){const h=n.sqr(N),d=n.mul(h,N);return n.add(n.add(d,n.mul(N,s.a)),s.b)}function R(N,h){const d=n.sqr(h),a=B(N);return n.eql(d,a)}if(!R(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const q=n.mul(n.pow(s.a,Bt),mn),gt=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(q,gt)))throw new Error("bad curve params: a or b");function V(N,h,d=!1){if(!n.isValid(h)||d&&n.is0(h))throw new Error(`bad point coordinate ${N}`);return h}function Q(N){if(!(N instanceof I))throw new Error("ProjectivePoint expected")}function F(N){if(!f||!f.basises)throw new Error("no endo");return yn(N,f.basises,o.ORDER)}const st=re((N,h)=>{const{X:d,Y:a,Z:w}=N;if(n.eql(w,n.ONE))return{x:d,y:a};const m=N.is0();h==null&&(h=m?n.ONE:n.inv(w));const v=n.mul(d,h),x=n.mul(a,h),E=n.mul(w,h);if(m)return{x:n.ZERO,y:n.ZERO};if(!n.eql(E,n.ONE))throw new Error("invZ was invalid");return{x:v,y:x}}),mt=re(N=>{if(N.is0()){if(e.allowInfinityPoint&&!n.is0(N.Y))return;throw new Error("bad point: ZERO")}const{x:h,y:d}=N.toAffine();if(!n.isValid(h)||!n.isValid(d))throw new Error("bad point: x or y not field elements");if(!R(h,d))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function it(N,h,d,a,w){return d=new I(n.mul(d.X,N),d.Y,d.Z),h=_t(a,h),d=_t(w,d),h.add(d)}class I{constructor(h,d,a){this.X=V("x",h),this.Y=V("y",d,!0),this.Z=V("z",a),Object.freeze(this)}static CURVE(){return s}static fromAffine(h){const{x:d,y:a}=h||{};if(!h||!n.isValid(d)||!n.isValid(a))throw new Error("invalid affine point");if(h instanceof I)throw new Error("projective point not allowed");return n.is0(d)&&n.is0(a)?I.ZERO:new I(d,a,n.ONE)}static fromBytes(h){const d=I.fromAffine(p(tt(h,void 0,"point")));return d.assertValidity(),d}static fromHex(h){return I.fromBytes(T("pointHex",h))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(h=8,d=!0){return J.createCache(this,h),d||this.multiply(Bt),this}assertValidity(){mt(this)}hasEvenY(){const{y:h}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(h)}equals(h){Q(h);const{X:d,Y:a,Z:w}=this,{X:m,Y:v,Z:x}=h,E=n.eql(n.mul(d,x),n.mul(m,w)),S=n.eql(n.mul(a,x),n.mul(v,w));return E&&S}negate(){return new I(this.X,n.neg(this.Y),this.Z)}double(){const{a:h,b:d}=s,a=n.mul(d,Bt),{X:w,Y:m,Z:v}=this;let x=n.ZERO,E=n.ZERO,S=n.ZERO,A=n.mul(w,w),L=n.mul(m,m),U=n.mul(v,v),_=n.mul(w,m);return _=n.add(_,_),S=n.mul(w,v),S=n.add(S,S),x=n.mul(h,S),E=n.mul(a,U),E=n.add(x,E),x=n.sub(L,E),E=n.add(L,E),E=n.mul(x,E),x=n.mul(_,x),S=n.mul(a,S),U=n.mul(h,U),_=n.sub(A,U),_=n.mul(h,_),_=n.add(_,S),S=n.add(A,A),A=n.add(S,A),A=n.add(A,U),A=n.mul(A,_),E=n.add(E,A),U=n.mul(m,v),U=n.add(U,U),A=n.mul(U,_),x=n.sub(x,A),S=n.mul(U,L),S=n.add(S,S),S=n.add(S,S),new I(x,E,S)}add(h){Q(h);const{X:d,Y:a,Z:w}=this,{X:m,Y:v,Z:x}=h;let E=n.ZERO,S=n.ZERO,A=n.ZERO;const L=s.a,U=n.mul(s.b,Bt);let _=n.mul(d,m),H=n.mul(a,v),Z=n.mul(w,x),K=n.add(d,a),O=n.add(m,v);K=n.mul(K,O),O=n.add(_,H),K=n.sub(K,O),O=n.add(d,w);let k=n.add(m,x);return O=n.mul(O,k),k=n.add(_,Z),O=n.sub(O,k),k=n.add(a,w),E=n.add(v,x),k=n.mul(k,E),E=n.add(H,Z),k=n.sub(k,E),A=n.mul(L,O),E=n.mul(U,Z),A=n.add(E,A),E=n.sub(H,A),A=n.add(H,A),S=n.mul(E,A),H=n.add(_,_),H=n.add(H,_),Z=n.mul(L,Z),O=n.mul(U,O),H=n.add(H,Z),Z=n.sub(_,Z),Z=n.mul(L,Z),O=n.add(O,Z),_=n.mul(H,O),S=n.add(S,_),_=n.mul(k,O),E=n.mul(K,E),E=n.sub(E,_),_=n.mul(K,H),A=n.mul(k,A),A=n.add(A,_),new I(E,S,A)}subtract(h){return this.add(h.negate())}is0(){return this.equals(I.ZERO)}multiply(h){const{endo:d}=e;if(!o.isValidNot0(h))throw new Error("invalid scalar: out of range");let a,w;const m=v=>J.cached(this,v,x=>Lt(I,x));if(d){const{k1neg:v,k1:x,k2neg:E,k2:S}=F(h),{p:A,f:L}=m(x),{p:U,f:_}=m(S);w=L.add(_),a=it(d.beta,A,U,v,E)}else{const{p:v,f:x}=m(h);a=v,w=x}return Lt(I,[a,w])[0]}multiplyUnsafe(h){const{endo:d}=e,a=this;if(!o.isValid(h))throw new Error("invalid scalar: out of range");if(h===G||a.is0())return I.ZERO;if(h===ut)return a;if(J.hasCache(this))return this.multiply(h);if(d){const{k1neg:w,k1:m,k2neg:v,k2:x}=F(h),{p1:E,p2:S}=hn(I,a,m,x);return it(d.beta,E,S,w,v)}else return J.unsafe(a,h)}multiplyAndAddUnsafe(h,d,a){const w=this.multiplyUnsafe(d).add(h.multiplyUnsafe(a));return w.is0()?void 0:w}toAffine(h){return st(this,h)}isTorsionFree(){const{isTorsionFree:h}=e;return i===ut?!0:h?h(I,this):J.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:h}=e;return i===ut?this:h?h(I,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(h=!0){return It(h,"isCompressed"),this.assertValidity(),l(I,this,h)}toHex(h=!0){return ft(this.toBytes(h))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(h=!0){return this.toBytes(h)}_setWindowSize(h){this.precompute(h)}static normalizeZ(h){return Lt(I,h)}static msm(h,d){return gn(I,o,h,d)}static fromPrivateKey(h){return I.BASE.multiply(rt(o,h))}}I.BASE=new I(s.Gx,s.Gy,n.ONE),I.ZERO=new I(n.ZERO,n.ONE,n.ZERO),I.Fp=n,I.Fn=o;const pt=o.BITS,J=new dn(I,e.endo?Math.ceil(pt/2):pt);return I.BASE.precompute(8),I}function ke(t){return Uint8Array.of(t?2:3)}function Ce(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function En(t,e={}){const{Fn:r}=t,n=e.randomBytes||Ht,o=Object.assign(Ce(t.Fp,r),{seed:qe(r.ORDER)});function s(l){try{return!!rt(r,l)}catch{return!1}}function i(l,p){const{publicKey:B,publicKeyUncompressed:R}=o;try{const q=l.length;return p===!0&&q!==B||p===!1&&q!==R?!1:!!t.fromBytes(l)}catch{return!1}}function c(l=n(o.seed)){return Ve(tt(l,o.seed,"seed"),r.ORDER)}function f(l,p=!0){return t.BASE.multiply(rt(r,l)).toBytes(p)}function g(l){const p=c(l);return{secretKey:p,publicKey:f(p)}}function y(l){if(typeof l=="bigint")return!1;if(l instanceof t)return!0;const{secretKey:p,publicKey:B,publicKeyUncompressed:R}=o;if(r.allowedLengths||p===B)return;const q=T("key",l).length;return q===B||q===R}function b(l,p,B=!0){if(y(l)===!0)throw new Error("first arg must be private key");if(y(p)===!1)throw new Error("second arg must be public key");const R=rt(r,l);return t.fromHex(p).multiply(R).toBytes(B)}return Object.freeze({getPublicKey:f,getSharedSecret:b,keygen:g,Point:t,utils:{isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c,isValidPrivateKey:s,randomPrivateKey:c,normPrivateKeyToScalar:l=>rt(r,l),precompute(l=8,p=t.BASE){return p.precompute(l,!1)}},lengths:o})}function xn(t,e,r={}){he(e),Ft(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=r.randomBytes||Ht,o=r.hmac||((d,...a)=>me(e,d,z(...a))),{Fp:s,Fn:i}=t,{ORDER:c,BITS:f}=i,{keygen:g,getPublicKey:y,getSharedSecret:b,utils:u,lengths:l}=En(t,r),p={prehash:!1,lowS:typeof r.lowS=="boolean"?r.lowS:!1,format:void 0,extraEntropy:!1},B="compact";function R(d){const a=c>>ut;return d>a}function q(d,a){if(!i.isValidNot0(a))throw new Error(`invalid signature ${d}: out of range 1..Point.Fn.ORDER`);return a}function gt(d,a){Yt(a);const w=l.signature,m=a==="compact"?w:a==="recovered"?w+1:void 0;return tt(d,m,`${a} signature`)}class V{constructor(a,w,m){this.r=q("r",a),this.s=q("s",w),m!=null&&(this.recovery=m),Object.freeze(this)}static fromBytes(a,w=B){gt(a,w);let m;if(w==="der"){const{r:S,s:A}=X.toSig(tt(a));return new V(S,A)}w==="recovered"&&(m=a[0],w="compact",a=a.subarray(1));const v=i.BYTES,x=a.subarray(0,v),E=a.subarray(v,v*2);return new V(i.fromBytes(x),i.fromBytes(E),m)}static fromHex(a,w){return this.fromBytes(At(a),w)}addRecoveryBit(a){return new V(this.r,this.s,a)}recoverPublicKey(a){const w=s.ORDER,{r:m,s:v,recovery:x}=this;if(x==null||![0,1,2,3].includes(x))throw new Error("recovery id invalid");if(c*Te<w&&x>1)throw new Error("recovery id is ambiguous for h>1 curve");const S=x===2||x===3?m+c:m;if(!s.isValid(S))throw new Error("recovery id 2 or 3 invalid");const A=s.toBytes(S),L=t.fromBytes(z(ke((x&1)===0),A)),U=i.inv(S),_=F(T("msgHash",a)),H=i.create(-_*U),Z=i.create(v*U),K=t.BASE.multiplyUnsafe(H).add(L.multiplyUnsafe(Z));if(K.is0())throw new Error("point at infinify");return K.assertValidity(),K}hasHighS(){return R(this.s)}toBytes(a=B){if(Yt(a),a==="der")return At(X.hexFromSig(this));const w=i.toBytes(this.r),m=i.toBytes(this.s);if(a==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return z(Uint8Array.of(this.recovery),w,m)}return z(w,m)}toHex(a){return ft(this.toBytes(a))}assertValidity(){}static fromCompact(a){return V.fromBytes(T("sig",a),"compact")}static fromDER(a){return V.fromBytes(T("sig",a),"der")}normalizeS(){return this.hasHighS()?new V(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return ft(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return ft(this.toBytes("compact"))}}const Q=r.bits2int||function(a){if(a.length>8192)throw new Error("input is too large");const w=dt(a),m=a.length*8-f;return m>0?w>>BigInt(m):w},F=r.bits2int_modN||function(a){return i.create(Q(a))},st=yt(f);function mt(d){return Je("num < 2^"+f,d,G,st),i.toBytes(d)}function it(d,a){return tt(d,void 0,"message"),a?tt(e(d),void 0,"prehashed message"):d}function I(d,a,w){if(["recovered","canonical"].some(H=>H in w))throw new Error("sign() legacy options not supported");const{lowS:m,prehash:v,extraEntropy:x}=Ct(w,p);d=it(d,v);const E=F(d),S=rt(i,a),A=[mt(S),mt(E)];if(x!=null&&x!==!1){const H=x===!0?n(l.secretKey):x;A.push(T("extraEntropy",H))}const L=z(...A),U=E;function _(H){const Z=Q(H);if(!i.isValidNot0(Z))return;const K=i.inv(Z),O=t.BASE.multiply(Z).toAffine(),k=i.create(O.x);if(k===G)return;const Et=i.create(K*i.create(U+k*S));if(Et===G)return;let te=(O.x===k?0:2)|Number(O.y&ut),ee=Et;return m&&R(Et)&&(ee=i.neg(Et),te^=1),new V(k,ee,te)}return{seed:L,k2sig:_}}function pt(d,a,w={}){d=T("message",d);const{seed:m,k2sig:v}=I(d,a,w);return tn(e.outputLen,i.BYTES,o)(m,v)}function J(d){let a;const w=typeof d=="string"||Ut(d),m=!w&&d!==null&&typeof d=="object"&&typeof d.r=="bigint"&&typeof d.s=="bigint";if(!w&&!m)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(m)a=new V(d.r,d.s);else if(w){try{a=V.fromBytes(T("sig",d),"der")}catch(v){if(!(v instanceof X.Err))throw v}if(!a)try{a=V.fromBytes(T("sig",d),"compact")}catch{return!1}}return a||!1}function N(d,a,w,m={}){const{lowS:v,prehash:x,format:E}=Ct(m,p);if(w=T("publicKey",w),a=it(T("message",a),x),"strict"in m)throw new Error("options.strict was renamed to lowS");const S=E===void 0?J(d):V.fromBytes(T("sig",d),E);if(S===!1)return!1;try{const A=t.fromBytes(w);if(v&&S.hasHighS())return!1;const{r:L,s:U}=S,_=F(a),H=i.inv(U),Z=i.create(_*H),K=i.create(L*H),O=t.BASE.multiplyUnsafe(Z).add(A.multiplyUnsafe(K));return O.is0()?!1:i.create(O.x)===L}catch{return!1}}function h(d,a,w={}){const{prehash:m}=Ct(w,p);return a=it(a,m),V.fromBytes(d,"recovered").recoverPublicKey(a).toBytes()}return Object.freeze({keygen:g,getPublicKey:y,getSharedSecret:b,utils:u,lengths:l,Point:t,sign:pt,verify:N,recoverPublicKey:h,Signature:V,hash:e})}function Bn(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp;let n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const o=bt(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),s={Fp:r,Fn:o,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:s}}function vn(t){const{CURVE:e,curveOpts:r}=Bn(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,hash:t.hash,ecdsaOpts:n}}function Sn(t,e){const r=e.Point;return Object.assign({},e,{ProjectivePoint:r,CURVE:Object.assign({},t,He(r.Fn.ORDER,r.Fn.BITS))})}function An(t){const{CURVE:e,curveOpts:r,hash:n,ecdsaOpts:o}=vn(t),s=pn(e,r),i=xn(s,n,o);return Sn(t,i)}function In(t,e){const r=n=>An({...t,hash:n});return{...r(e),create:r}}const lt={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},_n={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Nn=BigInt(0),ae=BigInt(1),zt=BigInt(2);function Rn(t){const e=lt.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),f=BigInt(88),g=t*t*t%e,y=g*g*t%e,b=M(y,r,e)*y%e,u=M(b,r,e)*y%e,l=M(u,zt,e)*g%e,p=M(l,o,e)*l%e,B=M(p,s,e)*p%e,R=M(B,c,e)*B%e,q=M(R,f,e)*R%e,gt=M(q,c,e)*B%e,V=M(gt,r,e)*y%e,Q=M(V,i,e)*p%e,F=M(Q,n,e)*g%e,st=M(F,zt,e);if(!Nt.eql(Nt.sqr(st),t))throw new Error("Cannot find square root");return st}const Nt=bt(lt.p,{sqrt:Rn}),Wt=In({...lt,Fp:Nt,lowS:!0,endo:_n},$t),le={};function Rt(t,...e){let r=le[t];if(r===void 0){const n=$t(we(t));r=z(n,n),le[t]=r}return $t(z(r,...e))}const Qt=t=>t.toBytes(!0).slice(1),ht=Wt.Point,Jt=t=>t%zt===Nn;function Dt(t){const{Fn:e,BASE:r}=ht,n=rt(e,t),o=r.multiply(n);return{scalar:Jt(o.y)?n:e.neg(n),bytes:Qt(o)}}function Ke(t){const e=Nt;if(!e.isValidNot0(t))throw new Error("invalid x: Fail if x ≥ p");const r=e.create(t*t),n=e.create(r*t+BigInt(7));let o=e.sqrt(n);Jt(o)||(o=e.neg(o));const s=ht.fromAffine({x:t,y:o});return s.assertValidity(),s}const wt=dt;function $e(...t){return ht.Fn.create(wt(Rt("BIP0340/challenge",...t)))}function de(t){return Dt(t).bytes}function Un(t,e,r=Ht(32)){const{Fn:n}=ht,o=T("message",t),{bytes:s,scalar:i}=Dt(e),c=T("auxRand",r,32),f=n.toBytes(i^wt(Rt("BIP0340/aux",c))),g=Rt("BIP0340/nonce",f,s,o),{bytes:y,scalar:b}=Dt(g),u=$e(y,s,o),l=new Uint8Array(64);if(l.set(y,0),l.set(n.toBytes(n.create(b+u*i)),32),!Me(l,o,s))throw new Error("sign: Invalid signature produced");return l}function Me(t,e,r){const{Fn:n,BASE:o}=ht,s=T("signature",t,64),i=T("message",e),c=T("publicKey",r,32);try{const f=Ke(wt(c)),g=wt(s.subarray(0,32));if(!jt(g,ae,lt.p))return!1;const y=wt(s.subarray(32,64));if(!jt(y,ae,lt.n))return!1;const b=$e(n.toBytes(g),Qt(f),i),u=o.multiplyUnsafe(y).add(f.multiplyUnsafe(n.neg(b))),{x:l,y:p}=u.toAffine();return!(u.is0()||!Jt(p)||l!==g)}catch{return!1}}const Hn=(()=>{const r=(o=Ht(48))=>Ve(o,lt.n);Wt.utils.randomSecretKey;function n(o){const s=r(o);return{secretKey:s,publicKey:de(s)}}return{keygen:n,getPublicKey:de,sign:Un,verify:Me,Point:ht,utils:{randomSecretKey:r,randomPrivateKey:r,taggedHash:Rt,lift_x:Ke,pointToBytes:Qt,numberToBytesBE:Ot,bytesToNumberBE:dt,mod:j},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();exports.assertValidVaultCoreVersion=je;exports.schnorr=Hn;exports.secp256k1=Wt;
2
+ //# sourceMappingURL=secp256k1-DDHQ1_za.cjs.map