@dcl/explorer-website 2.6.1-25865517797.commit-b7a7cba → 2.6.1-25877826901.commit-3465800

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 (140) hide show
  1. package/assets/{ConstantsUtil-ByjAYmvC.js → ConstantsUtil-C4lJZ9QJ.js} +1 -1
  2. package/assets/{ExchangeController-Bp8ztJrX.js → ExchangeController-BSoHrJkH.js} +1 -1
  3. package/assets/{HelpersUtil-Dp4e1zvd.js → HelpersUtil-COJM8Fma.js} +1 -1
  4. package/assets/{NetworkUtil-DqGcuBfF.js → NetworkUtil-XsBaDkTf.js} +1 -1
  5. package/assets/{SwapController-DUCq2f7d.js → SwapController-CykJEtRW.js} +1 -1
  6. package/assets/{W3MFrameProviderSingleton-9eitOT0j.js → W3MFrameProviderSingleton-eYQGtm7P.js} +3 -3
  7. package/assets/{basic-C7tUDecp.js → basic-OoSQYHEk.js} +1 -1
  8. package/assets/{biconomy-plHCR2Qq.js → biconomy-PKn4tIKl.js} +1 -1
  9. package/assets/{browser-VYI7gorG.js → browser-DoJWAFam.js} +1 -1
  10. package/assets/browser-ponyfill-CqiVi-O8.js +1 -0
  11. package/assets/{ccip-CrAifiNa.js → ccip-BvTmJITs.js} +1 -1
  12. package/assets/{ccip-Bldffu31.js → ccip-ByLIoOC6.js} +1 -1
  13. package/assets/{chains-DTVDhUwv.js → chains-icJ3HR5v.js} +1 -1
  14. package/assets/{common-BEf2T7Hi.js → common-DMnogLd5.js} +1 -1
  15. package/assets/{controller-B8Iy-6V9.js → controller-BXwg_bJl.js} +2 -2
  16. package/assets/{core-XFvzSI58.js → core-DOL3gnfb.js} +4 -4
  17. package/assets/{custom-cPmISGcH.js → custom-CZYipZz1.js} +1 -1
  18. package/assets/{data-capture-DnvAEYWK.js → data-capture-CRDSEIY_.js} +1 -1
  19. package/assets/{decimals-8g2-fBFa.js → decimals-DNQm_OiO.js} +1 -1
  20. package/assets/decimals-DnutWGXb.js +1 -0
  21. package/assets/{detectExtension-yvI5WWZb.js → detectExtension-BfmE7TOs.js} +1 -1
  22. package/assets/{email-C8DRQjTT.js → email-CvS0g63O.js} +1 -1
  23. package/assets/{embedded-wallet-BxgtT1uV.js → embedded-wallet-BH2dkm4W.js} +1 -1
  24. package/assets/{engine-BERe87yT.js → engine-Di9rAbBn.js} +1 -1
  25. package/assets/{estimate-l1-fee-BTeKvFv5.js → estimate-l1-fee-D5Yk5K_j.js} +1 -1
  26. package/assets/eth_estimateGas-BmOR31h-.js +1 -0
  27. package/assets/{eth_getStorageAt-SbVMAQY-.js → eth_getStorageAt-7xIaoYHZ.js} +1 -1
  28. package/assets/{eth_getTransactionCount-qv0oO1Md.js → eth_getTransactionCount-DrnF23O4.js} +1 -1
  29. package/assets/{ethereum-BP59xYBe.js → ethereum-2kM2S7dx.js} +1 -1
  30. package/assets/{extractIPFS-BOFlZk7U.js → extractIPFS-C9Vdpa9n.js} +1 -1
  31. package/assets/{features-DVWd8_kC.js → features-DRiKivpi.js} +1 -1
  32. package/assets/{fetchTokenMetadata-BaJXN6RH.js → fetchTokenMetadata-DZl1qOjc.js} +2 -2
  33. package/assets/{fortmatic-DARkeYTE.js → fortmatic-6-9Hxtzg.js} +1 -1
  34. package/assets/get-ecosystem-wallet-info-DQQrfAsE.js +1 -0
  35. package/assets/{getBalance-D6wpo61w.js → getBalance-BfwFhtAu.js} +2 -2
  36. package/assets/{getInstalledModules-Dkj379ys.js → getInstalledModules-Dlcyw_6V.js} +1 -1
  37. package/assets/{getNFT-HMkoXD7L.js → getNFT-CkUzlgLt.js} +2 -2
  38. package/assets/{getNFT-Drn4rxrk.js → getNFT-DIu1VS3y.js} +1 -1
  39. package/assets/{hashTypedData-B5shS-rs.js → hashTypedData-CM_9VEoH.js} +1 -1
  40. package/assets/{hashTypedData-CMDSWYgs.js → hashTypedData-DrZol7nF.js} +1 -1
  41. package/assets/{in-app-wallet-calls-l9-2W_Em.js → in-app-wallet-calls-BABhagi9.js} +1 -1
  42. package/assets/{index-CH0zI801.js → index--SuwY_Sr.js} +1 -1
  43. package/assets/{index-B9U0GcYk.js → index-3gZjXx6v.js} +1 -1
  44. package/assets/{index-BXAxcybX.js → index-3jhEomSV.js} +1 -1
  45. package/assets/{index-D0LvjNIX.js → index-8eDD30Uv.js} +1 -1
  46. package/assets/{index-DfWsAOhN.js → index-B26CWJm4.js} +3 -3
  47. package/assets/{index-8M7OkBFm.js → index-B3Bk-Bdi.js} +1 -1
  48. package/assets/{index-DPxCDCvr.js → index-B7_b_SxX.js} +1 -1
  49. package/assets/{index-DK-ZMNLh.js → index-BI0nsxQ1.js} +1 -1
  50. package/assets/{index-BKL7nv1p.js → index-BPxeLdJF.js} +1 -1
  51. package/assets/{index-CWnFK_-0.js → index-BQJscq8u.js} +1 -1
  52. package/assets/{index-B5ECjSS9.js → index-BSmpP1mK.js} +1 -1
  53. package/assets/{index-JfVynEph.js → index-BUjSLaXy.js} +1 -1
  54. package/assets/{index-aoxVkzFE.js → index-BVL3WVs3.js} +1 -1
  55. package/assets/{index-829Uxa3Y.css → index-BXaGpRRD.css} +1 -1
  56. package/assets/{index-TBthDmkl.js → index-BYwd36WC.js} +1 -1
  57. package/assets/{index-0ShVRzxt.js → index-BlANYCHN.js} +1 -1
  58. package/assets/{index-BaGjqMte.js → index-BxZwJKty.js} +2 -2
  59. package/assets/{index-DOnRCLNP.js → index-C68kxEIB.js} +2 -2
  60. package/assets/{index-okvlQSs2.js → index-CEE50lK9.js} +1 -1
  61. package/assets/{index-BxdNwV86.js → index-CFn3Q12F.js} +1 -1
  62. package/assets/{index-DP1DuCnR.js → index-CNR7tadx.js} +1 -1
  63. package/assets/{index-CWGeCZBJ.js → index-CNttLYqM.js} +1 -1
  64. package/assets/{index-B-vyBZw9.js → index-CPCCdjXg.js} +1 -1
  65. package/assets/{index-C8NSq3HK.js → index-CQx7Nvt8.js} +1 -1
  66. package/assets/{index-I68folnJ.js → index-CUqVNGI9.js} +1 -1
  67. package/assets/{index-wds8TuUm.js → index-CYGUludi.js} +1 -1
  68. package/assets/{index-DS2Lm9tG.js → index-CcHsPndE.js} +1 -1
  69. package/assets/{index-DFE6t65x.js → index-CdCaVlZ8.js} +1 -1
  70. package/assets/{index-r_1z0VI_.js → index-CpGStcFm.js} +1 -1
  71. package/assets/{index-i4VBSYqA.js → index-CzGhZ9cz.js} +1 -1
  72. package/assets/{index-kXKMGszW.js → index-D2eOGoyM.js} +1 -1
  73. package/assets/{index-DIlwNfpB.js → index-D4_P_6_0.js} +1 -1
  74. package/assets/{index-D2ZBQG8w.js → index-D4h65XPa.js} +1 -1
  75. package/assets/{index-CE5G6IEJ.js → index-D6EwKnFm.js} +1 -1
  76. package/assets/{index-BDgZ3gDE.js → index-DD7htze-.js} +1 -1
  77. package/assets/{index-CjiwjbqL.js → index-DErCc5s3.js} +1 -1
  78. package/assets/{index-DvJmANzU.js → index-DIZhmTRA.js} +1 -1
  79. package/assets/{index-Cp7mdTuR.js → index-DNf75mcI.js} +1 -1
  80. package/assets/{index-BIPd_vR5.js → index-DVWnrfKr.js} +1 -1
  81. package/assets/{index-C5ciuua_.js → index-DcSeumRb.js} +1 -1
  82. package/assets/{index-DWRq2SN_.js → index-Dh25pQLC.js} +1 -1
  83. package/assets/{index-mZa0UiRt.js → index-DhJ5PMMP.js} +1 -1
  84. package/assets/{index-C51HwlD0.js → index-DvBfOXXL.js} +1 -1
  85. package/assets/{index-C-uqursN.js → index-ZSDK0Ila.js} +1 -1
  86. package/assets/{index-Cu4ZjLNb.js → index-a-a2MqTK.js} +5 -5
  87. package/assets/{index-B7Jt3b4d.js → index-jd0SXoNg.js} +1 -1
  88. package/assets/{index-BlykZ8Gp.js → index-kYi3llt9.js} +1 -1
  89. package/assets/{index-DbAu4Peg.js → index-mUrlue57.js} +3 -3
  90. package/assets/{index-Cy1X3n_C.js → index-vqWCp_18.js} +1 -1
  91. package/assets/{index.es-cEGj7JU0.js → index.es-B6W15sA5.js} +4 -4
  92. package/assets/{index.es-YpI01v2I.js → index.es-BpysnXQX.js} +1 -1
  93. package/assets/{index.es-CkxUaFYS.js → index.es-CjcoN6we.js} +1 -1
  94. package/assets/{localBatchGatewayRequest-CNIOIq-Z.js → localBatchGatewayRequest-BH_HSMtg.js} +1 -1
  95. package/assets/{networks-DJ72puSk.js → networks-xuo_6MCS.js} +1 -1
  96. package/assets/{onramp--l5ZLxWE.js → onramp-CYabKBjQ.js} +1 -1
  97. package/assets/{openzeppelin-CqtRqxtF.js → openzeppelin-ChIJtXh7.js} +1 -1
  98. package/assets/{ownerOf-cWkgEtd8.js → ownerOf-CpA7K1ak.js} +1 -1
  99. package/assets/{parseEventLogs-D1xiFnCH.js → parseEventLogs-DTRl5YJ_.js} +3 -3
  100. package/assets/{parseNft-DH5KlHPI.js → parseNft-BmgScKdM.js} +2 -2
  101. package/assets/{parseSignature-BYhcrVdX.js → parseSignature-On3IHrnn.js} +1 -1
  102. package/assets/{parseSignature-HAlgOHnm.js → parseSignature-XxRbPHFh.js} +3 -3
  103. package/assets/{pay-with-exchange-CiXPJJ6-.js → pay-with-exchange-DehF3o8r.js} +1 -1
  104. package/assets/{qr-overlay-CmFgwJBd.js → qr-overlay-BEl3x4xw.js} +3 -3
  105. package/assets/{receive-t2TxUItI.js → receive-C_KTgg4c.js} +1 -1
  106. package/assets/{resolveImplementation-iG9WRRnW.js → resolveImplementation-LbazawSf.js} +1 -1
  107. package/assets/{rpc-sIdV4wiJ.js → rpc-BVFdxD_n.js} +1 -1
  108. package/assets/{secp256k1-Co_Jve4c.js → secp256k1-6WLSeO2i.js} +1 -1
  109. package/assets/{secp256k1-Rk5k9i7o.js → secp256k1-CUFDPHqP.js} +1 -1
  110. package/assets/{secp256k1-Bg2aUJRs.js → secp256k1-DjijwK4n.js} +1 -1
  111. package/assets/{send-ByB5fOtm.js → send-BvXhUAZg.js} +1 -1
  112. package/assets/{send-batch-transaction-D79MC_wr.js → send-batch-transaction-PvOdFKh_.js} +1 -1
  113. package/assets/{send-eip712-transaction-CB6qLgks.js → send-eip712-transaction-DW2Z39R_.js} +2 -2
  114. package/assets/{send-gasless-transaction-Dt1qtUR8.js → send-gasless-transaction-DZNXePZn.js} +2 -2
  115. package/assets/{session-proposal-CY0k9Jnm.js → session-proposal-BDKOEjOS.js} +1 -1
  116. package/assets/{session-request-B_2glC9e.js → session-request-C6gEdmiF.js} +2 -2
  117. package/assets/{sha256-Dy8KQE_5.js → sha256-DOODwtIM.js} +1 -1
  118. package/assets/{signing-gNn6SJWz.js → signing-lyeTiv6v.js} +5 -5
  119. package/assets/{socials-Dx84-PrV.js → socials-J163g-WS.js} +1 -1
  120. package/assets/{swaps-CK9Sfcew.js → swaps-DhRGH4D_.js} +1 -1
  121. package/assets/{thirdweb-Bx5V_C1s.js → thirdweb-Dqspr20y.js} +3 -3
  122. package/assets/{totalSupply-O-VFDoRO.js → totalSupply-C4K7aOAr.js} +1 -1
  123. package/assets/{transactionReceipt-BqEjx5q-.js → transactionReceipt-DIRSM0gr.js} +1 -1
  124. package/assets/{transactions-BLOC2qYE.js → transactions-CIkqFxc1.js} +1 -1
  125. package/assets/{utils-h8VUSGPW.js → utils-Cj9H0gW-.js} +1 -1
  126. package/assets/{verifyHash-CNJ6t8Wp.js → verifyHash-CoWeO2NB.js} +1 -1
  127. package/assets/{w3m-modal-CCQuGDus.js → w3m-modal-BkrZujFe.js} +1 -1
  128. package/assets/{w3m-modal-nzPxg0Fr.js → w3m-modal-Cam7s-1S.js} +1 -1
  129. package/assets/{wait-for-tx-receipt-5pSBMNe2.js → wait-for-tx-receipt-CN6uf72q.js} +1 -1
  130. package/assets/{wallets-Bz03-Btm.js → wallets-HiUhftO5.js} +6 -6
  131. package/assets/{web-connector-CAOe_uvv.js → web-connector-Dq2kV8N4.js} +3 -3
  132. package/assets/{writeContract-CCar3Ocq.js → writeContract-jh5z7q6H.js} +1 -1
  133. package/assets/{zora-sepolia-D6mjhB5j.js → zora-sepolia-CS_uSNQg.js} +1 -1
  134. package/assets/{zoraTestnet-WLSFziQl.js → zoraTestnet-CvoUlJGq.js} +1 -1
  135. package/index.html +4 -4
  136. package/package.json +3 -3
  137. package/assets/browser-ponyfill-BmgQyNz0.js +0 -1
  138. package/assets/decimals-DR6jraOc.js +0 -1
  139. package/assets/eth_estimateGas-DKKwG-Ue.js +0 -1
  140. package/assets/get-ecosystem-wallet-info-Cvjz8DFX.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-VYI7gorG.js","assets/index-Cu4ZjLNb.js","assets/index-829Uxa3Y.css"])))=>i.map(i=>d[i]);
2
- import{_ as C}from"./index-Cu4ZjLNb.js";function T(l,o={}){const{qrSize:s=280,showCloseButton:y=!0,closeButtonText:p="×",theme:n="light",container:m=document.body,onCancel:x}=o,t=document.createElement("div");t.style.cssText=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-DoJWAFam.js","assets/index-a-a2MqTK.js","assets/index-BXaGpRRD.css"])))=>i.map(i=>d[i]);
2
+ import{_ as C}from"./index-a-a2MqTK.js";function T(l,o={}){const{qrSize:s=280,showCloseButton:y=!0,closeButtonText:p="×",theme:n="light",container:m=document.body,onCancel:x}=o,t=document.createElement("div");t.style.cssText=`
3
3
  position: fixed;
4
4
  inset: 0;
5
5
  background-color: ${n==="dark"?"rgba(0, 0, 0, 0.8)":"rgba(0, 0, 0, 0.5)"};
@@ -74,4 +74,4 @@ import{_ as C}from"./index-Cu4ZjLNb.js";function T(l,o={}){const{qrSize:s=280,sh
74
74
  from { transform: scale(1); opacity: 1; }
75
75
  to { transform: scale(0.9); opacity: 0; }
76
76
  }
77
- `,document.head.appendChild(d);const h=e=>{e.key==="Escape"&&f(!0)},g=e=>{e.target===t&&f(!0)};document.addEventListener("keydown",h),t.addEventListener("click",g),m.appendChild(t);function f(e=!1){document.removeEventListener("keydown",h),t.removeEventListener("click",g),e&&x&&x(),t.style.animation="fadeOut 200ms ease-in",r.style.animation="scaleOut 200ms ease-in";const v=()=>{t.parentNode&&t.parentNode.removeChild(t),d.parentNode&&d.parentNode.removeChild(d)};t.addEventListener("animationend",v,{once:!0}),setTimeout(v,250)}function b(){t.style.display="none"}function k(){t.style.display="flex"}return{destroy:()=>f(!1),hide:b,show:k}}async function E(l,o,s){if(!o.getContext("2d"))return;const{toCanvas:p}=await C(async()=>{const{toCanvas:n}=await import("./browser-VYI7gorG.js").then(m=>m.b);return{toCanvas:n}},__vite__mapDeps([0,1,2]));await p(o,l,{width:s,margin:2,color:{dark:"#000000",light:"#ffffff"}})}export{T as createQROverlay};
77
+ `,document.head.appendChild(d);const h=e=>{e.key==="Escape"&&f(!0)},g=e=>{e.target===t&&f(!0)};document.addEventListener("keydown",h),t.addEventListener("click",g),m.appendChild(t);function f(e=!1){document.removeEventListener("keydown",h),t.removeEventListener("click",g),e&&x&&x(),t.style.animation="fadeOut 200ms ease-in",r.style.animation="scaleOut 200ms ease-in";const v=()=>{t.parentNode&&t.parentNode.removeChild(t),d.parentNode&&d.parentNode.removeChild(d)};t.addEventListener("animationend",v,{once:!0}),setTimeout(v,250)}function b(){t.style.display="none"}function k(){t.style.display="flex"}return{destroy:()=>f(!1),hide:b,show:k}}async function E(l,o,s){if(!o.getContext("2d"))return;const{toCanvas:p}=await C(async()=>{const{toCanvas:n}=await import("./browser-DoJWAFam.js").then(m=>m.b);return{toCanvas:n}},__vite__mapDeps([0,1,2]));await p(o,l,{width:s,margin:2,color:{dark:"#000000",light:"#ffffff"}})}export{T as createQROverlay};
@@ -1,4 +1,4 @@
1
- import{i as g,b as l}from"./lit-element-Cn7T8F1W.js";import{n as k,r as f}from"./class-map-mFRv1nW8.js";import{o as v}from"./if-defined-DsPifBxM.js";import{d as y,r as $,e as C}from"./index-DbAu4Peg.js";import{c as x,U as N}from"./index-wds8TuUm.js";import"./index-i4VBSYqA.js";import"./index-0ShVRzxt.js";import{C as c,S as m,q as w,T as h,l as R,W as A,R as S,b as I}from"./W3MFrameProviderSingleton-9eitOT0j.js";import"./index-Cu4ZjLNb.js";import"./index-B-vyBZw9.js";import"./index-DS2Lm9tG.js";import"./index-nibyPLVP.js";import"./index-r_1z0VI_.js";import"./sha2-D3ryOfi3.js";import"./hmac-BMnSt9Ou.js";import"./NetworkUtil-DqGcuBfF.js";import"./index.es-CkxUaFYS.js";import"./browser-ponyfill-BmgQyNz0.js";import"./browser-VYI7gorG.js";const T=y`
1
+ import{i as g,b as l}from"./lit-element-Cn7T8F1W.js";import{n as k,r as f}from"./class-map-mFRv1nW8.js";import{o as v}from"./if-defined-DsPifBxM.js";import{d as y,r as $,e as C}from"./index-mUrlue57.js";import{c as x,U as N}from"./index-CYGUludi.js";import"./index-CzGhZ9cz.js";import"./index-BlANYCHN.js";import{C as c,S as m,q as w,T as h,l as R,W as A,R as S,b as I}from"./W3MFrameProviderSingleton-eYQGtm7P.js";import"./index-a-a2MqTK.js";import"./index-CPCCdjXg.js";import"./index-CcHsPndE.js";import"./index-nibyPLVP.js";import"./index-CpGStcFm.js";import"./sha2-D3ryOfi3.js";import"./hmac-BMnSt9Ou.js";import"./NetworkUtil-XsBaDkTf.js";import"./index.es-CjcoN6we.js";import"./browser-ponyfill-CqiVi-O8.js";import"./browser-DoJWAFam.js";const T=y`
2
2
  button {
3
3
  width: 100%;
4
4
  display: flex;
@@ -1 +1 @@
1
- import{H as d,b as l,i as p,m as f,r as c}from"./signing-gNn6SJWz.js";import{e as r}from"./eth_getStorageAt-SbVMAQY-.js";import"./utils-h8VUSGPW.js";import"./index-Cu4ZjLNb.js";function u(e){if(e.startsWith("0x")||(e=`0x${e}`),e.startsWith("0x363d3d373d3d3d363d73"))return`0x${e.slice(22,62)}`;if(e.startsWith("0x36603057343d5230"))return`0x${e.slice(122,162)}`;if(e.startsWith("0x3d3d3d3d363d3d37363d73"))return`0x${e.slice(24,64)}`;if(e.startsWith("0x366000600037611000600036600073"))return`0x${e.slice(32,72)}`;if(e.startsWith("0x36600080376020600036600073"))return`0x${e.slice(28,68)}`;if(e.startsWith("0x365f5f375f5f365f73"))return`0x${e.slice(20,60)}`;if(e.length===48&&e.startsWith("0xef0100"))return`0x${e.slice(8,48)}`}const o="0x0000000000000000000000000000000000000000",x="0x0000000000000000000000000000000000000000000000000000000000000000";async function W(e){const[s,t]=await Promise.all([d(e),A(e)]),n=u(s);if(n)return{address:n,bytecode:await d(l({...e,address:n}))};t&&t!==o&&(e=l({...e,address:t}));const a=await Promise.all([h(e),S(e)]);for(const i of a)if(i&&p(i)&&i!==o){const m=await d({...e,address:i});return m==="0x"?{address:e.address,bytecode:s}:{address:i,bytecode:m}}return{address:e.address,bytecode:s}}async function A(e){const s=f({chain:e.chain,client:e.client});try{const t=await r(s,{address:e.address,position:"0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50"});return t.length>=40?`0x${t.slice(-40)}`:void 0}catch{return}}async function h(e){const s=f({chain:e.chain,client:e.client});try{const t=[r(s,{address:e.address,position:"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"}),r(s,{address:e.address,position:"0xbaab7dbf64751104133af04abc7d9979f0fda3b059a322a8333f533d3f32bf7f"}),r(s,{address:e.address,position:"0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3"})],a=(await Promise.all(t)).find(i=>i!==x);return a?`0x${a.slice(-40)}`:o}catch{return}}const g={inputs:[],name:"implementation",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"};async function S(e){try{return await c({contract:e,method:g})}catch{return}}export{W as resolveImplementation};
1
+ import{H as d,b as l,i as p,m as f,r as c}from"./signing-lyeTiv6v.js";import{e as r}from"./eth_getStorageAt-7xIaoYHZ.js";import"./utils-Cj9H0gW-.js";import"./index-a-a2MqTK.js";function u(e){if(e.startsWith("0x")||(e=`0x${e}`),e.startsWith("0x363d3d373d3d3d363d73"))return`0x${e.slice(22,62)}`;if(e.startsWith("0x36603057343d5230"))return`0x${e.slice(122,162)}`;if(e.startsWith("0x3d3d3d3d363d3d37363d73"))return`0x${e.slice(24,64)}`;if(e.startsWith("0x366000600037611000600036600073"))return`0x${e.slice(32,72)}`;if(e.startsWith("0x36600080376020600036600073"))return`0x${e.slice(28,68)}`;if(e.startsWith("0x365f5f375f5f365f73"))return`0x${e.slice(20,60)}`;if(e.length===48&&e.startsWith("0xef0100"))return`0x${e.slice(8,48)}`}const o="0x0000000000000000000000000000000000000000",x="0x0000000000000000000000000000000000000000000000000000000000000000";async function W(e){const[s,t]=await Promise.all([d(e),A(e)]),n=u(s);if(n)return{address:n,bytecode:await d(l({...e,address:n}))};t&&t!==o&&(e=l({...e,address:t}));const a=await Promise.all([h(e),S(e)]);for(const i of a)if(i&&p(i)&&i!==o){const m=await d({...e,address:i});return m==="0x"?{address:e.address,bytecode:s}:{address:i,bytecode:m}}return{address:e.address,bytecode:s}}async function A(e){const s=f({chain:e.chain,client:e.client});try{const t=await r(s,{address:e.address,position:"0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50"});return t.length>=40?`0x${t.slice(-40)}`:void 0}catch{return}}async function h(e){const s=f({chain:e.chain,client:e.client});try{const t=[r(s,{address:e.address,position:"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"}),r(s,{address:e.address,position:"0xbaab7dbf64751104133af04abc7d9979f0fda3b059a322a8333f533d3f32bf7f"}),r(s,{address:e.address,position:"0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3"})],a=(await Promise.all(t)).find(i=>i!==x);return a?`0x${a.slice(-40)}`:o}catch{return}}const g={inputs:[],name:"implementation",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"};async function S(e){try{return await c({contract:e,method:g})}catch{return}}export{W as resolveImplementation};
@@ -1,3 +1,3 @@
1
- import{B as c,C as i}from"./signing-gNn6SJWz.js";const D=s=>s,d=s=>s;class L extends c{constructor({body:e,cause:r,details:a,headers:n,status:u,url:l}){super("HTTP request failed.",{cause:r,details:a,metaMessages:[u&&`Status: ${u}`,`URL: ${d(l)}`,e&&`Request body: ${i(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=n,this.status=u,this.url=l}}class J extends c{constructor({body:e,cause:r,details:a,url:n}){super("WebSocket request failed.",{cause:r,details:a,metaMessages:[`URL: ${d(n)}`,e&&`Request body: ${i(e)}`].filter(Boolean),name:"WebSocketRequestError"})}}class W extends c{constructor({body:e,error:r,url:a}){super("RPC Request failed.",{cause:r,details:r.message,metaMessages:[`URL: ${d(a)}`,`Request body: ${i(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=r.code,this.data=r.data}}class H extends c{constructor({url:e}={}){super("The socket has been closed.",{metaMessages:[e&&`URL: ${d(e)}`].filter(Boolean),name:"SocketClosedError"})}}class F extends c{constructor({body:e,url:r}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${d(r)}`,`Request body: ${i(e)}`],name:"TimeoutError"})}}const A=-1;class t extends c{constructor(e,{code:r,docsPath:a,metaMessages:n,name:u,shortMessage:l}){super(l,{cause:e,docsPath:a,metaMessages:n||e?.metaMessages,name:u||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=u||e.name,this.code=e instanceof W?e.code:r??A}}class o extends t{constructor(e,r){super(e,r),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=r.data}}class b extends t{constructor(e){super(e,{code:b.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(b,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class p extends t{constructor(e){super(e,{code:p.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(p,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class h extends t{constructor(e,{method:r}={}){super(e,{code:h.code,name:"MethodNotFoundRpcError",shortMessage:`The method${r?` "${r}"`:""} does not exist / is not available.`})}}Object.defineProperty(h,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class m extends t{constructor(e){super(e,{code:m.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
1
+ import{B as c,C as i}from"./signing-lyeTiv6v.js";const D=s=>s,d=s=>s;class L extends c{constructor({body:e,cause:r,details:a,headers:n,status:u,url:l}){super("HTTP request failed.",{cause:r,details:a,metaMessages:[u&&`Status: ${u}`,`URL: ${d(l)}`,e&&`Request body: ${i(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=n,this.status=u,this.url=l}}class J extends c{constructor({body:e,cause:r,details:a,url:n}){super("WebSocket request failed.",{cause:r,details:a,metaMessages:[`URL: ${d(n)}`,e&&`Request body: ${i(e)}`].filter(Boolean),name:"WebSocketRequestError"})}}class W extends c{constructor({body:e,error:r,url:a}){super("RPC Request failed.",{cause:r,details:r.message,metaMessages:[`URL: ${d(a)}`,`Request body: ${i(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=r.code,this.data=r.data}}class H extends c{constructor({url:e}={}){super("The socket has been closed.",{metaMessages:[e&&`URL: ${d(e)}`].filter(Boolean),name:"SocketClosedError"})}}class F extends c{constructor({body:e,url:r}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${d(r)}`,`Request body: ${i(e)}`],name:"TimeoutError"})}}const A=-1;class t extends c{constructor(e,{code:r,docsPath:a,metaMessages:n,name:u,shortMessage:l}){super(l,{cause:e,docsPath:a,metaMessages:n||e?.metaMessages,name:u||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=u||e.name,this.code=e instanceof W?e.code:r??A}}class o extends t{constructor(e,r){super(e,r),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=r.data}}class b extends t{constructor(e){super(e,{code:b.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(b,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class p extends t{constructor(e){super(e,{code:p.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(p,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class h extends t{constructor(e,{method:r}={}){super(e,{code:h.code,name:"MethodNotFoundRpcError",shortMessage:`The method${r?` "${r}"`:""} does not exist / is not available.`})}}Object.defineProperty(h,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class m extends t{constructor(e){super(e,{code:m.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
2
2
  `)})}}Object.defineProperty(m,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class f extends t{constructor(e){super(e,{code:f.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(f,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class g extends t{constructor(e){super(e,{code:g.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
3
3
  `)})}}Object.defineProperty(g,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class v extends t{constructor(e){super(e,{code:v.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(v,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class R extends t{constructor(e){super(e,{code:R.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(R,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class w extends t{constructor(e){super(e,{code:w.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(w,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class P extends t{constructor(e,{method:r}={}){super(e,{code:P.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${r?` "${r}"`:""} is not supported.`})}}Object.defineProperty(P,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class y extends t{constructor(e){super(e,{code:y.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(y,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class E extends t{constructor(e){super(e,{code:E.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(E,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class j extends o{constructor(e){super(e,{code:j.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(j,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class x extends o{constructor(e){super(e,{code:x.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(x,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class M extends o{constructor(e,{method:r}={}){super(e,{code:M.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${r?` " ${r}"`:""}.`})}}Object.defineProperty(M,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class O extends o{constructor(e){super(e,{code:O.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(O,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class q extends o{constructor(e){super(e,{code:q.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(q,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class T extends o{constructor(e){super(e,{code:T.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(T,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class U extends o{constructor(e){super(e,{code:U.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(U,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class k extends o{constructor(e){super(e,{code:k.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(k,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class $ extends o{constructor(e){super(e,{code:$.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty($,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class C extends o{constructor(e){super(e,{code:C.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(C,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class S extends o{constructor(e){super(e,{code:S.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(S,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class I extends o{constructor(e){super(e,{code:I.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(I,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class N extends o{constructor(e){super(e,{code:N.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(N,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class z extends t{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}export{I as A,S as B,q as C,$ as D,L as H,f as I,E as J,y as L,h as M,b as P,W as R,T as S,F as T,j as U,J as W,H as a,w as b,N as c,g as d,m as e,p as f,d as g,P as h,O as i,o as j,v as k,R as l,t as m,x as n,C as o,z as p,k as q,U as r,M as s,D as t};
@@ -1 +1 @@
1
- import{H as Xt,c as St,a as xt,t as Qt,b as de,w as he,r as P,d as ge,e as we,f as pe,g as be}from"./index.es-cEGj7JU0.js";import"./index-Cu4ZjLNb.js";import"./index-B-vyBZw9.js";import"./index-DS2Lm9tG.js";import"./index-nibyPLVP.js";import"./index-CJdot1dH.js";import"./index.es-CkxUaFYS.js";import"./browser-ponyfill-BmgQyNz0.js";function ye(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const o=BigInt(32),s=BigInt(4294967295),c=Number(t>>o&s),f=Number(t&s),i=r?4:0,u=r?0:4;n.setUint32(e+i,c,r),n.setUint32(e+u,f,r)}function me(n,e,t){return n&e^~n&t}function xe(n,e,t){return n&e^n&t^e&t}class Ee extends Xt{constructor(e,t,r,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=St(this.buffer)}update(e){xt(this);const{view:t,buffer:r,blockLen:o}=this;e=Qt(e);const s=e.length;for(let c=0;c<s;){const f=Math.min(o-this.pos,s-c);if(f===o){const i=St(e);for(;o<=s-c;c+=o)this.process(i,c);continue}r.set(e.subarray(c,c+f),this.pos),this.pos+=f,c+=f,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){xt(this),de(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:o,isLE:s}=this;let{pos:c}=this;t[c++]=128,this.buffer.subarray(c).fill(0),this.padOffset>o-c&&(this.process(r,0),c=0);for(let h=c;h<o;h++)t[h]=0;ye(r,o-8,BigInt(this.length*8),s),this.process(r,0);const f=St(e),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=i/4,y=this.get();if(u>y.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)f.setUint32(4*h,y[h],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:o,finished:s,destroyed:c,pos:f}=this;return e.length=o,e.pos=f,e.finished=s,e.destroyed=c,o%t&&e.buffer.set(r),e}}const Be=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Q=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),J=new Uint32Array(64);class ve extends Ee{constructor(){super(64,32,8,!1),this.A=Q[0]|0,this.B=Q[1]|0,this.C=Q[2]|0,this.D=Q[3]|0,this.E=Q[4]|0,this.F=Q[5]|0,this.G=Q[6]|0,this.H=Q[7]|0}get(){const{A:e,B:t,C:r,D:o,E:s,F:c,G:f,H:i}=this;return[e,t,r,o,s,c,f,i]}set(e,t,r,o,s,c,f,i){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=c|0,this.G=f|0,this.H=i|0}process(e,t){for(let h=0;h<16;h++,t+=4)J[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const l=J[h-15],m=J[h-2],N=P(l,7)^P(l,18)^l>>>3,b=P(m,17)^P(m,19)^m>>>10;J[h]=b+J[h-7]+N+J[h-16]|0}let{A:r,B:o,C:s,D:c,E:f,F:i,G:u,H:y}=this;for(let h=0;h<64;h++){const l=P(f,6)^P(f,11)^P(f,25),m=y+l+me(f,i,u)+Be[h]+J[h]|0,b=(P(r,2)^P(r,13)^P(r,22))+xe(r,o,s)|0;y=u,u=i,i=f,f=c+m|0,c=s,s=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,c=c+this.D|0,f=f+this.E|0,i=i+this.F|0,u=u+this.G|0,y=y+this.H|0,this.set(r,o,s,c,f,i,u,y)}roundClean(){J.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Se=he(()=>new ve);const zt=BigInt(0),Jt=BigInt(1),Ae=BigInt(2);function it(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function bt(n){if(!it(n))throw new Error("Uint8Array expected")}function at(n,e){if(typeof e!="boolean")throw new Error(n+" boolean expected, got "+e)}const Ie=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function ut(n){bt(n);let e="";for(let t=0;t<n.length;t++)e+=Ie[n[t]];return e}function gt(n){const e=n.toString(16);return e.length&1?"0"+e:e}function Ct(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return n===""?zt:BigInt("0x"+n)}const D={_0:48,_9:57,A:65,F:70,a:97,f:102};function jt(n){if(n>=D._0&&n<=D._9)return n-D._0;if(n>=D.A&&n<=D.F)return n-(D.A-10);if(n>=D.a&&n<=D.f)return n-(D.a-10)}function wt(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let o=0,s=0;o<t;o++,s+=2){const c=jt(n.charCodeAt(s)),f=jt(n.charCodeAt(s+1));if(c===void 0||f===void 0){const i=n[s]+n[s+1];throw new Error('hex string expected, got non-hex character "'+i+'" at index '+s)}r[o]=c*16+f}return r}function rt(n){return Ct(ut(n))}function Zt(n){return bt(n),Ct(ut(Uint8Array.from(n).reverse()))}function lt(n,e){return wt(n.toString(16).padStart(e*2,"0"))}function Rt(n,e){return lt(n,e).reverse()}function K(n,e,t){let r;if(typeof e=="string")try{r=wt(e)}catch(s){throw new Error(n+" must be hex string or Uint8Array, cause: "+s)}else if(it(e))r=Uint8Array.from(e);else throw new Error(n+" must be hex string or Uint8Array");const o=r.length;if(typeof t=="number"&&o!==t)throw new Error(n+" of length "+t+" expected, got "+o);return r}function pt(...n){let e=0;for(let r=0;r<n.length;r++){const o=n[r];bt(o),e+=o.length}const t=new Uint8Array(e);for(let r=0,o=0;r<n.length;r++){const s=n[r];t.set(s,o),o+=s.length}return t}const At=n=>typeof n=="bigint"&&zt<=n;function Et(n,e,t){return At(n)&&At(e)&&At(t)&&e<=n&&n<t}function ot(n,e,t,r){if(!Et(e,t,r))throw new Error("expected valid "+n+": "+t+" <= n < "+r+", got "+e)}function te(n){let e;for(e=0;n>zt;n>>=Jt,e+=1);return e}const Mt=n=>(Ae<<BigInt(n-1))-Jt,It=n=>new Uint8Array(n),Yt=n=>Uint8Array.from(n);function ee(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=It(n),o=It(n),s=0;const c=()=>{r.fill(1),o.fill(0),s=0},f=(...h)=>t(o,r,...h),i=(h=It())=>{o=f(Yt([0]),h),r=f(),h.length!==0&&(o=f(Yt([1]),h),r=f())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const l=[];for(;h<e;){r=f();const m=r.slice();l.push(m),h+=r.length}return pt(...l)};return(h,l)=>{c(),i(h);let m;for(;!(m=l(u()));)i();return c(),m}}const Ne={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||it(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function yt(n,e,t={}){const r=(o,s,c)=>{const f=Ne[s];if(typeof f!="function")throw new Error("invalid validator function");const i=n[o];if(!(c&&i===void 0)&&!f(i,n))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+i)};for(const[o,s]of Object.entries(e))r(o,s,!1);for(const[o,s]of Object.entries(t))r(o,s,!0);return n}function Ht(n){const e=new WeakMap;return(t,...r)=>{const o=e.get(t);if(o!==void 0)return o;const s=n(t,...r);return e.set(t,s),s}}const qe=Object.freeze(Object.defineProperty({__proto__:null,aInRange:ot,abool:at,abytes:bt,bitLen:te,bitMask:Mt,bytesToHex:ut,bytesToNumberBE:rt,bytesToNumberLE:Zt,concatBytes:pt,createHmacDrbg:ee,ensureBytes:K,hexToBytes:wt,hexToNumber:Ct,inRange:Et,isBytes:it,memoized:Ht,numberToBytesBE:lt,numberToBytesLE:Rt,numberToHexUnpadded:gt,validateObject:yt},Symbol.toStringTag,{value:"Module"}));class ne extends Xt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ge(e);const r=Qt(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?e.create().update(r).digest():r);for(let c=0;c<s.length;c++)s[c]^=54;this.iHash.update(s),this.oHash=e.create();for(let c=0;c<s.length;c++)s[c]^=106;this.oHash.update(s),s.fill(0)}update(e){return xt(this),this.iHash.update(e),this}digestInto(e){xt(this),we(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:o,destroyed:s,blockLen:c,outputLen:f}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=c,e.outputLen=f,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const re=(n,e,t)=>new ne(n,e).update(t).digest();re.create=(n,e)=>new ne(n,e);const z=BigInt(0),_=BigInt(1),nt=BigInt(2),Oe=BigInt(3),Ut=BigInt(4),Ft=BigInt(5),Kt=BigInt(8);function V(n,e){const t=n%e;return t>=z?t:e+t}function Le(n,e,t){if(e<z)throw new Error("invalid exponent, negatives unsupported");if(t<=z)throw new Error("invalid modulus");if(t===_)return z;let r=_;for(;e>z;)e&_&&(r=r*n%t),n=n*n%t,e>>=_;return r}function Y(n,e,t){let r=n;for(;e-- >z;)r*=r,r%=t;return r}function _t(n,e){if(n===z)throw new Error("invert: expected non-zero number");if(e<=z)throw new Error("invert: expected positive modulus, got "+e);let t=V(n,e),r=e,o=z,s=_;for(;t!==z;){const f=r/t,i=r%t,u=o-s*f;r=t,t=i,o=s,s=u}if(r!==_)throw new Error("invert: does not exist");return V(o,e)}function He(n){const e=(n-_)/nt;let t,r,o;for(t=n-_,r=0;t%nt===z;t/=nt,r++);for(o=nt;o<n&&Le(o,e,n)!==n-_;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const c=(n+_)/Ut;return function(i,u){const y=i.pow(u,c);if(!i.eql(i.sqr(y),u))throw new Error("Cannot find square root");return y}}const s=(t+_)/nt;return function(f,i){if(f.pow(i,e)===f.neg(f.ONE))throw new Error("Cannot find square root");let u=r,y=f.pow(f.mul(f.ONE,o),t),h=f.pow(i,s),l=f.pow(i,t);for(;!f.eql(l,f.ONE);){if(f.eql(l,f.ZERO))return f.ZERO;let m=1;for(let b=f.sqr(l);m<u&&!f.eql(b,f.ONE);m++)b=f.sqr(b);const N=f.pow(y,_<<BigInt(u-m-1));y=f.sqr(N),h=f.mul(h,N),l=f.mul(l,y),u=m}return h}}function Ue(n){if(n%Ut===Oe){const e=(n+_)/Ut;return function(r,o){const s=r.pow(o,e);if(!r.eql(r.sqr(s),o))throw new Error("Cannot find square root");return s}}if(n%Kt===Ft){const e=(n-Ft)/Kt;return function(r,o){const s=r.mul(o,nt),c=r.pow(s,e),f=r.mul(o,c),i=r.mul(r.mul(f,nt),c),u=r.mul(f,r.sub(i,r.ONE));if(!r.eql(r.sqr(u),o))throw new Error("Cannot find square root");return u}}return He(n)}const _e=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Te(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=_e.reduce((r,o)=>(r[o]="function",r),e);return yt(n,t)}function ke(n,e,t){if(t<z)throw new Error("invalid exponent, negatives unsupported");if(t===z)return n.ONE;if(t===_)return e;let r=n.ONE,o=e;for(;t>z;)t&_&&(r=n.mul(r,o)),o=n.sqr(o),t>>=_;return r}function ze(n,e){const t=new Array(e.length),r=e.reduce((s,c,f)=>n.is0(c)?s:(t[f]=s,n.mul(s,c)),n.ONE),o=n.inv(r);return e.reduceRight((s,c,f)=>n.is0(c)?s:(t[f]=n.mul(s,t[f]),n.mul(s,c)),o),t}function oe(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function ie(n,e,t=!1,r={}){if(n<=z)throw new Error("invalid field: expected ORDER > 0, got "+n);const{nBitLength:o,nByteLength:s}=oe(n,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c;const f=Object.freeze({ORDER:n,isLE:t,BITS:o,BYTES:s,MASK:Mt(o),ZERO:z,ONE:_,create:i=>V(i,n),isValid:i=>{if(typeof i!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof i);return z<=i&&i<n},is0:i=>i===z,isOdd:i=>(i&_)===_,neg:i=>V(-i,n),eql:(i,u)=>i===u,sqr:i=>V(i*i,n),add:(i,u)=>V(i+u,n),sub:(i,u)=>V(i-u,n),mul:(i,u)=>V(i*u,n),pow:(i,u)=>ke(f,i,u),div:(i,u)=>V(i*_t(u,n),n),sqrN:i=>i*i,addN:(i,u)=>i+u,subN:(i,u)=>i-u,mulN:(i,u)=>i*u,inv:i=>_t(i,n),sqrt:r.sqrt||(i=>(c||(c=Ue(n)),c(f,i))),invertBatch:i=>ze(f,i),cmov:(i,u,y)=>y?u:i,toBytes:i=>t?Rt(i,s):lt(i,s),fromBytes:i=>{if(i.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+i.length);return t?Zt(i):rt(i)}});return Object.freeze(f)}function se(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function ce(n){const e=se(n);return e+Math.ceil(e/2)}function Ce(n,e,t=!1){const r=n.length,o=se(e),s=ce(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const c=t?Zt(n):rt(n),f=V(c,e-_)+_;return t?Rt(f,o):lt(f,o)}const Pt=BigInt(0),mt=BigInt(1);function Nt(n,e){const t=e.negate();return n?t:e}function fe(n,e){if(!Number.isSafeInteger(n)||n<=0||n>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+n)}function qt(n,e){fe(n,e);const t=Math.ceil(e/n)+1,r=2**(n-1);return{windows:t,windowSize:r}}function Ze(n,e){if(!Array.isArray(n))throw new Error("array expected");n.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})}function Re(n,e){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}const Ot=new WeakMap,ae=new WeakMap;function Lt(n){return ae.get(n)||1}function Me(n,e){return{constTimeNegate:Nt,hasPrecomputes(t){return Lt(t)!==1},unsafeLadder(t,r,o=n.ZERO){let s=t;for(;r>Pt;)r&mt&&(o=o.add(s)),s=s.double(),r>>=mt;return o},precomputeWindow(t,r){const{windows:o,windowSize:s}=qt(r,e),c=[];let f=t,i=f;for(let u=0;u<o;u++){i=f,c.push(i);for(let y=1;y<s;y++)i=i.add(f),c.push(i);f=i.double()}return c},wNAF(t,r,o){const{windows:s,windowSize:c}=qt(t,e);let f=n.ZERO,i=n.BASE;const u=BigInt(2**t-1),y=2**t,h=BigInt(t);for(let l=0;l<s;l++){const m=l*c;let N=Number(o&u);o>>=h,N>c&&(N-=y,o+=mt);const b=m,a=m+Math.abs(N)-1,g=l%2!==0,x=N<0;N===0?i=i.add(Nt(g,r[b])):f=f.add(Nt(x,r[a]))}return{p:f,f:i}},wNAFUnsafe(t,r,o,s=n.ZERO){const{windows:c,windowSize:f}=qt(t,e),i=BigInt(2**t-1),u=2**t,y=BigInt(t);for(let h=0;h<c;h++){const l=h*f;if(o===Pt)break;let m=Number(o&i);if(o>>=y,m>f&&(m-=u,o+=mt),m===0)continue;let N=r[l+Math.abs(m)-1];m<0&&(N=N.negate()),s=s.add(N)}return s},getPrecomputes(t,r,o){let s=Ot.get(r);return s||(s=this.precomputeWindow(r,t),t!==1&&Ot.set(r,o(s))),s},wNAFCached(t,r,o){const s=Lt(t);return this.wNAF(s,this.getPrecomputes(s,t,o),r)},wNAFCachedUnsafe(t,r,o,s){const c=Lt(t);return c===1?this.unsafeLadder(t,r,s):this.wNAFUnsafe(c,this.getPrecomputes(c,t,o),r,s)},setWindowSize(t,r){fe(r,e),ae.set(t,r),Ot.delete(t)}}}function Ve(n,e,t,r){if(Ze(t,n),Re(r,e),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const o=n.ZERO,s=te(BigInt(t.length)),c=s>12?s-3:s>4?s-2:s?2:1,f=(1<<c)-1,i=new Array(f+1).fill(o),u=Math.floor((e.BITS-1)/c)*c;let y=o;for(let h=u;h>=0;h-=c){i.fill(o);for(let m=0;m<r.length;m++){const N=r[m],b=Number(N>>BigInt(h)&BigInt(f));i[b]=i[b].add(t[m])}let l=o;for(let m=i.length-1,N=o;m>0;m--)N=N.add(i[m]),l=l.add(N);if(y=y.add(l),h!==0)for(let m=0;m<c;m++)y=y.double()}return y}function ue(n){return Te(n.Fp),yt(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...oe(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}function Gt(n){n.lowS!==void 0&&at("lowS",n.lowS),n.prehash!==void 0&&at("prehash",n.prehash)}function je(n){const e=ue(n);yt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:o}=e;if(t){if(!r.eql(o,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Ye,hexToBytes:Fe}=qe;class Ke extends Error{constructor(e=""){super(e)}}const $={Err:Ke,_tlv:{encode:(n,e)=>{const{Err:t}=$;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const r=e.length/2,o=gt(r);if(o.length/2&128)throw new t("tlv.encode: long form length too big");const s=r>127?gt(o.length/2|128):"";return gt(n)+s+o+e},decode(n,e){const{Err:t}=$;let r=0;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[r++]!==n)throw new t("tlv.decode: wrong tlv");const o=e[r++],s=!!(o&128);let c=0;if(!s)c=o;else{const i=o&127;if(!i)throw new t("tlv.decode(long): indefinite length not supported");if(i>4)throw new t("tlv.decode(long): byte length is too big");const u=e.subarray(r,r+i);if(u.length!==i)throw new t("tlv.decode: length bytes not complete");if(u[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const y of u)c=c<<8|y;if(r+=i,c<128)throw new t("tlv.decode(long): not minimal encoding")}const f=e.subarray(r,r+c);if(f.length!==c)throw new t("tlv.decode: wrong value length");return{v:f,l:e.subarray(r+c)}}},_int:{encode(n){const{Err:e}=$;if(n<W)throw new e("integer: negative integers are not allowed");let t=gt(n);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(n){const{Err:e}=$;if(n[0]&128)throw new e("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ye(n)}},toSig(n){const{Err:e,_int:t,_tlv:r}=$,o=typeof n=="string"?Fe(n):n;bt(o);const{v:s,l:c}=r.decode(48,o);if(c.length)throw new e("invalid signature: left bytes after parsing");const{v:f,l:i}=r.decode(2,s),{v:u,l:y}=r.decode(2,i);if(y.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(f),s:t.decode(u)}},hexFromSig(n){const{_tlv:e,_int:t}=$,r=e.encode(2,t.encode(n.r)),o=e.encode(2,t.encode(n.s)),s=r+o;return e.encode(48,s)}},W=BigInt(0),k=BigInt(1);BigInt(2);const Dt=BigInt(3);BigInt(4);function Pe(n){const e=je(n),{Fp:t}=e,r=ie(e.n,e.nBitLength),o=e.toBytes||((b,a,g)=>{const x=a.toAffine();return pt(Uint8Array.from([4]),t.toBytes(x.x),t.toBytes(x.y))}),s=e.fromBytes||(b=>{const a=b.subarray(1),g=t.fromBytes(a.subarray(0,t.BYTES)),x=t.fromBytes(a.subarray(t.BYTES,2*t.BYTES));return{x:g,y:x}});function c(b){const{a,b:g}=e,x=t.sqr(b),E=t.mul(x,b);return t.add(t.add(E,t.mul(b,a)),g)}if(!t.eql(t.sqr(e.Gy),c(e.Gx)))throw new Error("bad generator point: equation left != right");function f(b){return Et(b,k,e.n)}function i(b){const{allowedPrivateKeyLengths:a,nByteLength:g,wrapPrivateKey:x,n:E}=e;if(a&&typeof b!="bigint"){if(it(b)&&(b=ut(b)),typeof b!="string"||!a.includes(b.length))throw new Error("invalid private key");b=b.padStart(g*2,"0")}let q;try{q=typeof b=="bigint"?b:rt(K("private key",b,g))}catch{throw new Error("invalid private key, expected hex or "+g+" bytes, got "+typeof b)}return x&&(q=V(q,E)),ot("private key",q,k,E),q}function u(b){if(!(b instanceof l))throw new Error("ProjectivePoint expected")}const y=Ht((b,a)=>{const{px:g,py:x,pz:E}=b;if(t.eql(E,t.ONE))return{x:g,y:x};const q=b.is0();a==null&&(a=q?t.ONE:t.inv(E));const L=t.mul(g,a),I=t.mul(x,a),B=t.mul(E,a);if(q)return{x:t.ZERO,y:t.ZERO};if(!t.eql(B,t.ONE))throw new Error("invZ was invalid");return{x:L,y:I}}),h=Ht(b=>{if(b.is0()){if(e.allowInfinityPoint&&!t.is0(b.py))return;throw new Error("bad point: ZERO")}const{x:a,y:g}=b.toAffine();if(!t.isValid(a)||!t.isValid(g))throw new Error("bad point: x or y not FE");const x=t.sqr(g),E=c(a);if(!t.eql(x,E))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class l{constructor(a,g,x){if(this.px=a,this.py=g,this.pz=x,a==null||!t.isValid(a))throw new Error("x required");if(g==null||!t.isValid(g))throw new Error("y required");if(x==null||!t.isValid(x))throw new Error("z required");Object.freeze(this)}static fromAffine(a){const{x:g,y:x}=a||{};if(!a||!t.isValid(g)||!t.isValid(x))throw new Error("invalid affine point");if(a instanceof l)throw new Error("projective point not allowed");const E=q=>t.eql(q,t.ZERO);return E(g)&&E(x)?l.ZERO:new l(g,x,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(a){const g=t.invertBatch(a.map(x=>x.pz));return a.map((x,E)=>x.toAffine(g[E])).map(l.fromAffine)}static fromHex(a){const g=l.fromAffine(s(K("pointHex",a)));return g.assertValidity(),g}static fromPrivateKey(a){return l.BASE.multiply(i(a))}static msm(a,g){return Ve(l,r,a,g)}_setWindowSize(a){N.setWindowSize(this,a)}assertValidity(){h(this)}hasEvenY(){const{y:a}=this.toAffine();if(t.isOdd)return!t.isOdd(a);throw new Error("Field doesn't support isOdd")}equals(a){u(a);const{px:g,py:x,pz:E}=this,{px:q,py:L,pz:I}=a,B=t.eql(t.mul(g,I),t.mul(q,E)),A=t.eql(t.mul(x,I),t.mul(L,E));return B&&A}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){const{a,b:g}=e,x=t.mul(g,Dt),{px:E,py:q,pz:L}=this;let I=t.ZERO,B=t.ZERO,A=t.ZERO,v=t.mul(E,E),C=t.mul(q,q),U=t.mul(L,L),H=t.mul(E,q);return H=t.add(H,H),A=t.mul(E,L),A=t.add(A,A),I=t.mul(a,A),B=t.mul(x,U),B=t.add(I,B),I=t.sub(C,B),B=t.add(C,B),B=t.mul(I,B),I=t.mul(H,I),A=t.mul(x,A),U=t.mul(a,U),H=t.sub(v,U),H=t.mul(a,H),H=t.add(H,A),A=t.add(v,v),v=t.add(A,v),v=t.add(v,U),v=t.mul(v,H),B=t.add(B,v),U=t.mul(q,L),U=t.add(U,U),v=t.mul(U,H),I=t.sub(I,v),A=t.mul(U,C),A=t.add(A,A),A=t.add(A,A),new l(I,B,A)}add(a){u(a);const{px:g,py:x,pz:E}=this,{px:q,py:L,pz:I}=a;let B=t.ZERO,A=t.ZERO,v=t.ZERO;const C=e.a,U=t.mul(e.b,Dt);let H=t.mul(g,q),j=t.mul(x,L),d=t.mul(E,I),w=t.add(g,x),p=t.add(q,L);w=t.mul(w,p),p=t.add(H,j),w=t.sub(w,p),p=t.add(g,E);let S=t.add(q,I);return p=t.mul(p,S),S=t.add(H,d),p=t.sub(p,S),S=t.add(x,E),B=t.add(L,I),S=t.mul(S,B),B=t.add(j,d),S=t.sub(S,B),v=t.mul(C,p),B=t.mul(U,d),v=t.add(B,v),B=t.sub(j,v),v=t.add(j,v),A=t.mul(B,v),j=t.add(H,H),j=t.add(j,H),d=t.mul(C,d),p=t.mul(U,p),j=t.add(j,d),d=t.sub(H,d),d=t.mul(C,d),p=t.add(p,d),H=t.mul(j,p),A=t.add(A,H),H=t.mul(S,p),B=t.mul(w,B),B=t.sub(B,H),H=t.mul(w,j),v=t.mul(S,v),v=t.add(v,H),new l(B,A,v)}subtract(a){return this.add(a.negate())}is0(){return this.equals(l.ZERO)}wNAF(a){return N.wNAFCached(this,a,l.normalizeZ)}multiplyUnsafe(a){const{endo:g,n:x}=e;ot("scalar",a,W,x);const E=l.ZERO;if(a===W)return E;if(this.is0()||a===k)return this;if(!g||N.hasPrecomputes(this))return N.wNAFCachedUnsafe(this,a,l.normalizeZ);let{k1neg:q,k1:L,k2neg:I,k2:B}=g.splitScalar(a),A=E,v=E,C=this;for(;L>W||B>W;)L&k&&(A=A.add(C)),B&k&&(v=v.add(C)),C=C.double(),L>>=k,B>>=k;return q&&(A=A.negate()),I&&(v=v.negate()),v=new l(t.mul(v.px,g.beta),v.py,v.pz),A.add(v)}multiply(a){const{endo:g,n:x}=e;ot("scalar",a,k,x);let E,q;if(g){const{k1neg:L,k1:I,k2neg:B,k2:A}=g.splitScalar(a);let{p:v,f:C}=this.wNAF(I),{p:U,f:H}=this.wNAF(A);v=N.constTimeNegate(L,v),U=N.constTimeNegate(B,U),U=new l(t.mul(U.px,g.beta),U.py,U.pz),E=v.add(U),q=C.add(H)}else{const{p:L,f:I}=this.wNAF(a);E=L,q=I}return l.normalizeZ([E,q])[0]}multiplyAndAddUnsafe(a,g,x){const E=l.BASE,q=(I,B)=>B===W||B===k||!I.equals(E)?I.multiplyUnsafe(B):I.multiply(B),L=q(this,g).add(q(a,x));return L.is0()?void 0:L}toAffine(a){return y(this,a)}isTorsionFree(){const{h:a,isTorsionFree:g}=e;if(a===k)return!0;if(g)return g(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:a,clearCofactor:g}=e;return a===k?this:g?g(l,this):this.multiplyUnsafe(e.h)}toRawBytes(a=!0){return at("isCompressed",a),this.assertValidity(),o(l,this,a)}toHex(a=!0){return at("isCompressed",a),ut(this.toRawBytes(a))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);const m=e.nBitLength,N=Me(l,e.endo?Math.ceil(m/2):m);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:i,weierstrassEquation:c,isWithinCurveOrder:f}}function Ge(n){const e=ue(n);return yt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function De(n){const e=Ge(n),{Fp:t,n:r}=e,o=t.BYTES+1,s=2*t.BYTES+1;function c(d){return V(d,r)}function f(d){return _t(d,r)}const{ProjectivePoint:i,normPrivateKeyToScalar:u,weierstrassEquation:y,isWithinCurveOrder:h}=Pe({...e,toBytes(d,w,p){const S=w.toAffine(),O=t.toBytes(S.x),T=pt;return at("isCompressed",p),p?T(Uint8Array.from([w.hasEvenY()?2:3]),O):T(Uint8Array.from([4]),O,t.toBytes(S.y))},fromBytes(d){const w=d.length,p=d[0],S=d.subarray(1);if(w===o&&(p===2||p===3)){const O=rt(S);if(!Et(O,k,t.ORDER))throw new Error("Point is not on curve");const T=y(O);let R;try{R=t.sqrt(T)}catch(F){const M=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+M)}const Z=(R&k)===k;return(p&1)===1!==Z&&(R=t.neg(R)),{x:O,y:R}}else if(w===s&&p===4){const O=t.fromBytes(S.subarray(0,t.BYTES)),T=t.fromBytes(S.subarray(t.BYTES,2*t.BYTES));return{x:O,y:T}}else{const O=o,T=s;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+T+", got "+w)}}}),l=d=>ut(lt(d,e.nByteLength));function m(d){const w=r>>k;return d>w}function N(d){return m(d)?c(-d):d}const b=(d,w,p)=>rt(d.slice(w,p));class a{constructor(w,p,S){this.r=w,this.s=p,this.recovery=S,this.assertValidity()}static fromCompact(w){const p=e.nByteLength;return w=K("compactSignature",w,p*2),new a(b(w,0,p),b(w,p,2*p))}static fromDER(w){const{r:p,s:S}=$.toSig(K("DER",w));return new a(p,S)}assertValidity(){ot("r",this.r,k,r),ot("s",this.s,k,r)}addRecoveryBit(w){return new a(this.r,this.s,w)}recoverPublicKey(w){const{r:p,s:S,recovery:O}=this,T=I(K("msgHash",w));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const R=O===2||O===3?p+e.n:p;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const Z=(O&1)===0?"02":"03",G=i.fromHex(Z+l(R)),F=f(R),M=c(-T*F),st=c(S*F),X=i.BASE.multiplyAndAddUnsafe(G,M,st);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new a(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return wt(this.toDERHex())}toDERHex(){return $.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return wt(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}const g={isValidPrivateKey(d){try{return u(d),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const d=ce(e.n);return Ce(e.randomBytes(d),e.n)},precompute(d=8,w=i.BASE){return w._setWindowSize(d),w.multiply(BigInt(3)),w}};function x(d,w=!0){return i.fromPrivateKey(d).toRawBytes(w)}function E(d){const w=it(d),p=typeof d=="string",S=(w||p)&&d.length;return w?S===o||S===s:p?S===2*o||S===2*s:d instanceof i}function q(d,w,p=!0){if(E(d))throw new Error("first arg must be private key");if(!E(w))throw new Error("second arg must be public key");return i.fromHex(w).multiply(u(d)).toRawBytes(p)}const L=e.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");const w=rt(d),p=d.length*8-e.nBitLength;return p>0?w>>BigInt(p):w},I=e.bits2int_modN||function(d){return c(L(d))},B=Mt(e.nBitLength);function A(d){return ot("num < 2^"+e.nBitLength,d,W,B),lt(d,e.nByteLength)}function v(d,w,p=C){if(["recovered","canonical"].some(tt=>tt in p))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:O}=e;let{lowS:T,prehash:R,extraEntropy:Z}=p;T==null&&(T=!0),d=K("msgHash",d),Gt(p),R&&(d=K("prehashed msgHash",S(d)));const G=I(d),F=u(w),M=[A(F),A(G)];if(Z!=null&&Z!==!1){const tt=Z===!0?O(t.BYTES):Z;M.push(K("extraEntropy",tt))}const st=pt(...M),X=G;function Bt(tt){const ct=L(tt);if(!h(ct))return;const vt=f(ct),dt=i.BASE.multiply(ct).toAffine(),et=c(dt.x);if(et===W)return;const ht=c(vt*c(X+et*F));if(ht===W)return;let ft=(dt.x===et?0:2)|Number(dt.y&k),Vt=ht;return T&&m(ht)&&(Vt=N(ht),ft^=1),new a(et,Vt,ft)}return{seed:st,k2sig:Bt}}const C={lowS:e.lowS,prehash:!1},U={lowS:e.lowS,prehash:!1};function H(d,w,p=C){const{seed:S,k2sig:O}=v(d,w,p),T=e;return ee(T.hash.outputLen,T.nByteLength,T.hmac)(S,O)}i.BASE._setWindowSize(8);function j(d,w,p,S=U){const O=d;w=K("msgHash",w),p=K("publicKey",p);const{lowS:T,prehash:R,format:Z}=S;if(Gt(S),"strict"in S)throw new Error("options.strict was renamed to lowS");if(Z!==void 0&&Z!=="compact"&&Z!=="der")throw new Error("format must be compact or der");const G=typeof O=="string"||it(O),F=!G&&!Z&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!G&&!F)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let M,st;try{if(F&&(M=new a(O.r,O.s)),G){try{Z!=="compact"&&(M=a.fromDER(O))}catch(ft){if(!(ft instanceof $.Err))throw ft}!M&&Z!=="der"&&(M=a.fromCompact(O))}st=i.fromHex(p)}catch{return!1}if(!M||T&&M.hasHighS())return!1;R&&(w=e.hash(w));const{r:X,s:Bt}=M,tt=I(w),ct=f(Bt),vt=c(tt*ct),dt=c(X*ct),et=i.BASE.multiplyAndAddUnsafe(st,vt,dt)?.toAffine();return et?c(et.x)===X:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:q,sign:H,verify:j,ProjectivePoint:i,Signature:a,utils:g}}function $e(n){return{hash:n,hmac:(e,...t)=>re(n,e,be(...t)),randomBytes:pe}}function We(n,e){const t=r=>De({...n,...$e(r)});return{...t(e),create:t}}const le=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),$t=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Xe=BigInt(1),Tt=BigInt(2),Wt=(n,e)=>(n+e/Tt)/e;function Qe(n){const e=le,t=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),c=BigInt(23),f=BigInt(44),i=BigInt(88),u=n*n*n%e,y=u*u*n%e,h=Y(y,t,e)*y%e,l=Y(h,t,e)*y%e,m=Y(l,Tt,e)*u%e,N=Y(m,o,e)*m%e,b=Y(N,s,e)*N%e,a=Y(b,f,e)*b%e,g=Y(a,i,e)*a%e,x=Y(g,f,e)*b%e,E=Y(x,t,e)*y%e,q=Y(E,c,e)*N%e,L=Y(q,r,e)*u%e,I=Y(L,Tt,e);if(!kt.eql(kt.sqr(I),n))throw new Error("Cannot find square root");return I}const kt=ie(le,void 0,void 0,{sqrt:Qe}),Je=We({a:BigInt(0),b:BigInt(7),Fp:kt,n:$t,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=$t,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Xe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,c=BigInt("0x100000000000000000000000000000000"),f=Wt(s*n,e),i=Wt(-r*n,e);let u=V(n-f*t-i*o,e),y=V(-f*r-i*s,e);const h=u>c,l=y>c;if(h&&(u=e-u),l&&(y=e-y),u>c||y>c)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:h,k1:u,k2neg:l,k2:y}}}},Se);BigInt(0);Je.ProjectivePoint;export{Je as secp256k1};
1
+ import{H as Xt,c as St,a as xt,t as Qt,b as de,w as he,r as P,d as ge,e as we,f as pe,g as be}from"./index.es-B6W15sA5.js";import"./index-a-a2MqTK.js";import"./index-CPCCdjXg.js";import"./index-CcHsPndE.js";import"./index-nibyPLVP.js";import"./index-CJdot1dH.js";import"./index.es-CjcoN6we.js";import"./browser-ponyfill-CqiVi-O8.js";function ye(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const o=BigInt(32),s=BigInt(4294967295),c=Number(t>>o&s),f=Number(t&s),i=r?4:0,u=r?0:4;n.setUint32(e+i,c,r),n.setUint32(e+u,f,r)}function me(n,e,t){return n&e^~n&t}function xe(n,e,t){return n&e^n&t^e&t}class Ee extends Xt{constructor(e,t,r,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=St(this.buffer)}update(e){xt(this);const{view:t,buffer:r,blockLen:o}=this;e=Qt(e);const s=e.length;for(let c=0;c<s;){const f=Math.min(o-this.pos,s-c);if(f===o){const i=St(e);for(;o<=s-c;c+=o)this.process(i,c);continue}r.set(e.subarray(c,c+f),this.pos),this.pos+=f,c+=f,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){xt(this),de(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:o,isLE:s}=this;let{pos:c}=this;t[c++]=128,this.buffer.subarray(c).fill(0),this.padOffset>o-c&&(this.process(r,0),c=0);for(let h=c;h<o;h++)t[h]=0;ye(r,o-8,BigInt(this.length*8),s),this.process(r,0);const f=St(e),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=i/4,y=this.get();if(u>y.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)f.setUint32(4*h,y[h],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:o,finished:s,destroyed:c,pos:f}=this;return e.length=o,e.pos=f,e.finished=s,e.destroyed=c,o%t&&e.buffer.set(r),e}}const Be=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Q=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),J=new Uint32Array(64);class ve extends Ee{constructor(){super(64,32,8,!1),this.A=Q[0]|0,this.B=Q[1]|0,this.C=Q[2]|0,this.D=Q[3]|0,this.E=Q[4]|0,this.F=Q[5]|0,this.G=Q[6]|0,this.H=Q[7]|0}get(){const{A:e,B:t,C:r,D:o,E:s,F:c,G:f,H:i}=this;return[e,t,r,o,s,c,f,i]}set(e,t,r,o,s,c,f,i){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=c|0,this.G=f|0,this.H=i|0}process(e,t){for(let h=0;h<16;h++,t+=4)J[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const l=J[h-15],m=J[h-2],N=P(l,7)^P(l,18)^l>>>3,b=P(m,17)^P(m,19)^m>>>10;J[h]=b+J[h-7]+N+J[h-16]|0}let{A:r,B:o,C:s,D:c,E:f,F:i,G:u,H:y}=this;for(let h=0;h<64;h++){const l=P(f,6)^P(f,11)^P(f,25),m=y+l+me(f,i,u)+Be[h]+J[h]|0,b=(P(r,2)^P(r,13)^P(r,22))+xe(r,o,s)|0;y=u,u=i,i=f,f=c+m|0,c=s,s=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,c=c+this.D|0,f=f+this.E|0,i=i+this.F|0,u=u+this.G|0,y=y+this.H|0,this.set(r,o,s,c,f,i,u,y)}roundClean(){J.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Se=he(()=>new ve);const zt=BigInt(0),Jt=BigInt(1),Ae=BigInt(2);function it(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function bt(n){if(!it(n))throw new Error("Uint8Array expected")}function at(n,e){if(typeof e!="boolean")throw new Error(n+" boolean expected, got "+e)}const Ie=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function ut(n){bt(n);let e="";for(let t=0;t<n.length;t++)e+=Ie[n[t]];return e}function gt(n){const e=n.toString(16);return e.length&1?"0"+e:e}function Ct(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return n===""?zt:BigInt("0x"+n)}const D={_0:48,_9:57,A:65,F:70,a:97,f:102};function jt(n){if(n>=D._0&&n<=D._9)return n-D._0;if(n>=D.A&&n<=D.F)return n-(D.A-10);if(n>=D.a&&n<=D.f)return n-(D.a-10)}function wt(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let o=0,s=0;o<t;o++,s+=2){const c=jt(n.charCodeAt(s)),f=jt(n.charCodeAt(s+1));if(c===void 0||f===void 0){const i=n[s]+n[s+1];throw new Error('hex string expected, got non-hex character "'+i+'" at index '+s)}r[o]=c*16+f}return r}function rt(n){return Ct(ut(n))}function Zt(n){return bt(n),Ct(ut(Uint8Array.from(n).reverse()))}function lt(n,e){return wt(n.toString(16).padStart(e*2,"0"))}function Rt(n,e){return lt(n,e).reverse()}function K(n,e,t){let r;if(typeof e=="string")try{r=wt(e)}catch(s){throw new Error(n+" must be hex string or Uint8Array, cause: "+s)}else if(it(e))r=Uint8Array.from(e);else throw new Error(n+" must be hex string or Uint8Array");const o=r.length;if(typeof t=="number"&&o!==t)throw new Error(n+" of length "+t+" expected, got "+o);return r}function pt(...n){let e=0;for(let r=0;r<n.length;r++){const o=n[r];bt(o),e+=o.length}const t=new Uint8Array(e);for(let r=0,o=0;r<n.length;r++){const s=n[r];t.set(s,o),o+=s.length}return t}const At=n=>typeof n=="bigint"&&zt<=n;function Et(n,e,t){return At(n)&&At(e)&&At(t)&&e<=n&&n<t}function ot(n,e,t,r){if(!Et(e,t,r))throw new Error("expected valid "+n+": "+t+" <= n < "+r+", got "+e)}function te(n){let e;for(e=0;n>zt;n>>=Jt,e+=1);return e}const Mt=n=>(Ae<<BigInt(n-1))-Jt,It=n=>new Uint8Array(n),Yt=n=>Uint8Array.from(n);function ee(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=It(n),o=It(n),s=0;const c=()=>{r.fill(1),o.fill(0),s=0},f=(...h)=>t(o,r,...h),i=(h=It())=>{o=f(Yt([0]),h),r=f(),h.length!==0&&(o=f(Yt([1]),h),r=f())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const l=[];for(;h<e;){r=f();const m=r.slice();l.push(m),h+=r.length}return pt(...l)};return(h,l)=>{c(),i(h);let m;for(;!(m=l(u()));)i();return c(),m}}const Ne={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||it(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function yt(n,e,t={}){const r=(o,s,c)=>{const f=Ne[s];if(typeof f!="function")throw new Error("invalid validator function");const i=n[o];if(!(c&&i===void 0)&&!f(i,n))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+i)};for(const[o,s]of Object.entries(e))r(o,s,!1);for(const[o,s]of Object.entries(t))r(o,s,!0);return n}function Ht(n){const e=new WeakMap;return(t,...r)=>{const o=e.get(t);if(o!==void 0)return o;const s=n(t,...r);return e.set(t,s),s}}const qe=Object.freeze(Object.defineProperty({__proto__:null,aInRange:ot,abool:at,abytes:bt,bitLen:te,bitMask:Mt,bytesToHex:ut,bytesToNumberBE:rt,bytesToNumberLE:Zt,concatBytes:pt,createHmacDrbg:ee,ensureBytes:K,hexToBytes:wt,hexToNumber:Ct,inRange:Et,isBytes:it,memoized:Ht,numberToBytesBE:lt,numberToBytesLE:Rt,numberToHexUnpadded:gt,validateObject:yt},Symbol.toStringTag,{value:"Module"}));class ne extends Xt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ge(e);const r=Qt(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?e.create().update(r).digest():r);for(let c=0;c<s.length;c++)s[c]^=54;this.iHash.update(s),this.oHash=e.create();for(let c=0;c<s.length;c++)s[c]^=106;this.oHash.update(s),s.fill(0)}update(e){return xt(this),this.iHash.update(e),this}digestInto(e){xt(this),we(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:o,destroyed:s,blockLen:c,outputLen:f}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=c,e.outputLen=f,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const re=(n,e,t)=>new ne(n,e).update(t).digest();re.create=(n,e)=>new ne(n,e);const z=BigInt(0),_=BigInt(1),nt=BigInt(2),Oe=BigInt(3),Ut=BigInt(4),Ft=BigInt(5),Kt=BigInt(8);function V(n,e){const t=n%e;return t>=z?t:e+t}function Le(n,e,t){if(e<z)throw new Error("invalid exponent, negatives unsupported");if(t<=z)throw new Error("invalid modulus");if(t===_)return z;let r=_;for(;e>z;)e&_&&(r=r*n%t),n=n*n%t,e>>=_;return r}function Y(n,e,t){let r=n;for(;e-- >z;)r*=r,r%=t;return r}function _t(n,e){if(n===z)throw new Error("invert: expected non-zero number");if(e<=z)throw new Error("invert: expected positive modulus, got "+e);let t=V(n,e),r=e,o=z,s=_;for(;t!==z;){const f=r/t,i=r%t,u=o-s*f;r=t,t=i,o=s,s=u}if(r!==_)throw new Error("invert: does not exist");return V(o,e)}function He(n){const e=(n-_)/nt;let t,r,o;for(t=n-_,r=0;t%nt===z;t/=nt,r++);for(o=nt;o<n&&Le(o,e,n)!==n-_;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const c=(n+_)/Ut;return function(i,u){const y=i.pow(u,c);if(!i.eql(i.sqr(y),u))throw new Error("Cannot find square root");return y}}const s=(t+_)/nt;return function(f,i){if(f.pow(i,e)===f.neg(f.ONE))throw new Error("Cannot find square root");let u=r,y=f.pow(f.mul(f.ONE,o),t),h=f.pow(i,s),l=f.pow(i,t);for(;!f.eql(l,f.ONE);){if(f.eql(l,f.ZERO))return f.ZERO;let m=1;for(let b=f.sqr(l);m<u&&!f.eql(b,f.ONE);m++)b=f.sqr(b);const N=f.pow(y,_<<BigInt(u-m-1));y=f.sqr(N),h=f.mul(h,N),l=f.mul(l,y),u=m}return h}}function Ue(n){if(n%Ut===Oe){const e=(n+_)/Ut;return function(r,o){const s=r.pow(o,e);if(!r.eql(r.sqr(s),o))throw new Error("Cannot find square root");return s}}if(n%Kt===Ft){const e=(n-Ft)/Kt;return function(r,o){const s=r.mul(o,nt),c=r.pow(s,e),f=r.mul(o,c),i=r.mul(r.mul(f,nt),c),u=r.mul(f,r.sub(i,r.ONE));if(!r.eql(r.sqr(u),o))throw new Error("Cannot find square root");return u}}return He(n)}const _e=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Te(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=_e.reduce((r,o)=>(r[o]="function",r),e);return yt(n,t)}function ke(n,e,t){if(t<z)throw new Error("invalid exponent, negatives unsupported");if(t===z)return n.ONE;if(t===_)return e;let r=n.ONE,o=e;for(;t>z;)t&_&&(r=n.mul(r,o)),o=n.sqr(o),t>>=_;return r}function ze(n,e){const t=new Array(e.length),r=e.reduce((s,c,f)=>n.is0(c)?s:(t[f]=s,n.mul(s,c)),n.ONE),o=n.inv(r);return e.reduceRight((s,c,f)=>n.is0(c)?s:(t[f]=n.mul(s,t[f]),n.mul(s,c)),o),t}function oe(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function ie(n,e,t=!1,r={}){if(n<=z)throw new Error("invalid field: expected ORDER > 0, got "+n);const{nBitLength:o,nByteLength:s}=oe(n,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c;const f=Object.freeze({ORDER:n,isLE:t,BITS:o,BYTES:s,MASK:Mt(o),ZERO:z,ONE:_,create:i=>V(i,n),isValid:i=>{if(typeof i!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof i);return z<=i&&i<n},is0:i=>i===z,isOdd:i=>(i&_)===_,neg:i=>V(-i,n),eql:(i,u)=>i===u,sqr:i=>V(i*i,n),add:(i,u)=>V(i+u,n),sub:(i,u)=>V(i-u,n),mul:(i,u)=>V(i*u,n),pow:(i,u)=>ke(f,i,u),div:(i,u)=>V(i*_t(u,n),n),sqrN:i=>i*i,addN:(i,u)=>i+u,subN:(i,u)=>i-u,mulN:(i,u)=>i*u,inv:i=>_t(i,n),sqrt:r.sqrt||(i=>(c||(c=Ue(n)),c(f,i))),invertBatch:i=>ze(f,i),cmov:(i,u,y)=>y?u:i,toBytes:i=>t?Rt(i,s):lt(i,s),fromBytes:i=>{if(i.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+i.length);return t?Zt(i):rt(i)}});return Object.freeze(f)}function se(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function ce(n){const e=se(n);return e+Math.ceil(e/2)}function Ce(n,e,t=!1){const r=n.length,o=se(e),s=ce(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const c=t?Zt(n):rt(n),f=V(c,e-_)+_;return t?Rt(f,o):lt(f,o)}const Pt=BigInt(0),mt=BigInt(1);function Nt(n,e){const t=e.negate();return n?t:e}function fe(n,e){if(!Number.isSafeInteger(n)||n<=0||n>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+n)}function qt(n,e){fe(n,e);const t=Math.ceil(e/n)+1,r=2**(n-1);return{windows:t,windowSize:r}}function Ze(n,e){if(!Array.isArray(n))throw new Error("array expected");n.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})}function Re(n,e){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}const Ot=new WeakMap,ae=new WeakMap;function Lt(n){return ae.get(n)||1}function Me(n,e){return{constTimeNegate:Nt,hasPrecomputes(t){return Lt(t)!==1},unsafeLadder(t,r,o=n.ZERO){let s=t;for(;r>Pt;)r&mt&&(o=o.add(s)),s=s.double(),r>>=mt;return o},precomputeWindow(t,r){const{windows:o,windowSize:s}=qt(r,e),c=[];let f=t,i=f;for(let u=0;u<o;u++){i=f,c.push(i);for(let y=1;y<s;y++)i=i.add(f),c.push(i);f=i.double()}return c},wNAF(t,r,o){const{windows:s,windowSize:c}=qt(t,e);let f=n.ZERO,i=n.BASE;const u=BigInt(2**t-1),y=2**t,h=BigInt(t);for(let l=0;l<s;l++){const m=l*c;let N=Number(o&u);o>>=h,N>c&&(N-=y,o+=mt);const b=m,a=m+Math.abs(N)-1,g=l%2!==0,x=N<0;N===0?i=i.add(Nt(g,r[b])):f=f.add(Nt(x,r[a]))}return{p:f,f:i}},wNAFUnsafe(t,r,o,s=n.ZERO){const{windows:c,windowSize:f}=qt(t,e),i=BigInt(2**t-1),u=2**t,y=BigInt(t);for(let h=0;h<c;h++){const l=h*f;if(o===Pt)break;let m=Number(o&i);if(o>>=y,m>f&&(m-=u,o+=mt),m===0)continue;let N=r[l+Math.abs(m)-1];m<0&&(N=N.negate()),s=s.add(N)}return s},getPrecomputes(t,r,o){let s=Ot.get(r);return s||(s=this.precomputeWindow(r,t),t!==1&&Ot.set(r,o(s))),s},wNAFCached(t,r,o){const s=Lt(t);return this.wNAF(s,this.getPrecomputes(s,t,o),r)},wNAFCachedUnsafe(t,r,o,s){const c=Lt(t);return c===1?this.unsafeLadder(t,r,s):this.wNAFUnsafe(c,this.getPrecomputes(c,t,o),r,s)},setWindowSize(t,r){fe(r,e),ae.set(t,r),Ot.delete(t)}}}function Ve(n,e,t,r){if(Ze(t,n),Re(r,e),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const o=n.ZERO,s=te(BigInt(t.length)),c=s>12?s-3:s>4?s-2:s?2:1,f=(1<<c)-1,i=new Array(f+1).fill(o),u=Math.floor((e.BITS-1)/c)*c;let y=o;for(let h=u;h>=0;h-=c){i.fill(o);for(let m=0;m<r.length;m++){const N=r[m],b=Number(N>>BigInt(h)&BigInt(f));i[b]=i[b].add(t[m])}let l=o;for(let m=i.length-1,N=o;m>0;m--)N=N.add(i[m]),l=l.add(N);if(y=y.add(l),h!==0)for(let m=0;m<c;m++)y=y.double()}return y}function ue(n){return Te(n.Fp),yt(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...oe(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}function Gt(n){n.lowS!==void 0&&at("lowS",n.lowS),n.prehash!==void 0&&at("prehash",n.prehash)}function je(n){const e=ue(n);yt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:o}=e;if(t){if(!r.eql(o,r.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Ye,hexToBytes:Fe}=qe;class Ke extends Error{constructor(e=""){super(e)}}const $={Err:Ke,_tlv:{encode:(n,e)=>{const{Err:t}=$;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const r=e.length/2,o=gt(r);if(o.length/2&128)throw new t("tlv.encode: long form length too big");const s=r>127?gt(o.length/2|128):"";return gt(n)+s+o+e},decode(n,e){const{Err:t}=$;let r=0;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[r++]!==n)throw new t("tlv.decode: wrong tlv");const o=e[r++],s=!!(o&128);let c=0;if(!s)c=o;else{const i=o&127;if(!i)throw new t("tlv.decode(long): indefinite length not supported");if(i>4)throw new t("tlv.decode(long): byte length is too big");const u=e.subarray(r,r+i);if(u.length!==i)throw new t("tlv.decode: length bytes not complete");if(u[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const y of u)c=c<<8|y;if(r+=i,c<128)throw new t("tlv.decode(long): not minimal encoding")}const f=e.subarray(r,r+c);if(f.length!==c)throw new t("tlv.decode: wrong value length");return{v:f,l:e.subarray(r+c)}}},_int:{encode(n){const{Err:e}=$;if(n<W)throw new e("integer: negative integers are not allowed");let t=gt(n);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(n){const{Err:e}=$;if(n[0]&128)throw new e("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ye(n)}},toSig(n){const{Err:e,_int:t,_tlv:r}=$,o=typeof n=="string"?Fe(n):n;bt(o);const{v:s,l:c}=r.decode(48,o);if(c.length)throw new e("invalid signature: left bytes after parsing");const{v:f,l:i}=r.decode(2,s),{v:u,l:y}=r.decode(2,i);if(y.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(f),s:t.decode(u)}},hexFromSig(n){const{_tlv:e,_int:t}=$,r=e.encode(2,t.encode(n.r)),o=e.encode(2,t.encode(n.s)),s=r+o;return e.encode(48,s)}},W=BigInt(0),k=BigInt(1);BigInt(2);const Dt=BigInt(3);BigInt(4);function Pe(n){const e=je(n),{Fp:t}=e,r=ie(e.n,e.nBitLength),o=e.toBytes||((b,a,g)=>{const x=a.toAffine();return pt(Uint8Array.from([4]),t.toBytes(x.x),t.toBytes(x.y))}),s=e.fromBytes||(b=>{const a=b.subarray(1),g=t.fromBytes(a.subarray(0,t.BYTES)),x=t.fromBytes(a.subarray(t.BYTES,2*t.BYTES));return{x:g,y:x}});function c(b){const{a,b:g}=e,x=t.sqr(b),E=t.mul(x,b);return t.add(t.add(E,t.mul(b,a)),g)}if(!t.eql(t.sqr(e.Gy),c(e.Gx)))throw new Error("bad generator point: equation left != right");function f(b){return Et(b,k,e.n)}function i(b){const{allowedPrivateKeyLengths:a,nByteLength:g,wrapPrivateKey:x,n:E}=e;if(a&&typeof b!="bigint"){if(it(b)&&(b=ut(b)),typeof b!="string"||!a.includes(b.length))throw new Error("invalid private key");b=b.padStart(g*2,"0")}let q;try{q=typeof b=="bigint"?b:rt(K("private key",b,g))}catch{throw new Error("invalid private key, expected hex or "+g+" bytes, got "+typeof b)}return x&&(q=V(q,E)),ot("private key",q,k,E),q}function u(b){if(!(b instanceof l))throw new Error("ProjectivePoint expected")}const y=Ht((b,a)=>{const{px:g,py:x,pz:E}=b;if(t.eql(E,t.ONE))return{x:g,y:x};const q=b.is0();a==null&&(a=q?t.ONE:t.inv(E));const L=t.mul(g,a),I=t.mul(x,a),B=t.mul(E,a);if(q)return{x:t.ZERO,y:t.ZERO};if(!t.eql(B,t.ONE))throw new Error("invZ was invalid");return{x:L,y:I}}),h=Ht(b=>{if(b.is0()){if(e.allowInfinityPoint&&!t.is0(b.py))return;throw new Error("bad point: ZERO")}const{x:a,y:g}=b.toAffine();if(!t.isValid(a)||!t.isValid(g))throw new Error("bad point: x or y not FE");const x=t.sqr(g),E=c(a);if(!t.eql(x,E))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class l{constructor(a,g,x){if(this.px=a,this.py=g,this.pz=x,a==null||!t.isValid(a))throw new Error("x required");if(g==null||!t.isValid(g))throw new Error("y required");if(x==null||!t.isValid(x))throw new Error("z required");Object.freeze(this)}static fromAffine(a){const{x:g,y:x}=a||{};if(!a||!t.isValid(g)||!t.isValid(x))throw new Error("invalid affine point");if(a instanceof l)throw new Error("projective point not allowed");const E=q=>t.eql(q,t.ZERO);return E(g)&&E(x)?l.ZERO:new l(g,x,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(a){const g=t.invertBatch(a.map(x=>x.pz));return a.map((x,E)=>x.toAffine(g[E])).map(l.fromAffine)}static fromHex(a){const g=l.fromAffine(s(K("pointHex",a)));return g.assertValidity(),g}static fromPrivateKey(a){return l.BASE.multiply(i(a))}static msm(a,g){return Ve(l,r,a,g)}_setWindowSize(a){N.setWindowSize(this,a)}assertValidity(){h(this)}hasEvenY(){const{y:a}=this.toAffine();if(t.isOdd)return!t.isOdd(a);throw new Error("Field doesn't support isOdd")}equals(a){u(a);const{px:g,py:x,pz:E}=this,{px:q,py:L,pz:I}=a,B=t.eql(t.mul(g,I),t.mul(q,E)),A=t.eql(t.mul(x,I),t.mul(L,E));return B&&A}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){const{a,b:g}=e,x=t.mul(g,Dt),{px:E,py:q,pz:L}=this;let I=t.ZERO,B=t.ZERO,A=t.ZERO,v=t.mul(E,E),C=t.mul(q,q),U=t.mul(L,L),H=t.mul(E,q);return H=t.add(H,H),A=t.mul(E,L),A=t.add(A,A),I=t.mul(a,A),B=t.mul(x,U),B=t.add(I,B),I=t.sub(C,B),B=t.add(C,B),B=t.mul(I,B),I=t.mul(H,I),A=t.mul(x,A),U=t.mul(a,U),H=t.sub(v,U),H=t.mul(a,H),H=t.add(H,A),A=t.add(v,v),v=t.add(A,v),v=t.add(v,U),v=t.mul(v,H),B=t.add(B,v),U=t.mul(q,L),U=t.add(U,U),v=t.mul(U,H),I=t.sub(I,v),A=t.mul(U,C),A=t.add(A,A),A=t.add(A,A),new l(I,B,A)}add(a){u(a);const{px:g,py:x,pz:E}=this,{px:q,py:L,pz:I}=a;let B=t.ZERO,A=t.ZERO,v=t.ZERO;const C=e.a,U=t.mul(e.b,Dt);let H=t.mul(g,q),j=t.mul(x,L),d=t.mul(E,I),w=t.add(g,x),p=t.add(q,L);w=t.mul(w,p),p=t.add(H,j),w=t.sub(w,p),p=t.add(g,E);let S=t.add(q,I);return p=t.mul(p,S),S=t.add(H,d),p=t.sub(p,S),S=t.add(x,E),B=t.add(L,I),S=t.mul(S,B),B=t.add(j,d),S=t.sub(S,B),v=t.mul(C,p),B=t.mul(U,d),v=t.add(B,v),B=t.sub(j,v),v=t.add(j,v),A=t.mul(B,v),j=t.add(H,H),j=t.add(j,H),d=t.mul(C,d),p=t.mul(U,p),j=t.add(j,d),d=t.sub(H,d),d=t.mul(C,d),p=t.add(p,d),H=t.mul(j,p),A=t.add(A,H),H=t.mul(S,p),B=t.mul(w,B),B=t.sub(B,H),H=t.mul(w,j),v=t.mul(S,v),v=t.add(v,H),new l(B,A,v)}subtract(a){return this.add(a.negate())}is0(){return this.equals(l.ZERO)}wNAF(a){return N.wNAFCached(this,a,l.normalizeZ)}multiplyUnsafe(a){const{endo:g,n:x}=e;ot("scalar",a,W,x);const E=l.ZERO;if(a===W)return E;if(this.is0()||a===k)return this;if(!g||N.hasPrecomputes(this))return N.wNAFCachedUnsafe(this,a,l.normalizeZ);let{k1neg:q,k1:L,k2neg:I,k2:B}=g.splitScalar(a),A=E,v=E,C=this;for(;L>W||B>W;)L&k&&(A=A.add(C)),B&k&&(v=v.add(C)),C=C.double(),L>>=k,B>>=k;return q&&(A=A.negate()),I&&(v=v.negate()),v=new l(t.mul(v.px,g.beta),v.py,v.pz),A.add(v)}multiply(a){const{endo:g,n:x}=e;ot("scalar",a,k,x);let E,q;if(g){const{k1neg:L,k1:I,k2neg:B,k2:A}=g.splitScalar(a);let{p:v,f:C}=this.wNAF(I),{p:U,f:H}=this.wNAF(A);v=N.constTimeNegate(L,v),U=N.constTimeNegate(B,U),U=new l(t.mul(U.px,g.beta),U.py,U.pz),E=v.add(U),q=C.add(H)}else{const{p:L,f:I}=this.wNAF(a);E=L,q=I}return l.normalizeZ([E,q])[0]}multiplyAndAddUnsafe(a,g,x){const E=l.BASE,q=(I,B)=>B===W||B===k||!I.equals(E)?I.multiplyUnsafe(B):I.multiply(B),L=q(this,g).add(q(a,x));return L.is0()?void 0:L}toAffine(a){return y(this,a)}isTorsionFree(){const{h:a,isTorsionFree:g}=e;if(a===k)return!0;if(g)return g(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:a,clearCofactor:g}=e;return a===k?this:g?g(l,this):this.multiplyUnsafe(e.h)}toRawBytes(a=!0){return at("isCompressed",a),this.assertValidity(),o(l,this,a)}toHex(a=!0){return at("isCompressed",a),ut(this.toRawBytes(a))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);const m=e.nBitLength,N=Me(l,e.endo?Math.ceil(m/2):m);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:i,weierstrassEquation:c,isWithinCurveOrder:f}}function Ge(n){const e=ue(n);return yt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function De(n){const e=Ge(n),{Fp:t,n:r}=e,o=t.BYTES+1,s=2*t.BYTES+1;function c(d){return V(d,r)}function f(d){return _t(d,r)}const{ProjectivePoint:i,normPrivateKeyToScalar:u,weierstrassEquation:y,isWithinCurveOrder:h}=Pe({...e,toBytes(d,w,p){const S=w.toAffine(),O=t.toBytes(S.x),T=pt;return at("isCompressed",p),p?T(Uint8Array.from([w.hasEvenY()?2:3]),O):T(Uint8Array.from([4]),O,t.toBytes(S.y))},fromBytes(d){const w=d.length,p=d[0],S=d.subarray(1);if(w===o&&(p===2||p===3)){const O=rt(S);if(!Et(O,k,t.ORDER))throw new Error("Point is not on curve");const T=y(O);let R;try{R=t.sqrt(T)}catch(F){const M=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+M)}const Z=(R&k)===k;return(p&1)===1!==Z&&(R=t.neg(R)),{x:O,y:R}}else if(w===s&&p===4){const O=t.fromBytes(S.subarray(0,t.BYTES)),T=t.fromBytes(S.subarray(t.BYTES,2*t.BYTES));return{x:O,y:T}}else{const O=o,T=s;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+T+", got "+w)}}}),l=d=>ut(lt(d,e.nByteLength));function m(d){const w=r>>k;return d>w}function N(d){return m(d)?c(-d):d}const b=(d,w,p)=>rt(d.slice(w,p));class a{constructor(w,p,S){this.r=w,this.s=p,this.recovery=S,this.assertValidity()}static fromCompact(w){const p=e.nByteLength;return w=K("compactSignature",w,p*2),new a(b(w,0,p),b(w,p,2*p))}static fromDER(w){const{r:p,s:S}=$.toSig(K("DER",w));return new a(p,S)}assertValidity(){ot("r",this.r,k,r),ot("s",this.s,k,r)}addRecoveryBit(w){return new a(this.r,this.s,w)}recoverPublicKey(w){const{r:p,s:S,recovery:O}=this,T=I(K("msgHash",w));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const R=O===2||O===3?p+e.n:p;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const Z=(O&1)===0?"02":"03",G=i.fromHex(Z+l(R)),F=f(R),M=c(-T*F),st=c(S*F),X=i.BASE.multiplyAndAddUnsafe(G,M,st);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new a(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return wt(this.toDERHex())}toDERHex(){return $.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return wt(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}const g={isValidPrivateKey(d){try{return u(d),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const d=ce(e.n);return Ce(e.randomBytes(d),e.n)},precompute(d=8,w=i.BASE){return w._setWindowSize(d),w.multiply(BigInt(3)),w}};function x(d,w=!0){return i.fromPrivateKey(d).toRawBytes(w)}function E(d){const w=it(d),p=typeof d=="string",S=(w||p)&&d.length;return w?S===o||S===s:p?S===2*o||S===2*s:d instanceof i}function q(d,w,p=!0){if(E(d))throw new Error("first arg must be private key");if(!E(w))throw new Error("second arg must be public key");return i.fromHex(w).multiply(u(d)).toRawBytes(p)}const L=e.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");const w=rt(d),p=d.length*8-e.nBitLength;return p>0?w>>BigInt(p):w},I=e.bits2int_modN||function(d){return c(L(d))},B=Mt(e.nBitLength);function A(d){return ot("num < 2^"+e.nBitLength,d,W,B),lt(d,e.nByteLength)}function v(d,w,p=C){if(["recovered","canonical"].some(tt=>tt in p))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:O}=e;let{lowS:T,prehash:R,extraEntropy:Z}=p;T==null&&(T=!0),d=K("msgHash",d),Gt(p),R&&(d=K("prehashed msgHash",S(d)));const G=I(d),F=u(w),M=[A(F),A(G)];if(Z!=null&&Z!==!1){const tt=Z===!0?O(t.BYTES):Z;M.push(K("extraEntropy",tt))}const st=pt(...M),X=G;function Bt(tt){const ct=L(tt);if(!h(ct))return;const vt=f(ct),dt=i.BASE.multiply(ct).toAffine(),et=c(dt.x);if(et===W)return;const ht=c(vt*c(X+et*F));if(ht===W)return;let ft=(dt.x===et?0:2)|Number(dt.y&k),Vt=ht;return T&&m(ht)&&(Vt=N(ht),ft^=1),new a(et,Vt,ft)}return{seed:st,k2sig:Bt}}const C={lowS:e.lowS,prehash:!1},U={lowS:e.lowS,prehash:!1};function H(d,w,p=C){const{seed:S,k2sig:O}=v(d,w,p),T=e;return ee(T.hash.outputLen,T.nByteLength,T.hmac)(S,O)}i.BASE._setWindowSize(8);function j(d,w,p,S=U){const O=d;w=K("msgHash",w),p=K("publicKey",p);const{lowS:T,prehash:R,format:Z}=S;if(Gt(S),"strict"in S)throw new Error("options.strict was renamed to lowS");if(Z!==void 0&&Z!=="compact"&&Z!=="der")throw new Error("format must be compact or der");const G=typeof O=="string"||it(O),F=!G&&!Z&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!G&&!F)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let M,st;try{if(F&&(M=new a(O.r,O.s)),G){try{Z!=="compact"&&(M=a.fromDER(O))}catch(ft){if(!(ft instanceof $.Err))throw ft}!M&&Z!=="der"&&(M=a.fromCompact(O))}st=i.fromHex(p)}catch{return!1}if(!M||T&&M.hasHighS())return!1;R&&(w=e.hash(w));const{r:X,s:Bt}=M,tt=I(w),ct=f(Bt),vt=c(tt*ct),dt=c(X*ct),et=i.BASE.multiplyAndAddUnsafe(st,vt,dt)?.toAffine();return et?c(et.x)===X:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:q,sign:H,verify:j,ProjectivePoint:i,Signature:a,utils:g}}function $e(n){return{hash:n,hmac:(e,...t)=>re(n,e,be(...t)),randomBytes:pe}}function We(n,e){const t=r=>De({...n,...$e(r)});return{...t(e),create:t}}const le=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),$t=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Xe=BigInt(1),Tt=BigInt(2),Wt=(n,e)=>(n+e/Tt)/e;function Qe(n){const e=le,t=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),c=BigInt(23),f=BigInt(44),i=BigInt(88),u=n*n*n%e,y=u*u*n%e,h=Y(y,t,e)*y%e,l=Y(h,t,e)*y%e,m=Y(l,Tt,e)*u%e,N=Y(m,o,e)*m%e,b=Y(N,s,e)*N%e,a=Y(b,f,e)*b%e,g=Y(a,i,e)*a%e,x=Y(g,f,e)*b%e,E=Y(x,t,e)*y%e,q=Y(E,c,e)*N%e,L=Y(q,r,e)*u%e,I=Y(L,Tt,e);if(!kt.eql(kt.sqr(I),n))throw new Error("Cannot find square root");return I}const kt=ie(le,void 0,void 0,{sqrt:Qe}),Je=We({a:BigInt(0),b:BigInt(7),Fp:kt,n:$t,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=$t,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Xe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,c=BigInt("0x100000000000000000000000000000000"),f=Wt(s*n,e),i=Wt(-r*n,e);let u=V(n-f*t-i*o,e),y=V(-f*r-i*s,e);const h=u>c,l=y>c;if(h&&(u=e-u),l&&(y=e-y),u>c||y>c)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:h,k1:u,k2neg:l,k2:y}}}},Se);BigInt(0);Je.ProjectivePoint;export{Je as secp256k1};
@@ -1 +1 @@
1
- import{H as Qt,y as St,z as pt,A as Jt,C as te,E as ye,G as mt,I as xe,J as G,L as Ee,M as Be,O as ve,Q as Se}from"./wallets-Bz03-Btm.js";import"./signing-gNn6SJWz.js";import"./utils-h8VUSGPW.js";import"./index-Cu4ZjLNb.js";import"./store-DOLZnwHk.js";import"./hashTypedData-CMDSWYgs.js";import"./index-B-vyBZw9.js";import"./index-DS2Lm9tG.js";import"./index-nibyPLVP.js";import"./index-CJdot1dH.js";import"./index-r_1z0VI_.js";import"./ethereum-BP59xYBe.js";function Ae(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const i=BigInt(32),s=BigInt(4294967295),c=Number(t>>i&s),f=Number(t&s),o=r?4:0,l=r?0:4;n.setUint32(e+o,c,r),n.setUint32(e+l,f,r)}function Ie(n,e,t){return n&e^~n&t}function Ne(n,e,t){return n&e^n&t^e&t}class Oe extends Qt{constructor(e,t,r,i){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=St(this.buffer)}update(e){pt(this),e=Jt(e),te(e);const{view:t,buffer:r,blockLen:i}=this,s=e.length;for(let c=0;c<s;){const f=Math.min(i-this.pos,s-c);if(f===i){const o=St(e);for(;i<=s-c;c+=i)this.process(o,c);continue}r.set(e.subarray(c,c+f),this.pos),this.pos+=f,c+=f,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){pt(this),ye(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:i,isLE:s}=this;let{pos:c}=this;t[c++]=128,mt(this.buffer.subarray(c)),this.padOffset>i-c&&(this.process(r,0),c=0);for(let h=c;h<i;h++)t[h]=0;Ae(r,i-8,BigInt(this.length*8),s),this.process(r,0);const f=St(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=o/4,g=this.get();if(l>g.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)f.setUint32(4*h,g[h],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:i,finished:s,destroyed:c,pos:f}=this;return e.destroyed=c,e.finished=s,e.length=i,e.pos=f,i%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const J=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qe=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),tt=new Uint32Array(64);class He extends Oe{constructor(e=32){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}get(){const{A:e,B:t,C:r,D:i,E:s,F:c,G:f,H:o}=this;return[e,t,r,i,s,c,f,o]}set(e,t,r,i,s,c,f,o){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}process(e,t){for(let h=0;h<16;h++,t+=4)tt[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){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;tt[h]=p+tt[h-7]+_+tt[h-16]|0}let{A:r,B:i,C:s,D:c,E:f,F:o,G:l,H:g}=this;for(let h=0;h<64;h++){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;g=l,l=o,o=f,f=c+q|0,c=s,s=i,i=r,r=q+p|0}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)}roundClean(){mt(tt)}destroy(){this.set(0,0,0,0,0,0,0,0),mt(this.buffer)}}const Le=xe(()=>new He);class ee extends Qt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ee(e);const r=Jt(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?e.create().update(r).digest():r);for(let c=0;c<s.length;c++)s[c]^=54;this.iHash.update(s),this.oHash=e.create();for(let c=0;c<s.length;c++)s[c]^=106;this.oHash.update(s),mt(s)}update(e){return pt(this),this.iHash.update(e),this}digestInto(e){pt(this),te(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:i,destroyed:s,blockLen:c,outputLen:f}=this;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}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ne=(n,e,t)=>new ee(n,e).update(t).digest();ne.create=(n,e)=>new ee(n,e);const kt=BigInt(0),_t=BigInt(1);function ht(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function Ct(n){if(!ht(n))throw new Error("Uint8Array expected")}function lt(n,e){if(typeof e!="boolean")throw new Error(n+" boolean expected, got "+e)}function gt(n){const e=n.toString(16);return e.length&1?"0"+e:e}function re(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return n===""?kt:BigInt("0x"+n)}const oe=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ue=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function dt(n){if(Ct(n),oe)return n.toHex();let e="";for(let t=0;t<n.length;t++)e+=Ue[n[t]];return e}const $={_0:48,_9:57,A:65,F:70,a:97,f:102};function Yt(n){if(n>=$._0&&n<=$._9)return n-$._0;if(n>=$.A&&n<=$.F)return n-($.A-10);if(n>=$.a&&n<=$.f)return n-($.a-10)}function bt(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);if(oe)return Uint8Array.fromHex(n);const e=n.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){const c=Yt(n.charCodeAt(s)),f=Yt(n.charCodeAt(s+1));if(c===void 0||f===void 0){const o=n[s]+n[s+1];throw new Error('hex string expected, got non-hex character "'+o+'" at index '+s)}r[i]=c*16+f}return r}function ot(n){return re(dt(n))}function ie(n){return Ct(n),re(dt(Uint8Array.from(n).reverse()))}function wt(n,e){return bt(n.toString(16).padStart(e*2,"0"))}function se(n,e){return wt(n,e).reverse()}function K(n,e,t){let r;if(typeof e=="string")try{r=bt(e)}catch(s){throw new Error(n+" must be hex string or Uint8Array, cause: "+s)}else if(ht(e))r=Uint8Array.from(e);else throw new Error(n+" must be hex string or Uint8Array");const i=r.length;if(typeof t=="number"&&i!==t)throw new Error(n+" of length "+t+" expected, got "+i);return r}function yt(...n){let e=0;for(let r=0;r<n.length;r++){const i=n[r];Ct(i),e+=i.length}const t=new Uint8Array(e);for(let r=0,i=0;r<n.length;r++){const s=n[r];t.set(s,i),i+=s.length}return t}const At=n=>typeof n=="bigint"&&kt<=n;function Vt(n,e,t){return At(n)&&At(e)&&At(t)&&e<=n&&n<t}function ft(n,e,t,r){if(!Vt(e,t,r))throw new Error("expected valid "+n+": "+t+" <= n < "+r+", got "+e)}function _e(n){let e;for(e=0;n>kt;n>>=_t,e+=1);return e}const xt=n=>(_t<<BigInt(n))-_t,It=n=>new Uint8Array(n),Kt=n=>Uint8Array.from(n);function Re(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=It(n),i=It(n),s=0;const c=()=>{r.fill(1),i.fill(0),s=0},f=(...h)=>t(i,r,...h),o=(h=It(0))=>{i=f(Kt([0]),h),r=f(),h.length!==0&&(i=f(Kt([1]),h),r=f())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const B=[];for(;h<e;){r=f();const q=r.slice();B.push(q),h+=r.length}return yt(...B)};return(h,B)=>{c(),o(h);let q;for(;!(q=B(l()));)o();return c(),q}}const ze={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||ht(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function Et(n,e,t={}){const r=(i,s,c)=>{const f=ze[s];if(typeof f!="function")throw new Error("invalid validator function");const o=n[i];if(!(c&&o===void 0)&&!f(o,n))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+o)};for(const[i,s]of Object.entries(e))r(i,s,!1);for(const[i,s]of Object.entries(t))r(i,s,!0);return n}function Pt(n){const e=new WeakMap;return(t,...r)=>{const i=e.get(t);if(i!==void 0)return i;const s=n(t,...r);return e.set(t,s),s}}const j=BigInt(0),C=BigInt(1),rt=BigInt(2),Te=BigInt(3),ce=BigInt(4),fe=BigInt(5),ae=BigInt(8);function M(n,e){const t=n%e;return t>=j?t:e+t}function Y(n,e,t){let r=n;for(;e-- >j;)r*=r,r%=t;return r}function Rt(n,e){if(n===j)throw new Error("invert: expected non-zero number");if(e<=j)throw new Error("invert: expected positive modulus, got "+e);let t=M(n,e),r=e,i=j,s=C;for(;t!==j;){const f=r/t,o=r%t,l=i-s*f;r=t,t=o,i=s,s=l}if(r!==C)throw new Error("invert: does not exist");return M(i,e)}function ue(n,e){const t=(n.ORDER+C)/ce,r=n.pow(e,t);if(!n.eql(n.sqr(r),e))throw new Error("Cannot find square root");return r}function Ze(n,e){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));if(!n.eql(n.sqr(f),e))throw new Error("Cannot find square root");return f}function ke(n){if(n<BigInt(3))throw new Error("sqrt is not defined for small field");let e=n-C,t=0;for(;e%rt===j;)e/=rt,t++;let r=rt;const i=Mt(n);for(;Dt(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return ue;let s=i.pow(r,e);const c=(e+C)/rt;return function(o,l){if(o.is0(l))return l;if(Dt(o,l)!==1)throw new Error("Cannot find square root");let g=t,h=o.mul(o.ONE,s),B=o.pow(l,e),q=o.pow(l,c);for(;!o.eql(B,o.ONE);){if(o.is0(B))return o.ZERO;let _=1,p=o.sqr(B);for(;!o.eql(p,o.ONE);)if(_++,p=o.sqr(p),_===g)throw new Error("Cannot find square root");const Z=C<<BigInt(g-_-1),R=o.pow(h,Z);g=_,h=o.sqr(R),B=o.mul(B,h),q=o.mul(q,R)}return q}}function Ce(n){return n%ce===Te?ue:n%ae===fe?Ze:ke(n)}const Ve=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Me(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Ve.reduce((r,i)=>(r[i]="function",r),e);return Et(n,t)}function je(n,e,t){if(t<j)throw new Error("invalid exponent, negatives unsupported");if(t===j)return n.ONE;if(t===C)return e;let r=n.ONE,i=e;for(;t>j;)t&C&&(r=n.mul(r,i)),i=n.sqr(i),t>>=C;return r}function le(n,e,t=!1){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);return e.reduceRight((c,f,o)=>n.is0(f)?c:(r[o]=n.mul(c,r[o]),n.mul(c,f)),s),r}function Dt(n,e){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));if(!i&&!s&&!c)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function de(n,e){e!==void 0&&Be(e);const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function Mt(n,e,t=!1,r={}){if(n<=j)throw new Error("invalid field: expected ORDER > 0, got "+n);const{nBitLength:i,nByteLength:s}=de(n,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c;const f=Object.freeze({ORDER:n,isLE:t,BITS:i,BYTES:s,MASK:xt(i),ZERO:j,ONE:C,create:o=>M(o,n),isValid:o=>{if(typeof o!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof o);return j<=o&&o<n},is0:o=>o===j,isOdd:o=>(o&C)===C,neg:o=>M(-o,n),eql:(o,l)=>o===l,sqr:o=>M(o*o,n),add:(o,l)=>M(o+l,n),sub:(o,l)=>M(o-l,n),mul:(o,l)=>M(o*l,n),pow:(o,l)=>je(f,o,l),div:(o,l)=>M(o*Rt(l,n),n),sqrN:o=>o*o,addN:(o,l)=>o+l,subN:(o,l)=>o-l,mulN:(o,l)=>o*l,inv:o=>Rt(o,n),sqrt:r.sqrt||(o=>(c||(c=Ce(n)),c(f,o))),toBytes:o=>t?se(o,s):wt(o,s),fromBytes:o=>{if(o.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+o.length);return t?ie(o):ot(o)},invertBatch:o=>le(f,o),cmov:(o,l,g)=>g?l:o});return Object.freeze(f)}function he(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function we(n){const e=he(n);return e+Math.ceil(e/2)}function Ye(n,e,t=!1){const r=n.length,i=he(e),s=we(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const c=t?ie(n):ot(n),f=M(c,e-C)+C;return t?se(f,i):wt(f,i)}const Gt=BigInt(0),zt=BigInt(1);function Nt(n,e){const t=e.negate();return n?t:e}function ge(n,e){if(!Number.isSafeInteger(n)||n<=0||n>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+n)}function Ot(n,e){ge(n,e);const t=Math.ceil(e/n)+1,r=2**(n-1),i=2**n,s=xt(n),c=BigInt(n);return{windows:t,windowSize:r,mask:s,maxNumber:i,shiftBy:c}}function Wt(n,e,t){const{windowSize:r,mask:i,maxNumber:s,shiftBy:c}=t;let f=Number(n&i),o=n>>c;f>r&&(f-=s,o+=zt);const l=e*r,g=l+Math.abs(f)-1,h=f===0,B=f<0,q=e%2!==0;return{nextN:o,offset:g,isZero:h,isNeg:B,isNegF:q,offsetF:l}}function Ke(n,e){if(!Array.isArray(n))throw new Error("array expected");n.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})}function Pe(n,e){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}const qt=new WeakMap,pe=new WeakMap;function Ht(n){return pe.get(n)||1}function De(n,e){return{constTimeNegate:Nt,hasPrecomputes(t){return Ht(t)!==1},unsafeLadder(t,r,i=n.ZERO){let s=t;for(;r>Gt;)r&zt&&(i=i.add(s)),s=s.double(),r>>=zt;return i},precomputeWindow(t,r){const{windows:i,windowSize:s}=Ot(r,e),c=[];let f=t,o=f;for(let l=0;l<i;l++){o=f,c.push(o);for(let g=1;g<s;g++)o=o.add(f),c.push(o);f=o.double()}return c},wNAF(t,r,i){let s=n.ZERO,c=n.BASE;const f=Ot(t,e);for(let o=0;o<f.windows;o++){const{nextN:l,offset:g,isZero:h,isNeg:B,isNegF:q,offsetF:_}=Wt(i,o,f);i=l,h?c=c.add(Nt(q,r[_])):s=s.add(Nt(B,r[g]))}return{p:s,f:c}},wNAFUnsafe(t,r,i,s=n.ZERO){const c=Ot(t,e);for(let f=0;f<c.windows&&i!==Gt;f++){const{nextN:o,offset:l,isZero:g,isNeg:h}=Wt(i,f,c);if(i=o,!g){const B=r[l];s=s.add(h?B.negate():B)}}return s},getPrecomputes(t,r,i){let s=qt.get(r);return s||(s=this.precomputeWindow(r,t),t!==1&&qt.set(r,i(s))),s},wNAFCached(t,r,i){const s=Ht(t);return this.wNAF(s,this.getPrecomputes(s,t,i),r)},wNAFCachedUnsafe(t,r,i,s){const c=Ht(t);return c===1?this.unsafeLadder(t,r,s):this.wNAFUnsafe(c,this.getPrecomputes(c,t,i),r,s)},setWindowSize(t,r){ge(r,e),pe.set(t,r),qt.delete(t)}}}function Ge(n,e,t,r){Ke(t,n),Pe(r,e);const i=t.length,s=r.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");const c=n.ZERO,f=_e(BigInt(i));let o=1;f>12?o=f-3:f>4?o=f-2:f>0&&(o=2);const l=xt(o),g=new Array(Number(l)+1).fill(c),h=Math.floor((e.BITS-1)/o)*o;let B=c;for(let q=h;q>=0;q-=o){g.fill(c);for(let p=0;p<s;p++){const Z=r[p],R=Number(Z>>BigInt(q)&l);g[R]=g[R].add(t[p])}let _=c;for(let p=g.length-1,Z=c;p>0;p--)Z=Z.add(g[p]),_=_.add(Z);if(B=B.add(_),q!==0)for(let p=0;p<o;p++)B=B.double()}return B}function me(n){return Me(n.Fp),Et(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...de(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}function $t(n){n.lowS!==void 0&&lt("lowS",n.lowS),n.prehash!==void 0&&lt("prehash",n.prehash)}function We(n){const e=me(n);Et(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:t,Fp:r,a:i}=e;if(t){if(!r.eql(i,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class $e extends Error{constructor(e=""){super(e)}}const F={Err:$e,_tlv:{encode:(n,e)=>{const{Err:t}=F;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const r=e.length/2,i=gt(r);if(i.length/2&128)throw new t("tlv.encode: long form length too big");const s=r>127?gt(i.length/2|128):"";return gt(n)+s+i+e},decode(n,e){const{Err:t}=F;let r=0;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[r++]!==n)throw new t("tlv.decode: wrong tlv");const i=e[r++],s=!!(i&128);let c=0;if(!s)c=i;else{const o=i&127;if(!o)throw new t("tlv.decode(long): indefinite length not supported");if(o>4)throw new t("tlv.decode(long): byte length is too big");const l=e.subarray(r,r+o);if(l.length!==o)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const g of l)c=c<<8|g;if(r+=o,c<128)throw new t("tlv.decode(long): not minimal encoding")}const f=e.subarray(r,r+c);if(f.length!==c)throw new t("tlv.decode: wrong value length");return{v:f,l:e.subarray(r+c)}}},_int:{encode(n){const{Err:e}=F;if(n<X)throw new e("integer: negative integers are not allowed");let t=gt(n);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(n){const{Err:e}=F;if(n[0]&128)throw new e("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return ot(n)}},toSig(n){const{Err:e,_int:t,_tlv:r}=F,i=K("signature",n),{v:s,l:c}=r.decode(48,i);if(c.length)throw new e("invalid signature: left bytes after parsing");const{v:f,l:o}=r.decode(2,s),{v:l,l:g}=r.decode(2,o);if(g.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(f),s:t.decode(l)}},hexFromSig(n){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;return e.encode(48,s)}};function Lt(n,e){return dt(wt(n,e))}const X=BigInt(0),z=BigInt(1);BigInt(2);const Ut=BigInt(3),Fe=BigInt(4);function Xe(n){const e=We(n),{Fp:t}=e,r=Mt(e.n,e.nBitLength),i=e.toBytes||((A,a,w)=>{const b=a.toAffine();return yt(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),s=e.fromBytes||(A=>{const a=A.subarray(1),w=t.fromBytes(a.subarray(0,t.BYTES)),b=t.fromBytes(a.subarray(t.BYTES,2*t.BYTES));return{x:w,y:b}});function c(A){const{a,b:w}=e,b=t.sqr(A),v=t.mul(b,A);return t.add(t.add(v,t.mul(A,a)),w)}function f(A,a){const w=t.sqr(a),b=c(A);return t.eql(w,b)}if(!f(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const o=t.mul(t.pow(e.a,Ut),Fe),l=t.mul(t.sqr(e.b),BigInt(27));if(t.is0(t.add(o,l)))throw new Error("bad curve params: a or b");function g(A){return Vt(A,z,e.n)}function h(A){const{allowedPrivateKeyLengths:a,nByteLength:w,wrapPrivateKey:b,n:v}=e;if(a&&typeof A!="bigint"){if(ht(A)&&(A=dt(A)),typeof A!="string"||!a.includes(A.length))throw new Error("invalid private key");A=A.padStart(w*2,"0")}let O;try{O=typeof A=="bigint"?A:ot(K("private key",A,w))}catch{throw new Error("invalid private key, expected hex or "+w+" bytes, got "+typeof A)}return b&&(O=M(O,v)),ft("private key",O,z,v),O}function B(A){if(!(A instanceof p))throw new Error("ProjectivePoint expected")}const q=Pt((A,a)=>{const{px:w,py:b,pz:v}=A;if(t.eql(v,t.ONE))return{x:w,y:b};const O=A.is0();a==null&&(a=O?t.ONE:t.inv(v));const L=t.mul(w,a),H=t.mul(b,a),y=t.mul(v,a);if(O)return{x:t.ZERO,y:t.ZERO};if(!t.eql(y,t.ONE))throw new Error("invZ was invalid");return{x:L,y:H}}),_=Pt(A=>{if(A.is0()){if(e.allowInfinityPoint&&!t.is0(A.py))return;throw new Error("bad point: ZERO")}const{x:a,y:w}=A.toAffine();if(!t.isValid(a)||!t.isValid(w))throw new Error("bad point: x or y not FE");if(!f(a,w))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(a,w,b){if(a==null||!t.isValid(a))throw new Error("x required");if(w==null||!t.isValid(w)||t.is0(w))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required");this.px=a,this.py=w,this.pz=b,Object.freeze(this)}static fromAffine(a){const{x:w,y:b}=a||{};if(!a||!t.isValid(w)||!t.isValid(b))throw new Error("invalid affine point");if(a instanceof p)throw new Error("projective point not allowed");const v=O=>t.eql(O,t.ZERO);return v(w)&&v(b)?p.ZERO:new p(w,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(a){const w=le(t,a.map(b=>b.pz));return a.map((b,v)=>b.toAffine(w[v])).map(p.fromAffine)}static fromHex(a){const w=p.fromAffine(s(K("pointHex",a)));return w.assertValidity(),w}static fromPrivateKey(a){return p.BASE.multiply(h(a))}static msm(a,w){return Ge(p,r,a,w)}_setWindowSize(a){D.setWindowSize(this,a)}assertValidity(){_(this)}hasEvenY(){const{y:a}=this.toAffine();if(t.isOdd)return!t.isOdd(a);throw new Error("Field doesn't support isOdd")}equals(a){B(a);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));return y&&N}negate(){return new p(this.px,t.neg(this.py),this.pz)}double(){const{a,b:w}=e,b=t.mul(w,Ut),{px:v,py:O,pz:L}=this;let H=t.ZERO,y=t.ZERO,N=t.ZERO,x=t.mul(v,v),T=t.mul(O,O),d=t.mul(L,L),u=t.mul(v,O);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(T,y),y=t.add(T,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,T),N=t.add(N,N),N=t.add(N,N),new p(H,y,N)}add(a){B(a);const{px:w,py:b,pz:v}=this,{px:O,py:L,pz:H}=a;let y=t.ZERO,N=t.ZERO,x=t.ZERO;const T=e.a,d=t.mul(e.b,Ut);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);E=t.mul(E,S),S=t.add(u,m),E=t.sub(E,S),S=t.add(w,v);let U=t.add(O,H);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(T,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(T,I),S=t.mul(d,S),m=t.add(m,I),I=t.sub(u,I),I=t.mul(T,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)}subtract(a){return this.add(a.negate())}is0(){return this.equals(p.ZERO)}wNAF(a){return D.wNAFCached(this,a,p.normalizeZ)}multiplyUnsafe(a){const{endo:w,n:b}=e;ft("scalar",a,X,b);const v=p.ZERO;if(a===X)return v;if(this.is0()||a===z)return this;if(!w||D.hasPrecomputes(this))return D.wNAFCachedUnsafe(this,a,p.normalizeZ);let{k1neg:O,k1:L,k2neg:H,k2:y}=w.splitScalar(a),N=v,x=v,T=this;for(;L>X||y>X;)L&z&&(N=N.add(T)),y&z&&(x=x.add(T)),T=T.double(),L>>=z,y>>=z;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)}multiply(a){const{endo:w,n:b}=e;ft("scalar",a,z,b);let v,O;if(w){const{k1neg:L,k1:H,k2neg:y,k2:N}=w.splitScalar(a);let{p:x,f:T}=this.wNAF(H),{p:d,f:u}=this.wNAF(N);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=T.add(u)}else{const{p:L,f:H}=this.wNAF(a);v=L,O=H}return p.normalizeZ([v,O])[0]}multiplyAndAddUnsafe(a,w,b){const v=p.BASE,O=(H,y)=>y===X||y===z||!H.equals(v)?H.multiplyUnsafe(y):H.multiply(y),L=O(this,w).add(O(a,b));return L.is0()?void 0:L}toAffine(a){return q(this,a)}isTorsionFree(){const{h:a,isTorsionFree:w}=e;if(a===z)return!0;if(w)return w(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:a,clearCofactor:w}=e;return a===z?this:w?w(p,this):this.multiplyUnsafe(e.h)}toRawBytes(a=!0){return lt("isCompressed",a),this.assertValidity(),i(p,this,a)}toHex(a=!0){return lt("isCompressed",a),dt(this.toRawBytes(a))}}p.BASE=new p(e.Gx,e.Gy,t.ONE),p.ZERO=new p(t.ZERO,t.ONE,t.ZERO);const{endo:Z,nBitLength:R}=e,D=De(p,Z?Math.ceil(R/2):R);return{CURVE:e,ProjectivePoint:p,normPrivateKeyToScalar:h,weierstrassEquation:c,isWithinCurveOrder:g}}function Qe(n){const e=me(n);return Et(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Je(n){const e=Qe(n),{Fp:t,n:r,nByteLength:i,nBitLength:s}=e,c=t.BYTES+1,f=2*t.BYTES+1;function o(d){return M(d,r)}function l(d){return Rt(d,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:h,weierstrassEquation:B,isWithinCurveOrder:q}=Xe({...e,toBytes(d,u,m){const I=u.toAffine(),E=t.toBytes(I.x),S=yt;return lt("isCompressed",m),m?S(Uint8Array.from([u.hasEvenY()?2:3]),E):S(Uint8Array.from([4]),E,t.toBytes(I.y))},fromBytes(d){const u=d.length,m=d[0],I=d.subarray(1);if(u===c&&(m===2||m===3)){const E=ot(I);if(!Vt(E,z,t.ORDER))throw new Error("Point is not on curve");const S=B(E);let U;try{U=t.sqrt(S)}catch(P){const V=P instanceof Error?": "+P.message:"";throw new Error("Point is not on curve"+V)}const k=(U&z)===z;return(m&1)===1!==k&&(U=t.neg(U)),{x:E,y:U}}else if(u===f&&m===4){const E=t.fromBytes(I.subarray(0,t.BYTES)),S=t.fromBytes(I.subarray(t.BYTES,2*t.BYTES));return{x:E,y:S}}else{const E=c,S=f;throw new Error("invalid Point, expected length of "+E+", or uncompressed "+S+", got "+u)}}});function _(d){const u=r>>z;return d>u}function p(d){return _(d)?o(-d):d}const Z=(d,u,m)=>ot(d.slice(u,m));class R{constructor(u,m,I){ft("r",u,z,r),ft("s",m,z,r),this.r=u,this.s=m,I!=null&&(this.recovery=I),Object.freeze(this)}static fromCompact(u){const m=i;return u=K("compactSignature",u,m*2),new R(Z(u,0,m),Z(u,m,2*m))}static fromDER(u){const{r:m,s:I}=F.toSig(K("DER",u));return new R(m,I)}assertValidity(){}addRecoveryBit(u){return new R(this.r,this.s,u)}recoverPublicKey(u){const{r:m,s:I,recovery:E}=this,S=v(K("msgHash",u));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");const U=E===2||E===3?m+e.n:m;if(U>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const k=(E&1)===0?"02":"03",W=g.fromHex(k+Lt(U,t.BYTES)),P=l(U),V=o(-S*P),it=o(I*P),Q=g.BASE.multiplyAndAddUnsafe(W,V,it);if(!Q)throw new Error("point at infinify");return Q.assertValidity(),Q}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new R(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return bt(this.toDERHex())}toDERHex(){return F.hexFromSig(this)}toCompactRawBytes(){return bt(this.toCompactHex())}toCompactHex(){const u=i;return Lt(this.r,u)+Lt(this.s,u)}}const D={isValidPrivateKey(d){try{return h(d),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const d=we(e.n);return Ye(e.randomBytes(d),e.n)},precompute(d=8,u=g.BASE){return u._setWindowSize(d),u.multiply(BigInt(3)),u}};function A(d,u=!0){return g.fromPrivateKey(d).toRawBytes(u)}function a(d){if(typeof d=="bigint")return!1;if(d instanceof g)return!0;const m=K("key",d).length,I=t.BYTES,E=I+1,S=2*I+1;if(!(e.allowedPrivateKeyLengths||i===E))return m===E||m===S}function w(d,u,m=!0){if(a(d)===!0)throw new Error("first arg must be private key");if(a(u)===!1)throw new Error("second arg must be public key");return g.fromHex(u).multiply(h(d)).toRawBytes(m)}const b=e.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");const u=ot(d),m=d.length*8-s;return m>0?u>>BigInt(m):u},v=e.bits2int_modN||function(d){return o(b(d))},O=xt(s);function L(d){return ft("num < 2^"+s,d,X,O),wt(d,i)}function H(d,u,m=y){if(["recovered","canonical"].some(et=>et in m))throw new Error("sign() legacy options not supported");const{hash:I,randomBytes:E}=e;let{lowS:S,prehash:U,extraEntropy:k}=m;S==null&&(S=!0),d=K("msgHash",d),$t(m),U&&(d=K("prehashed msgHash",I(d)));const W=v(d),P=h(u),V=[L(P),L(W)];if(k!=null&&k!==!1){const et=k===!0?E(t.BYTES):k;V.push(K("extraEntropy",et))}const it=yt(...V),Q=W;function Bt(et){const st=b(et);if(!q(st))return;const vt=l(st),at=g.BASE.multiply(st).toAffine(),nt=o(at.x);if(nt===X)return;const ut=o(vt*o(Q+nt*P));if(ut===X)return;let ct=(at.x===nt?0:2)|Number(at.y&z),jt=ut;return S&&_(ut)&&(jt=p(ut),ct^=1),new R(nt,jt,ct)}return{seed:it,k2sig:Bt}}const y={lowS:e.lowS,prehash:!1},N={lowS:e.lowS,prehash:!1};function x(d,u,m=y){const{seed:I,k2sig:E}=H(d,u,m),S=e;return Re(S.hash.outputLen,S.nByteLength,S.hmac)(I,E)}g.BASE._setWindowSize(8);function T(d,u,m,I=N){const E=d;u=K("msgHash",u),m=K("publicKey",m);const{lowS:S,prehash:U,format:k}=I;if($t(I),"strict"in I)throw new Error("options.strict was renamed to lowS");if(k!==void 0&&k!=="compact"&&k!=="der")throw new Error("format must be compact or der");const W=typeof E=="string"||ht(E),P=!W&&!k&&typeof E=="object"&&E!==null&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!W&&!P)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let V,it;try{if(P&&(V=new R(E.r,E.s)),W){try{k!=="compact"&&(V=R.fromDER(E))}catch(ct){if(!(ct instanceof F.Err))throw ct}!V&&k!=="der"&&(V=R.fromCompact(E))}it=g.fromHex(m)}catch{return!1}if(!V||S&&V.hasHighS())return!1;U&&(u=e.hash(u));const{r:Q,s:Bt}=V,et=v(u),st=l(Bt),vt=o(et*st),at=o(Q*st),nt=g.BASE.multiplyAndAddUnsafe(it,vt,at)?.toAffine();return nt?o(nt.x)===Q:!1}return{CURVE:e,getPublicKey:A,getSharedSecret:w,sign:x,verify:T,ProjectivePoint:g,Signature:R,utils:D}}function tn(n){return{hash:n,hmac:(e,...t)=>ne(n,e,Se(...t)),randomBytes:ve}}function en(n,e){const t=r=>Je({...n,...tn(r)});return{...t(e),create:t}}const be=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ft=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),nn=BigInt(0),rn=BigInt(1),Tt=BigInt(2),Xt=(n,e)=>(n+e/Tt)/e;function on(n){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,Tt,e)*l%e,_=Y(q,i,e)*q%e,p=Y(_,s,e)*_%e,Z=Y(p,f,e)*p%e,R=Y(Z,o,e)*Z%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,Tt,e);if(!Zt.eql(Zt.sqr(b),n))throw new Error("Cannot find square root");return b}const Zt=Mt(be,void 0,void 0,{sqrt:on}),bn=en({a:nn,b:BigInt(7),Fp:Zt,n:Ft,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{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);let l=M(n-f*t-o*i,e),g=M(-f*r-o*s,e);const h=l>c,B=g>c;if(h&&(l=e-l),B&&(g=e-g),l>c||g>c)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:h,k1:l,k2neg:B,k2:g}}}},Le);export{bn as secp256k1};
1
+ import{H as Qt,y as St,z as pt,A as Jt,C as te,E as ye,G as mt,I as xe,J as G,L as Ee,M as Be,O as ve,Q as Se}from"./wallets-HiUhftO5.js";import"./signing-lyeTiv6v.js";import"./utils-Cj9H0gW-.js";import"./index-a-a2MqTK.js";import"./store-DOLZnwHk.js";import"./hashTypedData-DrZol7nF.js";import"./index-CPCCdjXg.js";import"./index-CcHsPndE.js";import"./index-nibyPLVP.js";import"./index-CJdot1dH.js";import"./index-CpGStcFm.js";import"./ethereum-2kM2S7dx.js";function Ae(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const i=BigInt(32),s=BigInt(4294967295),c=Number(t>>i&s),f=Number(t&s),o=r?4:0,l=r?0:4;n.setUint32(e+o,c,r),n.setUint32(e+l,f,r)}function Ie(n,e,t){return n&e^~n&t}function Ne(n,e,t){return n&e^n&t^e&t}class Oe extends Qt{constructor(e,t,r,i){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=St(this.buffer)}update(e){pt(this),e=Jt(e),te(e);const{view:t,buffer:r,blockLen:i}=this,s=e.length;for(let c=0;c<s;){const f=Math.min(i-this.pos,s-c);if(f===i){const o=St(e);for(;i<=s-c;c+=i)this.process(o,c);continue}r.set(e.subarray(c,c+f),this.pos),this.pos+=f,c+=f,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){pt(this),ye(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:i,isLE:s}=this;let{pos:c}=this;t[c++]=128,mt(this.buffer.subarray(c)),this.padOffset>i-c&&(this.process(r,0),c=0);for(let h=c;h<i;h++)t[h]=0;Ae(r,i-8,BigInt(this.length*8),s),this.process(r,0);const f=St(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=o/4,g=this.get();if(l>g.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)f.setUint32(4*h,g[h],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:i,finished:s,destroyed:c,pos:f}=this;return e.destroyed=c,e.finished=s,e.length=i,e.pos=f,i%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const J=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qe=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),tt=new Uint32Array(64);class He extends Oe{constructor(e=32){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}get(){const{A:e,B:t,C:r,D:i,E:s,F:c,G:f,H:o}=this;return[e,t,r,i,s,c,f,o]}set(e,t,r,i,s,c,f,o){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}process(e,t){for(let h=0;h<16;h++,t+=4)tt[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){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;tt[h]=p+tt[h-7]+_+tt[h-16]|0}let{A:r,B:i,C:s,D:c,E:f,F:o,G:l,H:g}=this;for(let h=0;h<64;h++){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;g=l,l=o,o=f,f=c+q|0,c=s,s=i,i=r,r=q+p|0}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)}roundClean(){mt(tt)}destroy(){this.set(0,0,0,0,0,0,0,0),mt(this.buffer)}}const Le=xe(()=>new He);class ee extends Qt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ee(e);const r=Jt(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?e.create().update(r).digest():r);for(let c=0;c<s.length;c++)s[c]^=54;this.iHash.update(s),this.oHash=e.create();for(let c=0;c<s.length;c++)s[c]^=106;this.oHash.update(s),mt(s)}update(e){return pt(this),this.iHash.update(e),this}digestInto(e){pt(this),te(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:i,destroyed:s,blockLen:c,outputLen:f}=this;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}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ne=(n,e,t)=>new ee(n,e).update(t).digest();ne.create=(n,e)=>new ee(n,e);const kt=BigInt(0),_t=BigInt(1);function ht(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function Ct(n){if(!ht(n))throw new Error("Uint8Array expected")}function lt(n,e){if(typeof e!="boolean")throw new Error(n+" boolean expected, got "+e)}function gt(n){const e=n.toString(16);return e.length&1?"0"+e:e}function re(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return n===""?kt:BigInt("0x"+n)}const oe=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ue=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function dt(n){if(Ct(n),oe)return n.toHex();let e="";for(let t=0;t<n.length;t++)e+=Ue[n[t]];return e}const $={_0:48,_9:57,A:65,F:70,a:97,f:102};function Yt(n){if(n>=$._0&&n<=$._9)return n-$._0;if(n>=$.A&&n<=$.F)return n-($.A-10);if(n>=$.a&&n<=$.f)return n-($.a-10)}function bt(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);if(oe)return Uint8Array.fromHex(n);const e=n.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){const c=Yt(n.charCodeAt(s)),f=Yt(n.charCodeAt(s+1));if(c===void 0||f===void 0){const o=n[s]+n[s+1];throw new Error('hex string expected, got non-hex character "'+o+'" at index '+s)}r[i]=c*16+f}return r}function ot(n){return re(dt(n))}function ie(n){return Ct(n),re(dt(Uint8Array.from(n).reverse()))}function wt(n,e){return bt(n.toString(16).padStart(e*2,"0"))}function se(n,e){return wt(n,e).reverse()}function K(n,e,t){let r;if(typeof e=="string")try{r=bt(e)}catch(s){throw new Error(n+" must be hex string or Uint8Array, cause: "+s)}else if(ht(e))r=Uint8Array.from(e);else throw new Error(n+" must be hex string or Uint8Array");const i=r.length;if(typeof t=="number"&&i!==t)throw new Error(n+" of length "+t+" expected, got "+i);return r}function yt(...n){let e=0;for(let r=0;r<n.length;r++){const i=n[r];Ct(i),e+=i.length}const t=new Uint8Array(e);for(let r=0,i=0;r<n.length;r++){const s=n[r];t.set(s,i),i+=s.length}return t}const At=n=>typeof n=="bigint"&&kt<=n;function Vt(n,e,t){return At(n)&&At(e)&&At(t)&&e<=n&&n<t}function ft(n,e,t,r){if(!Vt(e,t,r))throw new Error("expected valid "+n+": "+t+" <= n < "+r+", got "+e)}function _e(n){let e;for(e=0;n>kt;n>>=_t,e+=1);return e}const xt=n=>(_t<<BigInt(n))-_t,It=n=>new Uint8Array(n),Kt=n=>Uint8Array.from(n);function Re(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=It(n),i=It(n),s=0;const c=()=>{r.fill(1),i.fill(0),s=0},f=(...h)=>t(i,r,...h),o=(h=It(0))=>{i=f(Kt([0]),h),r=f(),h.length!==0&&(i=f(Kt([1]),h),r=f())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const B=[];for(;h<e;){r=f();const q=r.slice();B.push(q),h+=r.length}return yt(...B)};return(h,B)=>{c(),o(h);let q;for(;!(q=B(l()));)o();return c(),q}}const ze={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||ht(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function Et(n,e,t={}){const r=(i,s,c)=>{const f=ze[s];if(typeof f!="function")throw new Error("invalid validator function");const o=n[i];if(!(c&&o===void 0)&&!f(o,n))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+o)};for(const[i,s]of Object.entries(e))r(i,s,!1);for(const[i,s]of Object.entries(t))r(i,s,!0);return n}function Pt(n){const e=new WeakMap;return(t,...r)=>{const i=e.get(t);if(i!==void 0)return i;const s=n(t,...r);return e.set(t,s),s}}const j=BigInt(0),C=BigInt(1),rt=BigInt(2),Te=BigInt(3),ce=BigInt(4),fe=BigInt(5),ae=BigInt(8);function M(n,e){const t=n%e;return t>=j?t:e+t}function Y(n,e,t){let r=n;for(;e-- >j;)r*=r,r%=t;return r}function Rt(n,e){if(n===j)throw new Error("invert: expected non-zero number");if(e<=j)throw new Error("invert: expected positive modulus, got "+e);let t=M(n,e),r=e,i=j,s=C;for(;t!==j;){const f=r/t,o=r%t,l=i-s*f;r=t,t=o,i=s,s=l}if(r!==C)throw new Error("invert: does not exist");return M(i,e)}function ue(n,e){const t=(n.ORDER+C)/ce,r=n.pow(e,t);if(!n.eql(n.sqr(r),e))throw new Error("Cannot find square root");return r}function Ze(n,e){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));if(!n.eql(n.sqr(f),e))throw new Error("Cannot find square root");return f}function ke(n){if(n<BigInt(3))throw new Error("sqrt is not defined for small field");let e=n-C,t=0;for(;e%rt===j;)e/=rt,t++;let r=rt;const i=Mt(n);for(;Dt(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return ue;let s=i.pow(r,e);const c=(e+C)/rt;return function(o,l){if(o.is0(l))return l;if(Dt(o,l)!==1)throw new Error("Cannot find square root");let g=t,h=o.mul(o.ONE,s),B=o.pow(l,e),q=o.pow(l,c);for(;!o.eql(B,o.ONE);){if(o.is0(B))return o.ZERO;let _=1,p=o.sqr(B);for(;!o.eql(p,o.ONE);)if(_++,p=o.sqr(p),_===g)throw new Error("Cannot find square root");const Z=C<<BigInt(g-_-1),R=o.pow(h,Z);g=_,h=o.sqr(R),B=o.mul(B,h),q=o.mul(q,R)}return q}}function Ce(n){return n%ce===Te?ue:n%ae===fe?Ze:ke(n)}const Ve=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Me(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Ve.reduce((r,i)=>(r[i]="function",r),e);return Et(n,t)}function je(n,e,t){if(t<j)throw new Error("invalid exponent, negatives unsupported");if(t===j)return n.ONE;if(t===C)return e;let r=n.ONE,i=e;for(;t>j;)t&C&&(r=n.mul(r,i)),i=n.sqr(i),t>>=C;return r}function le(n,e,t=!1){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);return e.reduceRight((c,f,o)=>n.is0(f)?c:(r[o]=n.mul(c,r[o]),n.mul(c,f)),s),r}function Dt(n,e){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));if(!i&&!s&&!c)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function de(n,e){e!==void 0&&Be(e);const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function Mt(n,e,t=!1,r={}){if(n<=j)throw new Error("invalid field: expected ORDER > 0, got "+n);const{nBitLength:i,nByteLength:s}=de(n,e);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c;const f=Object.freeze({ORDER:n,isLE:t,BITS:i,BYTES:s,MASK:xt(i),ZERO:j,ONE:C,create:o=>M(o,n),isValid:o=>{if(typeof o!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof o);return j<=o&&o<n},is0:o=>o===j,isOdd:o=>(o&C)===C,neg:o=>M(-o,n),eql:(o,l)=>o===l,sqr:o=>M(o*o,n),add:(o,l)=>M(o+l,n),sub:(o,l)=>M(o-l,n),mul:(o,l)=>M(o*l,n),pow:(o,l)=>je(f,o,l),div:(o,l)=>M(o*Rt(l,n),n),sqrN:o=>o*o,addN:(o,l)=>o+l,subN:(o,l)=>o-l,mulN:(o,l)=>o*l,inv:o=>Rt(o,n),sqrt:r.sqrt||(o=>(c||(c=Ce(n)),c(f,o))),toBytes:o=>t?se(o,s):wt(o,s),fromBytes:o=>{if(o.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+o.length);return t?ie(o):ot(o)},invertBatch:o=>le(f,o),cmov:(o,l,g)=>g?l:o});return Object.freeze(f)}function he(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function we(n){const e=he(n);return e+Math.ceil(e/2)}function Ye(n,e,t=!1){const r=n.length,i=he(e),s=we(e);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const c=t?ie(n):ot(n),f=M(c,e-C)+C;return t?se(f,i):wt(f,i)}const Gt=BigInt(0),zt=BigInt(1);function Nt(n,e){const t=e.negate();return n?t:e}function ge(n,e){if(!Number.isSafeInteger(n)||n<=0||n>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+n)}function Ot(n,e){ge(n,e);const t=Math.ceil(e/n)+1,r=2**(n-1),i=2**n,s=xt(n),c=BigInt(n);return{windows:t,windowSize:r,mask:s,maxNumber:i,shiftBy:c}}function Wt(n,e,t){const{windowSize:r,mask:i,maxNumber:s,shiftBy:c}=t;let f=Number(n&i),o=n>>c;f>r&&(f-=s,o+=zt);const l=e*r,g=l+Math.abs(f)-1,h=f===0,B=f<0,q=e%2!==0;return{nextN:o,offset:g,isZero:h,isNeg:B,isNegF:q,offsetF:l}}function Ke(n,e){if(!Array.isArray(n))throw new Error("array expected");n.forEach((t,r)=>{if(!(t instanceof e))throw new Error("invalid point at index "+r)})}function Pe(n,e){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((t,r)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+r)})}const qt=new WeakMap,pe=new WeakMap;function Ht(n){return pe.get(n)||1}function De(n,e){return{constTimeNegate:Nt,hasPrecomputes(t){return Ht(t)!==1},unsafeLadder(t,r,i=n.ZERO){let s=t;for(;r>Gt;)r&zt&&(i=i.add(s)),s=s.double(),r>>=zt;return i},precomputeWindow(t,r){const{windows:i,windowSize:s}=Ot(r,e),c=[];let f=t,o=f;for(let l=0;l<i;l++){o=f,c.push(o);for(let g=1;g<s;g++)o=o.add(f),c.push(o);f=o.double()}return c},wNAF(t,r,i){let s=n.ZERO,c=n.BASE;const f=Ot(t,e);for(let o=0;o<f.windows;o++){const{nextN:l,offset:g,isZero:h,isNeg:B,isNegF:q,offsetF:_}=Wt(i,o,f);i=l,h?c=c.add(Nt(q,r[_])):s=s.add(Nt(B,r[g]))}return{p:s,f:c}},wNAFUnsafe(t,r,i,s=n.ZERO){const c=Ot(t,e);for(let f=0;f<c.windows&&i!==Gt;f++){const{nextN:o,offset:l,isZero:g,isNeg:h}=Wt(i,f,c);if(i=o,!g){const B=r[l];s=s.add(h?B.negate():B)}}return s},getPrecomputes(t,r,i){let s=qt.get(r);return s||(s=this.precomputeWindow(r,t),t!==1&&qt.set(r,i(s))),s},wNAFCached(t,r,i){const s=Ht(t);return this.wNAF(s,this.getPrecomputes(s,t,i),r)},wNAFCachedUnsafe(t,r,i,s){const c=Ht(t);return c===1?this.unsafeLadder(t,r,s):this.wNAFUnsafe(c,this.getPrecomputes(c,t,i),r,s)},setWindowSize(t,r){ge(r,e),pe.set(t,r),qt.delete(t)}}}function Ge(n,e,t,r){Ke(t,n),Pe(r,e);const i=t.length,s=r.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");const c=n.ZERO,f=_e(BigInt(i));let o=1;f>12?o=f-3:f>4?o=f-2:f>0&&(o=2);const l=xt(o),g=new Array(Number(l)+1).fill(c),h=Math.floor((e.BITS-1)/o)*o;let B=c;for(let q=h;q>=0;q-=o){g.fill(c);for(let p=0;p<s;p++){const Z=r[p],R=Number(Z>>BigInt(q)&l);g[R]=g[R].add(t[p])}let _=c;for(let p=g.length-1,Z=c;p>0;p--)Z=Z.add(g[p]),_=_.add(Z);if(B=B.add(_),q!==0)for(let p=0;p<o;p++)B=B.double()}return B}function me(n){return Me(n.Fp),Et(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...de(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}function $t(n){n.lowS!==void 0&&lt("lowS",n.lowS),n.prehash!==void 0&&lt("prehash",n.prehash)}function We(n){const e=me(n);Et(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:t,Fp:r,a:i}=e;if(t){if(!r.eql(i,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class $e extends Error{constructor(e=""){super(e)}}const F={Err:$e,_tlv:{encode:(n,e)=>{const{Err:t}=F;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const r=e.length/2,i=gt(r);if(i.length/2&128)throw new t("tlv.encode: long form length too big");const s=r>127?gt(i.length/2|128):"";return gt(n)+s+i+e},decode(n,e){const{Err:t}=F;let r=0;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[r++]!==n)throw new t("tlv.decode: wrong tlv");const i=e[r++],s=!!(i&128);let c=0;if(!s)c=i;else{const o=i&127;if(!o)throw new t("tlv.decode(long): indefinite length not supported");if(o>4)throw new t("tlv.decode(long): byte length is too big");const l=e.subarray(r,r+o);if(l.length!==o)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const g of l)c=c<<8|g;if(r+=o,c<128)throw new t("tlv.decode(long): not minimal encoding")}const f=e.subarray(r,r+c);if(f.length!==c)throw new t("tlv.decode: wrong value length");return{v:f,l:e.subarray(r+c)}}},_int:{encode(n){const{Err:e}=F;if(n<X)throw new e("integer: negative integers are not allowed");let t=gt(n);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(n){const{Err:e}=F;if(n[0]&128)throw new e("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return ot(n)}},toSig(n){const{Err:e,_int:t,_tlv:r}=F,i=K("signature",n),{v:s,l:c}=r.decode(48,i);if(c.length)throw new e("invalid signature: left bytes after parsing");const{v:f,l:o}=r.decode(2,s),{v:l,l:g}=r.decode(2,o);if(g.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(f),s:t.decode(l)}},hexFromSig(n){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;return e.encode(48,s)}};function Lt(n,e){return dt(wt(n,e))}const X=BigInt(0),z=BigInt(1);BigInt(2);const Ut=BigInt(3),Fe=BigInt(4);function Xe(n){const e=We(n),{Fp:t}=e,r=Mt(e.n,e.nBitLength),i=e.toBytes||((A,a,w)=>{const b=a.toAffine();return yt(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),s=e.fromBytes||(A=>{const a=A.subarray(1),w=t.fromBytes(a.subarray(0,t.BYTES)),b=t.fromBytes(a.subarray(t.BYTES,2*t.BYTES));return{x:w,y:b}});function c(A){const{a,b:w}=e,b=t.sqr(A),v=t.mul(b,A);return t.add(t.add(v,t.mul(A,a)),w)}function f(A,a){const w=t.sqr(a),b=c(A);return t.eql(w,b)}if(!f(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const o=t.mul(t.pow(e.a,Ut),Fe),l=t.mul(t.sqr(e.b),BigInt(27));if(t.is0(t.add(o,l)))throw new Error("bad curve params: a or b");function g(A){return Vt(A,z,e.n)}function h(A){const{allowedPrivateKeyLengths:a,nByteLength:w,wrapPrivateKey:b,n:v}=e;if(a&&typeof A!="bigint"){if(ht(A)&&(A=dt(A)),typeof A!="string"||!a.includes(A.length))throw new Error("invalid private key");A=A.padStart(w*2,"0")}let O;try{O=typeof A=="bigint"?A:ot(K("private key",A,w))}catch{throw new Error("invalid private key, expected hex or "+w+" bytes, got "+typeof A)}return b&&(O=M(O,v)),ft("private key",O,z,v),O}function B(A){if(!(A instanceof p))throw new Error("ProjectivePoint expected")}const q=Pt((A,a)=>{const{px:w,py:b,pz:v}=A;if(t.eql(v,t.ONE))return{x:w,y:b};const O=A.is0();a==null&&(a=O?t.ONE:t.inv(v));const L=t.mul(w,a),H=t.mul(b,a),y=t.mul(v,a);if(O)return{x:t.ZERO,y:t.ZERO};if(!t.eql(y,t.ONE))throw new Error("invZ was invalid");return{x:L,y:H}}),_=Pt(A=>{if(A.is0()){if(e.allowInfinityPoint&&!t.is0(A.py))return;throw new Error("bad point: ZERO")}const{x:a,y:w}=A.toAffine();if(!t.isValid(a)||!t.isValid(w))throw new Error("bad point: x or y not FE");if(!f(a,w))throw new Error("bad point: equation left != right");if(!A.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(a,w,b){if(a==null||!t.isValid(a))throw new Error("x required");if(w==null||!t.isValid(w)||t.is0(w))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required");this.px=a,this.py=w,this.pz=b,Object.freeze(this)}static fromAffine(a){const{x:w,y:b}=a||{};if(!a||!t.isValid(w)||!t.isValid(b))throw new Error("invalid affine point");if(a instanceof p)throw new Error("projective point not allowed");const v=O=>t.eql(O,t.ZERO);return v(w)&&v(b)?p.ZERO:new p(w,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(a){const w=le(t,a.map(b=>b.pz));return a.map((b,v)=>b.toAffine(w[v])).map(p.fromAffine)}static fromHex(a){const w=p.fromAffine(s(K("pointHex",a)));return w.assertValidity(),w}static fromPrivateKey(a){return p.BASE.multiply(h(a))}static msm(a,w){return Ge(p,r,a,w)}_setWindowSize(a){D.setWindowSize(this,a)}assertValidity(){_(this)}hasEvenY(){const{y:a}=this.toAffine();if(t.isOdd)return!t.isOdd(a);throw new Error("Field doesn't support isOdd")}equals(a){B(a);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));return y&&N}negate(){return new p(this.px,t.neg(this.py),this.pz)}double(){const{a,b:w}=e,b=t.mul(w,Ut),{px:v,py:O,pz:L}=this;let H=t.ZERO,y=t.ZERO,N=t.ZERO,x=t.mul(v,v),T=t.mul(O,O),d=t.mul(L,L),u=t.mul(v,O);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(T,y),y=t.add(T,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,T),N=t.add(N,N),N=t.add(N,N),new p(H,y,N)}add(a){B(a);const{px:w,py:b,pz:v}=this,{px:O,py:L,pz:H}=a;let y=t.ZERO,N=t.ZERO,x=t.ZERO;const T=e.a,d=t.mul(e.b,Ut);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);E=t.mul(E,S),S=t.add(u,m),E=t.sub(E,S),S=t.add(w,v);let U=t.add(O,H);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(T,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(T,I),S=t.mul(d,S),m=t.add(m,I),I=t.sub(u,I),I=t.mul(T,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)}subtract(a){return this.add(a.negate())}is0(){return this.equals(p.ZERO)}wNAF(a){return D.wNAFCached(this,a,p.normalizeZ)}multiplyUnsafe(a){const{endo:w,n:b}=e;ft("scalar",a,X,b);const v=p.ZERO;if(a===X)return v;if(this.is0()||a===z)return this;if(!w||D.hasPrecomputes(this))return D.wNAFCachedUnsafe(this,a,p.normalizeZ);let{k1neg:O,k1:L,k2neg:H,k2:y}=w.splitScalar(a),N=v,x=v,T=this;for(;L>X||y>X;)L&z&&(N=N.add(T)),y&z&&(x=x.add(T)),T=T.double(),L>>=z,y>>=z;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)}multiply(a){const{endo:w,n:b}=e;ft("scalar",a,z,b);let v,O;if(w){const{k1neg:L,k1:H,k2neg:y,k2:N}=w.splitScalar(a);let{p:x,f:T}=this.wNAF(H),{p:d,f:u}=this.wNAF(N);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=T.add(u)}else{const{p:L,f:H}=this.wNAF(a);v=L,O=H}return p.normalizeZ([v,O])[0]}multiplyAndAddUnsafe(a,w,b){const v=p.BASE,O=(H,y)=>y===X||y===z||!H.equals(v)?H.multiplyUnsafe(y):H.multiply(y),L=O(this,w).add(O(a,b));return L.is0()?void 0:L}toAffine(a){return q(this,a)}isTorsionFree(){const{h:a,isTorsionFree:w}=e;if(a===z)return!0;if(w)return w(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:a,clearCofactor:w}=e;return a===z?this:w?w(p,this):this.multiplyUnsafe(e.h)}toRawBytes(a=!0){return lt("isCompressed",a),this.assertValidity(),i(p,this,a)}toHex(a=!0){return lt("isCompressed",a),dt(this.toRawBytes(a))}}p.BASE=new p(e.Gx,e.Gy,t.ONE),p.ZERO=new p(t.ZERO,t.ONE,t.ZERO);const{endo:Z,nBitLength:R}=e,D=De(p,Z?Math.ceil(R/2):R);return{CURVE:e,ProjectivePoint:p,normPrivateKeyToScalar:h,weierstrassEquation:c,isWithinCurveOrder:g}}function Qe(n){const e=me(n);return Et(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Je(n){const e=Qe(n),{Fp:t,n:r,nByteLength:i,nBitLength:s}=e,c=t.BYTES+1,f=2*t.BYTES+1;function o(d){return M(d,r)}function l(d){return Rt(d,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:h,weierstrassEquation:B,isWithinCurveOrder:q}=Xe({...e,toBytes(d,u,m){const I=u.toAffine(),E=t.toBytes(I.x),S=yt;return lt("isCompressed",m),m?S(Uint8Array.from([u.hasEvenY()?2:3]),E):S(Uint8Array.from([4]),E,t.toBytes(I.y))},fromBytes(d){const u=d.length,m=d[0],I=d.subarray(1);if(u===c&&(m===2||m===3)){const E=ot(I);if(!Vt(E,z,t.ORDER))throw new Error("Point is not on curve");const S=B(E);let U;try{U=t.sqrt(S)}catch(P){const V=P instanceof Error?": "+P.message:"";throw new Error("Point is not on curve"+V)}const k=(U&z)===z;return(m&1)===1!==k&&(U=t.neg(U)),{x:E,y:U}}else if(u===f&&m===4){const E=t.fromBytes(I.subarray(0,t.BYTES)),S=t.fromBytes(I.subarray(t.BYTES,2*t.BYTES));return{x:E,y:S}}else{const E=c,S=f;throw new Error("invalid Point, expected length of "+E+", or uncompressed "+S+", got "+u)}}});function _(d){const u=r>>z;return d>u}function p(d){return _(d)?o(-d):d}const Z=(d,u,m)=>ot(d.slice(u,m));class R{constructor(u,m,I){ft("r",u,z,r),ft("s",m,z,r),this.r=u,this.s=m,I!=null&&(this.recovery=I),Object.freeze(this)}static fromCompact(u){const m=i;return u=K("compactSignature",u,m*2),new R(Z(u,0,m),Z(u,m,2*m))}static fromDER(u){const{r:m,s:I}=F.toSig(K("DER",u));return new R(m,I)}assertValidity(){}addRecoveryBit(u){return new R(this.r,this.s,u)}recoverPublicKey(u){const{r:m,s:I,recovery:E}=this,S=v(K("msgHash",u));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");const U=E===2||E===3?m+e.n:m;if(U>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const k=(E&1)===0?"02":"03",W=g.fromHex(k+Lt(U,t.BYTES)),P=l(U),V=o(-S*P),it=o(I*P),Q=g.BASE.multiplyAndAddUnsafe(W,V,it);if(!Q)throw new Error("point at infinify");return Q.assertValidity(),Q}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new R(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return bt(this.toDERHex())}toDERHex(){return F.hexFromSig(this)}toCompactRawBytes(){return bt(this.toCompactHex())}toCompactHex(){const u=i;return Lt(this.r,u)+Lt(this.s,u)}}const D={isValidPrivateKey(d){try{return h(d),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const d=we(e.n);return Ye(e.randomBytes(d),e.n)},precompute(d=8,u=g.BASE){return u._setWindowSize(d),u.multiply(BigInt(3)),u}};function A(d,u=!0){return g.fromPrivateKey(d).toRawBytes(u)}function a(d){if(typeof d=="bigint")return!1;if(d instanceof g)return!0;const m=K("key",d).length,I=t.BYTES,E=I+1,S=2*I+1;if(!(e.allowedPrivateKeyLengths||i===E))return m===E||m===S}function w(d,u,m=!0){if(a(d)===!0)throw new Error("first arg must be private key");if(a(u)===!1)throw new Error("second arg must be public key");return g.fromHex(u).multiply(h(d)).toRawBytes(m)}const b=e.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");const u=ot(d),m=d.length*8-s;return m>0?u>>BigInt(m):u},v=e.bits2int_modN||function(d){return o(b(d))},O=xt(s);function L(d){return ft("num < 2^"+s,d,X,O),wt(d,i)}function H(d,u,m=y){if(["recovered","canonical"].some(et=>et in m))throw new Error("sign() legacy options not supported");const{hash:I,randomBytes:E}=e;let{lowS:S,prehash:U,extraEntropy:k}=m;S==null&&(S=!0),d=K("msgHash",d),$t(m),U&&(d=K("prehashed msgHash",I(d)));const W=v(d),P=h(u),V=[L(P),L(W)];if(k!=null&&k!==!1){const et=k===!0?E(t.BYTES):k;V.push(K("extraEntropy",et))}const it=yt(...V),Q=W;function Bt(et){const st=b(et);if(!q(st))return;const vt=l(st),at=g.BASE.multiply(st).toAffine(),nt=o(at.x);if(nt===X)return;const ut=o(vt*o(Q+nt*P));if(ut===X)return;let ct=(at.x===nt?0:2)|Number(at.y&z),jt=ut;return S&&_(ut)&&(jt=p(ut),ct^=1),new R(nt,jt,ct)}return{seed:it,k2sig:Bt}}const y={lowS:e.lowS,prehash:!1},N={lowS:e.lowS,prehash:!1};function x(d,u,m=y){const{seed:I,k2sig:E}=H(d,u,m),S=e;return Re(S.hash.outputLen,S.nByteLength,S.hmac)(I,E)}g.BASE._setWindowSize(8);function T(d,u,m,I=N){const E=d;u=K("msgHash",u),m=K("publicKey",m);const{lowS:S,prehash:U,format:k}=I;if($t(I),"strict"in I)throw new Error("options.strict was renamed to lowS");if(k!==void 0&&k!=="compact"&&k!=="der")throw new Error("format must be compact or der");const W=typeof E=="string"||ht(E),P=!W&&!k&&typeof E=="object"&&E!==null&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!W&&!P)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let V,it;try{if(P&&(V=new R(E.r,E.s)),W){try{k!=="compact"&&(V=R.fromDER(E))}catch(ct){if(!(ct instanceof F.Err))throw ct}!V&&k!=="der"&&(V=R.fromCompact(E))}it=g.fromHex(m)}catch{return!1}if(!V||S&&V.hasHighS())return!1;U&&(u=e.hash(u));const{r:Q,s:Bt}=V,et=v(u),st=l(Bt),vt=o(et*st),at=o(Q*st),nt=g.BASE.multiplyAndAddUnsafe(it,vt,at)?.toAffine();return nt?o(nt.x)===Q:!1}return{CURVE:e,getPublicKey:A,getSharedSecret:w,sign:x,verify:T,ProjectivePoint:g,Signature:R,utils:D}}function tn(n){return{hash:n,hmac:(e,...t)=>ne(n,e,Se(...t)),randomBytes:ve}}function en(n,e){const t=r=>Je({...n,...tn(r)});return{...t(e),create:t}}const be=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ft=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),nn=BigInt(0),rn=BigInt(1),Tt=BigInt(2),Xt=(n,e)=>(n+e/Tt)/e;function on(n){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,Tt,e)*l%e,_=Y(q,i,e)*q%e,p=Y(_,s,e)*_%e,Z=Y(p,f,e)*p%e,R=Y(Z,o,e)*Z%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,Tt,e);if(!Zt.eql(Zt.sqr(b),n))throw new Error("Cannot find square root");return b}const Zt=Mt(be,void 0,void 0,{sqrt:on}),bn=en({a:nn,b:BigInt(7),Fp:Zt,n:Ft,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{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);let l=M(n-f*t-o*i,e),g=M(-f*r-o*s,e);const h=l>c,B=g>c;if(h&&(l=e-l),B&&(g=e-g),l>c||g>c)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:h,k1:l,k2neg:B,k2:g}}}},Le);export{bn as secp256k1};
@@ -1 +1 @@
1
- import{e as Ft,r as Jt,f as te,s as ee}from"./sha2-D3ryOfi3.js";import{h as ne}from"./hmac-BMnSt9Ou.js";import{bj as kt,bk as tt,bl as Ct,bm as at,bn as lt,bo as ut,bp as re,bq as Et,br as ot,bs as K,bt as It,bu as jt,bv as oe,bw as ct,bx as Bt,by as Mt,bz as ft,bA as At}from"./parseEventLogs-D1xiFnCH.js";const H=BigInt(0),M=BigInt(1),J=BigInt(2),ie=BigInt(3),Vt=BigInt(4),Yt=BigInt(5),Ht=BigInt(8);function Y(n,e){const t=n%e;return t>=H?t:e+t}function U(n,e,t){let o=n;for(;e-- >H;)o*=o,o%=t;return o}function vt(n,e){if(n===H)throw new Error("invert: expected non-zero number");if(e<=H)throw new Error("invert: expected positive modulus, got "+e);let t=Y(n,e),o=e,c=H,f=M;for(;t!==H;){const d=o/t,r=o%t,u=c-f*d;o=t,t=r,c=f,f=u}if(o!==M)throw new Error("invert: does not exist");return Y(c,e)}function Ut(n,e){const t=(n.ORDER+M)/Vt,o=n.pow(e,t);if(!n.eql(n.sqr(o),e))throw new Error("Cannot find square root");return o}function se(n,e){const t=(n.ORDER-Yt)/Ht,o=n.mul(e,J),c=n.pow(o,t),f=n.mul(e,c),l=n.mul(n.mul(f,J),c),d=n.mul(f,n.sub(l,n.ONE));if(!n.eql(n.sqr(d),e))throw new Error("Cannot find square root");return d}function ce(n){if(n<BigInt(3))throw new Error("sqrt is not defined for small field");let e=n-M,t=0;for(;e%J===H;)e/=J,t++;let o=J;const c=qt(n);for(;Rt(c,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return Ut;let f=c.pow(o,e);const l=(e+M)/J;return function(r,u){if(r.is0(u))return u;if(Rt(r,u)!==1)throw new Error("Cannot find square root");let m=t,z=r.mul(r.ONE,f),I=r.pow(u,e),T=r.pow(u,l);for(;!r.eql(I,r.ONE);){if(r.is0(I))return r.ZERO;let Z=1,g=r.sqr(I);for(;!r.eql(g,r.ONE);)if(Z++,g=r.sqr(g),Z===m)throw new Error("Cannot find square root");const C=M<<BigInt(m-Z-1),L=r.pow(z,C);m=Z,z=r.sqr(L),I=r.mul(I,z),T=r.mul(T,L)}return T}}function fe(n){return n%Vt===ie?Ut:n%Ht===Yt?se:ce(n)}const ae=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function le(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=ae.reduce((o,c)=>(o[c]="function",o),e);return ut(n,t)}function ue(n,e,t){if(t<H)throw new Error("invalid exponent, negatives unsupported");if(t===H)return n.ONE;if(t===M)return e;let o=n.ONE,c=e;for(;t>H;)t&M&&(o=n.mul(o,c)),c=n.sqr(c),t>>=M;return o}function Kt(n,e,t=!1){const o=new Array(e.length).fill(t?n.ZERO:void 0),c=e.reduce((l,d,r)=>n.is0(d)?l:(o[r]=l,n.mul(l,d)),n.ONE),f=n.inv(c);return e.reduceRight((l,d,r)=>n.is0(d)?l:(o[r]=n.mul(l,o[r]),n.mul(l,d)),f),o}function Rt(n,e){const t=(n.ORDER-M)/J,o=n.pow(e,t),c=n.eql(o,n.ONE),f=n.eql(o,n.ZERO),l=n.eql(o,n.neg(n.ONE));if(!c&&!f&&!l)throw new Error("invalid Legendre symbol result");return c?1:f?0:-1}function Pt(n,e){e!==void 0&&Ft(e);const t=e!==void 0?e:n.toString(2).length,o=Math.ceil(t/8);return{nBitLength:t,nByteLength:o}}function qt(n,e,t=!1,o={}){if(n<=H)throw new Error("invalid field: expected ORDER > 0, got "+n);const{nBitLength:c,nByteLength:f}=Pt(n,e);if(f>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const d=Object.freeze({ORDER:n,isLE:t,BITS:c,BYTES:f,MASK:lt(c),ZERO:H,ONE:M,create:r=>Y(r,n),isValid:r=>{if(typeof r!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof r);return H<=r&&r<n},is0:r=>r===H,isOdd:r=>(r&M)===M,neg:r=>Y(-r,n),eql:(r,u)=>r===u,sqr:r=>Y(r*r,n),add:(r,u)=>Y(r+u,n),sub:(r,u)=>Y(r-u,n),mul:(r,u)=>Y(r*u,n),pow:(r,u)=>ue(d,r,u),div:(r,u)=>Y(r*vt(u,n),n),sqrN:r=>r*r,addN:(r,u)=>r+u,subN:(r,u)=>r-u,mulN:(r,u)=>r*u,inv:r=>vt(r,n),sqrt:o.sqrt||(r=>(l||(l=fe(n)),l(d,r))),toBytes:r=>t?Ct(r,f):at(r,f),fromBytes:r=>{if(r.length!==f)throw new Error("Field.fromBytes: expected "+f+" bytes, got "+r.length);return t?kt(r):tt(r)},invertBatch:r=>Kt(d,r),cmov:(r,u,m)=>m?u:r});return Object.freeze(d)}function $t(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function Dt(n){const e=$t(n);return e+Math.ceil(e/2)}function de(n,e,t=!1){const o=n.length,c=$t(e),f=Dt(e);if(o<16||o<f||o>1024)throw new Error("expected "+f+"-1024 bytes of input, got "+o);const l=t?kt(n):tt(n),d=Y(l,e-M)+M;return t?Ct(d,c):at(d,c)}const zt=BigInt(0),xt=BigInt(1);function wt(n,e){const t=e.negate();return n?t:e}function Gt(n,e){if(!Number.isSafeInteger(n)||n<=0||n>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+n)}function gt(n,e){Gt(n,e);const t=Math.ceil(e/n)+1,o=2**(n-1),c=2**n,f=lt(n),l=BigInt(n);return{windows:t,windowSize:o,mask:f,maxNumber:c,shiftBy:l}}function Zt(n,e,t){const{windowSize:o,mask:c,maxNumber:f,shiftBy:l}=t;let d=Number(n&c),r=n>>l;d>o&&(d-=f,r+=xt);const u=e*o,m=u+Math.abs(d)-1,z=d===0,I=d<0,T=e%2!==0;return{nextN:r,offset:m,isZero:z,isNeg:I,isNegF:T,offsetF:u}}function he(n,e){if(!Array.isArray(n))throw new Error("array expected");n.forEach((t,o)=>{if(!(t instanceof e))throw new Error("invalid point at index "+o)})}function we(n,e){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((t,o)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+o)})}const mt=new WeakMap,Wt=new WeakMap;function bt(n){return Wt.get(n)||1}function ge(n,e){return{constTimeNegate:wt,hasPrecomputes(t){return bt(t)!==1},unsafeLadder(t,o,c=n.ZERO){let f=t;for(;o>zt;)o&xt&&(c=c.add(f)),f=f.double(),o>>=xt;return c},precomputeWindow(t,o){const{windows:c,windowSize:f}=gt(o,e),l=[];let d=t,r=d;for(let u=0;u<c;u++){r=d,l.push(r);for(let m=1;m<f;m++)r=r.add(d),l.push(r);d=r.double()}return l},wNAF(t,o,c){let f=n.ZERO,l=n.BASE;const d=gt(t,e);for(let r=0;r<d.windows;r++){const{nextN:u,offset:m,isZero:z,isNeg:I,isNegF:T,offsetF:Z}=Zt(c,r,d);c=u,z?l=l.add(wt(T,o[Z])):f=f.add(wt(I,o[m]))}return{p:f,f:l}},wNAFUnsafe(t,o,c,f=n.ZERO){const l=gt(t,e);for(let d=0;d<l.windows&&c!==zt;d++){const{nextN:r,offset:u,isZero:m,isNeg:z}=Zt(c,d,l);if(c=r,!m){const I=o[u];f=f.add(z?I.negate():I)}}return f},getPrecomputes(t,o,c){let f=mt.get(o);return f||(f=this.precomputeWindow(o,t),t!==1&&mt.set(o,c(f))),f},wNAFCached(t,o,c){const f=bt(t);return this.wNAF(f,this.getPrecomputes(f,t,c),o)},wNAFCachedUnsafe(t,o,c,f){const l=bt(t);return l===1?this.unsafeLadder(t,o,f):this.wNAFUnsafe(l,this.getPrecomputes(l,t,c),o,f)},setWindowSize(t,o){Gt(o,e),Wt.set(t,o),mt.delete(t)}}}function me(n,e,t,o){he(t,n),we(o,e);const c=t.length,f=o.length;if(c!==f)throw new Error("arrays of points and scalars must have equal length");const l=n.ZERO,d=re(BigInt(c));let r=1;d>12?r=d-3:d>4?r=d-2:d>0&&(r=2);const u=lt(r),m=new Array(Number(u)+1).fill(l),z=Math.floor((e.BITS-1)/r)*r;let I=l;for(let T=z;T>=0;T-=r){m.fill(l);for(let g=0;g<f;g++){const C=o[g],L=Number(C>>BigInt(T)&u);m[L]=m[L].add(t[g])}let Z=l;for(let g=m.length-1,C=l;g>0;g--)C=C.add(m[g]),Z=Z.add(C);if(I=I.add(Z),T!==0)for(let g=0;g<r;g++)I=I.double()}return I}function Xt(n){return le(n.Fp),ut(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Pt(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}function Lt(n){n.lowS!==void 0&&ct("lowS",n.lowS),n.prehash!==void 0&&ct("prehash",n.prehash)}function be(n){const e=Xt(n);ut(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:t,Fp:o,a:c}=e;if(t){if(!o.eql(c,o.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class pe extends Error{constructor(e=""){super(e)}}const G={Err:pe,_tlv:{encode:(n,e)=>{const{Err:t}=G;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const o=e.length/2,c=ft(o);if(c.length/2&128)throw new t("tlv.encode: long form length too big");const f=o>127?ft(c.length/2|128):"";return ft(n)+f+c+e},decode(n,e){const{Err:t}=G;let o=0;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[o++]!==n)throw new t("tlv.decode: wrong tlv");const c=e[o++],f=!!(c&128);let l=0;if(!f)l=c;else{const r=c&127;if(!r)throw new t("tlv.decode(long): indefinite length not supported");if(r>4)throw new t("tlv.decode(long): byte length is too big");const u=e.subarray(o,o+r);if(u.length!==r)throw new t("tlv.decode: length bytes not complete");if(u[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const m of u)l=l<<8|m;if(o+=r,l<128)throw new t("tlv.decode(long): not minimal encoding")}const d=e.subarray(o,o+l);if(d.length!==l)throw new t("tlv.decode: wrong value length");return{v:d,l:e.subarray(o+l)}}},_int:{encode(n){const{Err:e}=G;if(n<W)throw new e("integer: negative integers are not allowed");let t=ft(n);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(n){const{Err:e}=G;if(n[0]&128)throw new e("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return tt(n)}},toSig(n){const{Err:e,_int:t,_tlv:o}=G,c=K("signature",n),{v:f,l}=o.decode(48,c);if(l.length)throw new e("invalid signature: left bytes after parsing");const{v:d,l:r}=o.decode(2,f),{v:u,l:m}=o.decode(2,r);if(m.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(d),s:t.decode(u)}},hexFromSig(n){const{_tlv:e,_int:t}=G,o=e.encode(2,t.encode(n.r)),c=e.encode(2,t.encode(n.s)),f=o+c;return e.encode(48,f)}};function pt(n,e){return Bt(at(n,e))}const W=BigInt(0),_=BigInt(1);BigInt(2);const yt=BigInt(3),ye=BigInt(4);function Ee(n){const e=be(n),{Fp:t}=e,o=qt(e.n,e.nBitLength),c=e.toBytes||((x,i,h)=>{const b=i.toAffine();return Et(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),f=e.fromBytes||(x=>{const i=x.subarray(1),h=t.fromBytes(i.subarray(0,t.BYTES)),b=t.fromBytes(i.subarray(t.BYTES,2*t.BYTES));return{x:h,y:b}});function l(x){const{a:i,b:h}=e,b=t.sqr(x),B=t.mul(b,x);return t.add(t.add(B,t.mul(x,i)),h)}function d(x,i){const h=t.sqr(i),b=l(x);return t.eql(h,b)}if(!d(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const r=t.mul(t.pow(e.a,yt),ye),u=t.mul(t.sqr(e.b),BigInt(27));if(t.is0(t.add(r,u)))throw new Error("bad curve params: a or b");function m(x){return Mt(x,_,e.n)}function z(x){const{allowedPrivateKeyLengths:i,nByteLength:h,wrapPrivateKey:b,n:B}=e;if(i&&typeof x!="bigint"){if(jt(x)&&(x=Bt(x)),typeof x!="string"||!i.includes(x.length))throw new Error("invalid private key");x=x.padStart(h*2,"0")}let q;try{q=typeof x=="bigint"?x:tt(K("private key",x,h))}catch{throw new Error("invalid private key, expected hex or "+h+" bytes, got "+typeof x)}return b&&(q=Y(q,B)),ot("private key",q,_,B),q}function I(x){if(!(x instanceof g))throw new Error("ProjectivePoint expected")}const T=At((x,i)=>{const{px:h,py:b,pz:B}=x;if(t.eql(B,t.ONE))return{x:h,y:b};const q=x.is0();i==null&&(i=q?t.ONE:t.inv(B));const A=t.mul(h,i),O=t.mul(b,i),p=t.mul(B,i);if(q)return{x:t.ZERO,y:t.ZERO};if(!t.eql(p,t.ONE))throw new Error("invZ was invalid");return{x:A,y:O}}),Z=At(x=>{if(x.is0()){if(e.allowInfinityPoint&&!t.is0(x.py))return;throw new Error("bad point: ZERO")}const{x:i,y:h}=x.toAffine();if(!t.isValid(i)||!t.isValid(h))throw new Error("bad point: x or y not FE");if(!d(i,h))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(i,h,b){if(i==null||!t.isValid(i))throw new Error("x required");if(h==null||!t.isValid(h)||t.is0(h))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required");this.px=i,this.py=h,this.pz=b,Object.freeze(this)}static fromAffine(i){const{x:h,y:b}=i||{};if(!i||!t.isValid(h)||!t.isValid(b))throw new Error("invalid affine point");if(i instanceof g)throw new Error("projective point not allowed");const B=q=>t.eql(q,t.ZERO);return B(h)&&B(b)?g.ZERO:new g(h,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(i){const h=Kt(t,i.map(b=>b.pz));return i.map((b,B)=>b.toAffine(h[B])).map(g.fromAffine)}static fromHex(i){const h=g.fromAffine(f(K("pointHex",i)));return h.assertValidity(),h}static fromPrivateKey(i){return g.BASE.multiply(z(i))}static msm(i,h){return me(g,o,i,h)}_setWindowSize(i){$.setWindowSize(this,i)}assertValidity(){Z(this)}hasEvenY(){const{y:i}=this.toAffine();if(t.isOdd)return!t.isOdd(i);throw new Error("Field doesn't support isOdd")}equals(i){I(i);const{px:h,py:b,pz:B}=this,{px:q,py:A,pz:O}=i,p=t.eql(t.mul(h,O),t.mul(q,B)),N=t.eql(t.mul(b,O),t.mul(A,B));return p&&N}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){const{a:i,b:h}=e,b=t.mul(h,yt),{px:B,py:q,pz:A}=this;let O=t.ZERO,p=t.ZERO,N=t.ZERO,y=t.mul(B,B),k=t.mul(q,q),a=t.mul(A,A),s=t.mul(B,q);return s=t.add(s,s),N=t.mul(B,A),N=t.add(N,N),O=t.mul(i,N),p=t.mul(b,a),p=t.add(O,p),O=t.sub(k,p),p=t.add(k,p),p=t.mul(O,p),O=t.mul(s,O),N=t.mul(b,N),a=t.mul(i,a),s=t.sub(y,a),s=t.mul(i,s),s=t.add(s,N),N=t.add(y,y),y=t.add(N,y),y=t.add(y,a),y=t.mul(y,s),p=t.add(p,y),a=t.mul(q,A),a=t.add(a,a),y=t.mul(a,s),O=t.sub(O,y),N=t.mul(a,k),N=t.add(N,N),N=t.add(N,N),new g(O,p,N)}add(i){I(i);const{px:h,py:b,pz:B}=this,{px:q,py:A,pz:O}=i;let p=t.ZERO,N=t.ZERO,y=t.ZERO;const k=e.a,a=t.mul(e.b,yt);let s=t.mul(h,q),w=t.mul(b,A),S=t.mul(B,O),E=t.add(h,b),v=t.add(q,A);E=t.mul(E,v),v=t.add(s,w),E=t.sub(E,v),v=t.add(h,B);let R=t.add(q,O);return v=t.mul(v,R),R=t.add(s,S),v=t.sub(v,R),R=t.add(b,B),p=t.add(A,O),R=t.mul(R,p),p=t.add(w,S),R=t.sub(R,p),y=t.mul(k,v),p=t.mul(a,S),y=t.add(p,y),p=t.sub(w,y),y=t.add(w,y),N=t.mul(p,y),w=t.add(s,s),w=t.add(w,s),S=t.mul(k,S),v=t.mul(a,v),w=t.add(w,S),S=t.sub(s,S),S=t.mul(k,S),v=t.add(v,S),s=t.mul(w,v),N=t.add(N,s),s=t.mul(R,v),p=t.mul(E,p),p=t.sub(p,s),s=t.mul(E,w),y=t.mul(R,y),y=t.add(y,s),new g(p,N,y)}subtract(i){return this.add(i.negate())}is0(){return this.equals(g.ZERO)}wNAF(i){return $.wNAFCached(this,i,g.normalizeZ)}multiplyUnsafe(i){const{endo:h,n:b}=e;ot("scalar",i,W,b);const B=g.ZERO;if(i===W)return B;if(this.is0()||i===_)return this;if(!h||$.hasPrecomputes(this))return $.wNAFCachedUnsafe(this,i,g.normalizeZ);let{k1neg:q,k1:A,k2neg:O,k2:p}=h.splitScalar(i),N=B,y=B,k=this;for(;A>W||p>W;)A&_&&(N=N.add(k)),p&_&&(y=y.add(k)),k=k.double(),A>>=_,p>>=_;return q&&(N=N.negate()),O&&(y=y.negate()),y=new g(t.mul(y.px,h.beta),y.py,y.pz),N.add(y)}multiply(i){const{endo:h,n:b}=e;ot("scalar",i,_,b);let B,q;if(h){const{k1neg:A,k1:O,k2neg:p,k2:N}=h.splitScalar(i);let{p:y,f:k}=this.wNAF(O),{p:a,f:s}=this.wNAF(N);y=$.constTimeNegate(A,y),a=$.constTimeNegate(p,a),a=new g(t.mul(a.px,h.beta),a.py,a.pz),B=y.add(a),q=k.add(s)}else{const{p:A,f:O}=this.wNAF(i);B=A,q=O}return g.normalizeZ([B,q])[0]}multiplyAndAddUnsafe(i,h,b){const B=g.BASE,q=(O,p)=>p===W||p===_||!O.equals(B)?O.multiplyUnsafe(p):O.multiply(p),A=q(this,h).add(q(i,b));return A.is0()?void 0:A}toAffine(i){return T(this,i)}isTorsionFree(){const{h:i,isTorsionFree:h}=e;if(i===_)return!0;if(h)return h(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:i,clearCofactor:h}=e;return i===_?this:h?h(g,this):this.multiplyUnsafe(e.h)}toRawBytes(i=!0){return ct("isCompressed",i),this.assertValidity(),c(g,this,i)}toHex(i=!0){return ct("isCompressed",i),Bt(this.toRawBytes(i))}}g.BASE=new g(e.Gx,e.Gy,t.ONE),g.ZERO=new g(t.ZERO,t.ONE,t.ZERO);const{endo:C,nBitLength:L}=e,$=ge(g,C?Math.ceil(L/2):L);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:z,weierstrassEquation:l,isWithinCurveOrder:m}}function Be(n){const e=Xt(n);return ut(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ve(n){const e=Be(n),{Fp:t,n:o,nByteLength:c,nBitLength:f}=e,l=t.BYTES+1,d=2*t.BYTES+1;function r(a){return Y(a,o)}function u(a){return vt(a,o)}const{ProjectivePoint:m,normPrivateKeyToScalar:z,weierstrassEquation:I,isWithinCurveOrder:T}=Ee({...e,toBytes(a,s,w){const S=s.toAffine(),E=t.toBytes(S.x),v=Et;return ct("isCompressed",w),w?v(Uint8Array.from([s.hasEvenY()?2:3]),E):v(Uint8Array.from([4]),E,t.toBytes(S.y))},fromBytes(a){const s=a.length,w=a[0],S=a.subarray(1);if(s===l&&(w===2||w===3)){const E=tt(S);if(!Mt(E,_,t.ORDER))throw new Error("Point is not on curve");const v=I(E);let R;try{R=t.sqrt(v)}catch(P){const V=P instanceof Error?": "+P.message:"";throw new Error("Point is not on curve"+V)}const j=(R&_)===_;return(w&1)===1!==j&&(R=t.neg(R)),{x:E,y:R}}else if(s===d&&w===4){const E=t.fromBytes(S.subarray(0,t.BYTES)),v=t.fromBytes(S.subarray(t.BYTES,2*t.BYTES));return{x:E,y:v}}else{const E=l,v=d;throw new Error("invalid Point, expected length of "+E+", or uncompressed "+v+", got "+s)}}});function Z(a){const s=o>>_;return a>s}function g(a){return Z(a)?r(-a):a}const C=(a,s,w)=>tt(a.slice(s,w));class L{constructor(s,w,S){ot("r",s,_,o),ot("s",w,_,o),this.r=s,this.s=w,S!=null&&(this.recovery=S),Object.freeze(this)}static fromCompact(s){const w=c;return s=K("compactSignature",s,w*2),new L(C(s,0,w),C(s,w,2*w))}static fromDER(s){const{r:w,s:S}=G.toSig(K("DER",s));return new L(w,S)}assertValidity(){}addRecoveryBit(s){return new L(this.r,this.s,s)}recoverPublicKey(s){const{r:w,s:S,recovery:E}=this,v=B(K("msgHash",s));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");const R=E===2||E===3?w+e.n:w;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const j=(E&1)===0?"02":"03",D=m.fromHex(j+pt(R,t.BYTES)),P=u(R),V=r(-v*P),et=r(S*P),X=m.BASE.multiplyAndAddUnsafe(D,V,et);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return Z(this.s)}normalizeS(){return this.hasHighS()?new L(this.r,r(-this.s),this.recovery):this}toDERRawBytes(){return It(this.toDERHex())}toDERHex(){return G.hexFromSig(this)}toCompactRawBytes(){return It(this.toCompactHex())}toCompactHex(){const s=c;return pt(this.r,s)+pt(this.s,s)}}const $={isValidPrivateKey(a){try{return z(a),!0}catch{return!1}},normPrivateKeyToScalar:z,randomPrivateKey:()=>{const a=Dt(e.n);return de(e.randomBytes(a),e.n)},precompute(a=8,s=m.BASE){return s._setWindowSize(a),s.multiply(BigInt(3)),s}};function x(a,s=!0){return m.fromPrivateKey(a).toRawBytes(s)}function i(a){if(typeof a=="bigint")return!1;if(a instanceof m)return!0;const w=K("key",a).length,S=t.BYTES,E=S+1,v=2*S+1;if(!(e.allowedPrivateKeyLengths||c===E))return w===E||w===v}function h(a,s,w=!0){if(i(a)===!0)throw new Error("first arg must be private key");if(i(s)===!1)throw new Error("second arg must be public key");return m.fromHex(s).multiply(z(a)).toRawBytes(w)}const b=e.bits2int||function(a){if(a.length>8192)throw new Error("input is too large");const s=tt(a),w=a.length*8-f;return w>0?s>>BigInt(w):s},B=e.bits2int_modN||function(a){return r(b(a))},q=lt(f);function A(a){return ot("num < 2^"+f,a,W,q),at(a,c)}function O(a,s,w=p){if(["recovered","canonical"].some(Q=>Q in w))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:E}=e;let{lowS:v,prehash:R,extraEntropy:j}=w;v==null&&(v=!0),a=K("msgHash",a),Lt(w),R&&(a=K("prehashed msgHash",S(a)));const D=B(a),P=z(s),V=[A(P),A(D)];if(j!=null&&j!==!1){const Q=j===!0?E(t.BYTES):j;V.push(K("extraEntropy",Q))}const et=Et(...V),X=D;function dt(Q){const nt=b(Q);if(!T(nt))return;const ht=u(nt),it=m.BASE.multiply(nt).toAffine(),F=r(it.x);if(F===W)return;const st=r(ht*r(X+F*P));if(st===W)return;let rt=(it.x===F?0:2)|Number(it.y&_),Ot=st;return v&&Z(st)&&(Ot=g(st),rt^=1),new L(F,Ot,rt)}return{seed:et,k2sig:dt}}const p={lowS:e.lowS,prehash:!1},N={lowS:e.lowS,prehash:!1};function y(a,s,w=p){const{seed:S,k2sig:E}=O(a,s,w),v=e;return oe(v.hash.outputLen,v.nByteLength,v.hmac)(S,E)}m.BASE._setWindowSize(8);function k(a,s,w,S=N){const E=a;s=K("msgHash",s),w=K("publicKey",w);const{lowS:v,prehash:R,format:j}=S;if(Lt(S),"strict"in S)throw new Error("options.strict was renamed to lowS");if(j!==void 0&&j!=="compact"&&j!=="der")throw new Error("format must be compact or der");const D=typeof E=="string"||jt(E),P=!D&&!j&&typeof E=="object"&&E!==null&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!D&&!P)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let V,et;try{if(P&&(V=new L(E.r,E.s)),D){try{j!=="compact"&&(V=L.fromDER(E))}catch(rt){if(!(rt instanceof G.Err))throw rt}!V&&j!=="der"&&(V=L.fromCompact(E))}et=m.fromHex(w)}catch{return!1}if(!V||v&&V.hasHighS())return!1;R&&(s=e.hash(s));const{r:X,s:dt}=V,Q=B(s),nt=u(dt),ht=r(Q*nt),it=r(X*nt),F=m.BASE.multiplyAndAddUnsafe(et,ht,it)?.toAffine();return F?r(F.x)===X:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:h,sign:y,verify:k,ProjectivePoint:m,Signature:L,utils:$}}function xe(n){return{hash:n,hmac:(e,...t)=>ne(n,e,te(...t)),randomBytes:Jt}}function Se(n,e){const t=o=>ve({...n,...xe(o)});return{...t(e),create:t}}const Qt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Tt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ne=BigInt(0),qe=BigInt(1),St=BigInt(2),_t=(n,e)=>(n+e/St)/e;function Oe(n){const e=Qt,t=BigInt(3),o=BigInt(6),c=BigInt(11),f=BigInt(22),l=BigInt(23),d=BigInt(44),r=BigInt(88),u=n*n*n%e,m=u*u*n%e,z=U(m,t,e)*m%e,I=U(z,t,e)*m%e,T=U(I,St,e)*u%e,Z=U(T,c,e)*T%e,g=U(Z,f,e)*Z%e,C=U(g,d,e)*g%e,L=U(C,r,e)*C%e,$=U(L,d,e)*g%e,x=U($,t,e)*m%e,i=U(x,l,e)*Z%e,h=U(i,o,e)*u%e,b=U(h,St,e);if(!Nt.eql(Nt.sqr(b),n))throw new Error("Cannot find square root");return b}const Nt=qt(Qt,void 0,void 0,{sqrt:Oe}),Ie=Se({a:Ne,b:BigInt(7),Fp:Nt,n:Tt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=Tt,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),o=-qe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),c=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),f=t,l=BigInt("0x100000000000000000000000000000000"),d=_t(f*n,e),r=_t(-o*n,e);let u=Y(n-d*t-r*c,e),m=Y(-d*o-r*f,e);const z=u>l,I=m>l;if(z&&(u=e-u),I&&(m=e-m),u>l||m>l)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:z,k1:u,k2neg:I,k2:m}}}},ee),Ze=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:Ie},Symbol.toStringTag,{value:"Module"}));export{qt as F,Ze as a,Se as c,Ie as s};
1
+ import{e as Ft,r as Jt,f as te,s as ee}from"./sha2-D3ryOfi3.js";import{h as ne}from"./hmac-BMnSt9Ou.js";import{bj as kt,bk as tt,bl as Ct,bm as at,bn as lt,bo as ut,bp as re,bq as Et,br as ot,bs as K,bt as It,bu as jt,bv as oe,bw as ct,bx as Bt,by as Mt,bz as ft,bA as At}from"./parseEventLogs-DTRl5YJ_.js";const H=BigInt(0),M=BigInt(1),J=BigInt(2),ie=BigInt(3),Vt=BigInt(4),Yt=BigInt(5),Ht=BigInt(8);function Y(n,e){const t=n%e;return t>=H?t:e+t}function U(n,e,t){let o=n;for(;e-- >H;)o*=o,o%=t;return o}function vt(n,e){if(n===H)throw new Error("invert: expected non-zero number");if(e<=H)throw new Error("invert: expected positive modulus, got "+e);let t=Y(n,e),o=e,c=H,f=M;for(;t!==H;){const d=o/t,r=o%t,u=c-f*d;o=t,t=r,c=f,f=u}if(o!==M)throw new Error("invert: does not exist");return Y(c,e)}function Ut(n,e){const t=(n.ORDER+M)/Vt,o=n.pow(e,t);if(!n.eql(n.sqr(o),e))throw new Error("Cannot find square root");return o}function se(n,e){const t=(n.ORDER-Yt)/Ht,o=n.mul(e,J),c=n.pow(o,t),f=n.mul(e,c),l=n.mul(n.mul(f,J),c),d=n.mul(f,n.sub(l,n.ONE));if(!n.eql(n.sqr(d),e))throw new Error("Cannot find square root");return d}function ce(n){if(n<BigInt(3))throw new Error("sqrt is not defined for small field");let e=n-M,t=0;for(;e%J===H;)e/=J,t++;let o=J;const c=qt(n);for(;Rt(c,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return Ut;let f=c.pow(o,e);const l=(e+M)/J;return function(r,u){if(r.is0(u))return u;if(Rt(r,u)!==1)throw new Error("Cannot find square root");let m=t,z=r.mul(r.ONE,f),I=r.pow(u,e),T=r.pow(u,l);for(;!r.eql(I,r.ONE);){if(r.is0(I))return r.ZERO;let Z=1,g=r.sqr(I);for(;!r.eql(g,r.ONE);)if(Z++,g=r.sqr(g),Z===m)throw new Error("Cannot find square root");const C=M<<BigInt(m-Z-1),L=r.pow(z,C);m=Z,z=r.sqr(L),I=r.mul(I,z),T=r.mul(T,L)}return T}}function fe(n){return n%Vt===ie?Ut:n%Ht===Yt?se:ce(n)}const ae=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function le(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=ae.reduce((o,c)=>(o[c]="function",o),e);return ut(n,t)}function ue(n,e,t){if(t<H)throw new Error("invalid exponent, negatives unsupported");if(t===H)return n.ONE;if(t===M)return e;let o=n.ONE,c=e;for(;t>H;)t&M&&(o=n.mul(o,c)),c=n.sqr(c),t>>=M;return o}function Kt(n,e,t=!1){const o=new Array(e.length).fill(t?n.ZERO:void 0),c=e.reduce((l,d,r)=>n.is0(d)?l:(o[r]=l,n.mul(l,d)),n.ONE),f=n.inv(c);return e.reduceRight((l,d,r)=>n.is0(d)?l:(o[r]=n.mul(l,o[r]),n.mul(l,d)),f),o}function Rt(n,e){const t=(n.ORDER-M)/J,o=n.pow(e,t),c=n.eql(o,n.ONE),f=n.eql(o,n.ZERO),l=n.eql(o,n.neg(n.ONE));if(!c&&!f&&!l)throw new Error("invalid Legendre symbol result");return c?1:f?0:-1}function Pt(n,e){e!==void 0&&Ft(e);const t=e!==void 0?e:n.toString(2).length,o=Math.ceil(t/8);return{nBitLength:t,nByteLength:o}}function qt(n,e,t=!1,o={}){if(n<=H)throw new Error("invalid field: expected ORDER > 0, got "+n);const{nBitLength:c,nByteLength:f}=Pt(n,e);if(f>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const d=Object.freeze({ORDER:n,isLE:t,BITS:c,BYTES:f,MASK:lt(c),ZERO:H,ONE:M,create:r=>Y(r,n),isValid:r=>{if(typeof r!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof r);return H<=r&&r<n},is0:r=>r===H,isOdd:r=>(r&M)===M,neg:r=>Y(-r,n),eql:(r,u)=>r===u,sqr:r=>Y(r*r,n),add:(r,u)=>Y(r+u,n),sub:(r,u)=>Y(r-u,n),mul:(r,u)=>Y(r*u,n),pow:(r,u)=>ue(d,r,u),div:(r,u)=>Y(r*vt(u,n),n),sqrN:r=>r*r,addN:(r,u)=>r+u,subN:(r,u)=>r-u,mulN:(r,u)=>r*u,inv:r=>vt(r,n),sqrt:o.sqrt||(r=>(l||(l=fe(n)),l(d,r))),toBytes:r=>t?Ct(r,f):at(r,f),fromBytes:r=>{if(r.length!==f)throw new Error("Field.fromBytes: expected "+f+" bytes, got "+r.length);return t?kt(r):tt(r)},invertBatch:r=>Kt(d,r),cmov:(r,u,m)=>m?u:r});return Object.freeze(d)}function $t(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function Dt(n){const e=$t(n);return e+Math.ceil(e/2)}function de(n,e,t=!1){const o=n.length,c=$t(e),f=Dt(e);if(o<16||o<f||o>1024)throw new Error("expected "+f+"-1024 bytes of input, got "+o);const l=t?kt(n):tt(n),d=Y(l,e-M)+M;return t?Ct(d,c):at(d,c)}const zt=BigInt(0),xt=BigInt(1);function wt(n,e){const t=e.negate();return n?t:e}function Gt(n,e){if(!Number.isSafeInteger(n)||n<=0||n>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+n)}function gt(n,e){Gt(n,e);const t=Math.ceil(e/n)+1,o=2**(n-1),c=2**n,f=lt(n),l=BigInt(n);return{windows:t,windowSize:o,mask:f,maxNumber:c,shiftBy:l}}function Zt(n,e,t){const{windowSize:o,mask:c,maxNumber:f,shiftBy:l}=t;let d=Number(n&c),r=n>>l;d>o&&(d-=f,r+=xt);const u=e*o,m=u+Math.abs(d)-1,z=d===0,I=d<0,T=e%2!==0;return{nextN:r,offset:m,isZero:z,isNeg:I,isNegF:T,offsetF:u}}function he(n,e){if(!Array.isArray(n))throw new Error("array expected");n.forEach((t,o)=>{if(!(t instanceof e))throw new Error("invalid point at index "+o)})}function we(n,e){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((t,o)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+o)})}const mt=new WeakMap,Wt=new WeakMap;function bt(n){return Wt.get(n)||1}function ge(n,e){return{constTimeNegate:wt,hasPrecomputes(t){return bt(t)!==1},unsafeLadder(t,o,c=n.ZERO){let f=t;for(;o>zt;)o&xt&&(c=c.add(f)),f=f.double(),o>>=xt;return c},precomputeWindow(t,o){const{windows:c,windowSize:f}=gt(o,e),l=[];let d=t,r=d;for(let u=0;u<c;u++){r=d,l.push(r);for(let m=1;m<f;m++)r=r.add(d),l.push(r);d=r.double()}return l},wNAF(t,o,c){let f=n.ZERO,l=n.BASE;const d=gt(t,e);for(let r=0;r<d.windows;r++){const{nextN:u,offset:m,isZero:z,isNeg:I,isNegF:T,offsetF:Z}=Zt(c,r,d);c=u,z?l=l.add(wt(T,o[Z])):f=f.add(wt(I,o[m]))}return{p:f,f:l}},wNAFUnsafe(t,o,c,f=n.ZERO){const l=gt(t,e);for(let d=0;d<l.windows&&c!==zt;d++){const{nextN:r,offset:u,isZero:m,isNeg:z}=Zt(c,d,l);if(c=r,!m){const I=o[u];f=f.add(z?I.negate():I)}}return f},getPrecomputes(t,o,c){let f=mt.get(o);return f||(f=this.precomputeWindow(o,t),t!==1&&mt.set(o,c(f))),f},wNAFCached(t,o,c){const f=bt(t);return this.wNAF(f,this.getPrecomputes(f,t,c),o)},wNAFCachedUnsafe(t,o,c,f){const l=bt(t);return l===1?this.unsafeLadder(t,o,f):this.wNAFUnsafe(l,this.getPrecomputes(l,t,c),o,f)},setWindowSize(t,o){Gt(o,e),Wt.set(t,o),mt.delete(t)}}}function me(n,e,t,o){he(t,n),we(o,e);const c=t.length,f=o.length;if(c!==f)throw new Error("arrays of points and scalars must have equal length");const l=n.ZERO,d=re(BigInt(c));let r=1;d>12?r=d-3:d>4?r=d-2:d>0&&(r=2);const u=lt(r),m=new Array(Number(u)+1).fill(l),z=Math.floor((e.BITS-1)/r)*r;let I=l;for(let T=z;T>=0;T-=r){m.fill(l);for(let g=0;g<f;g++){const C=o[g],L=Number(C>>BigInt(T)&u);m[L]=m[L].add(t[g])}let Z=l;for(let g=m.length-1,C=l;g>0;g--)C=C.add(m[g]),Z=Z.add(C);if(I=I.add(Z),T!==0)for(let g=0;g<r;g++)I=I.double()}return I}function Xt(n){return le(n.Fp),ut(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Pt(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}function Lt(n){n.lowS!==void 0&&ct("lowS",n.lowS),n.prehash!==void 0&&ct("prehash",n.prehash)}function be(n){const e=Xt(n);ut(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:t,Fp:o,a:c}=e;if(t){if(!o.eql(c,o.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class pe extends Error{constructor(e=""){super(e)}}const G={Err:pe,_tlv:{encode:(n,e)=>{const{Err:t}=G;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const o=e.length/2,c=ft(o);if(c.length/2&128)throw new t("tlv.encode: long form length too big");const f=o>127?ft(c.length/2|128):"";return ft(n)+f+c+e},decode(n,e){const{Err:t}=G;let o=0;if(n<0||n>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[o++]!==n)throw new t("tlv.decode: wrong tlv");const c=e[o++],f=!!(c&128);let l=0;if(!f)l=c;else{const r=c&127;if(!r)throw new t("tlv.decode(long): indefinite length not supported");if(r>4)throw new t("tlv.decode(long): byte length is too big");const u=e.subarray(o,o+r);if(u.length!==r)throw new t("tlv.decode: length bytes not complete");if(u[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const m of u)l=l<<8|m;if(o+=r,l<128)throw new t("tlv.decode(long): not minimal encoding")}const d=e.subarray(o,o+l);if(d.length!==l)throw new t("tlv.decode: wrong value length");return{v:d,l:e.subarray(o+l)}}},_int:{encode(n){const{Err:e}=G;if(n<W)throw new e("integer: negative integers are not allowed");let t=ft(n);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(n){const{Err:e}=G;if(n[0]&128)throw new e("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return tt(n)}},toSig(n){const{Err:e,_int:t,_tlv:o}=G,c=K("signature",n),{v:f,l}=o.decode(48,c);if(l.length)throw new e("invalid signature: left bytes after parsing");const{v:d,l:r}=o.decode(2,f),{v:u,l:m}=o.decode(2,r);if(m.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(d),s:t.decode(u)}},hexFromSig(n){const{_tlv:e,_int:t}=G,o=e.encode(2,t.encode(n.r)),c=e.encode(2,t.encode(n.s)),f=o+c;return e.encode(48,f)}};function pt(n,e){return Bt(at(n,e))}const W=BigInt(0),_=BigInt(1);BigInt(2);const yt=BigInt(3),ye=BigInt(4);function Ee(n){const e=be(n),{Fp:t}=e,o=qt(e.n,e.nBitLength),c=e.toBytes||((x,i,h)=>{const b=i.toAffine();return Et(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),f=e.fromBytes||(x=>{const i=x.subarray(1),h=t.fromBytes(i.subarray(0,t.BYTES)),b=t.fromBytes(i.subarray(t.BYTES,2*t.BYTES));return{x:h,y:b}});function l(x){const{a:i,b:h}=e,b=t.sqr(x),B=t.mul(b,x);return t.add(t.add(B,t.mul(x,i)),h)}function d(x,i){const h=t.sqr(i),b=l(x);return t.eql(h,b)}if(!d(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const r=t.mul(t.pow(e.a,yt),ye),u=t.mul(t.sqr(e.b),BigInt(27));if(t.is0(t.add(r,u)))throw new Error("bad curve params: a or b");function m(x){return Mt(x,_,e.n)}function z(x){const{allowedPrivateKeyLengths:i,nByteLength:h,wrapPrivateKey:b,n:B}=e;if(i&&typeof x!="bigint"){if(jt(x)&&(x=Bt(x)),typeof x!="string"||!i.includes(x.length))throw new Error("invalid private key");x=x.padStart(h*2,"0")}let q;try{q=typeof x=="bigint"?x:tt(K("private key",x,h))}catch{throw new Error("invalid private key, expected hex or "+h+" bytes, got "+typeof x)}return b&&(q=Y(q,B)),ot("private key",q,_,B),q}function I(x){if(!(x instanceof g))throw new Error("ProjectivePoint expected")}const T=At((x,i)=>{const{px:h,py:b,pz:B}=x;if(t.eql(B,t.ONE))return{x:h,y:b};const q=x.is0();i==null&&(i=q?t.ONE:t.inv(B));const A=t.mul(h,i),O=t.mul(b,i),p=t.mul(B,i);if(q)return{x:t.ZERO,y:t.ZERO};if(!t.eql(p,t.ONE))throw new Error("invZ was invalid");return{x:A,y:O}}),Z=At(x=>{if(x.is0()){if(e.allowInfinityPoint&&!t.is0(x.py))return;throw new Error("bad point: ZERO")}const{x:i,y:h}=x.toAffine();if(!t.isValid(i)||!t.isValid(h))throw new Error("bad point: x or y not FE");if(!d(i,h))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(i,h,b){if(i==null||!t.isValid(i))throw new Error("x required");if(h==null||!t.isValid(h)||t.is0(h))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required");this.px=i,this.py=h,this.pz=b,Object.freeze(this)}static fromAffine(i){const{x:h,y:b}=i||{};if(!i||!t.isValid(h)||!t.isValid(b))throw new Error("invalid affine point");if(i instanceof g)throw new Error("projective point not allowed");const B=q=>t.eql(q,t.ZERO);return B(h)&&B(b)?g.ZERO:new g(h,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(i){const h=Kt(t,i.map(b=>b.pz));return i.map((b,B)=>b.toAffine(h[B])).map(g.fromAffine)}static fromHex(i){const h=g.fromAffine(f(K("pointHex",i)));return h.assertValidity(),h}static fromPrivateKey(i){return g.BASE.multiply(z(i))}static msm(i,h){return me(g,o,i,h)}_setWindowSize(i){$.setWindowSize(this,i)}assertValidity(){Z(this)}hasEvenY(){const{y:i}=this.toAffine();if(t.isOdd)return!t.isOdd(i);throw new Error("Field doesn't support isOdd")}equals(i){I(i);const{px:h,py:b,pz:B}=this,{px:q,py:A,pz:O}=i,p=t.eql(t.mul(h,O),t.mul(q,B)),N=t.eql(t.mul(b,O),t.mul(A,B));return p&&N}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){const{a:i,b:h}=e,b=t.mul(h,yt),{px:B,py:q,pz:A}=this;let O=t.ZERO,p=t.ZERO,N=t.ZERO,y=t.mul(B,B),k=t.mul(q,q),a=t.mul(A,A),s=t.mul(B,q);return s=t.add(s,s),N=t.mul(B,A),N=t.add(N,N),O=t.mul(i,N),p=t.mul(b,a),p=t.add(O,p),O=t.sub(k,p),p=t.add(k,p),p=t.mul(O,p),O=t.mul(s,O),N=t.mul(b,N),a=t.mul(i,a),s=t.sub(y,a),s=t.mul(i,s),s=t.add(s,N),N=t.add(y,y),y=t.add(N,y),y=t.add(y,a),y=t.mul(y,s),p=t.add(p,y),a=t.mul(q,A),a=t.add(a,a),y=t.mul(a,s),O=t.sub(O,y),N=t.mul(a,k),N=t.add(N,N),N=t.add(N,N),new g(O,p,N)}add(i){I(i);const{px:h,py:b,pz:B}=this,{px:q,py:A,pz:O}=i;let p=t.ZERO,N=t.ZERO,y=t.ZERO;const k=e.a,a=t.mul(e.b,yt);let s=t.mul(h,q),w=t.mul(b,A),S=t.mul(B,O),E=t.add(h,b),v=t.add(q,A);E=t.mul(E,v),v=t.add(s,w),E=t.sub(E,v),v=t.add(h,B);let R=t.add(q,O);return v=t.mul(v,R),R=t.add(s,S),v=t.sub(v,R),R=t.add(b,B),p=t.add(A,O),R=t.mul(R,p),p=t.add(w,S),R=t.sub(R,p),y=t.mul(k,v),p=t.mul(a,S),y=t.add(p,y),p=t.sub(w,y),y=t.add(w,y),N=t.mul(p,y),w=t.add(s,s),w=t.add(w,s),S=t.mul(k,S),v=t.mul(a,v),w=t.add(w,S),S=t.sub(s,S),S=t.mul(k,S),v=t.add(v,S),s=t.mul(w,v),N=t.add(N,s),s=t.mul(R,v),p=t.mul(E,p),p=t.sub(p,s),s=t.mul(E,w),y=t.mul(R,y),y=t.add(y,s),new g(p,N,y)}subtract(i){return this.add(i.negate())}is0(){return this.equals(g.ZERO)}wNAF(i){return $.wNAFCached(this,i,g.normalizeZ)}multiplyUnsafe(i){const{endo:h,n:b}=e;ot("scalar",i,W,b);const B=g.ZERO;if(i===W)return B;if(this.is0()||i===_)return this;if(!h||$.hasPrecomputes(this))return $.wNAFCachedUnsafe(this,i,g.normalizeZ);let{k1neg:q,k1:A,k2neg:O,k2:p}=h.splitScalar(i),N=B,y=B,k=this;for(;A>W||p>W;)A&_&&(N=N.add(k)),p&_&&(y=y.add(k)),k=k.double(),A>>=_,p>>=_;return q&&(N=N.negate()),O&&(y=y.negate()),y=new g(t.mul(y.px,h.beta),y.py,y.pz),N.add(y)}multiply(i){const{endo:h,n:b}=e;ot("scalar",i,_,b);let B,q;if(h){const{k1neg:A,k1:O,k2neg:p,k2:N}=h.splitScalar(i);let{p:y,f:k}=this.wNAF(O),{p:a,f:s}=this.wNAF(N);y=$.constTimeNegate(A,y),a=$.constTimeNegate(p,a),a=new g(t.mul(a.px,h.beta),a.py,a.pz),B=y.add(a),q=k.add(s)}else{const{p:A,f:O}=this.wNAF(i);B=A,q=O}return g.normalizeZ([B,q])[0]}multiplyAndAddUnsafe(i,h,b){const B=g.BASE,q=(O,p)=>p===W||p===_||!O.equals(B)?O.multiplyUnsafe(p):O.multiply(p),A=q(this,h).add(q(i,b));return A.is0()?void 0:A}toAffine(i){return T(this,i)}isTorsionFree(){const{h:i,isTorsionFree:h}=e;if(i===_)return!0;if(h)return h(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:i,clearCofactor:h}=e;return i===_?this:h?h(g,this):this.multiplyUnsafe(e.h)}toRawBytes(i=!0){return ct("isCompressed",i),this.assertValidity(),c(g,this,i)}toHex(i=!0){return ct("isCompressed",i),Bt(this.toRawBytes(i))}}g.BASE=new g(e.Gx,e.Gy,t.ONE),g.ZERO=new g(t.ZERO,t.ONE,t.ZERO);const{endo:C,nBitLength:L}=e,$=ge(g,C?Math.ceil(L/2):L);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:z,weierstrassEquation:l,isWithinCurveOrder:m}}function Be(n){const e=Xt(n);return ut(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ve(n){const e=Be(n),{Fp:t,n:o,nByteLength:c,nBitLength:f}=e,l=t.BYTES+1,d=2*t.BYTES+1;function r(a){return Y(a,o)}function u(a){return vt(a,o)}const{ProjectivePoint:m,normPrivateKeyToScalar:z,weierstrassEquation:I,isWithinCurveOrder:T}=Ee({...e,toBytes(a,s,w){const S=s.toAffine(),E=t.toBytes(S.x),v=Et;return ct("isCompressed",w),w?v(Uint8Array.from([s.hasEvenY()?2:3]),E):v(Uint8Array.from([4]),E,t.toBytes(S.y))},fromBytes(a){const s=a.length,w=a[0],S=a.subarray(1);if(s===l&&(w===2||w===3)){const E=tt(S);if(!Mt(E,_,t.ORDER))throw new Error("Point is not on curve");const v=I(E);let R;try{R=t.sqrt(v)}catch(P){const V=P instanceof Error?": "+P.message:"";throw new Error("Point is not on curve"+V)}const j=(R&_)===_;return(w&1)===1!==j&&(R=t.neg(R)),{x:E,y:R}}else if(s===d&&w===4){const E=t.fromBytes(S.subarray(0,t.BYTES)),v=t.fromBytes(S.subarray(t.BYTES,2*t.BYTES));return{x:E,y:v}}else{const E=l,v=d;throw new Error("invalid Point, expected length of "+E+", or uncompressed "+v+", got "+s)}}});function Z(a){const s=o>>_;return a>s}function g(a){return Z(a)?r(-a):a}const C=(a,s,w)=>tt(a.slice(s,w));class L{constructor(s,w,S){ot("r",s,_,o),ot("s",w,_,o),this.r=s,this.s=w,S!=null&&(this.recovery=S),Object.freeze(this)}static fromCompact(s){const w=c;return s=K("compactSignature",s,w*2),new L(C(s,0,w),C(s,w,2*w))}static fromDER(s){const{r:w,s:S}=G.toSig(K("DER",s));return new L(w,S)}assertValidity(){}addRecoveryBit(s){return new L(this.r,this.s,s)}recoverPublicKey(s){const{r:w,s:S,recovery:E}=this,v=B(K("msgHash",s));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");const R=E===2||E===3?w+e.n:w;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const j=(E&1)===0?"02":"03",D=m.fromHex(j+pt(R,t.BYTES)),P=u(R),V=r(-v*P),et=r(S*P),X=m.BASE.multiplyAndAddUnsafe(D,V,et);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return Z(this.s)}normalizeS(){return this.hasHighS()?new L(this.r,r(-this.s),this.recovery):this}toDERRawBytes(){return It(this.toDERHex())}toDERHex(){return G.hexFromSig(this)}toCompactRawBytes(){return It(this.toCompactHex())}toCompactHex(){const s=c;return pt(this.r,s)+pt(this.s,s)}}const $={isValidPrivateKey(a){try{return z(a),!0}catch{return!1}},normPrivateKeyToScalar:z,randomPrivateKey:()=>{const a=Dt(e.n);return de(e.randomBytes(a),e.n)},precompute(a=8,s=m.BASE){return s._setWindowSize(a),s.multiply(BigInt(3)),s}};function x(a,s=!0){return m.fromPrivateKey(a).toRawBytes(s)}function i(a){if(typeof a=="bigint")return!1;if(a instanceof m)return!0;const w=K("key",a).length,S=t.BYTES,E=S+1,v=2*S+1;if(!(e.allowedPrivateKeyLengths||c===E))return w===E||w===v}function h(a,s,w=!0){if(i(a)===!0)throw new Error("first arg must be private key");if(i(s)===!1)throw new Error("second arg must be public key");return m.fromHex(s).multiply(z(a)).toRawBytes(w)}const b=e.bits2int||function(a){if(a.length>8192)throw new Error("input is too large");const s=tt(a),w=a.length*8-f;return w>0?s>>BigInt(w):s},B=e.bits2int_modN||function(a){return r(b(a))},q=lt(f);function A(a){return ot("num < 2^"+f,a,W,q),at(a,c)}function O(a,s,w=p){if(["recovered","canonical"].some(Q=>Q in w))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:E}=e;let{lowS:v,prehash:R,extraEntropy:j}=w;v==null&&(v=!0),a=K("msgHash",a),Lt(w),R&&(a=K("prehashed msgHash",S(a)));const D=B(a),P=z(s),V=[A(P),A(D)];if(j!=null&&j!==!1){const Q=j===!0?E(t.BYTES):j;V.push(K("extraEntropy",Q))}const et=Et(...V),X=D;function dt(Q){const nt=b(Q);if(!T(nt))return;const ht=u(nt),it=m.BASE.multiply(nt).toAffine(),F=r(it.x);if(F===W)return;const st=r(ht*r(X+F*P));if(st===W)return;let rt=(it.x===F?0:2)|Number(it.y&_),Ot=st;return v&&Z(st)&&(Ot=g(st),rt^=1),new L(F,Ot,rt)}return{seed:et,k2sig:dt}}const p={lowS:e.lowS,prehash:!1},N={lowS:e.lowS,prehash:!1};function y(a,s,w=p){const{seed:S,k2sig:E}=O(a,s,w),v=e;return oe(v.hash.outputLen,v.nByteLength,v.hmac)(S,E)}m.BASE._setWindowSize(8);function k(a,s,w,S=N){const E=a;s=K("msgHash",s),w=K("publicKey",w);const{lowS:v,prehash:R,format:j}=S;if(Lt(S),"strict"in S)throw new Error("options.strict was renamed to lowS");if(j!==void 0&&j!=="compact"&&j!=="der")throw new Error("format must be compact or der");const D=typeof E=="string"||jt(E),P=!D&&!j&&typeof E=="object"&&E!==null&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!D&&!P)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let V,et;try{if(P&&(V=new L(E.r,E.s)),D){try{j!=="compact"&&(V=L.fromDER(E))}catch(rt){if(!(rt instanceof G.Err))throw rt}!V&&j!=="der"&&(V=L.fromCompact(E))}et=m.fromHex(w)}catch{return!1}if(!V||v&&V.hasHighS())return!1;R&&(s=e.hash(s));const{r:X,s:dt}=V,Q=B(s),nt=u(dt),ht=r(Q*nt),it=r(X*nt),F=m.BASE.multiplyAndAddUnsafe(et,ht,it)?.toAffine();return F?r(F.x)===X:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:h,sign:y,verify:k,ProjectivePoint:m,Signature:L,utils:$}}function xe(n){return{hash:n,hmac:(e,...t)=>ne(n,e,te(...t)),randomBytes:Jt}}function Se(n,e){const t=o=>ve({...n,...xe(o)});return{...t(e),create:t}}const Qt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Tt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ne=BigInt(0),qe=BigInt(1),St=BigInt(2),_t=(n,e)=>(n+e/St)/e;function Oe(n){const e=Qt,t=BigInt(3),o=BigInt(6),c=BigInt(11),f=BigInt(22),l=BigInt(23),d=BigInt(44),r=BigInt(88),u=n*n*n%e,m=u*u*n%e,z=U(m,t,e)*m%e,I=U(z,t,e)*m%e,T=U(I,St,e)*u%e,Z=U(T,c,e)*T%e,g=U(Z,f,e)*Z%e,C=U(g,d,e)*g%e,L=U(C,r,e)*C%e,$=U(L,d,e)*g%e,x=U($,t,e)*m%e,i=U(x,l,e)*Z%e,h=U(i,o,e)*u%e,b=U(h,St,e);if(!Nt.eql(Nt.sqr(b),n))throw new Error("Cannot find square root");return b}const Nt=qt(Qt,void 0,void 0,{sqrt:Oe}),Ie=Se({a:Ne,b:BigInt(7),Fp:Nt,n:Tt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=Tt,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),o=-qe*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),c=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),f=t,l=BigInt("0x100000000000000000000000000000000"),d=_t(f*n,e),r=_t(-o*n,e);let u=Y(n-d*t-r*c,e),m=Y(-d*o-r*f,e);const z=u>l,I=m>l;if(z&&(u=e-u),I&&(m=e-m),u>l||m>l)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:z,k1:u,k2neg:I,k2:m}}}},ee),Ze=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:Ie},Symbol.toStringTag,{value:"Module"}));export{qt as F,Ze as a,Se as c,Ie as s};
@@ -1,4 +1,4 @@
1
- import{i as x,b as c}from"./lit-element-Cn7T8F1W.js";import{n as d,r as u}from"./class-map-mFRv1nW8.js";import{d as b,r as q,e as K}from"./index-DbAu4Peg.js";import{c as v,U as N}from"./index-wds8TuUm.js";import"./index-DP1DuCnR.js";import"./index-C5ciuua_.js";import"./index-CE5G6IEJ.js";import{e as F,n as z}from"./ref-CYZXcxoe.js";import{b as D,C as g,k as j,J as l,R as h,N as H,M as Y,S as y,d as G,n as X,q as J,P as L,Q as M,E as Z}from"./W3MFrameProviderSingleton-9eitOT0j.js";import"./index-CWGeCZBJ.js";import"./index-aoxVkzFE.js";import"./index-I68folnJ.js";import{S as Q}from"./SwapController-DUCq2f7d.js";import"./index-JfVynEph.js";import"./index-DWRq2SN_.js";import"./index-i4VBSYqA.js";import"./index-BxdNwV86.js";import{o as ee}from"./if-defined-DsPifBxM.js";import"./index-Cu4ZjLNb.js";import"./index-B-vyBZw9.js";import"./index-DS2Lm9tG.js";import"./index-nibyPLVP.js";import"./index-r_1z0VI_.js";import"./sha2-D3ryOfi3.js";import"./hmac-BMnSt9Ou.js";import"./NetworkUtil-DqGcuBfF.js";import"./index.es-CkxUaFYS.js";import"./browser-ponyfill-BmgQyNz0.js";import"./index-B9U0GcYk.js";import"./async-directive-DJs0ey8-.js";import"./index-TBthDmkl.js";const te=b`
1
+ import{i as x,b as c}from"./lit-element-Cn7T8F1W.js";import{n as d,r as u}from"./class-map-mFRv1nW8.js";import{d as b,r as q,e as K}from"./index-mUrlue57.js";import{c as v,U as N}from"./index-CYGUludi.js";import"./index-CNR7tadx.js";import"./index-DcSeumRb.js";import"./index-D6EwKnFm.js";import{e as F,n as z}from"./ref-CYZXcxoe.js";import{b as D,C as g,k as j,J as l,R as h,N as H,M as Y,S as y,d as G,n as X,q as J,P as L,Q as M,E as Z}from"./W3MFrameProviderSingleton-eYQGtm7P.js";import"./index-CNttLYqM.js";import"./index-BVL3WVs3.js";import"./index-CUqVNGI9.js";import{S as Q}from"./SwapController-CykJEtRW.js";import"./index-BUjSLaXy.js";import"./index-Dh25pQLC.js";import"./index-CzGhZ9cz.js";import"./index-CFn3Q12F.js";import{o as ee}from"./if-defined-DsPifBxM.js";import"./index-a-a2MqTK.js";import"./index-CPCCdjXg.js";import"./index-CcHsPndE.js";import"./index-nibyPLVP.js";import"./index-CpGStcFm.js";import"./sha2-D3ryOfi3.js";import"./hmac-BMnSt9Ou.js";import"./NetworkUtil-XsBaDkTf.js";import"./index.es-CjcoN6we.js";import"./browser-ponyfill-CqiVi-O8.js";import"./index-3gZjXx6v.js";import"./async-directive-DJs0ey8-.js";import"./index-BYwd36WC.js";const te=b`
2
2
  :host {
3
3
  width: 100%;
4
4
  height: 100px;
@@ -1 +1 @@
1
- import{v as w,w as h,x as r}from"./signing-gNn6SJWz.js";import{w as u}from"./wait-for-tx-receipt-5pSBMNe2.js";async function v(t){const n=await w(t);return u(n)}async function B(t){const{account:n,transactions:s}=t;if(!n)throw new Error("not connected");if(s.length===0)throw new Error("No transactions to send");const o=s[0];if(!o)throw new Error("No transactions to send");if(n.sendBatchTransaction){const e=await Promise.all(s.map(async a=>{const[i,c,d,l]=await Promise.all([h(a),r(a.to),r(a.accessList),r(a.value)]);return{accessList:d,chainId:a.chain.id,data:i,to:c,value:l}}));return{...await n.sendBatchTransaction(e),chain:o.chain,client:o.client}}throw new Error("Account doesn't implement sendBatchTransaction")}export{v as a,B as s};
1
+ import{v as w,w as h,x as r}from"./signing-lyeTiv6v.js";import{w as u}from"./wait-for-tx-receipt-CN6uf72q.js";async function v(t){const n=await w(t);return u(n)}async function B(t){const{account:n,transactions:s}=t;if(!n)throw new Error("not connected");if(s.length===0)throw new Error("No transactions to send");const o=s[0];if(!o)throw new Error("No transactions to send");if(n.sendBatchTransaction){const e=await Promise.all(s.map(async a=>{const[i,c,d,l]=await Promise.all([h(a),r(a.to),r(a.accessList),r(a.value)]);return{accessList:d,chainId:a.chain.id,data:i,to:c,value:l}}));return{...await n.sendBatchTransaction(e),chain:o.chain,client:o.client}}throw new Error("Account doesn't implement sendBatchTransaction")}export{v as a,B as s};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/signing-gNn6SJWz.js","assets/utils-h8VUSGPW.js","assets/index-Cu4ZjLNb.js","assets/index-829Uxa3Y.css"])))=>i.map(i=>d[i]);
2
- import{_ as B}from"./index-Cu4ZjLNb.js";import{B as b,T as h,U as v,u as L,V as m,m as T,W as D,x as p,g as z,t as O,w as S,X as A,Y as M}from"./signing-gNn6SJWz.js";import{m as $,s as V,t as H}from"./sha256-Dy8KQE_5.js";const _=$*32n;class R extends b{constructor({givenLength:e,maxBytecodeSize:a}){super(`Bytecode cannot be longer than ${a} bytes. Given length: ${e}`,{name:"BytecodeLengthExceedsMaxSizeError"})}}class W extends b{constructor({givenLengthInWords:e}){super(`Bytecode length in 32-byte words must be odd. Given length in words: ${e}`,{name:"BytecodeLengthInWordsMustBeOddError"})}}class U extends b{constructor({givenLength:e}){super(`The bytecode length in bytes must be divisible by 32. Given length: ${e}`,{name:"BytecodeLengthMustBeDivisibleBy32Error"})}}function k(t){const e=h(t);if(e.length%32!==0)throw new U({givenLength:e.length});if(e.length>_)throw new R({givenLength:e.length,maxBytecodeSize:_});const a=V(e),n=h(a),s=e.length/32;if(s%2===0)throw new W({givenLengthInWords:s});const r=h(s),i=v(r,{size:2}),o=new Uint8Array([1,0]);return n.set(o,0),n.set(i,2),n}function l(t){if(["string","number"].includes(typeof t)&&!Number.isInteger(Number(t)))throw new Error(`Expected value to be an integer to convert to a bigint, got ${t} of type ${typeof t}`);return t instanceof Uint8Array?BigInt(L(t)):BigInt(t)}const x=(t,e)=>typeof t=="bigint"?e(t):Array.isArray(t)?t.map(a=>x(a,e)):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([a,n])=>[a,x(n,e)])):t,G=50000n,N=t=>{const e=C(t);return{domain:{chainId:t.chainId,name:"zkSync",version:"2"},message:e,primaryType:"Transaction",types:{Transaction:[{name:"txType",type:"uint256"},{name:"from",type:"uint256"},{name:"to",type:"uint256"},{name:"gasLimit",type:"uint256"},{name:"gasPerPubdataByteLimit",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymaster",type:"uint256"},{name:"nonce",type:"uint256"},{name:"value",type:"uint256"},{name:"data",type:"bytes"},{name:"factoryDeps",type:"bytes32[]"},{name:"paymasterInput",type:"bytes"}]}}};function C(t){const{gas:e,nonce:a,to:n,from:s,value:r,maxFeePerGas:i,maxPriorityFeePerGas:o,paymaster:y,paymasterInput:g,gasPerPubdata:d,data:u,factoryDeps:P}=t;return{data:u||"0x0",factoryDeps:P?.map(c=>m(k(c)))??[],from:BigInt(s),gasLimit:e??0n,gasPerPubdataByteLimit:d??G,maxFeePerGas:i??0n,maxPriorityFeePerGas:o??0n,nonce:a?BigInt(a):0n,paymaster:y?BigInt(y):0n,paymasterInput:g||"0x",to:n?BigInt(n):0n,txType:113n,value:r??0n}}async function X(t){const{account:e,transaction:a}=t,n=await I(t),s=await w({account:e,chainId:a.chain.id,eip712Transaction:n}),r=T(a),i=await D(r,s);return{chain:a.chain,client:a.client,transactionHash:i}}async function w(t){const{account:e,eip712Transaction:a,chainId:n}=t,s=N(a),r=await e.signTypedData({...s});return Y({...a,chainId:n,customSignature:r})}async function I(t){const{account:e,transaction:a}=t,{gas:n,maxFeePerGas:s,maxPriorityFeePerGas:r,gasPerPubdata:i}=await F({from:z(e.address),transaction:a});return{...await O({from:e.address,transaction:{...a,gas:n,maxFeePerGas:s,maxPriorityFeePerGas:r}}),...a.eip712,from:e.address,gasPerPubdata:i}}function Y(t){const{chainId:e,gas:a,nonce:n,to:s,from:r,value:i,maxFeePerGas:o,maxPriorityFeePerGas:y,customSignature:g,factoryDeps:d,paymaster:u,paymasterInput:P,gasPerPubdata:c,data:f}=t,E=[n?m(n):"0x",y?m(y):"0x",o?m(o):"0x",a?m(a):"0x",s??"0x",i?m(i):"0x",f??"0x0",m(e),m(""),m(""),m(e),r??"0x",c?m(c):m(G),d??[],g??"0x",u&&P?[u,P]:[]];return M(["0x71",H(E)])}async function F(t){const{transaction:e,from:a}=t;let[n,s,r,i]=await Promise.all([p(e.gas),p(e.maxFeePerGas),p(e.maxPriorityFeePerGas),p(e.eip712)]),o=i?.gasPerPubdata;if(n===void 0||s===void 0||r===void 0){const y=T(e),g=await Z({from:a,transaction:e});try{const d=await y({method:"zks_estimateFee",params:[x(g,m)]});n=l(d.gas_limit)*2n,s=l(d.max_fee_per_gas)*2n,r=l(d.max_priority_fee_per_gas)||1n,o=l(d.gas_per_pubdata_limit)*2n,o<50000n&&(o=50000n)}catch{const[{estimateGas:d},{getDefaultGasOverrides:u}]=await Promise.all([B(()=>import("./signing-gNn6SJWz.js").then(f=>f.cV),__vite__mapDeps([0,1,2,3])),B(()=>import("./signing-gNn6SJWz.js").then(f=>f.cT),__vite__mapDeps([0,1,2,3]))]),[P,c]=await Promise.all([n===void 0?d({transaction:e,from:a}):Promise.resolve(n),u(e.client,e.chain)]);n=P*2n,"maxFeePerGas"in c&&c.maxFeePerGas?s=c.maxFeePerGas*2n:"gasPrice"in c&&c.gasPrice&&(s=c.gasPrice*2n),"maxPriorityFeePerGas"in c&&c.maxPriorityFeePerGas?r=c.maxPriorityFeePerGas:r=1n,o=100000n}}return{gas:n,gasPerPubdata:o,maxFeePerGas:s,maxPriorityFeePerGas:r}}async function Z(t){const{transaction:e,from:a}=t,[n,s,r,i]=await Promise.all([S(e),p(e.to),p(e.value),p(e.eip712)]),o=i?.gasPerPubdata;return{data:n,eip712Meta:{...i,factoryDeps:i?.factoryDeps?.map(y=>Array.from(A(y))),gasPerPubdata:o||50000n},from:a,gasPerPubdata:o,to:s,type:"0x71",value:r}}const Q=Object.freeze(Object.defineProperty({__proto__:null,getZkGasFees:F,populateEip712Transaction:I,sendEip712Transaction:X,signEip712Transaction:w},Symbol.toStringTag,{value:"Module"}));export{Q as a,I as p,w as s,l as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/signing-lyeTiv6v.js","assets/utils-Cj9H0gW-.js","assets/index-a-a2MqTK.js","assets/index-BXaGpRRD.css"])))=>i.map(i=>d[i]);
2
+ import{_ as B}from"./index-a-a2MqTK.js";import{B as b,T as h,U as v,u as L,V as m,m as T,W as D,x as p,g as z,t as O,w as S,X as A,Y as M}from"./signing-lyeTiv6v.js";import{m as $,s as V,t as H}from"./sha256-DOODwtIM.js";const _=$*32n;class R extends b{constructor({givenLength:e,maxBytecodeSize:a}){super(`Bytecode cannot be longer than ${a} bytes. Given length: ${e}`,{name:"BytecodeLengthExceedsMaxSizeError"})}}class W extends b{constructor({givenLengthInWords:e}){super(`Bytecode length in 32-byte words must be odd. Given length in words: ${e}`,{name:"BytecodeLengthInWordsMustBeOddError"})}}class U extends b{constructor({givenLength:e}){super(`The bytecode length in bytes must be divisible by 32. Given length: ${e}`,{name:"BytecodeLengthMustBeDivisibleBy32Error"})}}function k(t){const e=h(t);if(e.length%32!==0)throw new U({givenLength:e.length});if(e.length>_)throw new R({givenLength:e.length,maxBytecodeSize:_});const a=V(e),n=h(a),s=e.length/32;if(s%2===0)throw new W({givenLengthInWords:s});const r=h(s),i=v(r,{size:2}),o=new Uint8Array([1,0]);return n.set(o,0),n.set(i,2),n}function l(t){if(["string","number"].includes(typeof t)&&!Number.isInteger(Number(t)))throw new Error(`Expected value to be an integer to convert to a bigint, got ${t} of type ${typeof t}`);return t instanceof Uint8Array?BigInt(L(t)):BigInt(t)}const x=(t,e)=>typeof t=="bigint"?e(t):Array.isArray(t)?t.map(a=>x(a,e)):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([a,n])=>[a,x(n,e)])):t,G=50000n,N=t=>{const e=C(t);return{domain:{chainId:t.chainId,name:"zkSync",version:"2"},message:e,primaryType:"Transaction",types:{Transaction:[{name:"txType",type:"uint256"},{name:"from",type:"uint256"},{name:"to",type:"uint256"},{name:"gasLimit",type:"uint256"},{name:"gasPerPubdataByteLimit",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymaster",type:"uint256"},{name:"nonce",type:"uint256"},{name:"value",type:"uint256"},{name:"data",type:"bytes"},{name:"factoryDeps",type:"bytes32[]"},{name:"paymasterInput",type:"bytes"}]}}};function C(t){const{gas:e,nonce:a,to:n,from:s,value:r,maxFeePerGas:i,maxPriorityFeePerGas:o,paymaster:y,paymasterInput:g,gasPerPubdata:d,data:u,factoryDeps:P}=t;return{data:u||"0x0",factoryDeps:P?.map(c=>m(k(c)))??[],from:BigInt(s),gasLimit:e??0n,gasPerPubdataByteLimit:d??G,maxFeePerGas:i??0n,maxPriorityFeePerGas:o??0n,nonce:a?BigInt(a):0n,paymaster:y?BigInt(y):0n,paymasterInput:g||"0x",to:n?BigInt(n):0n,txType:113n,value:r??0n}}async function X(t){const{account:e,transaction:a}=t,n=await I(t),s=await w({account:e,chainId:a.chain.id,eip712Transaction:n}),r=T(a),i=await D(r,s);return{chain:a.chain,client:a.client,transactionHash:i}}async function w(t){const{account:e,eip712Transaction:a,chainId:n}=t,s=N(a),r=await e.signTypedData({...s});return Y({...a,chainId:n,customSignature:r})}async function I(t){const{account:e,transaction:a}=t,{gas:n,maxFeePerGas:s,maxPriorityFeePerGas:r,gasPerPubdata:i}=await F({from:z(e.address),transaction:a});return{...await O({from:e.address,transaction:{...a,gas:n,maxFeePerGas:s,maxPriorityFeePerGas:r}}),...a.eip712,from:e.address,gasPerPubdata:i}}function Y(t){const{chainId:e,gas:a,nonce:n,to:s,from:r,value:i,maxFeePerGas:o,maxPriorityFeePerGas:y,customSignature:g,factoryDeps:d,paymaster:u,paymasterInput:P,gasPerPubdata:c,data:f}=t,E=[n?m(n):"0x",y?m(y):"0x",o?m(o):"0x",a?m(a):"0x",s??"0x",i?m(i):"0x",f??"0x0",m(e),m(""),m(""),m(e),r??"0x",c?m(c):m(G),d??[],g??"0x",u&&P?[u,P]:[]];return M(["0x71",H(E)])}async function F(t){const{transaction:e,from:a}=t;let[n,s,r,i]=await Promise.all([p(e.gas),p(e.maxFeePerGas),p(e.maxPriorityFeePerGas),p(e.eip712)]),o=i?.gasPerPubdata;if(n===void 0||s===void 0||r===void 0){const y=T(e),g=await Z({from:a,transaction:e});try{const d=await y({method:"zks_estimateFee",params:[x(g,m)]});n=l(d.gas_limit)*2n,s=l(d.max_fee_per_gas)*2n,r=l(d.max_priority_fee_per_gas)||1n,o=l(d.gas_per_pubdata_limit)*2n,o<50000n&&(o=50000n)}catch{const[{estimateGas:d},{getDefaultGasOverrides:u}]=await Promise.all([B(()=>import("./signing-lyeTiv6v.js").then(f=>f.cV),__vite__mapDeps([0,1,2,3])),B(()=>import("./signing-lyeTiv6v.js").then(f=>f.cT),__vite__mapDeps([0,1,2,3]))]),[P,c]=await Promise.all([n===void 0?d({transaction:e,from:a}):Promise.resolve(n),u(e.client,e.chain)]);n=P*2n,"maxFeePerGas"in c&&c.maxFeePerGas?s=c.maxFeePerGas*2n:"gasPrice"in c&&c.gasPrice&&(s=c.gasPrice*2n),"maxPriorityFeePerGas"in c&&c.maxPriorityFeePerGas?r=c.maxPriorityFeePerGas:r=1n,o=100000n}}return{gas:n,gasPerPubdata:o,maxFeePerGas:s,maxPriorityFeePerGas:r}}async function Z(t){const{transaction:e,from:a}=t,[n,s,r,i]=await Promise.all([S(e),p(e.to),p(e.value),p(e.eip712)]),o=i?.gasPerPubdata;return{data:n,eip712Meta:{...i,factoryDeps:i?.factoryDeps?.map(y=>Array.from(A(y))),gasPerPubdata:o||50000n},from:a,gasPerPubdata:o,to:s,type:"0x71",value:r}}const Q=Object.freeze(Object.defineProperty({__proto__:null,getZkGasFees:F,populateEip712Transaction:I,sendEip712Transaction:X,signEip712Transaction:w},Symbol.toStringTag,{value:"Module"}));export{Q as a,I as p,w as s,l as t};