@pufferfinance/puffer-sdk 1.28.1 → 1.28.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/dist/api/puffer-client-helpers.cjs +1 -1
  2. package/dist/api/puffer-client-helpers.cjs.map +1 -1
  3. package/dist/api/puffer-client-helpers.js +7 -7
  4. package/dist/api/puffer-client-helpers.js.map +1 -1
  5. package/dist/api/puffer-client.cjs +1 -1
  6. package/dist/api/puffer-client.cjs.map +1 -1
  7. package/dist/api/puffer-client.js +119 -122
  8. package/dist/api/puffer-client.js.map +1 -1
  9. package/dist/ccip-78YM988s.js +150 -0
  10. package/dist/{ccip-C76-YhQK.js.map → ccip-78YM988s.js.map} +1 -1
  11. package/dist/ccip-LIGR3N1A.cjs +2 -0
  12. package/dist/{ccip-CEodLZ4s.cjs.map → ccip-LIGR3N1A.cjs.map} +1 -1
  13. package/dist/chains/constants.cjs +1 -1
  14. package/dist/chains/constants.js +1 -1
  15. package/dist/constants-6kuRTsbU.cjs +9 -0
  16. package/dist/{constants-CxSgz27h.cjs.map → constants-6kuRTsbU.cjs.map} +1 -1
  17. package/dist/{constants-C9YZ6Ewc.js → constants-CuIEh_ZS.js} +605 -656
  18. package/dist/{constants-C9YZ6Ewc.js.map → constants-CuIEh_ZS.js.map} +1 -1
  19. package/dist/contracts/abis/mainnet/Accountant.cjs.map +1 -1
  20. package/dist/contracts/abis/mainnet/Accountant.js.map +1 -1
  21. package/dist/contracts/abis/mainnet/AtomicQueue.cjs.map +1 -1
  22. package/dist/contracts/abis/mainnet/AtomicQueue.js.map +1 -1
  23. package/dist/contracts/abis/mainnet/BoringVault.cjs.map +1 -1
  24. package/dist/contracts/abis/mainnet/BoringVault.js.map +1 -1
  25. package/dist/contracts/abis/mainnet/CarrotStaker.cjs.map +1 -1
  26. package/dist/contracts/abis/mainnet/CarrotStaker.js.map +1 -1
  27. package/dist/contracts/abis/mainnet/CarrotVesting.cjs +1 -1
  28. package/dist/contracts/abis/mainnet/CarrotVesting.cjs.map +1 -1
  29. package/dist/contracts/abis/mainnet/CarrotVesting.d.ts +84 -92
  30. package/dist/contracts/abis/mainnet/CarrotVesting.js +56 -62
  31. package/dist/contracts/abis/mainnet/CarrotVesting.js.map +1 -1
  32. package/dist/contracts/abis/mainnet/ConcreteMultiStrategyVault.cjs.map +1 -1
  33. package/dist/contracts/abis/mainnet/ConcreteMultiStrategyVault.js.map +1 -1
  34. package/dist/contracts/abis/mainnet/Distributor.cjs.map +1 -1
  35. package/dist/contracts/abis/mainnet/Distributor.js.map +1 -1
  36. package/dist/contracts/abis/mainnet/ERC20Permit.cjs.map +1 -1
  37. package/dist/contracts/abis/mainnet/ERC20Permit.js.map +1 -1
  38. package/dist/contracts/abis/mainnet/GaugeRegistry.cjs.map +1 -1
  39. package/dist/contracts/abis/mainnet/GaugeRegistry.js.map +1 -1
  40. package/dist/contracts/abis/mainnet/GuardianModule.cjs.map +1 -1
  41. package/dist/contracts/abis/mainnet/GuardianModule.js.map +1 -1
  42. package/dist/contracts/abis/mainnet/InstitutionalAccessManager.cjs.map +1 -1
  43. package/dist/contracts/abis/mainnet/InstitutionalAccessManager.js.map +1 -1
  44. package/dist/contracts/abis/mainnet/InstitutionalVault.cjs.map +1 -1
  45. package/dist/contracts/abis/mainnet/InstitutionalVault.js.map +1 -1
  46. package/dist/contracts/abis/mainnet/L1RewardManager.cjs.map +1 -1
  47. package/dist/contracts/abis/mainnet/L1RewardManager.js.map +1 -1
  48. package/dist/contracts/abis/mainnet/L2RewardManager.cjs.map +1 -1
  49. package/dist/contracts/abis/mainnet/L2RewardManager.js.map +1 -1
  50. package/dist/contracts/abis/mainnet/LagoonVault.cjs.map +1 -1
  51. package/dist/contracts/abis/mainnet/LagoonVault.js.map +1 -1
  52. package/dist/contracts/abis/mainnet/PufLocker.cjs.map +1 -1
  53. package/dist/contracts/abis/mainnet/PufLocker.js.map +1 -1
  54. package/dist/contracts/abis/mainnet/PufferDepositor.cjs.map +1 -1
  55. package/dist/contracts/abis/mainnet/PufferDepositor.js.map +1 -1
  56. package/dist/contracts/abis/mainnet/PufferL2Depositor.cjs.map +1 -1
  57. package/dist/contracts/abis/mainnet/PufferL2Depositor.js.map +1 -1
  58. package/dist/contracts/abis/mainnet/PufferOracleV2.cjs.map +1 -1
  59. package/dist/contracts/abis/mainnet/PufferOracleV2.js.map +1 -1
  60. package/dist/contracts/abis/mainnet/PufferProtocol.cjs.map +1 -1
  61. package/dist/contracts/abis/mainnet/PufferProtocol.js.map +1 -1
  62. package/dist/contracts/abis/mainnet/PufferVaultV5.cjs.map +1 -1
  63. package/dist/contracts/abis/mainnet/PufferVaultV5.js.map +1 -1
  64. package/dist/contracts/abis/mainnet/PufferWithdrawalManager.cjs.map +1 -1
  65. package/dist/contracts/abis/mainnet/PufferWithdrawalManager.js.map +1 -1
  66. package/dist/contracts/abis/mainnet/Teller.cjs.map +1 -1
  67. package/dist/contracts/abis/mainnet/Teller.js.map +1 -1
  68. package/dist/contracts/abis/mainnet/ValidatorTicket.cjs.map +1 -1
  69. package/dist/contracts/abis/mainnet/ValidatorTicket.js.map +1 -1
  70. package/dist/contracts/abis/mainnet/mtwCARROT.cjs.map +1 -1
  71. package/dist/contracts/abis/mainnet/mtwCARROT.js.map +1 -1
  72. package/dist/contracts/abis/mainnet/vlPUFFER.cjs.map +1 -1
  73. package/dist/contracts/abis/mainnet/vlPUFFER.js.map +1 -1
  74. package/dist/contracts/addresses.cjs +1 -1
  75. package/dist/contracts/addresses.cjs.map +1 -1
  76. package/dist/contracts/addresses.js +5 -5
  77. package/dist/contracts/addresses.js.map +1 -1
  78. package/dist/contracts/handlers/carrot-staking-handler.cjs +1 -1
  79. package/dist/contracts/handlers/carrot-staking-handler.cjs.map +1 -1
  80. package/dist/contracts/handlers/carrot-staking-handler.d.ts +96 -6599
  81. package/dist/contracts/handlers/carrot-staking-handler.js +13 -16
  82. package/dist/contracts/handlers/carrot-staking-handler.js.map +1 -1
  83. package/dist/contracts/handlers/carrot-vesting-handler.cjs +1 -1
  84. package/dist/contracts/handlers/carrot-vesting-handler.cjs.map +1 -1
  85. package/dist/contracts/handlers/carrot-vesting-handler.d.ts +102 -6605
  86. package/dist/contracts/handlers/carrot-vesting-handler.js +25 -39
  87. package/dist/contracts/handlers/carrot-vesting-handler.js.map +1 -1
  88. package/dist/contracts/handlers/concrete-vault-handler.cjs +1 -1
  89. package/dist/contracts/handlers/concrete-vault-handler.cjs.map +1 -1
  90. package/dist/contracts/handlers/concrete-vault-handler.d.ts +96 -6599
  91. package/dist/contracts/handlers/concrete-vault-handler.js +15 -18
  92. package/dist/contracts/handlers/concrete-vault-handler.js.map +1 -1
  93. package/dist/contracts/handlers/distributor-handler.cjs +1 -1
  94. package/dist/contracts/handlers/distributor-handler.cjs.map +1 -1
  95. package/dist/contracts/handlers/distributor-handler.d.ts +96 -6599
  96. package/dist/contracts/handlers/distributor-handler.js +15 -18
  97. package/dist/contracts/handlers/distributor-handler.js.map +1 -1
  98. package/dist/contracts/handlers/erc20-permit-handler.cjs +1 -1
  99. package/dist/contracts/handlers/erc20-permit-handler.cjs.map +1 -1
  100. package/dist/contracts/handlers/erc20-permit-handler.d.ts +96 -6599
  101. package/dist/contracts/handlers/erc20-permit-handler.js +34 -38
  102. package/dist/contracts/handlers/erc20-permit-handler.js.map +1 -1
  103. package/dist/contracts/handlers/gauge-registry-handler.cjs +1 -1
  104. package/dist/contracts/handlers/gauge-registry-handler.cjs.map +1 -1
  105. package/dist/contracts/handlers/gauge-registry-handler.d.ts +96 -6599
  106. package/dist/contracts/handlers/gauge-registry-handler.js +11 -14
  107. package/dist/contracts/handlers/gauge-registry-handler.js.map +1 -1
  108. package/dist/contracts/handlers/guardian-module-handler.cjs +1 -1
  109. package/dist/contracts/handlers/guardian-module-handler.cjs.map +1 -1
  110. package/dist/contracts/handlers/guardian-module-handler.d.ts +96 -6599
  111. package/dist/contracts/handlers/guardian-module-handler.js +11 -14
  112. package/dist/contracts/handlers/guardian-module-handler.js.map +1 -1
  113. package/dist/contracts/handlers/institutional-access-manager-handler.cjs +1 -1
  114. package/dist/contracts/handlers/institutional-access-manager-handler.cjs.map +1 -1
  115. package/dist/contracts/handlers/institutional-access-manager-handler.d.ts +96 -6599
  116. package/dist/contracts/handlers/institutional-access-manager-handler.js +45 -50
  117. package/dist/contracts/handlers/institutional-access-manager-handler.js.map +1 -1
  118. package/dist/contracts/handlers/institutional-vault-handler.cjs +1 -1
  119. package/dist/contracts/handlers/institutional-vault-handler.cjs.map +1 -1
  120. package/dist/contracts/handlers/institutional-vault-handler.d.ts +96 -6599
  121. package/dist/contracts/handlers/institutional-vault-handler.js +16 -19
  122. package/dist/contracts/handlers/institutional-vault-handler.js.map +1 -1
  123. package/dist/contracts/handlers/l1-reward-manager-handler.cjs +1 -1
  124. package/dist/contracts/handlers/l1-reward-manager-handler.cjs.map +1 -1
  125. package/dist/contracts/handlers/l1-reward-manager-handler.d.ts +96 -6599
  126. package/dist/contracts/handlers/l1-reward-manager-handler.js +14 -17
  127. package/dist/contracts/handlers/l1-reward-manager-handler.js.map +1 -1
  128. package/dist/contracts/handlers/l2-reward-manager-handler.cjs +1 -1
  129. package/dist/contracts/handlers/l2-reward-manager-handler.cjs.map +1 -1
  130. package/dist/contracts/handlers/l2-reward-manager-handler.d.ts +96 -6599
  131. package/dist/contracts/handlers/l2-reward-manager-handler.js +13 -16
  132. package/dist/contracts/handlers/l2-reward-manager-handler.js.map +1 -1
  133. package/dist/contracts/handlers/lagoon-vault-handler.cjs +1 -1
  134. package/dist/contracts/handlers/lagoon-vault-handler.cjs.map +1 -1
  135. package/dist/contracts/handlers/lagoon-vault-handler.d.ts +96 -6599
  136. package/dist/contracts/handlers/lagoon-vault-handler.js +11 -14
  137. package/dist/contracts/handlers/lagoon-vault-handler.js.map +1 -1
  138. package/dist/contracts/handlers/mtw-carrot-handler.cjs +1 -1
  139. package/dist/contracts/handlers/mtw-carrot-handler.cjs.map +1 -1
  140. package/dist/contracts/handlers/mtw-carrot-handler.d.ts +96 -6599
  141. package/dist/contracts/handlers/mtw-carrot-handler.js +12 -15
  142. package/dist/contracts/handlers/mtw-carrot-handler.js.map +1 -1
  143. package/dist/contracts/handlers/nucleus-accountant-handler.cjs +1 -1
  144. package/dist/contracts/handlers/nucleus-accountant-handler.cjs.map +1 -1
  145. package/dist/contracts/handlers/nucleus-accountant-handler.d.ts +96 -6599
  146. package/dist/contracts/handlers/nucleus-accountant-handler.js +13 -16
  147. package/dist/contracts/handlers/nucleus-accountant-handler.js.map +1 -1
  148. package/dist/contracts/handlers/nucleus-atomic-queue-handler.cjs +1 -1
  149. package/dist/contracts/handlers/nucleus-atomic-queue-handler.cjs.map +1 -1
  150. package/dist/contracts/handlers/nucleus-atomic-queue-handler.d.ts +96 -6599
  151. package/dist/contracts/handlers/nucleus-atomic-queue-handler.js +14 -17
  152. package/dist/contracts/handlers/nucleus-atomic-queue-handler.js.map +1 -1
  153. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs +1 -1
  154. package/dist/contracts/handlers/nucleus-boring-vault-handler.cjs.map +1 -1
  155. package/dist/contracts/handlers/nucleus-boring-vault-handler.d.ts +96 -6599
  156. package/dist/contracts/handlers/nucleus-boring-vault-handler.js +18 -21
  157. package/dist/contracts/handlers/nucleus-boring-vault-handler.js.map +1 -1
  158. package/dist/contracts/handlers/nucleus-teller-handler.cjs +1 -1
  159. package/dist/contracts/handlers/nucleus-teller-handler.cjs.map +1 -1
  160. package/dist/contracts/handlers/nucleus-teller-handler.d.ts +96 -6599
  161. package/dist/contracts/handlers/nucleus-teller-handler.js +35 -38
  162. package/dist/contracts/handlers/nucleus-teller-handler.js.map +1 -1
  163. package/dist/contracts/handlers/puf-locker-handler.cjs +1 -1
  164. package/dist/contracts/handlers/puf-locker-handler.cjs.map +1 -1
  165. package/dist/contracts/handlers/puf-locker-handler.d.ts +96 -6599
  166. package/dist/contracts/handlers/puf-locker-handler.js +51 -54
  167. package/dist/contracts/handlers/puf-locker-handler.js.map +1 -1
  168. package/dist/contracts/handlers/puffer-depositor-handler.cjs +1 -1
  169. package/dist/contracts/handlers/puffer-depositor-handler.cjs.map +1 -1
  170. package/dist/contracts/handlers/puffer-depositor-handler.d.ts +96 -6599
  171. package/dist/contracts/handlers/puffer-depositor-handler.js +28 -31
  172. package/dist/contracts/handlers/puffer-depositor-handler.js.map +1 -1
  173. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs +1 -1
  174. package/dist/contracts/handlers/puffer-l2-depositor-handler.cjs.map +1 -1
  175. package/dist/contracts/handlers/puffer-l2-depositor-handler.d.ts +96 -6599
  176. package/dist/contracts/handlers/puffer-l2-depositor-handler.js +42 -45
  177. package/dist/contracts/handlers/puffer-l2-depositor-handler.js.map +1 -1
  178. package/dist/contracts/handlers/puffer-oracle-v2-handler.cjs +1 -1
  179. package/dist/contracts/handlers/puffer-oracle-v2-handler.cjs.map +1 -1
  180. package/dist/contracts/handlers/puffer-oracle-v2-handler.d.ts +96 -6599
  181. package/dist/contracts/handlers/puffer-oracle-v2-handler.js +13 -16
  182. package/dist/contracts/handlers/puffer-oracle-v2-handler.js.map +1 -1
  183. package/dist/contracts/handlers/puffer-protocol-handler.cjs +1 -1
  184. package/dist/contracts/handlers/puffer-protocol-handler.cjs.map +1 -1
  185. package/dist/contracts/handlers/puffer-protocol-handler.d.ts +96 -6599
  186. package/dist/contracts/handlers/puffer-protocol-handler.js +12 -15
  187. package/dist/contracts/handlers/puffer-protocol-handler.js.map +1 -1
  188. package/dist/contracts/handlers/puffer-vault-handler.cjs +1 -1
  189. package/dist/contracts/handlers/puffer-vault-handler.cjs.map +1 -1
  190. package/dist/contracts/handlers/puffer-vault-handler.d.ts +96 -6599
  191. package/dist/contracts/handlers/puffer-vault-handler.js +12 -15
  192. package/dist/contracts/handlers/puffer-vault-handler.js.map +1 -1
  193. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs +1 -1
  194. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.cjs.map +1 -1
  195. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.d.ts +96 -6599
  196. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js +15 -18
  197. package/dist/contracts/handlers/puffer-withdrawal-manager-handler.js.map +1 -1
  198. package/dist/contracts/handlers/validator-ticket-handler.cjs +1 -1
  199. package/dist/contracts/handlers/validator-ticket-handler.cjs.map +1 -1
  200. package/dist/contracts/handlers/validator-ticket-handler.d.ts +96 -6599
  201. package/dist/contracts/handlers/validator-ticket-handler.js +12 -15
  202. package/dist/contracts/handlers/validator-ticket-handler.js.map +1 -1
  203. package/dist/contracts/handlers/vl-puffer-handler.cjs +1 -1
  204. package/dist/contracts/handlers/vl-puffer-handler.cjs.map +1 -1
  205. package/dist/contracts/handlers/vl-puffer-handler.d.ts +96 -6599
  206. package/dist/contracts/handlers/vl-puffer-handler.js +19 -22
  207. package/dist/contracts/handlers/vl-puffer-handler.js.map +1 -1
  208. package/dist/contracts/tokens.cjs +1 -1
  209. package/dist/contracts/tokens.cjs.map +1 -1
  210. package/dist/contracts/tokens.js +1 -1
  211. package/dist/contracts/tokens.js.map +1 -1
  212. package/dist/contracts/vaults-addresses.cjs +1 -1
  213. package/dist/contracts/vaults-addresses.cjs.map +1 -1
  214. package/dist/contracts/vaults-addresses.js +1 -1
  215. package/dist/contracts/vaults-addresses.js.map +1 -1
  216. package/dist/errors/base-error.cjs.map +1 -1
  217. package/dist/errors/base-error.js.map +1 -1
  218. package/dist/{getContract-DUA3M2pm.cjs → getContract-D4_SEfqa.cjs} +2 -2
  219. package/dist/{getContract-DUA3M2pm.cjs.map → getContract-D4_SEfqa.cjs.map} +1 -1
  220. package/dist/{getContract-DEPNMZxg.js → getContract-DQN7VDBo.js} +2 -2
  221. package/dist/{getContract-DEPNMZxg.js.map → getContract-DQN7VDBo.js.map} +1 -1
  222. package/dist/http-CajzXkt4.js +4005 -0
  223. package/dist/http-CajzXkt4.js.map +1 -0
  224. package/dist/http-qhIDc8Dn.cjs +5 -0
  225. package/dist/http-qhIDc8Dn.cjs.map +1 -0
  226. package/dist/{localBatchGatewayRequest-CKLnLqib.cjs → localBatchGatewayRequest-C7zYTS2c.cjs} +2 -2
  227. package/dist/{localBatchGatewayRequest-CKLnLqib.cjs.map → localBatchGatewayRequest-C7zYTS2c.cjs.map} +1 -1
  228. package/dist/{localBatchGatewayRequest-C0QtijkB.js → localBatchGatewayRequest-DtOvBmA9.js} +3 -3
  229. package/dist/{localBatchGatewayRequest-C0QtijkB.js.map → localBatchGatewayRequest-DtOvBmA9.js.map} +1 -1
  230. package/dist/main.cjs +1 -1
  231. package/dist/main.js +1 -1
  232. package/dist/secp256k1-CMP_u7qb.cjs +2 -0
  233. package/dist/secp256k1-CMP_u7qb.cjs.map +1 -0
  234. package/dist/secp256k1-DCMgMsfV.js +1297 -0
  235. package/dist/secp256k1-DCMgMsfV.js.map +1 -0
  236. package/dist/utils/time.cjs.map +1 -1
  237. package/dist/utils/time.js.map +1 -1
  238. package/dist/utils/version.cjs +1 -1
  239. package/dist/utils/version.js +1 -1
  240. package/dist/writeContract-BnmmOPwy.cjs +36 -0
  241. package/dist/writeContract-BnmmOPwy.cjs.map +1 -0
  242. package/dist/{writeContract-DkC9wV5p.js → writeContract-DYAfDrRz.js} +1788 -1712
  243. package/dist/writeContract-DYAfDrRz.js.map +1 -0
  244. package/package.json +8 -8
  245. package/dist/ccip-C76-YhQK.js +0 -152
  246. package/dist/ccip-CEodLZ4s.cjs +0 -2
  247. package/dist/constants-CxSgz27h.cjs +0 -9
  248. package/dist/createWalletClient-Cct6ojqI.cjs +0 -5
  249. package/dist/createWalletClient-Cct6ojqI.cjs.map +0 -1
  250. package/dist/createWalletClient-DAuQCrLq.js +0 -3262
  251. package/dist/createWalletClient-DAuQCrLq.js.map +0 -1
  252. package/dist/secp256k1-ClOw2ksU.js +0 -1291
  253. package/dist/secp256k1-ClOw2ksU.js.map +0 -1
  254. package/dist/secp256k1-YUzyTLhP.cjs +0 -2
  255. package/dist/secp256k1-YUzyTLhP.cjs.map +0 -1
  256. package/dist/writeContract-BfAYISeL.cjs +0 -36
  257. package/dist/writeContract-BfAYISeL.cjs.map +0 -1
  258. package/dist/writeContract-DkC9wV5p.js.map +0 -1
@@ -0,0 +1,1297 @@
1
+ import { H as le, f as de, g as he, j as we, k as kt, l as ge, m as me, r as pe, o as ye, q as be } from "./constants-CuIEh_ZS.js";
2
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
+ const Rt = /* @__PURE__ */ BigInt(0), Nt = /* @__PURE__ */ BigInt(1);
4
+ function ut(e) {
5
+ return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
6
+ }
7
+ function Zt(e) {
8
+ if (!ut(e))
9
+ throw new Error("Uint8Array expected");
10
+ }
11
+ function ft(e, n) {
12
+ if (typeof n != "boolean")
13
+ throw new Error(e + " boolean expected, got " + n);
14
+ }
15
+ function dt(e) {
16
+ const n = e.toString(16);
17
+ return n.length & 1 ? "0" + n : n;
18
+ }
19
+ function Wt(e) {
20
+ if (typeof e != "string")
21
+ throw new Error("hex string expected, got " + typeof e);
22
+ return e === "" ? Rt : BigInt("0x" + e);
23
+ }
24
+ const Dt = (
25
+ // @ts-ignore
26
+ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function"
27
+ ), Ee = /* @__PURE__ */ Array.from({ length: 256 }, (e, n) => n.toString(16).padStart(2, "0"));
28
+ function at(e) {
29
+ if (Zt(e), Dt)
30
+ return e.toHex();
31
+ let n = "";
32
+ for (let t = 0; t < e.length; t++)
33
+ n += Ee[e[t]];
34
+ return n;
35
+ }
36
+ const D = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
37
+ function _t(e) {
38
+ if (e >= D._0 && e <= D._9)
39
+ return e - D._0;
40
+ if (e >= D.A && e <= D.F)
41
+ return e - (D.A - 10);
42
+ if (e >= D.a && e <= D.f)
43
+ return e - (D.a - 10);
44
+ }
45
+ function ht(e) {
46
+ if (typeof e != "string")
47
+ throw new Error("hex string expected, got " + typeof e);
48
+ if (Dt)
49
+ return Uint8Array.fromHex(e);
50
+ const n = e.length, t = n / 2;
51
+ if (n % 2)
52
+ throw new Error("hex string expected, got unpadded hex of length " + n);
53
+ const r = new Uint8Array(t);
54
+ for (let i = 0, s = 0; i < t; i++, s += 2) {
55
+ const c = _t(e.charCodeAt(s)), u = _t(e.charCodeAt(s + 1));
56
+ if (c === void 0 || u === void 0) {
57
+ const o = e[s] + e[s + 1];
58
+ throw new Error('hex string expected, got non-hex character "' + o + '" at index ' + s);
59
+ }
60
+ r[i] = c * 16 + u;
61
+ }
62
+ return r;
63
+ }
64
+ function et(e) {
65
+ return Wt(at(e));
66
+ }
67
+ function Gt(e) {
68
+ return Zt(e), Wt(at(Uint8Array.from(e).reverse()));
69
+ }
70
+ function lt(e, n) {
71
+ return ht(e.toString(16).padStart(n * 2, "0"));
72
+ }
73
+ function Xt(e, n) {
74
+ return lt(e, n).reverse();
75
+ }
76
+ function K(e, n, t) {
77
+ let r;
78
+ if (typeof n == "string")
79
+ try {
80
+ r = ht(n);
81
+ } catch (s) {
82
+ throw new Error(e + " must be hex string or Uint8Array, cause: " + s);
83
+ }
84
+ else if (ut(n))
85
+ r = Uint8Array.from(n);
86
+ else
87
+ throw new Error(e + " must be hex string or Uint8Array");
88
+ const i = r.length;
89
+ if (typeof t == "number" && i !== t)
90
+ throw new Error(e + " of length " + t + " expected, got " + i);
91
+ return r;
92
+ }
93
+ function wt(...e) {
94
+ let n = 0;
95
+ for (let r = 0; r < e.length; r++) {
96
+ const i = e[r];
97
+ Zt(i), n += i.length;
98
+ }
99
+ const t = new Uint8Array(n);
100
+ for (let r = 0, i = 0; r < e.length; r++) {
101
+ const s = e[r];
102
+ t.set(s, i), i += s.length;
103
+ }
104
+ return t;
105
+ }
106
+ const bt = (e) => typeof e == "bigint" && Rt <= e;
107
+ function zt(e, n, t) {
108
+ return bt(e) && bt(n) && bt(t) && n <= e && e < t;
109
+ }
110
+ function it(e, n, t, r) {
111
+ if (!zt(n, t, r))
112
+ throw new Error("expected valid " + e + ": " + t + " <= n < " + r + ", got " + n);
113
+ }
114
+ function Be(e) {
115
+ let n;
116
+ for (n = 0; e > Rt; e >>= Nt, n += 1)
117
+ ;
118
+ return n;
119
+ }
120
+ const gt = (e) => (Nt << BigInt(e)) - Nt, Et = (e) => new Uint8Array(e), Ct = (e) => Uint8Array.from(e);
121
+ function ve(e, n, t) {
122
+ if (typeof e != "number" || e < 2)
123
+ throw new Error("hashLen must be a number");
124
+ if (typeof n != "number" || n < 2)
125
+ throw new Error("qByteLen must be a number");
126
+ if (typeof t != "function")
127
+ throw new Error("hmacFn must be a function");
128
+ let r = Et(e), i = Et(e), s = 0;
129
+ const c = () => {
130
+ r.fill(1), i.fill(0), s = 0;
131
+ }, u = (...A) => t(i, r, ...A), o = (A = Et(0)) => {
132
+ i = u(Ct([0]), A), r = u(), A.length !== 0 && (i = u(Ct([1]), A), r = u());
133
+ }, d = () => {
134
+ if (s++ >= 1e3)
135
+ throw new Error("drbg: tried 1000 values");
136
+ let A = 0;
137
+ const N = [];
138
+ for (; A < n; ) {
139
+ r = u();
140
+ const R = r.slice();
141
+ N.push(R), A += r.length;
142
+ }
143
+ return wt(...N);
144
+ };
145
+ return (A, N) => {
146
+ c(), o(A);
147
+ let R;
148
+ for (; !(R = N(d())); )
149
+ o();
150
+ return c(), R;
151
+ };
152
+ }
153
+ const xe = {
154
+ bigint: (e) => typeof e == "bigint",
155
+ function: (e) => typeof e == "function",
156
+ boolean: (e) => typeof e == "boolean",
157
+ string: (e) => typeof e == "string",
158
+ stringOrUint8Array: (e) => typeof e == "string" || ut(e),
159
+ isSafeInteger: (e) => Number.isSafeInteger(e),
160
+ array: (e) => Array.isArray(e),
161
+ field: (e, n) => n.Fp.isValid(e),
162
+ hash: (e) => typeof e == "function" && Number.isSafeInteger(e.outputLen)
163
+ };
164
+ function mt(e, n, t = {}) {
165
+ const r = (i, s, c) => {
166
+ const u = xe[s];
167
+ if (typeof u != "function")
168
+ throw new Error("invalid validator function");
169
+ const o = e[i];
170
+ if (!(c && o === void 0) && !u(o, e))
171
+ throw new Error("param " + String(i) + " is invalid. Expected " + s + ", got " + o);
172
+ };
173
+ for (const [i, s] of Object.entries(n))
174
+ r(i, s, !1);
175
+ for (const [i, s] of Object.entries(t))
176
+ r(i, s, !0);
177
+ return e;
178
+ }
179
+ function Vt(e) {
180
+ const n = /* @__PURE__ */ new WeakMap();
181
+ return (t, ...r) => {
182
+ const i = n.get(t);
183
+ if (i !== void 0)
184
+ return i;
185
+ const s = e(t, ...r);
186
+ return n.set(t, s), s;
187
+ };
188
+ }
189
+ class Ft extends le {
190
+ constructor(n, t) {
191
+ super(), this.finished = !1, this.destroyed = !1, de(n);
192
+ const r = he(t);
193
+ if (this.iHash = n.create(), typeof this.iHash.update != "function")
194
+ throw new Error("Expected instance of class which extends utils.Hash");
195
+ this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
196
+ const i = this.blockLen, s = new Uint8Array(i);
197
+ s.set(r.length > i ? n.create().update(r).digest() : r);
198
+ for (let c = 0; c < s.length; c++)
199
+ s[c] ^= 54;
200
+ this.iHash.update(s), this.oHash = n.create();
201
+ for (let c = 0; c < s.length; c++)
202
+ s[c] ^= 106;
203
+ this.oHash.update(s), we(s);
204
+ }
205
+ update(n) {
206
+ return kt(this), this.iHash.update(n), this;
207
+ }
208
+ digestInto(n) {
209
+ kt(this), ge(n, this.outputLen), this.finished = !0, this.iHash.digestInto(n), this.oHash.update(n), this.oHash.digestInto(n), this.destroy();
210
+ }
211
+ digest() {
212
+ const n = new Uint8Array(this.oHash.outputLen);
213
+ return this.digestInto(n), n;
214
+ }
215
+ _cloneInto(n) {
216
+ n || (n = Object.create(Object.getPrototypeOf(this), {}));
217
+ const { oHash: t, iHash: r, finished: i, destroyed: s, blockLen: c, outputLen: u } = this;
218
+ return n = n, n.finished = i, n.destroyed = s, n.blockLen = c, n.outputLen = u, n.oHash = t._cloneInto(n.oHash), n.iHash = r._cloneInto(n.iHash), n;
219
+ }
220
+ clone() {
221
+ return this._cloneInto();
222
+ }
223
+ destroy() {
224
+ this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
225
+ }
226
+ }
227
+ const Qt = (e, n, t) => new Ft(e, n).update(t).digest();
228
+ Qt.create = (e, n) => new Ft(e, n);
229
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
230
+ const j = BigInt(0), C = BigInt(1), tt = /* @__PURE__ */ BigInt(2), Se = /* @__PURE__ */ BigInt(3), Jt = /* @__PURE__ */ BigInt(4), te = /* @__PURE__ */ BigInt(5), ee = /* @__PURE__ */ BigInt(8);
231
+ function M(e, n) {
232
+ const t = e % n;
233
+ return t >= j ? t : n + t;
234
+ }
235
+ function Y(e, n, t) {
236
+ let r = e;
237
+ for (; n-- > j; )
238
+ r *= r, r %= t;
239
+ return r;
240
+ }
241
+ function Ot(e, n) {
242
+ if (e === j)
243
+ throw new Error("invert: expected non-zero number");
244
+ if (n <= j)
245
+ throw new Error("invert: expected positive modulus, got " + n);
246
+ let t = M(e, n), r = n, i = j, s = C;
247
+ for (; t !== j; ) {
248
+ const u = r / t, o = r % t, d = i - s * u;
249
+ r = t, t = o, i = s, s = d;
250
+ }
251
+ if (r !== C)
252
+ throw new Error("invert: does not exist");
253
+ return M(i, n);
254
+ }
255
+ function ne(e, n) {
256
+ const t = (e.ORDER + C) / Jt, r = e.pow(n, t);
257
+ if (!e.eql(e.sqr(r), n))
258
+ throw new Error("Cannot find square root");
259
+ return r;
260
+ }
261
+ function Ae(e, n) {
262
+ const t = (e.ORDER - te) / ee, r = e.mul(n, tt), i = e.pow(r, t), s = e.mul(n, i), c = e.mul(e.mul(s, tt), i), u = e.mul(s, e.sub(c, e.ONE));
263
+ if (!e.eql(e.sqr(u), n))
264
+ throw new Error("Cannot find square root");
265
+ return u;
266
+ }
267
+ function Ie(e) {
268
+ if (e < BigInt(3))
269
+ throw new Error("sqrt is not defined for small field");
270
+ let n = e - C, t = 0;
271
+ for (; n % tt === j; )
272
+ n /= tt, t++;
273
+ let r = tt;
274
+ const i = Ut(e);
275
+ for (; Mt(i, r) === 1; )
276
+ if (r++ > 1e3)
277
+ throw new Error("Cannot find square root: probably non-prime P");
278
+ if (t === 1)
279
+ return ne;
280
+ let s = i.pow(r, n);
281
+ const c = (n + C) / tt;
282
+ return function(o, d) {
283
+ if (o.is0(d))
284
+ return d;
285
+ if (Mt(o, d) !== 1)
286
+ throw new Error("Cannot find square root");
287
+ let m = t, A = o.mul(o.ONE, s), N = o.pow(d, n), R = o.pow(d, c);
288
+ for (; !o.eql(N, o.ONE); ) {
289
+ if (o.is0(N))
290
+ return o.ZERO;
291
+ let Z = 1, g = o.sqr(N);
292
+ for (; !o.eql(g, o.ONE); )
293
+ if (Z++, g = o.sqr(g), Z === m)
294
+ throw new Error("Cannot find square root");
295
+ const k = C << BigInt(m - Z - 1), z = o.pow(A, k);
296
+ m = Z, A = o.sqr(z), N = o.mul(N, A), R = o.mul(R, z);
297
+ }
298
+ return R;
299
+ };
300
+ }
301
+ function Ne(e) {
302
+ return e % Jt === Se ? ne : e % ee === te ? Ae : Ie(e);
303
+ }
304
+ const Oe = [
305
+ "create",
306
+ "isValid",
307
+ "is0",
308
+ "neg",
309
+ "inv",
310
+ "sqrt",
311
+ "sqr",
312
+ "eql",
313
+ "add",
314
+ "sub",
315
+ "mul",
316
+ "pow",
317
+ "div",
318
+ "addN",
319
+ "subN",
320
+ "mulN",
321
+ "sqrN"
322
+ ];
323
+ function qe(e) {
324
+ const n = {
325
+ ORDER: "bigint",
326
+ MASK: "bigint",
327
+ BYTES: "isSafeInteger",
328
+ BITS: "isSafeInteger"
329
+ }, t = Oe.reduce((r, i) => (r[i] = "function", r), n);
330
+ return mt(e, t);
331
+ }
332
+ function He(e, n, t) {
333
+ if (t < j)
334
+ throw new Error("invalid exponent, negatives unsupported");
335
+ if (t === j)
336
+ return e.ONE;
337
+ if (t === C)
338
+ return n;
339
+ let r = e.ONE, i = n;
340
+ for (; t > j; )
341
+ t & C && (r = e.mul(r, i)), i = e.sqr(i), t >>= C;
342
+ return r;
343
+ }
344
+ function re(e, n, t = !1) {
345
+ const r = new Array(n.length).fill(t ? e.ZERO : void 0), i = n.reduce((c, u, o) => e.is0(u) ? c : (r[o] = c, e.mul(c, u)), e.ONE), s = e.inv(i);
346
+ return n.reduceRight((c, u, o) => e.is0(u) ? c : (r[o] = e.mul(c, r[o]), e.mul(c, u)), s), r;
347
+ }
348
+ function Mt(e, n) {
349
+ const t = (e.ORDER - C) / tt, r = e.pow(n, t), i = e.eql(r, e.ONE), s = e.eql(r, e.ZERO), c = e.eql(r, e.neg(e.ONE));
350
+ if (!i && !s && !c)
351
+ throw new Error("invalid Legendre symbol result");
352
+ return i ? 1 : s ? 0 : -1;
353
+ }
354
+ function oe(e, n) {
355
+ n !== void 0 && me(n);
356
+ const t = n !== void 0 ? n : e.toString(2).length, r = Math.ceil(t / 8);
357
+ return { nBitLength: t, nByteLength: r };
358
+ }
359
+ function Ut(e, n, t = !1, r = {}) {
360
+ if (e <= j)
361
+ throw new Error("invalid field: expected ORDER > 0, got " + e);
362
+ const { nBitLength: i, nByteLength: s } = oe(e, n);
363
+ if (s > 2048)
364
+ throw new Error("invalid field: expected ORDER of <= 2048 bytes");
365
+ let c;
366
+ const u = Object.freeze({
367
+ ORDER: e,
368
+ isLE: t,
369
+ BITS: i,
370
+ BYTES: s,
371
+ MASK: gt(i),
372
+ ZERO: j,
373
+ ONE: C,
374
+ create: (o) => M(o, e),
375
+ isValid: (o) => {
376
+ if (typeof o != "bigint")
377
+ throw new Error("invalid field element: expected bigint, got " + typeof o);
378
+ return j <= o && o < e;
379
+ },
380
+ is0: (o) => o === j,
381
+ isOdd: (o) => (o & C) === C,
382
+ neg: (o) => M(-o, e),
383
+ eql: (o, d) => o === d,
384
+ sqr: (o) => M(o * o, e),
385
+ add: (o, d) => M(o + d, e),
386
+ sub: (o, d) => M(o - d, e),
387
+ mul: (o, d) => M(o * d, e),
388
+ pow: (o, d) => He(u, o, d),
389
+ div: (o, d) => M(o * Ot(d, e), e),
390
+ // Same as above, but doesn't normalize
391
+ sqrN: (o) => o * o,
392
+ addN: (o, d) => o + d,
393
+ subN: (o, d) => o - d,
394
+ mulN: (o, d) => o * d,
395
+ inv: (o) => Ot(o, e),
396
+ sqrt: r.sqrt || ((o) => (c || (c = Ne(e)), c(u, o))),
397
+ toBytes: (o) => t ? Xt(o, s) : lt(o, s),
398
+ fromBytes: (o) => {
399
+ if (o.length !== s)
400
+ throw new Error("Field.fromBytes: expected " + s + " bytes, got " + o.length);
401
+ return t ? Gt(o) : et(o);
402
+ },
403
+ // TODO: we don't need it here, move out to separate fn
404
+ invertBatch: (o) => re(u, o),
405
+ // We can't move this out because Fp6, Fp12 implement it
406
+ // and it's unclear what to return in there.
407
+ cmov: (o, d, m) => m ? d : o
408
+ });
409
+ return Object.freeze(u);
410
+ }
411
+ function ie(e) {
412
+ if (typeof e != "bigint")
413
+ throw new Error("field order must be bigint");
414
+ const n = e.toString(2).length;
415
+ return Math.ceil(n / 8);
416
+ }
417
+ function se(e) {
418
+ const n = ie(e);
419
+ return n + Math.ceil(n / 2);
420
+ }
421
+ function Le(e, n, t = !1) {
422
+ const r = e.length, i = ie(n), s = se(n);
423
+ if (r < 16 || r < s || r > 1024)
424
+ throw new Error("expected " + s + "-1024 bytes of input, got " + r);
425
+ const c = t ? Gt(e) : et(e), u = M(c, n - C) + C;
426
+ return t ? Xt(u, i) : lt(u, i);
427
+ }
428
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
429
+ const jt = BigInt(0), qt = BigInt(1);
430
+ function Bt(e, n) {
431
+ const t = n.negate();
432
+ return e ? t : n;
433
+ }
434
+ function ce(e, n) {
435
+ if (!Number.isSafeInteger(e) || e <= 0 || e > n)
436
+ throw new Error("invalid window size, expected [1.." + n + "], got W=" + e);
437
+ }
438
+ function vt(e, n) {
439
+ ce(e, n);
440
+ const t = Math.ceil(n / e) + 1, r = 2 ** (e - 1), i = 2 ** e, s = gt(e), c = BigInt(e);
441
+ return { windows: t, windowSize: r, mask: s, maxNumber: i, shiftBy: c };
442
+ }
443
+ function Yt(e, n, t) {
444
+ const { windowSize: r, mask: i, maxNumber: s, shiftBy: c } = t;
445
+ let u = Number(e & i), o = e >> c;
446
+ u > r && (u -= s, o += qt);
447
+ const d = n * r, m = d + Math.abs(u) - 1, A = u === 0, N = u < 0, R = n % 2 !== 0;
448
+ return { nextN: o, offset: m, isZero: A, isNeg: N, isNegF: R, offsetF: d };
449
+ }
450
+ function Re(e, n) {
451
+ if (!Array.isArray(e))
452
+ throw new Error("array expected");
453
+ e.forEach((t, r) => {
454
+ if (!(t instanceof n))
455
+ throw new Error("invalid point at index " + r);
456
+ });
457
+ }
458
+ function Ze(e, n) {
459
+ if (!Array.isArray(e))
460
+ throw new Error("array of scalars expected");
461
+ e.forEach((t, r) => {
462
+ if (!n.isValid(t))
463
+ throw new Error("invalid scalar at index " + r);
464
+ });
465
+ }
466
+ const xt = /* @__PURE__ */ new WeakMap(), fe = /* @__PURE__ */ new WeakMap();
467
+ function St(e) {
468
+ return fe.get(e) || 1;
469
+ }
470
+ function ze(e, n) {
471
+ return {
472
+ constTimeNegate: Bt,
473
+ hasPrecomputes(t) {
474
+ return St(t) !== 1;
475
+ },
476
+ // non-const time multiplication ladder
477
+ unsafeLadder(t, r, i = e.ZERO) {
478
+ let s = t;
479
+ for (; r > jt; )
480
+ r & qt && (i = i.add(s)), s = s.double(), r >>= qt;
481
+ return i;
482
+ },
483
+ /**
484
+ * Creates a wNAF precomputation window. Used for caching.
485
+ * Default window size is set by `utils.precompute()` and is equal to 8.
486
+ * Number of precomputed points depends on the curve size:
487
+ * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
488
+ * - 𝑊 is the window size
489
+ * - 𝑛 is the bitlength of the curve order.
490
+ * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
491
+ * @param elm Point instance
492
+ * @param W window size
493
+ * @returns precomputed point tables flattened to a single array
494
+ */
495
+ precomputeWindow(t, r) {
496
+ const { windows: i, windowSize: s } = vt(r, n), c = [];
497
+ let u = t, o = u;
498
+ for (let d = 0; d < i; d++) {
499
+ o = u, c.push(o);
500
+ for (let m = 1; m < s; m++)
501
+ o = o.add(u), c.push(o);
502
+ u = o.double();
503
+ }
504
+ return c;
505
+ },
506
+ /**
507
+ * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
508
+ * @param W window size
509
+ * @param precomputes precomputed tables
510
+ * @param n scalar (we don't check here, but should be less than curve order)
511
+ * @returns real and fake (for const-time) points
512
+ */
513
+ wNAF(t, r, i) {
514
+ let s = e.ZERO, c = e.BASE;
515
+ const u = vt(t, n);
516
+ for (let o = 0; o < u.windows; o++) {
517
+ const { nextN: d, offset: m, isZero: A, isNeg: N, isNegF: R, offsetF: Z } = Yt(i, o, u);
518
+ i = d, A ? c = c.add(Bt(R, r[Z])) : s = s.add(Bt(N, r[m]));
519
+ }
520
+ return { p: s, f: c };
521
+ },
522
+ /**
523
+ * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
524
+ * @param W window size
525
+ * @param precomputes precomputed tables
526
+ * @param n scalar (we don't check here, but should be less than curve order)
527
+ * @param acc accumulator point to add result of multiplication
528
+ * @returns point
529
+ */
530
+ wNAFUnsafe(t, r, i, s = e.ZERO) {
531
+ const c = vt(t, n);
532
+ for (let u = 0; u < c.windows && i !== jt; u++) {
533
+ const { nextN: o, offset: d, isZero: m, isNeg: A } = Yt(i, u, c);
534
+ if (i = o, !m) {
535
+ const N = r[d];
536
+ s = s.add(A ? N.negate() : N);
537
+ }
538
+ }
539
+ return s;
540
+ },
541
+ getPrecomputes(t, r, i) {
542
+ let s = xt.get(r);
543
+ return s || (s = this.precomputeWindow(r, t), t !== 1 && xt.set(r, i(s))), s;
544
+ },
545
+ wNAFCached(t, r, i) {
546
+ const s = St(t);
547
+ return this.wNAF(s, this.getPrecomputes(s, t, i), r);
548
+ },
549
+ wNAFCachedUnsafe(t, r, i, s) {
550
+ const c = St(t);
551
+ return c === 1 ? this.unsafeLadder(t, r, s) : this.wNAFUnsafe(c, this.getPrecomputes(c, t, i), r, s);
552
+ },
553
+ // We calculate precomputes for elliptic curve point multiplication
554
+ // using windowed method. This specifies window size and
555
+ // stores precomputed values. Usually only base point would be precomputed.
556
+ setWindowSize(t, r) {
557
+ ce(r, n), fe.set(t, r), xt.delete(t);
558
+ }
559
+ };
560
+ }
561
+ function Ue(e, n, t, r) {
562
+ Re(t, e), Ze(r, n);
563
+ const i = t.length, s = r.length;
564
+ if (i !== s)
565
+ throw new Error("arrays of points and scalars must have equal length");
566
+ const c = e.ZERO, u = Be(BigInt(i));
567
+ let o = 1;
568
+ u > 12 ? o = u - 3 : u > 4 ? o = u - 2 : u > 0 && (o = 2);
569
+ const d = gt(o), m = new Array(Number(d) + 1).fill(c), A = Math.floor((n.BITS - 1) / o) * o;
570
+ let N = c;
571
+ for (let R = A; R >= 0; R -= o) {
572
+ m.fill(c);
573
+ for (let g = 0; g < s; g++) {
574
+ const k = r[g], z = Number(k >> BigInt(R) & d);
575
+ m[z] = m[z].add(t[g]);
576
+ }
577
+ let Z = c;
578
+ for (let g = m.length - 1, k = c; g > 0; g--)
579
+ k = k.add(m[g]), Z = Z.add(k);
580
+ if (N = N.add(Z), R !== 0)
581
+ for (let g = 0; g < o; g++)
582
+ N = N.double();
583
+ }
584
+ return N;
585
+ }
586
+ function ae(e) {
587
+ return qe(e.Fp), mt(e, {
588
+ n: "bigint",
589
+ h: "bigint",
590
+ Gx: "field",
591
+ Gy: "field"
592
+ }, {
593
+ nBitLength: "isSafeInteger",
594
+ nByteLength: "isSafeInteger"
595
+ }), Object.freeze({
596
+ ...oe(e.n, e.nBitLength),
597
+ ...e,
598
+ p: e.Fp.ORDER
599
+ });
600
+ }
601
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
602
+ function Kt(e) {
603
+ e.lowS !== void 0 && ft("lowS", e.lowS), e.prehash !== void 0 && ft("prehash", e.prehash);
604
+ }
605
+ function Te(e) {
606
+ const n = ae(e);
607
+ mt(n, {
608
+ a: "field",
609
+ b: "field"
610
+ }, {
611
+ allowInfinityPoint: "boolean",
612
+ allowedPrivateKeyLengths: "array",
613
+ clearCofactor: "function",
614
+ fromBytes: "function",
615
+ isTorsionFree: "function",
616
+ toBytes: "function",
617
+ wrapPrivateKey: "boolean"
618
+ });
619
+ const { endo: t, Fp: r, a: i } = n;
620
+ if (t) {
621
+ if (!r.eql(i, r.ZERO))
622
+ throw new Error("invalid endo: CURVE.a must be 0");
623
+ if (typeof t != "object" || typeof t.beta != "bigint" || typeof t.splitScalar != "function")
624
+ throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');
625
+ }
626
+ return Object.freeze({ ...n });
627
+ }
628
+ class ke extends Error {
629
+ constructor(n = "") {
630
+ super(n);
631
+ }
632
+ }
633
+ const G = {
634
+ // asn.1 DER encoding utils
635
+ Err: ke,
636
+ // Basic building block is TLV (Tag-Length-Value)
637
+ _tlv: {
638
+ encode: (e, n) => {
639
+ const { Err: t } = G;
640
+ if (e < 0 || e > 256)
641
+ throw new t("tlv.encode: wrong tag");
642
+ if (n.length & 1)
643
+ throw new t("tlv.encode: unpadded data");
644
+ const r = n.length / 2, i = dt(r);
645
+ if (i.length / 2 & 128)
646
+ throw new t("tlv.encode: long form length too big");
647
+ const s = r > 127 ? dt(i.length / 2 | 128) : "";
648
+ return dt(e) + s + i + n;
649
+ },
650
+ // v - value, l - left bytes (unparsed)
651
+ decode(e, n) {
652
+ const { Err: t } = G;
653
+ let r = 0;
654
+ if (e < 0 || e > 256)
655
+ throw new t("tlv.encode: wrong tag");
656
+ if (n.length < 2 || n[r++] !== e)
657
+ throw new t("tlv.decode: wrong tlv");
658
+ const i = n[r++], s = !!(i & 128);
659
+ let c = 0;
660
+ if (!s)
661
+ c = i;
662
+ else {
663
+ const o = i & 127;
664
+ if (!o)
665
+ throw new t("tlv.decode(long): indefinite length not supported");
666
+ if (o > 4)
667
+ throw new t("tlv.decode(long): byte length is too big");
668
+ const d = n.subarray(r, r + o);
669
+ if (d.length !== o)
670
+ throw new t("tlv.decode: length bytes not complete");
671
+ if (d[0] === 0)
672
+ throw new t("tlv.decode(long): zero leftmost byte");
673
+ for (const m of d)
674
+ c = c << 8 | m;
675
+ if (r += o, c < 128)
676
+ throw new t("tlv.decode(long): not minimal encoding");
677
+ }
678
+ const u = n.subarray(r, r + c);
679
+ if (u.length !== c)
680
+ throw new t("tlv.decode: wrong value length");
681
+ return { v: u, l: n.subarray(r + c) };
682
+ }
683
+ },
684
+ // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
685
+ // since we always use positive integers here. It must always be empty:
686
+ // - add zero byte if exists
687
+ // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
688
+ _int: {
689
+ encode(e) {
690
+ const { Err: n } = G;
691
+ if (e < X)
692
+ throw new n("integer: negative integers are not allowed");
693
+ let t = dt(e);
694
+ if (Number.parseInt(t[0], 16) & 8 && (t = "00" + t), t.length & 1)
695
+ throw new n("unexpected DER parsing assertion: unpadded hex");
696
+ return t;
697
+ },
698
+ decode(e) {
699
+ const { Err: n } = G;
700
+ if (e[0] & 128)
701
+ throw new n("invalid signature integer: negative");
702
+ if (e[0] === 0 && !(e[1] & 128))
703
+ throw new n("invalid signature integer: unnecessary leading zero");
704
+ return et(e);
705
+ }
706
+ },
707
+ toSig(e) {
708
+ const { Err: n, _int: t, _tlv: r } = G, i = K("signature", e), { v: s, l: c } = r.decode(48, i);
709
+ if (c.length)
710
+ throw new n("invalid signature: left bytes after parsing");
711
+ const { v: u, l: o } = r.decode(2, s), { v: d, l: m } = r.decode(2, o);
712
+ if (m.length)
713
+ throw new n("invalid signature: left bytes after parsing");
714
+ return { r: t.decode(u), s: t.decode(d) };
715
+ },
716
+ hexFromSig(e) {
717
+ const { _tlv: n, _int: t } = G, r = n.encode(2, t.encode(e.r)), i = n.encode(2, t.encode(e.s)), s = r + i;
718
+ return n.encode(48, s);
719
+ }
720
+ };
721
+ function At(e, n) {
722
+ return at(lt(e, n));
723
+ }
724
+ const X = BigInt(0), U = BigInt(1);
725
+ BigInt(2);
726
+ const It = BigInt(3), _e = BigInt(4);
727
+ function Ce(e) {
728
+ const n = Te(e), { Fp: t } = n, r = Ut(n.n, n.nBitLength), i = n.toBytes || ((x, f, h) => {
729
+ const p = f.toAffine();
730
+ return wt(Uint8Array.from([4]), t.toBytes(p.x), t.toBytes(p.y));
731
+ }), s = n.fromBytes || ((x) => {
732
+ const f = x.subarray(1), h = t.fromBytes(f.subarray(0, t.BYTES)), p = t.fromBytes(f.subarray(t.BYTES, 2 * t.BYTES));
733
+ return { x: h, y: p };
734
+ });
735
+ function c(x) {
736
+ const { a: f, b: h } = n, p = t.sqr(x), B = t.mul(p, x);
737
+ return t.add(t.add(B, t.mul(x, f)), h);
738
+ }
739
+ function u(x, f) {
740
+ const h = t.sqr(f), p = c(x);
741
+ return t.eql(h, p);
742
+ }
743
+ if (!u(n.Gx, n.Gy))
744
+ throw new Error("bad curve params: generator point");
745
+ const o = t.mul(t.pow(n.a, It), _e), d = t.mul(t.sqr(n.b), BigInt(27));
746
+ if (t.is0(t.add(o, d)))
747
+ throw new Error("bad curve params: a or b");
748
+ function m(x) {
749
+ return zt(x, U, n.n);
750
+ }
751
+ function A(x) {
752
+ const { allowedPrivateKeyLengths: f, nByteLength: h, wrapPrivateKey: p, n: B } = n;
753
+ if (f && typeof x != "bigint") {
754
+ if (ut(x) && (x = at(x)), typeof x != "string" || !f.includes(x.length))
755
+ throw new Error("invalid private key");
756
+ x = x.padStart(h * 2, "0");
757
+ }
758
+ let O;
759
+ try {
760
+ O = typeof x == "bigint" ? x : et(K("private key", x, h));
761
+ } catch {
762
+ throw new Error("invalid private key, expected hex or " + h + " bytes, got " + typeof x);
763
+ }
764
+ return p && (O = M(O, B)), it("private key", O, U, B), O;
765
+ }
766
+ function N(x) {
767
+ if (!(x instanceof g))
768
+ throw new Error("ProjectivePoint expected");
769
+ }
770
+ const R = Vt((x, f) => {
771
+ const { px: h, py: p, pz: B } = x;
772
+ if (t.eql(B, t.ONE))
773
+ return { x: h, y: p };
774
+ const O = x.is0();
775
+ f == null && (f = O ? t.ONE : t.inv(B));
776
+ const H = t.mul(h, f), q = t.mul(p, f), y = t.mul(B, f);
777
+ if (O)
778
+ return { x: t.ZERO, y: t.ZERO };
779
+ if (!t.eql(y, t.ONE))
780
+ throw new Error("invZ was invalid");
781
+ return { x: H, y: q };
782
+ }), Z = Vt((x) => {
783
+ if (x.is0()) {
784
+ if (n.allowInfinityPoint && !t.is0(x.py))
785
+ return;
786
+ throw new Error("bad point: ZERO");
787
+ }
788
+ const { x: f, y: h } = x.toAffine();
789
+ if (!t.isValid(f) || !t.isValid(h))
790
+ throw new Error("bad point: x or y not FE");
791
+ if (!u(f, h))
792
+ throw new Error("bad point: equation left != right");
793
+ if (!x.isTorsionFree())
794
+ throw new Error("bad point: not in prime-order subgroup");
795
+ return !0;
796
+ });
797
+ class g {
798
+ constructor(f, h, p) {
799
+ if (f == null || !t.isValid(f))
800
+ throw new Error("x required");
801
+ if (h == null || !t.isValid(h) || t.is0(h))
802
+ throw new Error("y required");
803
+ if (p == null || !t.isValid(p))
804
+ throw new Error("z required");
805
+ this.px = f, this.py = h, this.pz = p, Object.freeze(this);
806
+ }
807
+ // Does not validate if the point is on-curve.
808
+ // Use fromHex instead, or call assertValidity() later.
809
+ static fromAffine(f) {
810
+ const { x: h, y: p } = f || {};
811
+ if (!f || !t.isValid(h) || !t.isValid(p))
812
+ throw new Error("invalid affine point");
813
+ if (f instanceof g)
814
+ throw new Error("projective point not allowed");
815
+ const B = (O) => t.eql(O, t.ZERO);
816
+ return B(h) && B(p) ? g.ZERO : new g(h, p, t.ONE);
817
+ }
818
+ get x() {
819
+ return this.toAffine().x;
820
+ }
821
+ get y() {
822
+ return this.toAffine().y;
823
+ }
824
+ /**
825
+ * Takes a bunch of Projective Points but executes only one
826
+ * inversion on all of them. Inversion is very slow operation,
827
+ * so this improves performance massively.
828
+ * Optimization: converts a list of projective points to a list of identical points with Z=1.
829
+ */
830
+ static normalizeZ(f) {
831
+ const h = re(t, f.map((p) => p.pz));
832
+ return f.map((p, B) => p.toAffine(h[B])).map(g.fromAffine);
833
+ }
834
+ /**
835
+ * Converts hash string or Uint8Array to Point.
836
+ * @param hex short/long ECDSA hex
837
+ */
838
+ static fromHex(f) {
839
+ const h = g.fromAffine(s(K("pointHex", f)));
840
+ return h.assertValidity(), h;
841
+ }
842
+ // Multiplies generator point by privateKey.
843
+ static fromPrivateKey(f) {
844
+ return g.BASE.multiply(A(f));
845
+ }
846
+ // Multiscalar Multiplication
847
+ static msm(f, h) {
848
+ return Ue(g, r, f, h);
849
+ }
850
+ // "Private method", don't use it directly
851
+ _setWindowSize(f) {
852
+ $.setWindowSize(this, f);
853
+ }
854
+ // A point on curve is valid if it conforms to equation.
855
+ assertValidity() {
856
+ Z(this);
857
+ }
858
+ hasEvenY() {
859
+ const { y: f } = this.toAffine();
860
+ if (t.isOdd)
861
+ return !t.isOdd(f);
862
+ throw new Error("Field doesn't support isOdd");
863
+ }
864
+ /**
865
+ * Compare one point to another.
866
+ */
867
+ equals(f) {
868
+ N(f);
869
+ const { px: h, py: p, pz: B } = this, { px: O, py: H, pz: q } = f, y = t.eql(t.mul(h, q), t.mul(O, B)), I = t.eql(t.mul(p, q), t.mul(H, B));
870
+ return y && I;
871
+ }
872
+ /**
873
+ * Flips point to one corresponding to (x, -y) in Affine coordinates.
874
+ */
875
+ negate() {
876
+ return new g(this.px, t.neg(this.py), this.pz);
877
+ }
878
+ // Renes-Costello-Batina exception-free doubling formula.
879
+ // There is 30% faster Jacobian formula, but it is not complete.
880
+ // https://eprint.iacr.org/2015/1060, algorithm 3
881
+ // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
882
+ double() {
883
+ const { a: f, b: h } = n, p = t.mul(h, It), { px: B, py: O, pz: H } = this;
884
+ let q = t.ZERO, y = t.ZERO, I = t.ZERO, b = t.mul(B, B), T = t.mul(O, O), l = t.mul(H, H), a = t.mul(B, O);
885
+ return a = t.add(a, a), I = t.mul(B, H), I = t.add(I, I), q = t.mul(f, I), y = t.mul(p, l), y = t.add(q, y), q = t.sub(T, y), y = t.add(T, y), y = t.mul(q, y), q = t.mul(a, q), I = t.mul(p, I), l = t.mul(f, l), a = t.sub(b, l), a = t.mul(f, a), a = t.add(a, I), I = t.add(b, b), b = t.add(I, b), b = t.add(b, l), b = t.mul(b, a), y = t.add(y, b), l = t.mul(O, H), l = t.add(l, l), b = t.mul(l, a), q = t.sub(q, b), I = t.mul(l, T), I = t.add(I, I), I = t.add(I, I), new g(q, y, I);
886
+ }
887
+ // Renes-Costello-Batina exception-free addition formula.
888
+ // There is 30% faster Jacobian formula, but it is not complete.
889
+ // https://eprint.iacr.org/2015/1060, algorithm 1
890
+ // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
891
+ add(f) {
892
+ N(f);
893
+ const { px: h, py: p, pz: B } = this, { px: O, py: H, pz: q } = f;
894
+ let y = t.ZERO, I = t.ZERO, b = t.ZERO;
895
+ const T = n.a, l = t.mul(n.b, It);
896
+ let a = t.mul(h, O), w = t.mul(p, H), S = t.mul(B, q), E = t.add(h, p), v = t.add(O, H);
897
+ E = t.mul(E, v), v = t.add(a, w), E = t.sub(E, v), v = t.add(h, B);
898
+ let L = t.add(O, q);
899
+ return v = t.mul(v, L), L = t.add(a, S), v = t.sub(v, L), L = t.add(p, B), y = t.add(H, q), L = t.mul(L, y), y = t.add(w, S), L = t.sub(L, y), b = t.mul(T, v), y = t.mul(l, S), b = t.add(y, b), y = t.sub(w, b), b = t.add(w, b), I = t.mul(y, b), w = t.add(a, a), w = t.add(w, a), S = t.mul(T, S), v = t.mul(l, v), w = t.add(w, S), S = t.sub(a, S), S = t.mul(T, S), v = t.add(v, S), a = t.mul(w, v), I = t.add(I, a), a = t.mul(L, v), y = t.mul(E, y), y = t.sub(y, a), a = t.mul(E, w), b = t.mul(L, b), b = t.add(b, a), new g(y, I, b);
900
+ }
901
+ subtract(f) {
902
+ return this.add(f.negate());
903
+ }
904
+ is0() {
905
+ return this.equals(g.ZERO);
906
+ }
907
+ wNAF(f) {
908
+ return $.wNAFCached(this, f, g.normalizeZ);
909
+ }
910
+ /**
911
+ * Non-constant-time multiplication. Uses double-and-add algorithm.
912
+ * It's faster, but should only be used when you don't care about
913
+ * an exposed private key e.g. sig verification, which works over *public* keys.
914
+ */
915
+ multiplyUnsafe(f) {
916
+ const { endo: h, n: p } = n;
917
+ it("scalar", f, X, p);
918
+ const B = g.ZERO;
919
+ if (f === X)
920
+ return B;
921
+ if (this.is0() || f === U)
922
+ return this;
923
+ if (!h || $.hasPrecomputes(this))
924
+ return $.wNAFCachedUnsafe(this, f, g.normalizeZ);
925
+ let { k1neg: O, k1: H, k2neg: q, k2: y } = h.splitScalar(f), I = B, b = B, T = this;
926
+ for (; H > X || y > X; )
927
+ H & U && (I = I.add(T)), y & U && (b = b.add(T)), T = T.double(), H >>= U, y >>= U;
928
+ return O && (I = I.negate()), q && (b = b.negate()), b = new g(t.mul(b.px, h.beta), b.py, b.pz), I.add(b);
929
+ }
930
+ /**
931
+ * Constant time multiplication.
932
+ * Uses wNAF method. Windowed method may be 10% faster,
933
+ * but takes 2x longer to generate and consumes 2x memory.
934
+ * Uses precomputes when available.
935
+ * Uses endomorphism for Koblitz curves.
936
+ * @param scalar by which the point would be multiplied
937
+ * @returns New point
938
+ */
939
+ multiply(f) {
940
+ const { endo: h, n: p } = n;
941
+ it("scalar", f, U, p);
942
+ let B, O;
943
+ if (h) {
944
+ const { k1neg: H, k1: q, k2neg: y, k2: I } = h.splitScalar(f);
945
+ let { p: b, f: T } = this.wNAF(q), { p: l, f: a } = this.wNAF(I);
946
+ b = $.constTimeNegate(H, b), l = $.constTimeNegate(y, l), l = new g(t.mul(l.px, h.beta), l.py, l.pz), B = b.add(l), O = T.add(a);
947
+ } else {
948
+ const { p: H, f: q } = this.wNAF(f);
949
+ B = H, O = q;
950
+ }
951
+ return g.normalizeZ([B, O])[0];
952
+ }
953
+ /**
954
+ * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
955
+ * Not using Strauss-Shamir trick: precomputation tables are faster.
956
+ * The trick could be useful if both P and Q are not G (not in our case).
957
+ * @returns non-zero affine point
958
+ */
959
+ multiplyAndAddUnsafe(f, h, p) {
960
+ const B = g.BASE, O = (q, y) => y === X || y === U || !q.equals(B) ? q.multiplyUnsafe(y) : q.multiply(y), H = O(this, h).add(O(f, p));
961
+ return H.is0() ? void 0 : H;
962
+ }
963
+ // Converts Projective point to affine (x, y) coordinates.
964
+ // Can accept precomputed Z^-1 - for example, from invertBatch.
965
+ // (x, y, z) ∋ (x=x/z, y=y/z)
966
+ toAffine(f) {
967
+ return R(this, f);
968
+ }
969
+ isTorsionFree() {
970
+ const { h: f, isTorsionFree: h } = n;
971
+ if (f === U)
972
+ return !0;
973
+ if (h)
974
+ return h(g, this);
975
+ throw new Error("isTorsionFree() has not been declared for the elliptic curve");
976
+ }
977
+ clearCofactor() {
978
+ const { h: f, clearCofactor: h } = n;
979
+ return f === U ? this : h ? h(g, this) : this.multiplyUnsafe(n.h);
980
+ }
981
+ toRawBytes(f = !0) {
982
+ return ft("isCompressed", f), this.assertValidity(), i(g, this, f);
983
+ }
984
+ toHex(f = !0) {
985
+ return ft("isCompressed", f), at(this.toRawBytes(f));
986
+ }
987
+ }
988
+ g.BASE = new g(n.Gx, n.Gy, t.ONE), g.ZERO = new g(t.ZERO, t.ONE, t.ZERO);
989
+ const { endo: k, nBitLength: z } = n, $ = ze(g, k ? Math.ceil(z / 2) : z);
990
+ return {
991
+ CURVE: n,
992
+ ProjectivePoint: g,
993
+ normPrivateKeyToScalar: A,
994
+ weierstrassEquation: c,
995
+ isWithinCurveOrder: m
996
+ };
997
+ }
998
+ function Ve(e) {
999
+ const n = ae(e);
1000
+ return mt(n, {
1001
+ hash: "hash",
1002
+ hmac: "function",
1003
+ randomBytes: "function"
1004
+ }, {
1005
+ bits2int: "function",
1006
+ bits2int_modN: "function",
1007
+ lowS: "boolean"
1008
+ }), Object.freeze({ lowS: !0, ...n });
1009
+ }
1010
+ function Me(e) {
1011
+ const n = Ve(e), { Fp: t, n: r, nByteLength: i, nBitLength: s } = n, c = t.BYTES + 1, u = 2 * t.BYTES + 1;
1012
+ function o(l) {
1013
+ return M(l, r);
1014
+ }
1015
+ function d(l) {
1016
+ return Ot(l, r);
1017
+ }
1018
+ const { ProjectivePoint: m, normPrivateKeyToScalar: A, weierstrassEquation: N, isWithinCurveOrder: R } = Ce({
1019
+ ...n,
1020
+ toBytes(l, a, w) {
1021
+ const S = a.toAffine(), E = t.toBytes(S.x), v = wt;
1022
+ return ft("isCompressed", w), w ? v(Uint8Array.from([a.hasEvenY() ? 2 : 3]), E) : v(Uint8Array.from([4]), E, t.toBytes(S.y));
1023
+ },
1024
+ fromBytes(l) {
1025
+ const a = l.length, w = l[0], S = l.subarray(1);
1026
+ if (a === c && (w === 2 || w === 3)) {
1027
+ const E = et(S);
1028
+ if (!zt(E, U, t.ORDER))
1029
+ throw new Error("Point is not on curve");
1030
+ const v = N(E);
1031
+ let L;
1032
+ try {
1033
+ L = t.sqrt(v);
1034
+ } catch (P) {
1035
+ const V = P instanceof Error ? ": " + P.message : "";
1036
+ throw new Error("Point is not on curve" + V);
1037
+ }
1038
+ const _ = (L & U) === U;
1039
+ return (w & 1) === 1 !== _ && (L = t.neg(L)), { x: E, y: L };
1040
+ } else if (a === u && w === 4) {
1041
+ const E = t.fromBytes(S.subarray(0, t.BYTES)), v = t.fromBytes(S.subarray(t.BYTES, 2 * t.BYTES));
1042
+ return { x: E, y: v };
1043
+ } else {
1044
+ const E = c, v = u;
1045
+ throw new Error("invalid Point, expected length of " + E + ", or uncompressed " + v + ", got " + a);
1046
+ }
1047
+ }
1048
+ });
1049
+ function Z(l) {
1050
+ const a = r >> U;
1051
+ return l > a;
1052
+ }
1053
+ function g(l) {
1054
+ return Z(l) ? o(-l) : l;
1055
+ }
1056
+ const k = (l, a, w) => et(l.slice(a, w));
1057
+ class z {
1058
+ constructor(a, w, S) {
1059
+ it("r", a, U, r), it("s", w, U, r), this.r = a, this.s = w, S != null && (this.recovery = S), Object.freeze(this);
1060
+ }
1061
+ // pair (bytes of r, bytes of s)
1062
+ static fromCompact(a) {
1063
+ const w = i;
1064
+ return a = K("compactSignature", a, w * 2), new z(k(a, 0, w), k(a, w, 2 * w));
1065
+ }
1066
+ // DER encoded ECDSA signature
1067
+ // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
1068
+ static fromDER(a) {
1069
+ const { r: w, s: S } = G.toSig(K("DER", a));
1070
+ return new z(w, S);
1071
+ }
1072
+ /**
1073
+ * @todo remove
1074
+ * @deprecated
1075
+ */
1076
+ assertValidity() {
1077
+ }
1078
+ addRecoveryBit(a) {
1079
+ return new z(this.r, this.s, a);
1080
+ }
1081
+ recoverPublicKey(a) {
1082
+ const { r: w, s: S, recovery: E } = this, v = B(K("msgHash", a));
1083
+ if (E == null || ![0, 1, 2, 3].includes(E))
1084
+ throw new Error("recovery id invalid");
1085
+ const L = E === 2 || E === 3 ? w + n.n : w;
1086
+ if (L >= t.ORDER)
1087
+ throw new Error("recovery id 2 or 3 invalid");
1088
+ const _ = (E & 1) === 0 ? "02" : "03", W = m.fromHex(_ + At(L, t.BYTES)), P = d(L), V = o(-v * P), nt = o(S * P), F = m.BASE.multiplyAndAddUnsafe(W, V, nt);
1089
+ if (!F)
1090
+ throw new Error("point at infinify");
1091
+ return F.assertValidity(), F;
1092
+ }
1093
+ // Signatures should be low-s, to prevent malleability.
1094
+ hasHighS() {
1095
+ return Z(this.s);
1096
+ }
1097
+ normalizeS() {
1098
+ return this.hasHighS() ? new z(this.r, o(-this.s), this.recovery) : this;
1099
+ }
1100
+ // DER-encoded
1101
+ toDERRawBytes() {
1102
+ return ht(this.toDERHex());
1103
+ }
1104
+ toDERHex() {
1105
+ return G.hexFromSig(this);
1106
+ }
1107
+ // padded bytes of r, then padded bytes of s
1108
+ toCompactRawBytes() {
1109
+ return ht(this.toCompactHex());
1110
+ }
1111
+ toCompactHex() {
1112
+ const a = i;
1113
+ return At(this.r, a) + At(this.s, a);
1114
+ }
1115
+ }
1116
+ const $ = {
1117
+ isValidPrivateKey(l) {
1118
+ try {
1119
+ return A(l), !0;
1120
+ } catch {
1121
+ return !1;
1122
+ }
1123
+ },
1124
+ normPrivateKeyToScalar: A,
1125
+ /**
1126
+ * Produces cryptographically secure private key from random of size
1127
+ * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.
1128
+ */
1129
+ randomPrivateKey: () => {
1130
+ const l = se(n.n);
1131
+ return Le(n.randomBytes(l), n.n);
1132
+ },
1133
+ /**
1134
+ * Creates precompute table for an arbitrary EC point. Makes point "cached".
1135
+ * Allows to massively speed-up `point.multiply(scalar)`.
1136
+ * @returns cached point
1137
+ * @example
1138
+ * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));
1139
+ * fast.multiply(privKey); // much faster ECDH now
1140
+ */
1141
+ precompute(l = 8, a = m.BASE) {
1142
+ return a._setWindowSize(l), a.multiply(BigInt(3)), a;
1143
+ }
1144
+ };
1145
+ function x(l, a = !0) {
1146
+ return m.fromPrivateKey(l).toRawBytes(a);
1147
+ }
1148
+ function f(l) {
1149
+ if (typeof l == "bigint")
1150
+ return !1;
1151
+ if (l instanceof m)
1152
+ return !0;
1153
+ const w = K("key", l).length, S = t.BYTES, E = S + 1, v = 2 * S + 1;
1154
+ if (!(n.allowedPrivateKeyLengths || i === E))
1155
+ return w === E || w === v;
1156
+ }
1157
+ function h(l, a, w = !0) {
1158
+ if (f(l) === !0)
1159
+ throw new Error("first arg must be private key");
1160
+ if (f(a) === !1)
1161
+ throw new Error("second arg must be public key");
1162
+ return m.fromHex(a).multiply(A(l)).toRawBytes(w);
1163
+ }
1164
+ const p = n.bits2int || function(l) {
1165
+ if (l.length > 8192)
1166
+ throw new Error("input is too large");
1167
+ const a = et(l), w = l.length * 8 - s;
1168
+ return w > 0 ? a >> BigInt(w) : a;
1169
+ }, B = n.bits2int_modN || function(l) {
1170
+ return o(p(l));
1171
+ }, O = gt(s);
1172
+ function H(l) {
1173
+ return it("num < 2^" + s, l, X, O), lt(l, i);
1174
+ }
1175
+ function q(l, a, w = y) {
1176
+ if (["recovered", "canonical"].some((Q) => Q in w))
1177
+ throw new Error("sign() legacy options not supported");
1178
+ const { hash: S, randomBytes: E } = n;
1179
+ let { lowS: v, prehash: L, extraEntropy: _ } = w;
1180
+ v == null && (v = !0), l = K("msgHash", l), Kt(w), L && (l = K("prehashed msgHash", S(l)));
1181
+ const W = B(l), P = A(a), V = [H(P), H(W)];
1182
+ if (_ != null && _ !== !1) {
1183
+ const Q = _ === !0 ? E(t.BYTES) : _;
1184
+ V.push(K("extraEntropy", Q));
1185
+ }
1186
+ const nt = wt(...V), F = W;
1187
+ function pt(Q) {
1188
+ const rt = p(Q);
1189
+ if (!R(rt))
1190
+ return;
1191
+ const yt = d(rt), st = m.BASE.multiply(rt).toAffine(), J = o(st.x);
1192
+ if (J === X)
1193
+ return;
1194
+ const ct = o(yt * o(F + J * P));
1195
+ if (ct === X)
1196
+ return;
1197
+ let ot = (st.x === J ? 0 : 2) | Number(st.y & U), Tt = ct;
1198
+ return v && Z(ct) && (Tt = g(ct), ot ^= 1), new z(J, Tt, ot);
1199
+ }
1200
+ return { seed: nt, k2sig: pt };
1201
+ }
1202
+ const y = { lowS: n.lowS, prehash: !1 }, I = { lowS: n.lowS, prehash: !1 };
1203
+ function b(l, a, w = y) {
1204
+ const { seed: S, k2sig: E } = q(l, a, w), v = n;
1205
+ return ve(v.hash.outputLen, v.nByteLength, v.hmac)(S, E);
1206
+ }
1207
+ m.BASE._setWindowSize(8);
1208
+ function T(l, a, w, S = I) {
1209
+ const E = l;
1210
+ a = K("msgHash", a), w = K("publicKey", w);
1211
+ const { lowS: v, prehash: L, format: _ } = S;
1212
+ if (Kt(S), "strict" in S)
1213
+ throw new Error("options.strict was renamed to lowS");
1214
+ if (_ !== void 0 && _ !== "compact" && _ !== "der")
1215
+ throw new Error("format must be compact or der");
1216
+ const W = typeof E == "string" || ut(E), P = !W && !_ && typeof E == "object" && E !== null && typeof E.r == "bigint" && typeof E.s == "bigint";
1217
+ if (!W && !P)
1218
+ throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
1219
+ let V, nt;
1220
+ try {
1221
+ if (P && (V = new z(E.r, E.s)), W) {
1222
+ try {
1223
+ _ !== "compact" && (V = z.fromDER(E));
1224
+ } catch (ot) {
1225
+ if (!(ot instanceof G.Err))
1226
+ throw ot;
1227
+ }
1228
+ !V && _ !== "der" && (V = z.fromCompact(E));
1229
+ }
1230
+ nt = m.fromHex(w);
1231
+ } catch {
1232
+ return !1;
1233
+ }
1234
+ if (!V || v && V.hasHighS())
1235
+ return !1;
1236
+ L && (a = n.hash(a));
1237
+ const { r: F, s: pt } = V, Q = B(a), rt = d(pt), yt = o(Q * rt), st = o(F * rt), J = m.BASE.multiplyAndAddUnsafe(nt, yt, st)?.toAffine();
1238
+ return J ? o(J.x) === F : !1;
1239
+ }
1240
+ return {
1241
+ CURVE: n,
1242
+ getPublicKey: x,
1243
+ getSharedSecret: h,
1244
+ sign: b,
1245
+ verify: T,
1246
+ ProjectivePoint: m,
1247
+ Signature: z,
1248
+ utils: $
1249
+ };
1250
+ }
1251
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1252
+ function je(e) {
1253
+ return {
1254
+ hash: e,
1255
+ hmac: (n, ...t) => Qt(e, n, ye(...t)),
1256
+ randomBytes: pe
1257
+ };
1258
+ }
1259
+ function Ye(e, n) {
1260
+ const t = (r) => Me({ ...e, ...je(r) });
1261
+ return { ...t(n), create: t };
1262
+ }
1263
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1264
+ const ue = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), Pt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), Ke = BigInt(0), Pe = BigInt(1), Ht = BigInt(2), $t = (e, n) => (e + n / Ht) / n;
1265
+ function $e(e) {
1266
+ const n = ue, t = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), c = BigInt(23), u = BigInt(44), o = BigInt(88), d = e * e * e % n, m = d * d * e % n, A = Y(m, t, n) * m % n, N = Y(A, t, n) * m % n, R = Y(N, Ht, n) * d % n, Z = Y(R, i, n) * R % n, g = Y(Z, s, n) * Z % n, k = Y(g, u, n) * g % n, z = Y(k, o, n) * k % n, $ = Y(z, u, n) * g % n, x = Y($, t, n) * m % n, f = Y(x, c, n) * Z % n, h = Y(f, r, n) * d % n, p = Y(h, Ht, n);
1267
+ if (!Lt.eql(Lt.sqr(p), e))
1268
+ throw new Error("Cannot find square root");
1269
+ return p;
1270
+ }
1271
+ const Lt = Ut(ue, void 0, void 0, { sqrt: $e }), De = Ye({
1272
+ a: Ke,
1273
+ b: BigInt(7),
1274
+ Fp: Lt,
1275
+ n: Pt,
1276
+ Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
1277
+ Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),
1278
+ h: BigInt(1),
1279
+ lowS: !0,
1280
+ // Allow only low-S signatures by default in sign() and verify()
1281
+ endo: {
1282
+ // Endomorphism, see above
1283
+ beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
1284
+ splitScalar: (e) => {
1285
+ const n = Pt, t = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -Pe * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), s = t, c = BigInt("0x100000000000000000000000000000000"), u = $t(s * e, n), o = $t(-r * e, n);
1286
+ let d = M(e - u * t - o * i, n), m = M(-u * r - o * s, n);
1287
+ const A = d > c, N = m > c;
1288
+ if (A && (d = n - d), N && (m = n - m), d > c || m > c)
1289
+ throw new Error("splitScalar: Endomorphism failed, k=" + e);
1290
+ return { k1neg: A, k1: d, k2neg: N, k2: m };
1291
+ }
1292
+ }
1293
+ }, be);
1294
+ export {
1295
+ De as secp256k1
1296
+ };
1297
+ //# sourceMappingURL=secp256k1-DCMgMsfV.js.map