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