@0xbot/chat-react 1.0.8 → 1.0.10

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 (187) hide show
  1. package/README.md +1 -1
  2. package/dist/AaveLendingPoolABI-CdLq16uB-BGiZ7zvm.mjs +4 -0
  3. package/dist/AaveLendingPoolAddressesProvider-EOSAznLK-BSWFPv4x.mjs +4 -0
  4. package/dist/AavePriceOracleABI-C2UEpXR4-C_hStKK4.mjs +4 -0
  5. package/dist/AaveProtocolDataProviderABI-0JclmmLX-DLxLoyai.mjs +4 -0
  6. package/dist/BaseDrops-BrQZPqKk-B26CkeNy.mjs +4 -0
  7. package/dist/D3MM_READ_ABI-B5536S-z-CL3RJ1A8.mjs +4 -0
  8. package/dist/D3Proxy-CKIzLOhI-CGvfWU5A.mjs +4 -0
  9. package/dist/DODO1155-DDY5Jxhf-DGclqdqY.mjs +4 -0
  10. package/dist/DODO721-Kl5REiwU-CjPebx7D.mjs +4 -0
  11. package/dist/DODOCirculationHelperABI-gu1sCqZ2-DKVM1578.mjs +4 -0
  12. package/dist/DODORouteProxy-51kl6QgI-DjkLwYNY.mjs +4 -0
  13. package/dist/DODOV1PmmHelperABI-DQqthyaE-1aS8xEGz.mjs +4 -0
  14. package/dist/DVM-DjtWbqiJ-BbQRScdF.mjs +4 -0
  15. package/dist/DropsERC721-7Bckjcar-cRaNDmuo.mjs +4 -0
  16. package/dist/FilterAdmin-jm_-DS1l-BsNgsP2z.mjs +4 -0
  17. package/dist/FilterERC1155V1-VIUlIHdF-KqUEDK8Y.mjs +4 -0
  18. package/dist/FilterERC721V1-CWDEPGmH-BeOtdHta.mjs +4 -0
  19. package/dist/Fragment-Bd_AXeVx-C-ytfCBz.mjs +4 -0
  20. package/dist/FundingABI-WqQDGVVa-CaLckA9D.mjs +4 -0
  21. package/dist/IdodoV2-DlW8pwaE-1tII4uF5.mjs +4 -0
  22. package/dist/LockedTokenVaultABI-CfBj0wEX-CB4fg14z.mjs +4 -0
  23. package/dist/MarginTrading-CQ5odvHB-hsA_0CMf.mjs +4 -0
  24. package/dist/MarginTradingFactory-2RKqvCSO-DgmL1WxL.mjs +4 -0
  25. package/dist/MerkleDistributorABI-Ctn26fnA-BbXWPnph.mjs +4 -0
  26. package/dist/NonfungiblePositionManager-c8Yw_9-Q-DoGzZtUT.mjs +4 -0
  27. package/dist/PancakePairABI-Cc9LuXnX-CSfuOSUk.mjs +4 -0
  28. package/dist/UniswapV3Pool-Da11VKXE-Bpirv2VX.mjs +4 -0
  29. package/dist/add-CHJpf5Lw.mjs +19 -0
  30. package/dist/all-wallets-D2hkkUJ3.mjs +10 -0
  31. package/dist/api/index.d.ts +2 -0
  32. package/dist/app-store-CqLKqQ5V.mjs +21 -0
  33. package/dist/apple-B0XeUiD1.mjs +22 -0
  34. package/dist/arrow-bottom-aeJVAvnL.mjs +12 -0
  35. package/dist/arrow-bottom-circle-R6EgzTHW.mjs +15 -0
  36. package/dist/arrow-left-BqQ4buTv.mjs +12 -0
  37. package/dist/arrow-right-C6Ed0Mzu.mjs +12 -0
  38. package/dist/arrow-top-BidIjQzK.mjs +12 -0
  39. package/dist/bank-yI5ZTpcM.mjs +18 -0
  40. package/dist/baseFilterV1-BPjWXMKw-Hn2CtZK1.mjs +4 -0
  41. package/dist/basic-Ck_Otdyv.mjs +5718 -0
  42. package/dist/browser-DfN9W7W3.mjs +18 -0
  43. package/dist/bsc-3D5wcqPq-Crqli4pE.mjs +4 -0
  44. package/dist/card-DNVrOepi.mjs +18 -0
  45. package/dist/chat-library.es.js +6 -0
  46. package/dist/chat-library.umd.js +7790 -0
  47. package/dist/checkmark-Y_JAaFYi.mjs +15 -0
  48. package/dist/checkmark-bold-BaUBCwEZ.mjs +12 -0
  49. package/dist/chevron-bottom-DT-gLTLE.mjs +12 -0
  50. package/dist/chevron-left-Db6JDZK5.mjs +12 -0
  51. package/dist/chevron-right-CcBMjaBn.mjs +12 -0
  52. package/dist/chevron-top-RvW8f4V7.mjs +12 -0
  53. package/dist/chrome-store-DnpyKbMo.mjs +65 -0
  54. package/dist/classicalPoolABI-D5LxySAJ-D7PleszW.mjs +4 -0
  55. package/dist/clock-Bz19eiZx.mjs +12 -0
  56. package/dist/close-Pad_fUXU.mjs +12 -0
  57. package/dist/coinPlaceholder-B7RKkvE0.mjs +12 -0
  58. package/dist/compass-Dw45tdte.mjs +12 -0
  59. package/dist/components/DodoSwap.d.ts +14 -0
  60. package/dist/copy-CwnxEVdO.mjs +19 -0
  61. package/dist/core-BncCIRvy.mjs +16730 -0
  62. package/dist/cursor-C6uOuAov.mjs +7 -0
  63. package/dist/cursor-transparent-xIFYE_0X.mjs +16 -0
  64. package/dist/desktop-Dz5Hje94.mjs +13 -0
  65. package/dist/disconnect-CTdx5PqO.mjs +12 -0
  66. package/dist/discord-C-gRbozI.mjs +21 -0
  67. package/dist/dodoABI-CLkEBJ8P-Bu3dOG4h.mjs +4 -0
  68. package/dist/dodoBuyoutModel-BtQv3C3q-BdkKV4YI.mjs +4 -0
  69. package/dist/dodoCP-N8KA8JwJ-TdVQ5mZP.mjs +4 -0
  70. package/dist/dodoCPABI-CdAN0KhU-COvDVH7-.mjs +4 -0
  71. package/dist/dodoCPABIV2-yzF6FlEg-nSP7QBK6.mjs +4 -0
  72. package/dist/dodoCPFactory-CD0SxXT6-C-NYcE0L.mjs +4 -0
  73. package/dist/dodoCpProxy-D2AI9-4r-CNpIMaS9.mjs +4 -0
  74. package/dist/dodoCpProxyV2-CGZRqk2H-CFqfOsrA.mjs +4 -0
  75. package/dist/dodoCpProxyV202-CoZaEf_6-D3tcGKYm.mjs +4 -0
  76. package/dist/dodoCustomMintableERC20-CPpNoX1v-CheGl3pc.mjs +4 -0
  77. package/dist/dodoDPPAdmin-B-fmpTbV-DDnM12B9.mjs +4 -0
  78. package/dist/dodoDPPFactory-DwAkVskt-BlCcT0Y7.mjs +4 -0
  79. package/dist/dodoDSP-B6KYm-Cn-BlRNrfLD.mjs +4 -0
  80. package/dist/dodoDSPFactory-j1eg7Ez--DBzB5BJy.mjs +4 -0
  81. package/dist/dodoDVM-DDYx1JAy-Dvy00nJq.mjs +4 -0
  82. package/dist/dodoDVMFactory-FpnJdZb2-pnHsrTp3.mjs +4 -0
  83. package/dist/dodoDppProxy-A7PPYsqp-D06i9e-K.mjs +4 -0
  84. package/dist/dodoDropsProxy-vHUWsRNO-QPtLS8Fb.mjs +4 -0
  85. package/dist/dodoDspProxy-CU7OAvJG-jDB-e7lT.mjs +4 -0
  86. package/dist/dodoERC20V3Factory-Cz4XKDrU-BczFXEyV.mjs +4 -0
  87. package/dist/dodoEthProxyABI-CoX95QJI-ClpiGz9q.mjs +4 -0
  88. package/dist/dodoFeeImpl-zR9Qv4Tq-DEWk3Y40.mjs +4 -0
  89. package/dist/dodoFragment-4lxmE2XJ-CyrfbNi9.mjs +4 -0
  90. package/dist/dodoMineV3Proxy-xOGM7Jnv-DB_whEuY.mjs +4 -0
  91. package/dist/dodoMineV3ProxyOld-BqsZxJRU-D2D73qEi.mjs +4 -0
  92. package/dist/dodoMiningABI-9J5C_6kN-Dd9oBdgN.mjs +4 -0
  93. package/dist/dodoMiningReaderABI-DmUXA9Gv-5oVswgl3.mjs +4 -0
  94. package/dist/dodoNftERC1155-Bw6ID2NE-B6ec1_gD.mjs +4 -0
  95. package/dist/dodoNftERC721-CI1l0ip9-4w4aINlO.mjs +4 -0
  96. package/dist/dodoNftPoolProxy-DQkcZHUV-QkmZ2nMD.mjs +4 -0
  97. package/dist/dodoNftProxy-Di-aoLYM-DxMxz-31.mjs +4 -0
  98. package/dist/dodoNftVault-B4NZaXcd-CnVQXRy8.mjs +4 -0
  99. package/dist/dodoOracleABI-BxwZofBV-CMjdc9D8.mjs +4 -0
  100. package/dist/dodoPair-VN1aEVFz-yv3rmA46.mjs +4 -0
  101. package/dist/dodoPreminingABI-DU7ocR7L-DbnrMY8U.mjs +4 -0
  102. package/dist/dodoProxyV2-9ED9HqK5-D1IbsmqR.mjs +4 -0
  103. package/dist/dodoStarterProxy-B1TdMOvw-Dc_OorIU.mjs +4 -0
  104. package/dist/dodoTokenABI-Dd2DVUbK-H42B3M0V.mjs +4 -0
  105. package/dist/dodoUpCPFactoryABI-C1W0Q4Ft-BoaZdses.mjs +4 -0
  106. package/dist/dodoUpCpFactory-D8ifQyp--qgHD5MAq.mjs +4 -0
  107. package/dist/dodoV1PairProxy-DyRTqyPe-C8yy7JSs.mjs +4 -0
  108. package/dist/dodoZooABI-D9Uc4iLK-KrPSOwCN.mjs +4 -0
  109. package/dist/dppPoolABI-BvoeLJgK-CDxK1JW7.mjs +4 -0
  110. package/dist/erc20ABI-v08X4jmE-CVM8vD3s.mjs +4 -0
  111. package/dist/erc20Helper-CG659oLz-CFUQnmR-.mjs +4 -0
  112. package/dist/eth-B9cviUl5-CG8RPzNA.mjs +4 -0
  113. package/dist/etherscan-BoxwTKtb.mjs +10 -0
  114. package/dist/exclamation-triangle-lJzIh3b3.mjs +8 -0
  115. package/dist/extension-Cu9Cmk3m.mjs +12 -0
  116. package/dist/external-link-BvvHuuY0.mjs +12 -0
  117. package/dist/facebook-By3QHn59.mjs +30 -0
  118. package/dist/farcaster-B6Uk0IIz.mjs +16 -0
  119. package/dist/feeABI-DnQdJUpQ-DesVgwnT.mjs +4 -0
  120. package/dist/filters-7iolnXNp.mjs +12 -0
  121. package/dist/github-CbNFQ-rE.mjs +22 -0
  122. package/dist/google-B4kpRWe2.mjs +22 -0
  123. package/dist/help-circle-BHYOhZH-.mjs +16 -0
  124. package/dist/helper-DvTqUYSd-DjCOVcV8.mjs +22500 -0
  125. package/dist/id-B63SRnJH.mjs +16 -0
  126. package/dist/image-BFYG_I7p.mjs +8 -0
  127. package/dist/index-Cm7qS4de-ByNXzPPy.mjs +188 -0
  128. package/dist/index-Csyx760V.mjs +1037 -0
  129. package/dist/index-DId52aLZ.mjs +102718 -0
  130. package/dist/index-KEmmG3yM-D6PVhm18.mjs +390 -0
  131. package/dist/index.css +1 -0
  132. package/dist/info-MhMaxvuu.mjs +7 -0
  133. package/dist/info-circle-Br6R310O.mjs +16 -0
  134. package/dist/lightbulb-CvIgiu_8.mjs +7 -0
  135. package/dist/mail-C37s8I6x.mjs +12 -0
  136. package/dist/mobile-6yKClGQT.mjs +13 -0
  137. package/dist/more-CoCXkplN.mjs +15 -0
  138. package/dist/multicallABI-D9E1EeQD-BHmsV5Ww.mjs +4 -0
  139. package/dist/network-placeholder-RiVpBWSW.mjs +18 -0
  140. package/dist/nftContract-d4b6ObxG-DDocz_o1.mjs +4 -0
  141. package/dist/nftFilterAdmin-DMr_jrK_-CzdnxC1u.mjs +4 -0
  142. package/dist/nftPlaceholder-BqPW-YRA.mjs +12 -0
  143. package/dist/off-BYd8177g.mjs +12 -0
  144. package/dist/oneBitSettlement-DMzQ-0t_-6O4CfYZH.mjs +4 -0
  145. package/dist/play-store-DOI54pIO.mjs +36 -0
  146. package/dist/plus-D3V6i3OL.mjs +17 -0
  147. package/dist/qr-code-BMbd5nBQ.mjs +10 -0
  148. package/dist/react-datetime.cjs-BazkzJ-h.mjs +3535 -0
  149. package/dist/recycle-horizontal-Rf_bshe8.mjs +13 -0
  150. package/dist/refresh-D188VUaC.mjs +12 -0
  151. package/dist/reown-logo-BlqEBF0T.mjs +16 -0
  152. package/dist/search-BwlhXkfV.mjs +12 -0
  153. package/dist/secp256k1-B3zICmiT.mjs +1469 -0
  154. package/dist/secp256k1-DgHq90iL.mjs +1510 -0
  155. package/dist/send-gHEIp_-C.mjs +19 -0
  156. package/dist/setApprovalForAll-BvnCORJI-BsLcI446.mjs +4 -0
  157. package/dist/spaceIdABI-BS4XGAT1-BjuJy2_U.mjs +4 -0
  158. package/dist/spaceIdResolverABI-sYDT8GfP-D5rMp5Lb.mjs +4 -0
  159. package/dist/swapHorizontal-CSBQUUlD.mjs +12 -0
  160. package/dist/swapHorizontalBold-BJqpmrQd.mjs +12 -0
  161. package/dist/swapHorizontalMedium-R5UjzDTB.mjs +20 -0
  162. package/dist/swapHorizontalRoundedBold-Dajt5M8H.mjs +12 -0
  163. package/dist/swapVertical-C00VFvcQ.mjs +12 -0
  164. package/dist/telegram-BjMNjPGO.mjs +20 -0
  165. package/dist/three-dots-CzB3opP1.mjs +9 -0
  166. package/dist/twitch-BJyvHwSX.mjs +22 -0
  167. package/dist/twitterIcon-C13sV4pO.mjs +10 -0
  168. package/dist/types/index.d.ts +16 -0
  169. package/dist/utils/index.d.ts +1 -0
  170. package/dist/utils/request.d.ts +1 -0
  171. package/dist/utils/version.d.ts +13 -0
  172. package/dist/v3MiningABI-ZjGBkolS-DpOFVbMt.mjs +4 -0
  173. package/dist/vdodo-ttc2RVOs-BsdVbO8I.mjs +4 -0
  174. package/dist/vdodoTokenABI-PldrbOSo-CmQmhg5z.mjs +4 -0
  175. package/dist/verify-CZf1Key9.mjs +12 -0
  176. package/dist/verify-filled-TxR2AkrB.mjs +12 -0
  177. package/dist/w3m-modal-CtlM8yh_.mjs +1471 -0
  178. package/dist/wallet-placeholder-BZj9RGcX.mjs +18 -0
  179. package/dist/wallet-w_3wvddk.mjs +12 -0
  180. package/dist/walletconnect-Dst7WudJ.mjs +36 -0
  181. package/dist/warning-circle-BAvO6TFh.mjs +16 -0
  182. package/dist/weth-Dz5DGEIF-y7HuL7DE.mjs +4 -0
  183. package/dist/x-Ch4skAxW.mjs +16 -0
  184. package/package.json +23 -30
  185. package/dist/index.es.js +0 -1035
  186. package/dist/index.umd.js +0 -52
  187. package/dist/style.css +0 -1
@@ -0,0 +1,1510 @@
1
+ import { H as Qt, G as Nt, I as Et, J as Jt, K as de, L as he, N as P, P as ge, Q as we, U as pe, V as be } from "./core-BncCIRvy.mjs";
2
+ function ye(n, e, t, r) {
3
+ if (typeof n.setBigUint64 == "function")
4
+ return n.setBigUint64(e, t, r);
5
+ const o = BigInt(32), s = BigInt(4294967295), c = Number(t >> o & s), f = Number(t & s), i = r ? 4 : 0, u = r ? 0 : 4;
6
+ n.setUint32(e + i, c, r), n.setUint32(e + u, f, r);
7
+ }
8
+ function me(n, e, t) {
9
+ return n & e ^ ~n & t;
10
+ }
11
+ function xe(n, e, t) {
12
+ return n & e ^ n & t ^ e & t;
13
+ }
14
+ class Ee extends Qt {
15
+ constructor(e, t, r, o) {
16
+ super(), this.blockLen = e, this.outputLen = t, this.padOffset = r, this.isLE = o, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(e), this.view = Nt(this.buffer);
17
+ }
18
+ update(e) {
19
+ Et(this);
20
+ const { view: t, buffer: r, blockLen: o } = this;
21
+ e = Jt(e);
22
+ const s = e.length;
23
+ for (let c = 0; c < s; ) {
24
+ const f = Math.min(o - this.pos, s - c);
25
+ if (f === o) {
26
+ const i = Nt(e);
27
+ for (; o <= s - c; c += o)
28
+ this.process(i, c);
29
+ continue;
30
+ }
31
+ r.set(e.subarray(c, c + f), this.pos), this.pos += f, c += f, this.pos === o && (this.process(t, 0), this.pos = 0);
32
+ }
33
+ return this.length += e.length, this.roundClean(), this;
34
+ }
35
+ digestInto(e) {
36
+ Et(this), de(e, this), this.finished = !0;
37
+ const { buffer: t, view: r, blockLen: o, isLE: s } = this;
38
+ let { pos: c } = this;
39
+ t[c++] = 128, this.buffer.subarray(c).fill(0), this.padOffset > o - c && (this.process(r, 0), c = 0);
40
+ for (let h = c; h < o; h++)
41
+ t[h] = 0;
42
+ ye(r, o - 8, BigInt(this.length * 8), s), this.process(r, 0);
43
+ const f = Nt(e), i = this.outputLen;
44
+ if (i % 4)
45
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
46
+ const u = i / 4, y = this.get();
47
+ if (u > y.length)
48
+ throw new Error("_sha2: outputLen bigger than state");
49
+ for (let h = 0; h < u; h++)
50
+ f.setUint32(4 * h, y[h], s);
51
+ }
52
+ digest() {
53
+ const { buffer: e, outputLen: t } = this;
54
+ this.digestInto(e);
55
+ const r = e.slice(0, t);
56
+ return this.destroy(), r;
57
+ }
58
+ _cloneInto(e) {
59
+ e || (e = new this.constructor()), e.set(...this.get());
60
+ const { blockLen: t, buffer: r, length: o, finished: s, destroyed: c, pos: f } = this;
61
+ return e.length = o, e.pos = f, e.finished = s, e.destroyed = c, o % t && e.buffer.set(r), e;
62
+ }
63
+ }
64
+ const Be = /* @__PURE__ */ new Uint32Array([
65
+ 1116352408,
66
+ 1899447441,
67
+ 3049323471,
68
+ 3921009573,
69
+ 961987163,
70
+ 1508970993,
71
+ 2453635748,
72
+ 2870763221,
73
+ 3624381080,
74
+ 310598401,
75
+ 607225278,
76
+ 1426881987,
77
+ 1925078388,
78
+ 2162078206,
79
+ 2614888103,
80
+ 3248222580,
81
+ 3835390401,
82
+ 4022224774,
83
+ 264347078,
84
+ 604807628,
85
+ 770255983,
86
+ 1249150122,
87
+ 1555081692,
88
+ 1996064986,
89
+ 2554220882,
90
+ 2821834349,
91
+ 2952996808,
92
+ 3210313671,
93
+ 3336571891,
94
+ 3584528711,
95
+ 113926993,
96
+ 338241895,
97
+ 666307205,
98
+ 773529912,
99
+ 1294757372,
100
+ 1396182291,
101
+ 1695183700,
102
+ 1986661051,
103
+ 2177026350,
104
+ 2456956037,
105
+ 2730485921,
106
+ 2820302411,
107
+ 3259730800,
108
+ 3345764771,
109
+ 3516065817,
110
+ 3600352804,
111
+ 4094571909,
112
+ 275423344,
113
+ 430227734,
114
+ 506948616,
115
+ 659060556,
116
+ 883997877,
117
+ 958139571,
118
+ 1322822218,
119
+ 1537002063,
120
+ 1747873779,
121
+ 1955562222,
122
+ 2024104815,
123
+ 2227730452,
124
+ 2361852424,
125
+ 2428436474,
126
+ 2756734187,
127
+ 3204031479,
128
+ 3329325298
129
+ ]), Q = /* @__PURE__ */ new Uint32Array([
130
+ 1779033703,
131
+ 3144134277,
132
+ 1013904242,
133
+ 2773480762,
134
+ 1359893119,
135
+ 2600822924,
136
+ 528734635,
137
+ 1541459225
138
+ ]), J = /* @__PURE__ */ new Uint32Array(64);
139
+ class ve extends Ee {
140
+ constructor() {
141
+ super(64, 32, 8, !1), this.A = Q[0] | 0, this.B = Q[1] | 0, this.C = Q[2] | 0, this.D = Q[3] | 0, this.E = Q[4] | 0, this.F = Q[5] | 0, this.G = Q[6] | 0, this.H = Q[7] | 0;
142
+ }
143
+ get() {
144
+ const { A: e, B: t, C: r, D: o, E: s, F: c, G: f, H: i } = this;
145
+ return [e, t, r, o, s, c, f, i];
146
+ }
147
+ // prettier-ignore
148
+ set(e, t, r, o, s, c, f, i) {
149
+ this.A = e | 0, this.B = t | 0, this.C = r | 0, this.D = o | 0, this.E = s | 0, this.F = c | 0, this.G = f | 0, this.H = i | 0;
150
+ }
151
+ process(e, t) {
152
+ for (let h = 0; h < 16; h++, t += 4)
153
+ J[h] = e.getUint32(t, !1);
154
+ for (let h = 16; h < 64; h++) {
155
+ const l = J[h - 15], m = J[h - 2], N = P(l, 7) ^ P(l, 18) ^ l >>> 3, b = P(m, 17) ^ P(m, 19) ^ m >>> 10;
156
+ J[h] = b + J[h - 7] + N + J[h - 16] | 0;
157
+ }
158
+ let { A: r, B: o, C: s, D: c, E: f, F: i, G: u, H: y } = this;
159
+ for (let h = 0; h < 64; h++) {
160
+ const l = P(f, 6) ^ P(f, 11) ^ P(f, 25), m = y + l + me(f, i, u) + Be[h] + J[h] | 0, b = (P(r, 2) ^ P(r, 13) ^ P(r, 22)) + xe(r, o, s) | 0;
161
+ y = u, u = i, i = f, f = c + m | 0, c = s, s = o, o = r, r = m + b | 0;
162
+ }
163
+ r = r + this.A | 0, o = o + this.B | 0, s = s + this.C | 0, c = c + this.D | 0, f = f + this.E | 0, i = i + this.F | 0, u = u + this.G | 0, y = y + this.H | 0, this.set(r, o, s, c, f, i, u, y);
164
+ }
165
+ roundClean() {
166
+ J.fill(0);
167
+ }
168
+ destroy() {
169
+ this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
170
+ }
171
+ }
172
+ const Se = /* @__PURE__ */ he(() => new ve());
173
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
174
+ const Bt = /* @__PURE__ */ BigInt(0), vt = /* @__PURE__ */ BigInt(1), Ae = /* @__PURE__ */ BigInt(2);
175
+ function it(n) {
176
+ return n instanceof Uint8Array || ArrayBuffer.isView(n) && n.constructor.name === "Uint8Array";
177
+ }
178
+ function yt(n) {
179
+ if (!it(n))
180
+ throw new Error("Uint8Array expected");
181
+ }
182
+ function ut(n, e) {
183
+ if (typeof e != "boolean")
184
+ throw new Error(n + " boolean expected, got " + e);
185
+ }
186
+ const Ie = /* @__PURE__ */ Array.from({ length: 256 }, (n, e) => e.toString(16).padStart(2, "0"));
187
+ function lt(n) {
188
+ yt(n);
189
+ let e = "";
190
+ for (let t = 0; t < n.length; t++)
191
+ e += Ie[n[t]];
192
+ return e;
193
+ }
194
+ function at(n) {
195
+ const e = n.toString(16);
196
+ return e.length & 1 ? "0" + e : e;
197
+ }
198
+ function Rt(n) {
199
+ if (typeof n != "string")
200
+ throw new Error("hex string expected, got " + typeof n);
201
+ return n === "" ? Bt : BigInt("0x" + n);
202
+ }
203
+ const D = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
204
+ function Yt(n) {
205
+ if (n >= D._0 && n <= D._9)
206
+ return n - D._0;
207
+ if (n >= D.A && n <= D.F)
208
+ return n - (D.A - 10);
209
+ if (n >= D.a && n <= D.f)
210
+ return n - (D.a - 10);
211
+ }
212
+ function dt(n) {
213
+ if (typeof n != "string")
214
+ throw new Error("hex string expected, got " + typeof n);
215
+ const e = n.length, t = e / 2;
216
+ if (e % 2)
217
+ throw new Error("hex string expected, got unpadded hex of length " + e);
218
+ const r = new Uint8Array(t);
219
+ for (let o = 0, s = 0; o < t; o++, s += 2) {
220
+ const c = Yt(n.charCodeAt(s)), f = Yt(n.charCodeAt(s + 1));
221
+ if (c === void 0 || f === void 0) {
222
+ const i = n[s] + n[s + 1];
223
+ throw new Error('hex string expected, got non-hex character "' + i + '" at index ' + s);
224
+ }
225
+ r[o] = c * 16 + f;
226
+ }
227
+ return r;
228
+ }
229
+ function rt(n) {
230
+ return Rt(lt(n));
231
+ }
232
+ function Vt(n) {
233
+ return yt(n), Rt(lt(Uint8Array.from(n).reverse()));
234
+ }
235
+ function ht(n, e) {
236
+ return dt(n.toString(16).padStart(e * 2, "0"));
237
+ }
238
+ function Mt(n, e) {
239
+ return ht(n, e).reverse();
240
+ }
241
+ function Ne(n) {
242
+ return dt(at(n));
243
+ }
244
+ function K(n, e, t) {
245
+ let r;
246
+ if (typeof e == "string")
247
+ try {
248
+ r = dt(e);
249
+ } catch (s) {
250
+ throw new Error(n + " must be hex string or Uint8Array, cause: " + s);
251
+ }
252
+ else if (it(e))
253
+ r = Uint8Array.from(e);
254
+ else
255
+ throw new Error(n + " must be hex string or Uint8Array");
256
+ const o = r.length;
257
+ if (typeof t == "number" && o !== t)
258
+ throw new Error(n + " of length " + t + " expected, got " + o);
259
+ return r;
260
+ }
261
+ function bt(...n) {
262
+ let e = 0;
263
+ for (let r = 0; r < n.length; r++) {
264
+ const o = n[r];
265
+ yt(o), e += o.length;
266
+ }
267
+ const t = new Uint8Array(e);
268
+ for (let r = 0, o = 0; r < n.length; r++) {
269
+ const s = n[r];
270
+ t.set(s, o), o += s.length;
271
+ }
272
+ return t;
273
+ }
274
+ function qe(n, e) {
275
+ if (n.length !== e.length)
276
+ return !1;
277
+ let t = 0;
278
+ for (let r = 0; r < n.length; r++)
279
+ t |= n[r] ^ e[r];
280
+ return t === 0;
281
+ }
282
+ function Oe(n) {
283
+ if (typeof n != "string")
284
+ throw new Error("string expected");
285
+ return new Uint8Array(new TextEncoder().encode(n));
286
+ }
287
+ const qt = (n) => typeof n == "bigint" && Bt <= n;
288
+ function St(n, e, t) {
289
+ return qt(n) && qt(e) && qt(t) && e <= n && n < t;
290
+ }
291
+ function ot(n, e, t, r) {
292
+ if (!St(e, t, r))
293
+ throw new Error("expected valid " + n + ": " + t + " <= n < " + r + ", got " + e);
294
+ }
295
+ function te(n) {
296
+ let e;
297
+ for (e = 0; n > Bt; n >>= vt, e += 1)
298
+ ;
299
+ return e;
300
+ }
301
+ function Le(n, e) {
302
+ return n >> BigInt(e) & vt;
303
+ }
304
+ function He(n, e, t) {
305
+ return n | (t ? vt : Bt) << BigInt(e);
306
+ }
307
+ const jt = (n) => (Ae << BigInt(n - 1)) - vt, Ot = (n) => new Uint8Array(n), Ft = (n) => Uint8Array.from(n);
308
+ function ee(n, e, t) {
309
+ if (typeof n != "number" || n < 2)
310
+ throw new Error("hashLen must be a number");
311
+ if (typeof e != "number" || e < 2)
312
+ throw new Error("qByteLen must be a number");
313
+ if (typeof t != "function")
314
+ throw new Error("hmacFn must be a function");
315
+ let r = Ot(n), o = Ot(n), s = 0;
316
+ const c = () => {
317
+ r.fill(1), o.fill(0), s = 0;
318
+ }, f = (...h) => t(o, r, ...h), i = (h = Ot()) => {
319
+ o = f(Ft([0]), h), r = f(), h.length !== 0 && (o = f(Ft([1]), h), r = f());
320
+ }, u = () => {
321
+ if (s++ >= 1e3)
322
+ throw new Error("drbg: tried 1000 values");
323
+ let h = 0;
324
+ const l = [];
325
+ for (; h < e; ) {
326
+ r = f();
327
+ const m = r.slice();
328
+ l.push(m), h += r.length;
329
+ }
330
+ return bt(...l);
331
+ };
332
+ return (h, l) => {
333
+ c(), i(h);
334
+ let m;
335
+ for (; !(m = l(u())); )
336
+ i();
337
+ return c(), m;
338
+ };
339
+ }
340
+ const Ue = {
341
+ bigint: (n) => typeof n == "bigint",
342
+ function: (n) => typeof n == "function",
343
+ boolean: (n) => typeof n == "boolean",
344
+ string: (n) => typeof n == "string",
345
+ stringOrUint8Array: (n) => typeof n == "string" || it(n),
346
+ isSafeInteger: (n) => Number.isSafeInteger(n),
347
+ array: (n) => Array.isArray(n),
348
+ field: (n, e) => e.Fp.isValid(n),
349
+ hash: (n) => typeof n == "function" && Number.isSafeInteger(n.outputLen)
350
+ };
351
+ function mt(n, e, t = {}) {
352
+ const r = (o, s, c) => {
353
+ const f = Ue[s];
354
+ if (typeof f != "function")
355
+ throw new Error("invalid validator function");
356
+ const i = n[o];
357
+ if (!(c && i === void 0) && !f(i, n))
358
+ throw new Error("param " + String(o) + " is invalid. Expected " + s + ", got " + i);
359
+ };
360
+ for (const [o, s] of Object.entries(e))
361
+ r(o, s, !1);
362
+ for (const [o, s] of Object.entries(t))
363
+ r(o, s, !0);
364
+ return n;
365
+ }
366
+ const Te = () => {
367
+ throw new Error("not implemented");
368
+ };
369
+ function _t(n) {
370
+ const e = /* @__PURE__ */ new WeakMap();
371
+ return (t, ...r) => {
372
+ const o = e.get(t);
373
+ if (o !== void 0)
374
+ return o;
375
+ const s = n(t, ...r);
376
+ return e.set(t, s), s;
377
+ };
378
+ }
379
+ const _e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
380
+ __proto__: null,
381
+ aInRange: ot,
382
+ abool: ut,
383
+ abytes: yt,
384
+ bitGet: Le,
385
+ bitLen: te,
386
+ bitMask: jt,
387
+ bitSet: He,
388
+ bytesToHex: lt,
389
+ bytesToNumberBE: rt,
390
+ bytesToNumberLE: Vt,
391
+ concatBytes: bt,
392
+ createHmacDrbg: ee,
393
+ ensureBytes: K,
394
+ equalBytes: qe,
395
+ hexToBytes: dt,
396
+ hexToNumber: Rt,
397
+ inRange: St,
398
+ isBytes: it,
399
+ memoized: _t,
400
+ notImplemented: Te,
401
+ numberToBytesBE: ht,
402
+ numberToBytesLE: Mt,
403
+ numberToHexUnpadded: at,
404
+ numberToVarBytesBE: Ne,
405
+ utf8ToBytes: Oe,
406
+ validateObject: mt
407
+ }, Symbol.toStringTag, { value: "Module" }));
408
+ class ne extends Qt {
409
+ constructor(e, t) {
410
+ super(), this.finished = !1, this.destroyed = !1, ge(e);
411
+ const r = Jt(t);
412
+ if (this.iHash = e.create(), typeof this.iHash.update != "function")
413
+ throw new Error("Expected instance of class which extends utils.Hash");
414
+ this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
415
+ const o = this.blockLen, s = new Uint8Array(o);
416
+ s.set(r.length > o ? e.create().update(r).digest() : r);
417
+ for (let c = 0; c < s.length; c++)
418
+ s[c] ^= 54;
419
+ this.iHash.update(s), this.oHash = e.create();
420
+ for (let c = 0; c < s.length; c++)
421
+ s[c] ^= 106;
422
+ this.oHash.update(s), s.fill(0);
423
+ }
424
+ update(e) {
425
+ return Et(this), this.iHash.update(e), this;
426
+ }
427
+ digestInto(e) {
428
+ Et(this), we(e, this.outputLen), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
429
+ }
430
+ digest() {
431
+ const e = new Uint8Array(this.oHash.outputLen);
432
+ return this.digestInto(e), e;
433
+ }
434
+ _cloneInto(e) {
435
+ e || (e = Object.create(Object.getPrototypeOf(this), {}));
436
+ const { oHash: t, iHash: r, finished: o, destroyed: s, blockLen: c, outputLen: f } = this;
437
+ return e = e, e.finished = o, e.destroyed = s, e.blockLen = c, e.outputLen = f, e.oHash = t._cloneInto(e.oHash), e.iHash = r._cloneInto(e.iHash), e;
438
+ }
439
+ destroy() {
440
+ this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
441
+ }
442
+ }
443
+ const re = (n, e, t) => new ne(n, e).update(t).digest();
444
+ re.create = (n, e) => new ne(n, e);
445
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
446
+ const z = BigInt(0), T = BigInt(1), nt = /* @__PURE__ */ BigInt(2), ke = /* @__PURE__ */ BigInt(3), kt = /* @__PURE__ */ BigInt(4), Kt = /* @__PURE__ */ BigInt(5), Pt = /* @__PURE__ */ BigInt(8);
447
+ function M(n, e) {
448
+ const t = n % e;
449
+ return t >= z ? t : e + t;
450
+ }
451
+ function ze(n, e, t) {
452
+ if (e < z)
453
+ throw new Error("invalid exponent, negatives unsupported");
454
+ if (t <= z)
455
+ throw new Error("invalid modulus");
456
+ if (t === T)
457
+ return z;
458
+ let r = T;
459
+ for (; e > z; )
460
+ e & T && (r = r * n % t), n = n * n % t, e >>= T;
461
+ return r;
462
+ }
463
+ function Y(n, e, t) {
464
+ let r = n;
465
+ for (; e-- > z; )
466
+ r *= r, r %= t;
467
+ return r;
468
+ }
469
+ function zt(n, e) {
470
+ if (n === z)
471
+ throw new Error("invert: expected non-zero number");
472
+ if (e <= z)
473
+ throw new Error("invert: expected positive modulus, got " + e);
474
+ let t = M(n, e), r = e, o = z, s = T;
475
+ for (; t !== z; ) {
476
+ const f = r / t, i = r % t, u = o - s * f;
477
+ r = t, t = i, o = s, s = u;
478
+ }
479
+ if (r !== T)
480
+ throw new Error("invert: does not exist");
481
+ return M(o, e);
482
+ }
483
+ function Ce(n) {
484
+ const e = (n - T) / nt;
485
+ let t, r, o;
486
+ for (t = n - T, r = 0; t % nt === z; t /= nt, r++)
487
+ ;
488
+ for (o = nt; o < n && ze(o, e, n) !== n - T; o++)
489
+ if (o > 1e3)
490
+ throw new Error("Cannot find square root: likely non-prime P");
491
+ if (r === 1) {
492
+ const c = (n + T) / kt;
493
+ return function(i, u) {
494
+ const y = i.pow(u, c);
495
+ if (!i.eql(i.sqr(y), u))
496
+ throw new Error("Cannot find square root");
497
+ return y;
498
+ };
499
+ }
500
+ const s = (t + T) / nt;
501
+ return function(f, i) {
502
+ if (f.pow(i, e) === f.neg(f.ONE))
503
+ throw new Error("Cannot find square root");
504
+ let u = r, y = f.pow(f.mul(f.ONE, o), t), h = f.pow(i, s), l = f.pow(i, t);
505
+ for (; !f.eql(l, f.ONE); ) {
506
+ if (f.eql(l, f.ZERO))
507
+ return f.ZERO;
508
+ let m = 1;
509
+ for (let b = f.sqr(l); m < u && !f.eql(b, f.ONE); m++)
510
+ b = f.sqr(b);
511
+ const N = f.pow(y, T << BigInt(u - m - 1));
512
+ y = f.sqr(N), h = f.mul(h, N), l = f.mul(l, y), u = m;
513
+ }
514
+ return h;
515
+ };
516
+ }
517
+ function Ze(n) {
518
+ if (n % kt === ke) {
519
+ const e = (n + T) / kt;
520
+ return function(r, o) {
521
+ const s = r.pow(o, e);
522
+ if (!r.eql(r.sqr(s), o))
523
+ throw new Error("Cannot find square root");
524
+ return s;
525
+ };
526
+ }
527
+ if (n % Pt === Kt) {
528
+ const e = (n - Kt) / Pt;
529
+ return function(r, o) {
530
+ const s = r.mul(o, nt), c = r.pow(s, e), f = r.mul(o, c), i = r.mul(r.mul(f, nt), c), u = r.mul(f, r.sub(i, r.ONE));
531
+ if (!r.eql(r.sqr(u), o))
532
+ throw new Error("Cannot find square root");
533
+ return u;
534
+ };
535
+ }
536
+ return Ce(n);
537
+ }
538
+ const Re = [
539
+ "create",
540
+ "isValid",
541
+ "is0",
542
+ "neg",
543
+ "inv",
544
+ "sqrt",
545
+ "sqr",
546
+ "eql",
547
+ "add",
548
+ "sub",
549
+ "mul",
550
+ "pow",
551
+ "div",
552
+ "addN",
553
+ "subN",
554
+ "mulN",
555
+ "sqrN"
556
+ ];
557
+ function Ve(n) {
558
+ const e = {
559
+ ORDER: "bigint",
560
+ MASK: "bigint",
561
+ BYTES: "isSafeInteger",
562
+ BITS: "isSafeInteger"
563
+ }, t = Re.reduce((r, o) => (r[o] = "function", r), e);
564
+ return mt(n, t);
565
+ }
566
+ function Me(n, e, t) {
567
+ if (t < z)
568
+ throw new Error("invalid exponent, negatives unsupported");
569
+ if (t === z)
570
+ return n.ONE;
571
+ if (t === T)
572
+ return e;
573
+ let r = n.ONE, o = e;
574
+ for (; t > z; )
575
+ t & T && (r = n.mul(r, o)), o = n.sqr(o), t >>= T;
576
+ return r;
577
+ }
578
+ function je(n, e) {
579
+ const t = new Array(e.length), r = e.reduce((s, c, f) => n.is0(c) ? s : (t[f] = s, n.mul(s, c)), n.ONE), o = n.inv(r);
580
+ return e.reduceRight((s, c, f) => n.is0(c) ? s : (t[f] = n.mul(s, t[f]), n.mul(s, c)), o), t;
581
+ }
582
+ function oe(n, e) {
583
+ const t = e !== void 0 ? e : n.toString(2).length, r = Math.ceil(t / 8);
584
+ return { nBitLength: t, nByteLength: r };
585
+ }
586
+ function ie(n, e, t = !1, r = {}) {
587
+ if (n <= z)
588
+ throw new Error("invalid field: expected ORDER > 0, got " + n);
589
+ const { nBitLength: o, nByteLength: s } = oe(n, e);
590
+ if (s > 2048)
591
+ throw new Error("invalid field: expected ORDER of <= 2048 bytes");
592
+ let c;
593
+ const f = Object.freeze({
594
+ ORDER: n,
595
+ isLE: t,
596
+ BITS: o,
597
+ BYTES: s,
598
+ MASK: jt(o),
599
+ ZERO: z,
600
+ ONE: T,
601
+ create: (i) => M(i, n),
602
+ isValid: (i) => {
603
+ if (typeof i != "bigint")
604
+ throw new Error("invalid field element: expected bigint, got " + typeof i);
605
+ return z <= i && i < n;
606
+ },
607
+ is0: (i) => i === z,
608
+ isOdd: (i) => (i & T) === T,
609
+ neg: (i) => M(-i, n),
610
+ eql: (i, u) => i === u,
611
+ sqr: (i) => M(i * i, n),
612
+ add: (i, u) => M(i + u, n),
613
+ sub: (i, u) => M(i - u, n),
614
+ mul: (i, u) => M(i * u, n),
615
+ pow: (i, u) => Me(f, i, u),
616
+ div: (i, u) => M(i * zt(u, n), n),
617
+ // Same as above, but doesn't normalize
618
+ sqrN: (i) => i * i,
619
+ addN: (i, u) => i + u,
620
+ subN: (i, u) => i - u,
621
+ mulN: (i, u) => i * u,
622
+ inv: (i) => zt(i, n),
623
+ sqrt: r.sqrt || ((i) => (c || (c = Ze(n)), c(f, i))),
624
+ invertBatch: (i) => je(f, i),
625
+ // TODO: do we really need constant cmov?
626
+ // We don't have const-time bigints anyway, so probably will be not very useful
627
+ cmov: (i, u, y) => y ? u : i,
628
+ toBytes: (i) => t ? Mt(i, s) : ht(i, s),
629
+ fromBytes: (i) => {
630
+ if (i.length !== s)
631
+ throw new Error("Field.fromBytes: expected " + s + " bytes, got " + i.length);
632
+ return t ? Vt(i) : rt(i);
633
+ }
634
+ });
635
+ return Object.freeze(f);
636
+ }
637
+ function se(n) {
638
+ if (typeof n != "bigint")
639
+ throw new Error("field order must be bigint");
640
+ const e = n.toString(2).length;
641
+ return Math.ceil(e / 8);
642
+ }
643
+ function ce(n) {
644
+ const e = se(n);
645
+ return e + Math.ceil(e / 2);
646
+ }
647
+ function Ye(n, e, t = !1) {
648
+ const r = n.length, o = se(e), s = ce(e);
649
+ if (r < 16 || r < s || r > 1024)
650
+ throw new Error("expected " + s + "-1024 bytes of input, got " + r);
651
+ const c = t ? Vt(n) : rt(n), f = M(c, e - T) + T;
652
+ return t ? Mt(f, o) : ht(f, o);
653
+ }
654
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
655
+ const Gt = BigInt(0), xt = BigInt(1);
656
+ function Lt(n, e) {
657
+ const t = e.negate();
658
+ return n ? t : e;
659
+ }
660
+ function fe(n, e) {
661
+ if (!Number.isSafeInteger(n) || n <= 0 || n > e)
662
+ throw new Error("invalid window size, expected [1.." + e + "], got W=" + n);
663
+ }
664
+ function Ht(n, e) {
665
+ fe(n, e);
666
+ const t = Math.ceil(e / n) + 1, r = 2 ** (n - 1);
667
+ return { windows: t, windowSize: r };
668
+ }
669
+ function Fe(n, e) {
670
+ if (!Array.isArray(n))
671
+ throw new Error("array expected");
672
+ n.forEach((t, r) => {
673
+ if (!(t instanceof e))
674
+ throw new Error("invalid point at index " + r);
675
+ });
676
+ }
677
+ function Ke(n, e) {
678
+ if (!Array.isArray(n))
679
+ throw new Error("array of scalars expected");
680
+ n.forEach((t, r) => {
681
+ if (!e.isValid(t))
682
+ throw new Error("invalid scalar at index " + r);
683
+ });
684
+ }
685
+ const Ut = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakMap();
686
+ function Tt(n) {
687
+ return ae.get(n) || 1;
688
+ }
689
+ function Pe(n, e) {
690
+ return {
691
+ constTimeNegate: Lt,
692
+ hasPrecomputes(t) {
693
+ return Tt(t) !== 1;
694
+ },
695
+ // non-const time multiplication ladder
696
+ unsafeLadder(t, r, o = n.ZERO) {
697
+ let s = t;
698
+ for (; r > Gt; )
699
+ r & xt && (o = o.add(s)), s = s.double(), r >>= xt;
700
+ return o;
701
+ },
702
+ /**
703
+ * Creates a wNAF precomputation window. Used for caching.
704
+ * Default window size is set by `utils.precompute()` and is equal to 8.
705
+ * Number of precomputed points depends on the curve size:
706
+ * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
707
+ * - 𝑊 is the window size
708
+ * - 𝑛 is the bitlength of the curve order.
709
+ * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
710
+ * @param elm Point instance
711
+ * @param W window size
712
+ * @returns precomputed point tables flattened to a single array
713
+ */
714
+ precomputeWindow(t, r) {
715
+ const { windows: o, windowSize: s } = Ht(r, e), c = [];
716
+ let f = t, i = f;
717
+ for (let u = 0; u < o; u++) {
718
+ i = f, c.push(i);
719
+ for (let y = 1; y < s; y++)
720
+ i = i.add(f), c.push(i);
721
+ f = i.double();
722
+ }
723
+ return c;
724
+ },
725
+ /**
726
+ * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
727
+ * @param W window size
728
+ * @param precomputes precomputed tables
729
+ * @param n scalar (we don't check here, but should be less than curve order)
730
+ * @returns real and fake (for const-time) points
731
+ */
732
+ wNAF(t, r, o) {
733
+ const { windows: s, windowSize: c } = Ht(t, e);
734
+ let f = n.ZERO, i = n.BASE;
735
+ const u = BigInt(2 ** t - 1), y = 2 ** t, h = BigInt(t);
736
+ for (let l = 0; l < s; l++) {
737
+ const m = l * c;
738
+ let N = Number(o & u);
739
+ o >>= h, N > c && (N -= y, o += xt);
740
+ const b = m, a = m + Math.abs(N) - 1, g = l % 2 !== 0, x = N < 0;
741
+ N === 0 ? i = i.add(Lt(g, r[b])) : f = f.add(Lt(x, r[a]));
742
+ }
743
+ return { p: f, f: i };
744
+ },
745
+ /**
746
+ * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
747
+ * @param W window size
748
+ * @param precomputes precomputed tables
749
+ * @param n scalar (we don't check here, but should be less than curve order)
750
+ * @param acc accumulator point to add result of multiplication
751
+ * @returns point
752
+ */
753
+ wNAFUnsafe(t, r, o, s = n.ZERO) {
754
+ const { windows: c, windowSize: f } = Ht(t, e), i = BigInt(2 ** t - 1), u = 2 ** t, y = BigInt(t);
755
+ for (let h = 0; h < c; h++) {
756
+ const l = h * f;
757
+ if (o === Gt)
758
+ break;
759
+ let m = Number(o & i);
760
+ if (o >>= y, m > f && (m -= u, o += xt), m === 0)
761
+ continue;
762
+ let N = r[l + Math.abs(m) - 1];
763
+ m < 0 && (N = N.negate()), s = s.add(N);
764
+ }
765
+ return s;
766
+ },
767
+ getPrecomputes(t, r, o) {
768
+ let s = Ut.get(r);
769
+ return s || (s = this.precomputeWindow(r, t), t !== 1 && Ut.set(r, o(s))), s;
770
+ },
771
+ wNAFCached(t, r, o) {
772
+ const s = Tt(t);
773
+ return this.wNAF(s, this.getPrecomputes(s, t, o), r);
774
+ },
775
+ wNAFCachedUnsafe(t, r, o, s) {
776
+ const c = Tt(t);
777
+ return c === 1 ? this.unsafeLadder(t, r, s) : this.wNAFUnsafe(c, this.getPrecomputes(c, t, o), r, s);
778
+ },
779
+ // We calculate precomputes for elliptic curve point multiplication
780
+ // using windowed method. This specifies window size and
781
+ // stores precomputed values. Usually only base point would be precomputed.
782
+ setWindowSize(t, r) {
783
+ fe(r, e), ae.set(t, r), Ut.delete(t);
784
+ }
785
+ };
786
+ }
787
+ function Ge(n, e, t, r) {
788
+ if (Fe(t, n), Ke(r, e), t.length !== r.length)
789
+ throw new Error("arrays of points and scalars must have equal length");
790
+ const o = n.ZERO, s = te(BigInt(t.length)), c = s > 12 ? s - 3 : s > 4 ? s - 2 : s ? 2 : 1, f = (1 << c) - 1, i = new Array(f + 1).fill(o), u = Math.floor((e.BITS - 1) / c) * c;
791
+ let y = o;
792
+ for (let h = u; h >= 0; h -= c) {
793
+ i.fill(o);
794
+ for (let m = 0; m < r.length; m++) {
795
+ const N = r[m], b = Number(N >> BigInt(h) & BigInt(f));
796
+ i[b] = i[b].add(t[m]);
797
+ }
798
+ let l = o;
799
+ for (let m = i.length - 1, N = o; m > 0; m--)
800
+ N = N.add(i[m]), l = l.add(N);
801
+ if (y = y.add(l), h !== 0)
802
+ for (let m = 0; m < c; m++)
803
+ y = y.double();
804
+ }
805
+ return y;
806
+ }
807
+ function ue(n) {
808
+ return Ve(n.Fp), mt(n, {
809
+ n: "bigint",
810
+ h: "bigint",
811
+ Gx: "field",
812
+ Gy: "field"
813
+ }, {
814
+ nBitLength: "isSafeInteger",
815
+ nByteLength: "isSafeInteger"
816
+ }), Object.freeze({
817
+ ...oe(n.n, n.nBitLength),
818
+ ...n,
819
+ p: n.Fp.ORDER
820
+ });
821
+ }
822
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
823
+ function Dt(n) {
824
+ n.lowS !== void 0 && ut("lowS", n.lowS), n.prehash !== void 0 && ut("prehash", n.prehash);
825
+ }
826
+ function De(n) {
827
+ const e = ue(n);
828
+ mt(e, {
829
+ a: "field",
830
+ b: "field"
831
+ }, {
832
+ allowedPrivateKeyLengths: "array",
833
+ wrapPrivateKey: "boolean",
834
+ isTorsionFree: "function",
835
+ clearCofactor: "function",
836
+ allowInfinityPoint: "boolean",
837
+ fromBytes: "function",
838
+ toBytes: "function"
839
+ });
840
+ const { endo: t, Fp: r, a: o } = e;
841
+ if (t) {
842
+ if (!r.eql(o, r.ZERO))
843
+ throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");
844
+ if (typeof t != "object" || typeof t.beta != "bigint" || typeof t.splitScalar != "function")
845
+ throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function");
846
+ }
847
+ return Object.freeze({ ...e });
848
+ }
849
+ const { bytesToNumberBE: $e, hexToBytes: We } = _e;
850
+ class Xe extends Error {
851
+ constructor(e = "") {
852
+ super(e);
853
+ }
854
+ }
855
+ const $ = {
856
+ // asn.1 DER encoding utils
857
+ Err: Xe,
858
+ // Basic building block is TLV (Tag-Length-Value)
859
+ _tlv: {
860
+ encode: (n, e) => {
861
+ const { Err: t } = $;
862
+ if (n < 0 || n > 256)
863
+ throw new t("tlv.encode: wrong tag");
864
+ if (e.length & 1)
865
+ throw new t("tlv.encode: unpadded data");
866
+ const r = e.length / 2, o = at(r);
867
+ if (o.length / 2 & 128)
868
+ throw new t("tlv.encode: long form length too big");
869
+ const s = r > 127 ? at(o.length / 2 | 128) : "";
870
+ return at(n) + s + o + e;
871
+ },
872
+ // v - value, l - left bytes (unparsed)
873
+ decode(n, e) {
874
+ const { Err: t } = $;
875
+ let r = 0;
876
+ if (n < 0 || n > 256)
877
+ throw new t("tlv.encode: wrong tag");
878
+ if (e.length < 2 || e[r++] !== n)
879
+ throw new t("tlv.decode: wrong tlv");
880
+ const o = e[r++], s = !!(o & 128);
881
+ let c = 0;
882
+ if (!s)
883
+ c = o;
884
+ else {
885
+ const i = o & 127;
886
+ if (!i)
887
+ throw new t("tlv.decode(long): indefinite length not supported");
888
+ if (i > 4)
889
+ throw new t("tlv.decode(long): byte length is too big");
890
+ const u = e.subarray(r, r + i);
891
+ if (u.length !== i)
892
+ throw new t("tlv.decode: length bytes not complete");
893
+ if (u[0] === 0)
894
+ throw new t("tlv.decode(long): zero leftmost byte");
895
+ for (const y of u)
896
+ c = c << 8 | y;
897
+ if (r += i, c < 128)
898
+ throw new t("tlv.decode(long): not minimal encoding");
899
+ }
900
+ const f = e.subarray(r, r + c);
901
+ if (f.length !== c)
902
+ throw new t("tlv.decode: wrong value length");
903
+ return { v: f, l: e.subarray(r + c) };
904
+ }
905
+ },
906
+ // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
907
+ // since we always use positive integers here. It must always be empty:
908
+ // - add zero byte if exists
909
+ // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
910
+ _int: {
911
+ encode(n) {
912
+ const { Err: e } = $;
913
+ if (n < W)
914
+ throw new e("integer: negative integers are not allowed");
915
+ let t = at(n);
916
+ if (Number.parseInt(t[0], 16) & 8 && (t = "00" + t), t.length & 1)
917
+ throw new e("unexpected DER parsing assertion: unpadded hex");
918
+ return t;
919
+ },
920
+ decode(n) {
921
+ const { Err: e } = $;
922
+ if (n[0] & 128)
923
+ throw new e("invalid signature integer: negative");
924
+ if (n[0] === 0 && !(n[1] & 128))
925
+ throw new e("invalid signature integer: unnecessary leading zero");
926
+ return $e(n);
927
+ }
928
+ },
929
+ toSig(n) {
930
+ const { Err: e, _int: t, _tlv: r } = $, o = typeof n == "string" ? We(n) : n;
931
+ yt(o);
932
+ const { v: s, l: c } = r.decode(48, o);
933
+ if (c.length)
934
+ throw new e("invalid signature: left bytes after parsing");
935
+ const { v: f, l: i } = r.decode(2, s), { v: u, l: y } = r.decode(2, i);
936
+ if (y.length)
937
+ throw new e("invalid signature: left bytes after parsing");
938
+ return { r: t.decode(f), s: t.decode(u) };
939
+ },
940
+ hexFromSig(n) {
941
+ const { _tlv: e, _int: t } = $, r = e.encode(2, t.encode(n.r)), o = e.encode(2, t.encode(n.s)), s = r + o;
942
+ return e.encode(48, s);
943
+ }
944
+ }, W = BigInt(0), k = BigInt(1);
945
+ BigInt(2);
946
+ const $t = BigInt(3);
947
+ BigInt(4);
948
+ function Qe(n) {
949
+ const e = De(n), { Fp: t } = e, r = ie(e.n, e.nBitLength), o = e.toBytes || ((b, a, g) => {
950
+ const x = a.toAffine();
951
+ return bt(Uint8Array.from([4]), t.toBytes(x.x), t.toBytes(x.y));
952
+ }), s = e.fromBytes || ((b) => {
953
+ const a = b.subarray(1), g = t.fromBytes(a.subarray(0, t.BYTES)), x = t.fromBytes(a.subarray(t.BYTES, 2 * t.BYTES));
954
+ return { x: g, y: x };
955
+ });
956
+ function c(b) {
957
+ const { a, b: g } = e, x = t.sqr(b), E = t.mul(x, b);
958
+ return t.add(t.add(E, t.mul(b, a)), g);
959
+ }
960
+ if (!t.eql(t.sqr(e.Gy), c(e.Gx)))
961
+ throw new Error("bad generator point: equation left != right");
962
+ function f(b) {
963
+ return St(b, k, e.n);
964
+ }
965
+ function i(b) {
966
+ const { allowedPrivateKeyLengths: a, nByteLength: g, wrapPrivateKey: x, n: E } = e;
967
+ if (a && typeof b != "bigint") {
968
+ if (it(b) && (b = lt(b)), typeof b != "string" || !a.includes(b.length))
969
+ throw new Error("invalid private key");
970
+ b = b.padStart(g * 2, "0");
971
+ }
972
+ let q;
973
+ try {
974
+ q = typeof b == "bigint" ? b : rt(K("private key", b, g));
975
+ } catch {
976
+ throw new Error("invalid private key, expected hex or " + g + " bytes, got " + typeof b);
977
+ }
978
+ return x && (q = M(q, E)), ot("private key", q, k, E), q;
979
+ }
980
+ function u(b) {
981
+ if (!(b instanceof l))
982
+ throw new Error("ProjectivePoint expected");
983
+ }
984
+ const y = _t((b, a) => {
985
+ const { px: g, py: x, pz: E } = b;
986
+ if (t.eql(E, t.ONE))
987
+ return { x: g, y: x };
988
+ const q = b.is0();
989
+ a == null && (a = q ? t.ONE : t.inv(E));
990
+ const L = t.mul(g, a), I = t.mul(x, a), B = t.mul(E, a);
991
+ if (q)
992
+ return { x: t.ZERO, y: t.ZERO };
993
+ if (!t.eql(B, t.ONE))
994
+ throw new Error("invZ was invalid");
995
+ return { x: L, y: I };
996
+ }), h = _t((b) => {
997
+ if (b.is0()) {
998
+ if (e.allowInfinityPoint && !t.is0(b.py))
999
+ return;
1000
+ throw new Error("bad point: ZERO");
1001
+ }
1002
+ const { x: a, y: g } = b.toAffine();
1003
+ if (!t.isValid(a) || !t.isValid(g))
1004
+ throw new Error("bad point: x or y not FE");
1005
+ const x = t.sqr(g), E = c(a);
1006
+ if (!t.eql(x, E))
1007
+ throw new Error("bad point: equation left != right");
1008
+ if (!b.isTorsionFree())
1009
+ throw new Error("bad point: not in prime-order subgroup");
1010
+ return !0;
1011
+ });
1012
+ class l {
1013
+ constructor(a, g, x) {
1014
+ if (this.px = a, this.py = g, this.pz = x, a == null || !t.isValid(a))
1015
+ throw new Error("x required");
1016
+ if (g == null || !t.isValid(g))
1017
+ throw new Error("y required");
1018
+ if (x == null || !t.isValid(x))
1019
+ throw new Error("z required");
1020
+ Object.freeze(this);
1021
+ }
1022
+ // Does not validate if the point is on-curve.
1023
+ // Use fromHex instead, or call assertValidity() later.
1024
+ static fromAffine(a) {
1025
+ const { x: g, y: x } = a || {};
1026
+ if (!a || !t.isValid(g) || !t.isValid(x))
1027
+ throw new Error("invalid affine point");
1028
+ if (a instanceof l)
1029
+ throw new Error("projective point not allowed");
1030
+ const E = (q) => t.eql(q, t.ZERO);
1031
+ return E(g) && E(x) ? l.ZERO : new l(g, x, t.ONE);
1032
+ }
1033
+ get x() {
1034
+ return this.toAffine().x;
1035
+ }
1036
+ get y() {
1037
+ return this.toAffine().y;
1038
+ }
1039
+ /**
1040
+ * Takes a bunch of Projective Points but executes only one
1041
+ * inversion on all of them. Inversion is very slow operation,
1042
+ * so this improves performance massively.
1043
+ * Optimization: converts a list of projective points to a list of identical points with Z=1.
1044
+ */
1045
+ static normalizeZ(a) {
1046
+ const g = t.invertBatch(a.map((x) => x.pz));
1047
+ return a.map((x, E) => x.toAffine(g[E])).map(l.fromAffine);
1048
+ }
1049
+ /**
1050
+ * Converts hash string or Uint8Array to Point.
1051
+ * @param hex short/long ECDSA hex
1052
+ */
1053
+ static fromHex(a) {
1054
+ const g = l.fromAffine(s(K("pointHex", a)));
1055
+ return g.assertValidity(), g;
1056
+ }
1057
+ // Multiplies generator point by privateKey.
1058
+ static fromPrivateKey(a) {
1059
+ return l.BASE.multiply(i(a));
1060
+ }
1061
+ // Multiscalar Multiplication
1062
+ static msm(a, g) {
1063
+ return Ge(l, r, a, g);
1064
+ }
1065
+ // "Private method", don't use it directly
1066
+ _setWindowSize(a) {
1067
+ N.setWindowSize(this, a);
1068
+ }
1069
+ // A point on curve is valid if it conforms to equation.
1070
+ assertValidity() {
1071
+ h(this);
1072
+ }
1073
+ hasEvenY() {
1074
+ const { y: a } = this.toAffine();
1075
+ if (t.isOdd)
1076
+ return !t.isOdd(a);
1077
+ throw new Error("Field doesn't support isOdd");
1078
+ }
1079
+ /**
1080
+ * Compare one point to another.
1081
+ */
1082
+ equals(a) {
1083
+ u(a);
1084
+ const { px: g, py: x, pz: E } = this, { px: q, py: L, pz: I } = a, B = t.eql(t.mul(g, I), t.mul(q, E)), A = t.eql(t.mul(x, I), t.mul(L, E));
1085
+ return B && A;
1086
+ }
1087
+ /**
1088
+ * Flips point to one corresponding to (x, -y) in Affine coordinates.
1089
+ */
1090
+ negate() {
1091
+ return new l(this.px, t.neg(this.py), this.pz);
1092
+ }
1093
+ // Renes-Costello-Batina exception-free doubling formula.
1094
+ // There is 30% faster Jacobian formula, but it is not complete.
1095
+ // https://eprint.iacr.org/2015/1060, algorithm 3
1096
+ // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
1097
+ double() {
1098
+ const { a, b: g } = e, x = t.mul(g, $t), { px: E, py: q, pz: L } = this;
1099
+ let I = t.ZERO, B = t.ZERO, A = t.ZERO, v = t.mul(E, E), C = t.mul(q, q), U = t.mul(L, L), H = t.mul(E, q);
1100
+ return H = t.add(H, H), A = t.mul(E, L), A = t.add(A, A), I = t.mul(a, A), B = t.mul(x, U), B = t.add(I, B), I = t.sub(C, B), B = t.add(C, B), B = t.mul(I, B), I = t.mul(H, I), A = t.mul(x, A), U = t.mul(a, U), H = t.sub(v, U), H = t.mul(a, H), H = t.add(H, A), A = t.add(v, v), v = t.add(A, v), v = t.add(v, U), v = t.mul(v, H), B = t.add(B, v), U = t.mul(q, L), U = t.add(U, U), v = t.mul(U, H), I = t.sub(I, v), A = t.mul(U, C), A = t.add(A, A), A = t.add(A, A), new l(I, B, A);
1101
+ }
1102
+ // Renes-Costello-Batina exception-free addition formula.
1103
+ // There is 30% faster Jacobian formula, but it is not complete.
1104
+ // https://eprint.iacr.org/2015/1060, algorithm 1
1105
+ // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
1106
+ add(a) {
1107
+ u(a);
1108
+ const { px: g, py: x, pz: E } = this, { px: q, py: L, pz: I } = a;
1109
+ let B = t.ZERO, A = t.ZERO, v = t.ZERO;
1110
+ const C = e.a, U = t.mul(e.b, $t);
1111
+ let H = t.mul(g, q), j = t.mul(x, L), d = t.mul(E, I), w = t.add(g, x), p = t.add(q, L);
1112
+ w = t.mul(w, p), p = t.add(H, j), w = t.sub(w, p), p = t.add(g, E);
1113
+ let S = t.add(q, I);
1114
+ return p = t.mul(p, S), S = t.add(H, d), p = t.sub(p, S), S = t.add(x, E), B = t.add(L, I), S = t.mul(S, B), B = t.add(j, d), S = t.sub(S, B), v = t.mul(C, p), B = t.mul(U, d), v = t.add(B, v), B = t.sub(j, v), v = t.add(j, v), A = t.mul(B, v), j = t.add(H, H), j = t.add(j, H), d = t.mul(C, d), p = t.mul(U, p), j = t.add(j, d), d = t.sub(H, d), d = t.mul(C, d), p = t.add(p, d), H = t.mul(j, p), A = t.add(A, H), H = t.mul(S, p), B = t.mul(w, B), B = t.sub(B, H), H = t.mul(w, j), v = t.mul(S, v), v = t.add(v, H), new l(B, A, v);
1115
+ }
1116
+ subtract(a) {
1117
+ return this.add(a.negate());
1118
+ }
1119
+ is0() {
1120
+ return this.equals(l.ZERO);
1121
+ }
1122
+ wNAF(a) {
1123
+ return N.wNAFCached(this, a, l.normalizeZ);
1124
+ }
1125
+ /**
1126
+ * Non-constant-time multiplication. Uses double-and-add algorithm.
1127
+ * It's faster, but should only be used when you don't care about
1128
+ * an exposed private key e.g. sig verification, which works over *public* keys.
1129
+ */
1130
+ multiplyUnsafe(a) {
1131
+ const { endo: g, n: x } = e;
1132
+ ot("scalar", a, W, x);
1133
+ const E = l.ZERO;
1134
+ if (a === W)
1135
+ return E;
1136
+ if (this.is0() || a === k)
1137
+ return this;
1138
+ if (!g || N.hasPrecomputes(this))
1139
+ return N.wNAFCachedUnsafe(this, a, l.normalizeZ);
1140
+ let { k1neg: q, k1: L, k2neg: I, k2: B } = g.splitScalar(a), A = E, v = E, C = this;
1141
+ for (; L > W || B > W; )
1142
+ L & k && (A = A.add(C)), B & k && (v = v.add(C)), C = C.double(), L >>= k, B >>= k;
1143
+ return q && (A = A.negate()), I && (v = v.negate()), v = new l(t.mul(v.px, g.beta), v.py, v.pz), A.add(v);
1144
+ }
1145
+ /**
1146
+ * Constant time multiplication.
1147
+ * Uses wNAF method. Windowed method may be 10% faster,
1148
+ * but takes 2x longer to generate and consumes 2x memory.
1149
+ * Uses precomputes when available.
1150
+ * Uses endomorphism for Koblitz curves.
1151
+ * @param scalar by which the point would be multiplied
1152
+ * @returns New point
1153
+ */
1154
+ multiply(a) {
1155
+ const { endo: g, n: x } = e;
1156
+ ot("scalar", a, k, x);
1157
+ let E, q;
1158
+ if (g) {
1159
+ const { k1neg: L, k1: I, k2neg: B, k2: A } = g.splitScalar(a);
1160
+ let { p: v, f: C } = this.wNAF(I), { p: U, f: H } = this.wNAF(A);
1161
+ v = N.constTimeNegate(L, v), U = N.constTimeNegate(B, U), U = new l(t.mul(U.px, g.beta), U.py, U.pz), E = v.add(U), q = C.add(H);
1162
+ } else {
1163
+ const { p: L, f: I } = this.wNAF(a);
1164
+ E = L, q = I;
1165
+ }
1166
+ return l.normalizeZ([E, q])[0];
1167
+ }
1168
+ /**
1169
+ * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
1170
+ * Not using Strauss-Shamir trick: precomputation tables are faster.
1171
+ * The trick could be useful if both P and Q are not G (not in our case).
1172
+ * @returns non-zero affine point
1173
+ */
1174
+ multiplyAndAddUnsafe(a, g, x) {
1175
+ const E = l.BASE, q = (I, B) => B === W || B === k || !I.equals(E) ? I.multiplyUnsafe(B) : I.multiply(B), L = q(this, g).add(q(a, x));
1176
+ return L.is0() ? void 0 : L;
1177
+ }
1178
+ // Converts Projective point to affine (x, y) coordinates.
1179
+ // Can accept precomputed Z^-1 - for example, from invertBatch.
1180
+ // (x, y, z) ∋ (x=x/z, y=y/z)
1181
+ toAffine(a) {
1182
+ return y(this, a);
1183
+ }
1184
+ isTorsionFree() {
1185
+ const { h: a, isTorsionFree: g } = e;
1186
+ if (a === k)
1187
+ return !0;
1188
+ if (g)
1189
+ return g(l, this);
1190
+ throw new Error("isTorsionFree() has not been declared for the elliptic curve");
1191
+ }
1192
+ clearCofactor() {
1193
+ const { h: a, clearCofactor: g } = e;
1194
+ return a === k ? this : g ? g(l, this) : this.multiplyUnsafe(e.h);
1195
+ }
1196
+ toRawBytes(a = !0) {
1197
+ return ut("isCompressed", a), this.assertValidity(), o(l, this, a);
1198
+ }
1199
+ toHex(a = !0) {
1200
+ return ut("isCompressed", a), lt(this.toRawBytes(a));
1201
+ }
1202
+ }
1203
+ l.BASE = new l(e.Gx, e.Gy, t.ONE), l.ZERO = new l(t.ZERO, t.ONE, t.ZERO);
1204
+ const m = e.nBitLength, N = Pe(l, e.endo ? Math.ceil(m / 2) : m);
1205
+ return {
1206
+ CURVE: e,
1207
+ ProjectivePoint: l,
1208
+ normPrivateKeyToScalar: i,
1209
+ weierstrassEquation: c,
1210
+ isWithinCurveOrder: f
1211
+ };
1212
+ }
1213
+ function Je(n) {
1214
+ const e = ue(n);
1215
+ return mt(e, {
1216
+ hash: "hash",
1217
+ hmac: "function",
1218
+ randomBytes: "function"
1219
+ }, {
1220
+ bits2int: "function",
1221
+ bits2int_modN: "function",
1222
+ lowS: "boolean"
1223
+ }), Object.freeze({ lowS: !0, ...e });
1224
+ }
1225
+ function tn(n) {
1226
+ const e = Je(n), { Fp: t, n: r } = e, o = t.BYTES + 1, s = 2 * t.BYTES + 1;
1227
+ function c(d) {
1228
+ return M(d, r);
1229
+ }
1230
+ function f(d) {
1231
+ return zt(d, r);
1232
+ }
1233
+ const { ProjectivePoint: i, normPrivateKeyToScalar: u, weierstrassEquation: y, isWithinCurveOrder: h } = Qe({
1234
+ ...e,
1235
+ toBytes(d, w, p) {
1236
+ const S = w.toAffine(), O = t.toBytes(S.x), _ = bt;
1237
+ return ut("isCompressed", p), p ? _(Uint8Array.from([w.hasEvenY() ? 2 : 3]), O) : _(Uint8Array.from([4]), O, t.toBytes(S.y));
1238
+ },
1239
+ fromBytes(d) {
1240
+ const w = d.length, p = d[0], S = d.subarray(1);
1241
+ if (w === o && (p === 2 || p === 3)) {
1242
+ const O = rt(S);
1243
+ if (!St(O, k, t.ORDER))
1244
+ throw new Error("Point is not on curve");
1245
+ const _ = y(O);
1246
+ let R;
1247
+ try {
1248
+ R = t.sqrt(_);
1249
+ } catch (F) {
1250
+ const V = F instanceof Error ? ": " + F.message : "";
1251
+ throw new Error("Point is not on curve" + V);
1252
+ }
1253
+ const Z = (R & k) === k;
1254
+ return (p & 1) === 1 !== Z && (R = t.neg(R)), { x: O, y: R };
1255
+ } else if (w === s && p === 4) {
1256
+ const O = t.fromBytes(S.subarray(0, t.BYTES)), _ = t.fromBytes(S.subarray(t.BYTES, 2 * t.BYTES));
1257
+ return { x: O, y: _ };
1258
+ } else {
1259
+ const O = o, _ = s;
1260
+ throw new Error("invalid Point, expected length of " + O + ", or uncompressed " + _ + ", got " + w);
1261
+ }
1262
+ }
1263
+ }), l = (d) => lt(ht(d, e.nByteLength));
1264
+ function m(d) {
1265
+ const w = r >> k;
1266
+ return d > w;
1267
+ }
1268
+ function N(d) {
1269
+ return m(d) ? c(-d) : d;
1270
+ }
1271
+ const b = (d, w, p) => rt(d.slice(w, p));
1272
+ class a {
1273
+ constructor(w, p, S) {
1274
+ this.r = w, this.s = p, this.recovery = S, this.assertValidity();
1275
+ }
1276
+ // pair (bytes of r, bytes of s)
1277
+ static fromCompact(w) {
1278
+ const p = e.nByteLength;
1279
+ return w = K("compactSignature", w, p * 2), new a(b(w, 0, p), b(w, p, 2 * p));
1280
+ }
1281
+ // DER encoded ECDSA signature
1282
+ // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
1283
+ static fromDER(w) {
1284
+ const { r: p, s: S } = $.toSig(K("DER", w));
1285
+ return new a(p, S);
1286
+ }
1287
+ assertValidity() {
1288
+ ot("r", this.r, k, r), ot("s", this.s, k, r);
1289
+ }
1290
+ addRecoveryBit(w) {
1291
+ return new a(this.r, this.s, w);
1292
+ }
1293
+ recoverPublicKey(w) {
1294
+ const { r: p, s: S, recovery: O } = this, _ = I(K("msgHash", w));
1295
+ if (O == null || ![0, 1, 2, 3].includes(O))
1296
+ throw new Error("recovery id invalid");
1297
+ const R = O === 2 || O === 3 ? p + e.n : p;
1298
+ if (R >= t.ORDER)
1299
+ throw new Error("recovery id 2 or 3 invalid");
1300
+ const Z = O & 1 ? "03" : "02", G = i.fromHex(Z + l(R)), F = f(R), V = c(-_ * F), st = c(S * F), X = i.BASE.multiplyAndAddUnsafe(G, V, st);
1301
+ if (!X)
1302
+ throw new Error("point at infinify");
1303
+ return X.assertValidity(), X;
1304
+ }
1305
+ // Signatures should be low-s, to prevent malleability.
1306
+ hasHighS() {
1307
+ return m(this.s);
1308
+ }
1309
+ normalizeS() {
1310
+ return this.hasHighS() ? new a(this.r, c(-this.s), this.recovery) : this;
1311
+ }
1312
+ // DER-encoded
1313
+ toDERRawBytes() {
1314
+ return dt(this.toDERHex());
1315
+ }
1316
+ toDERHex() {
1317
+ return $.hexFromSig({ r: this.r, s: this.s });
1318
+ }
1319
+ // padded bytes of r, then padded bytes of s
1320
+ toCompactRawBytes() {
1321
+ return dt(this.toCompactHex());
1322
+ }
1323
+ toCompactHex() {
1324
+ return l(this.r) + l(this.s);
1325
+ }
1326
+ }
1327
+ const g = {
1328
+ isValidPrivateKey(d) {
1329
+ try {
1330
+ return u(d), !0;
1331
+ } catch {
1332
+ return !1;
1333
+ }
1334
+ },
1335
+ normPrivateKeyToScalar: u,
1336
+ /**
1337
+ * Produces cryptographically secure private key from random of size
1338
+ * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.
1339
+ */
1340
+ randomPrivateKey: () => {
1341
+ const d = ce(e.n);
1342
+ return Ye(e.randomBytes(d), e.n);
1343
+ },
1344
+ /**
1345
+ * Creates precompute table for an arbitrary EC point. Makes point "cached".
1346
+ * Allows to massively speed-up `point.multiply(scalar)`.
1347
+ * @returns cached point
1348
+ * @example
1349
+ * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));
1350
+ * fast.multiply(privKey); // much faster ECDH now
1351
+ */
1352
+ precompute(d = 8, w = i.BASE) {
1353
+ return w._setWindowSize(d), w.multiply(BigInt(3)), w;
1354
+ }
1355
+ };
1356
+ function x(d, w = !0) {
1357
+ return i.fromPrivateKey(d).toRawBytes(w);
1358
+ }
1359
+ function E(d) {
1360
+ const w = it(d), p = typeof d == "string", S = (w || p) && d.length;
1361
+ return w ? S === o || S === s : p ? S === 2 * o || S === 2 * s : d instanceof i;
1362
+ }
1363
+ function q(d, w, p = !0) {
1364
+ if (E(d))
1365
+ throw new Error("first arg must be private key");
1366
+ if (!E(w))
1367
+ throw new Error("second arg must be public key");
1368
+ return i.fromHex(w).multiply(u(d)).toRawBytes(p);
1369
+ }
1370
+ const L = e.bits2int || function(d) {
1371
+ if (d.length > 8192)
1372
+ throw new Error("input is too large");
1373
+ const w = rt(d), p = d.length * 8 - e.nBitLength;
1374
+ return p > 0 ? w >> BigInt(p) : w;
1375
+ }, I = e.bits2int_modN || function(d) {
1376
+ return c(L(d));
1377
+ }, B = jt(e.nBitLength);
1378
+ function A(d) {
1379
+ return ot("num < 2^" + e.nBitLength, d, W, B), ht(d, e.nByteLength);
1380
+ }
1381
+ function v(d, w, p = C) {
1382
+ if (["recovered", "canonical"].some((tt) => tt in p))
1383
+ throw new Error("sign() legacy options not supported");
1384
+ const { hash: S, randomBytes: O } = e;
1385
+ let { lowS: _, prehash: R, extraEntropy: Z } = p;
1386
+ _ == null && (_ = !0), d = K("msgHash", d), Dt(p), R && (d = K("prehashed msgHash", S(d)));
1387
+ const G = I(d), F = u(w), V = [A(F), A(G)];
1388
+ if (Z != null && Z !== !1) {
1389
+ const tt = Z === !0 ? O(t.BYTES) : Z;
1390
+ V.push(K("extraEntropy", tt));
1391
+ }
1392
+ const st = bt(...V), X = G;
1393
+ function At(tt) {
1394
+ const ct = L(tt);
1395
+ if (!h(ct))
1396
+ return;
1397
+ const It = f(ct), gt = i.BASE.multiply(ct).toAffine(), et = c(gt.x);
1398
+ if (et === W)
1399
+ return;
1400
+ const wt = c(It * c(X + et * F));
1401
+ if (wt === W)
1402
+ return;
1403
+ let pt = (gt.x === et ? 0 : 2) | Number(gt.y & k), ft = wt;
1404
+ return _ && m(wt) && (ft = N(wt), pt ^= 1), new a(et, ft, pt);
1405
+ }
1406
+ return { seed: st, k2sig: At };
1407
+ }
1408
+ const C = { lowS: e.lowS, prehash: !1 }, U = { lowS: e.lowS, prehash: !1 };
1409
+ function H(d, w, p = C) {
1410
+ const { seed: S, k2sig: O } = v(d, w, p), _ = e;
1411
+ return ee(_.hash.outputLen, _.nByteLength, _.hmac)(S, O);
1412
+ }
1413
+ i.BASE._setWindowSize(8);
1414
+ function j(d, w, p, S = U) {
1415
+ var pt;
1416
+ const O = d;
1417
+ w = K("msgHash", w), p = K("publicKey", p);
1418
+ const { lowS: _, prehash: R, format: Z } = S;
1419
+ if (Dt(S), "strict" in S)
1420
+ throw new Error("options.strict was renamed to lowS");
1421
+ if (Z !== void 0 && Z !== "compact" && Z !== "der")
1422
+ throw new Error("format must be compact or der");
1423
+ const G = typeof O == "string" || it(O), F = !G && !Z && typeof O == "object" && O !== null && typeof O.r == "bigint" && typeof O.s == "bigint";
1424
+ if (!G && !F)
1425
+ throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
1426
+ let V, st;
1427
+ try {
1428
+ if (F && (V = new a(O.r, O.s)), G) {
1429
+ try {
1430
+ Z !== "compact" && (V = a.fromDER(O));
1431
+ } catch (ft) {
1432
+ if (!(ft instanceof $.Err))
1433
+ throw ft;
1434
+ }
1435
+ !V && Z !== "der" && (V = a.fromCompact(O));
1436
+ }
1437
+ st = i.fromHex(p);
1438
+ } catch {
1439
+ return !1;
1440
+ }
1441
+ if (!V || _ && V.hasHighS())
1442
+ return !1;
1443
+ R && (w = e.hash(w));
1444
+ const { r: X, s: At } = V, tt = I(w), ct = f(At), It = c(tt * ct), gt = c(X * ct), et = (pt = i.BASE.multiplyAndAddUnsafe(st, It, gt)) == null ? void 0 : pt.toAffine();
1445
+ return et ? c(et.x) === X : !1;
1446
+ }
1447
+ return {
1448
+ CURVE: e,
1449
+ getPublicKey: x,
1450
+ getSharedSecret: q,
1451
+ sign: H,
1452
+ verify: j,
1453
+ ProjectivePoint: i,
1454
+ Signature: a,
1455
+ utils: g
1456
+ };
1457
+ }
1458
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1459
+ function en(n) {
1460
+ return {
1461
+ hash: n,
1462
+ hmac: (e, ...t) => re(n, e, be(...t)),
1463
+ randomBytes: pe
1464
+ };
1465
+ }
1466
+ function nn(n, e) {
1467
+ const t = (r) => tn({ ...n, ...en(r) });
1468
+ return { ...t(e), create: t };
1469
+ }
1470
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1471
+ const le = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), Wt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), rn = BigInt(1), Ct = BigInt(2), Xt = (n, e) => (n + e / Ct) / e;
1472
+ function on(n) {
1473
+ const e = le, t = BigInt(3), r = BigInt(6), o = BigInt(11), s = BigInt(22), c = BigInt(23), f = BigInt(44), i = BigInt(88), u = n * n * n % e, y = u * u * n % e, h = Y(y, t, e) * y % e, l = Y(h, t, e) * y % e, m = Y(l, Ct, e) * u % e, N = Y(m, o, e) * m % e, b = Y(N, s, e) * N % e, a = Y(b, f, e) * b % e, g = Y(a, i, e) * a % e, x = Y(g, f, e) * b % e, E = Y(x, t, e) * y % e, q = Y(E, c, e) * N % e, L = Y(q, r, e) * u % e, I = Y(L, Ct, e);
1474
+ if (!Zt.eql(Zt.sqr(I), n))
1475
+ throw new Error("Cannot find square root");
1476
+ return I;
1477
+ }
1478
+ const Zt = ie(le, void 0, void 0, { sqrt: on }), sn = nn({
1479
+ a: BigInt(0),
1480
+ // equation params: a, b
1481
+ b: BigInt(7),
1482
+ Fp: Zt,
1483
+ // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n
1484
+ n: Wt,
1485
+ // Curve order, total count of valid points in the field
1486
+ // Base point (x, y) aka generator point
1487
+ Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
1488
+ Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),
1489
+ h: BigInt(1),
1490
+ // Cofactor
1491
+ lowS: !0,
1492
+ // Allow only low-S signatures by default in sign() and verify()
1493
+ endo: {
1494
+ // Endomorphism, see above
1495
+ beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
1496
+ splitScalar: (n) => {
1497
+ const e = Wt, t = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -rn * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), o = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), s = t, c = BigInt("0x100000000000000000000000000000000"), f = Xt(s * n, e), i = Xt(-r * n, e);
1498
+ let u = M(n - f * t - i * o, e), y = M(-f * r - i * s, e);
1499
+ const h = u > c, l = y > c;
1500
+ if (h && (u = e - u), l && (y = e - y), u > c || y > c)
1501
+ throw new Error("splitScalar: Endomorphism failed, k=" + n);
1502
+ return { k1neg: h, k1: u, k2neg: l, k2: y };
1503
+ }
1504
+ }
1505
+ }, Se);
1506
+ BigInt(0);
1507
+ sn.ProjectivePoint;
1508
+ export {
1509
+ sn as secp256k1
1510
+ };