@hfunlabs/hyperliquid 0.30.0-hfunlabs.1 → 0.30.2-hfunlabs.2

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 (397) hide show
  1. package/esm/_dnt.shims.d.ts +2 -0
  2. package/esm/_dnt.shims.d.ts.map +1 -0
  3. package/esm/_dnt.shims.js +58 -0
  4. package/esm/_dnt.shims.js.map +1 -0
  5. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts +195 -0
  6. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js +457 -0
  8. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js.map +1 -0
  9. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts +90 -0
  10. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js +207 -0
  12. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js.map +1 -0
  13. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts +159 -0
  14. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js +555 -0
  16. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js.map +1 -0
  17. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts +325 -0
  18. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js +1222 -0
  20. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js.map +1 -0
  21. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts +76 -0
  22. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts.map +1 -0
  23. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js +283 -0
  24. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js.map +1 -0
  25. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts +103 -0
  26. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.js +241 -0
  28. package/esm/deps/jsr.io/@noble/curves/2.0.1/src/utils.js.map +1 -0
  29. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts +49 -0
  30. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts.map +1 -0
  31. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js +147 -0
  32. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js.map +1 -0
  33. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts +55 -0
  34. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts.map +1 -0
  35. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js +67 -0
  36. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js.map +1 -0
  37. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts +36 -0
  38. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js +90 -0
  40. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js.map +1 -0
  41. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts +199 -0
  42. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts.map +1 -0
  43. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js +397 -0
  44. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js.map +1 -0
  45. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts +58 -0
  46. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts.map +1 -0
  47. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js +254 -0
  48. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js.map +1 -0
  49. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts +124 -0
  50. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js +243 -0
  52. package/esm/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js.map +1 -0
  53. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts +44 -0
  54. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts.map +1 -0
  55. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js +144 -0
  56. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js.map +1 -0
  57. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts +38 -0
  58. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts.map +1 -0
  59. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js +96 -0
  60. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js.map +1 -0
  61. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts +23 -0
  62. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts.map +1 -0
  63. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js +98 -0
  64. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js.map +1 -0
  65. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts +300 -0
  66. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts.map +1 -0
  67. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js +535 -0
  68. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js.map +1 -0
  69. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts +98 -0
  70. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts.map +1 -0
  71. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js +207 -0
  72. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js.map +1 -0
  73. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts +78 -0
  74. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts.map +1 -0
  75. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js +298 -0
  76. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js.map +1 -0
  77. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts +6 -0
  78. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts.map +1 -0
  79. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js +6 -0
  80. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js.map +1 -0
  81. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts +66 -0
  82. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts.map +1 -0
  83. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js +180 -0
  84. package/esm/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js.map +1 -0
  85. package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts +877 -0
  86. package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts.map +1 -0
  87. package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js +2001 -0
  88. package/esm/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js.map +1 -0
  89. package/esm/deps/jsr.io/@scure/base/2.0.0/index.d.ts +294 -0
  90. package/esm/deps/jsr.io/@scure/base/2.0.0/index.d.ts.map +1 -0
  91. package/esm/deps/jsr.io/@scure/base/2.0.0/index.js +704 -0
  92. package/esm/deps/jsr.io/@scure/base/2.0.0/index.js.map +1 -0
  93. package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts +93 -0
  94. package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts.map +1 -0
  95. package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js +137 -0
  96. package/esm/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js.map +1 -0
  97. package/esm/src/api/exchange/_methods/_base/_nonce.d.ts +3 -2
  98. package/esm/src/api/exchange/_methods/_base/_nonce.d.ts.map +1 -1
  99. package/esm/src/api/exchange/_methods/_base/_nonce.js +3 -2
  100. package/esm/src/api/exchange/_methods/_base/_nonce.js.map +1 -1
  101. package/esm/src/api/exchange/_methods/_base/_semaphore.d.ts +7 -6
  102. package/esm/src/api/exchange/_methods/_base/_semaphore.d.ts.map +1 -1
  103. package/esm/src/api/exchange/_methods/_base/_semaphore.js +34 -47
  104. package/esm/src/api/exchange/_methods/_base/_semaphore.js.map +1 -1
  105. package/esm/src/api/exchange/_methods/_base/execute.d.ts +14 -3
  106. package/esm/src/api/exchange/_methods/_base/execute.d.ts.map +1 -1
  107. package/esm/src/api/exchange/_methods/_base/execute.js +44 -10
  108. package/esm/src/api/exchange/_methods/_base/execute.js.map +1 -1
  109. package/esm/src/api/exchange/_methods/batchModify.d.ts +6 -6
  110. package/esm/src/api/exchange/_methods/createVault.d.ts +5 -5
  111. package/esm/src/api/exchange/_methods/modify.d.ts +5 -5
  112. package/esm/src/api/exchange/_methods/order.d.ts +13 -13
  113. package/esm/src/api/exchange/_methods/order.d.ts.map +1 -1
  114. package/esm/src/api/exchange/_methods/order.js +4 -2
  115. package/esm/src/api/exchange/_methods/order.js.map +1 -1
  116. package/esm/src/api/exchange/client.d.ts +1 -1
  117. package/esm/src/api/exchange/client.d.ts.map +1 -1
  118. package/esm/src/api/exchange/client.js.map +1 -1
  119. package/esm/src/api/exchange/mod.d.ts +1 -1
  120. package/esm/src/api/exchange/mod.d.ts.map +1 -1
  121. package/esm/src/api/exchange/mod.js.map +1 -1
  122. package/esm/src/api/info/_methods/_base/commonSchemas.d.ts +8 -8
  123. package/esm/src/api/info/_methods/frontendOpenOrders.d.ts +3 -3
  124. package/esm/src/api/info/_methods/historicalOrders.d.ts +4 -4
  125. package/esm/src/api/info/_methods/l3Orders.d.ts +11 -11
  126. package/esm/src/api/info/_methods/l4Orders.d.ts +6 -6
  127. package/esm/src/api/info/_methods/openOrders.d.ts +3 -3
  128. package/esm/src/api/info/_methods/orderStatus.d.ts +5 -5
  129. package/esm/src/api/info/_methods/recentTrades.d.ts +2 -2
  130. package/esm/src/api/info/_methods/twapHistory.d.ts +4 -4
  131. package/esm/src/api/info/_methods/userFills.d.ts +3 -3
  132. package/esm/src/api/info/_methods/userFillsByTime.d.ts +4 -4
  133. package/esm/src/api/info/_methods/userFunding.d.ts +3 -3
  134. package/esm/src/api/info/_methods/userFunding.js +2 -2
  135. package/esm/src/api/info/_methods/userFunding.js.map +1 -1
  136. package/esm/src/api/info/_methods/userTwapSliceFills.d.ts +4 -4
  137. package/esm/src/api/info/_methods/userTwapSliceFillsByTime.d.ts +5 -5
  138. package/esm/src/api/info/_methods/webData2.d.ts +9 -9
  139. package/esm/src/api/subscription/_methods/assetCtxs.d.ts +2 -0
  140. package/esm/src/api/subscription/_methods/assetCtxs.d.ts.map +1 -1
  141. package/esm/src/api/subscription/_methods/assetCtxs.js.map +1 -1
  142. package/esm/src/api/subscription/_methods/clearinghouseState.d.ts +2 -0
  143. package/esm/src/api/subscription/_methods/clearinghouseState.d.ts.map +1 -1
  144. package/esm/src/api/subscription/_methods/clearinghouseState.js +2 -0
  145. package/esm/src/api/subscription/_methods/clearinghouseState.js.map +1 -1
  146. package/esm/src/api/subscription/_methods/explorerBlock.d.ts +2 -0
  147. package/esm/src/api/subscription/_methods/explorerBlock.d.ts.map +1 -1
  148. package/esm/src/api/subscription/_methods/explorerBlock.js +2 -0
  149. package/esm/src/api/subscription/_methods/explorerBlock.js.map +1 -1
  150. package/esm/src/api/subscription/_methods/explorerTxs.d.ts +2 -0
  151. package/esm/src/api/subscription/_methods/explorerTxs.d.ts.map +1 -1
  152. package/esm/src/api/subscription/_methods/explorerTxs.js +2 -0
  153. package/esm/src/api/subscription/_methods/explorerTxs.js.map +1 -1
  154. package/esm/src/api/subscription/_methods/openOrders.d.ts +5 -5
  155. package/esm/src/api/subscription/_methods/orderUpdates.d.ts +4 -4
  156. package/esm/src/api/subscription/_methods/trades.d.ts +3 -3
  157. package/esm/src/api/subscription/_methods/twapStates.d.ts +9 -4
  158. package/esm/src/api/subscription/_methods/twapStates.d.ts.map +1 -1
  159. package/esm/src/api/subscription/_methods/twapStates.js +6 -1
  160. package/esm/src/api/subscription/_methods/twapStates.js.map +1 -1
  161. package/esm/src/api/subscription/_methods/userEvents.d.ts +17 -17
  162. package/esm/src/api/subscription/_methods/userFills.d.ts +5 -5
  163. package/esm/src/api/subscription/_methods/userHistoricalOrders.d.ts +6 -6
  164. package/esm/src/api/subscription/_methods/userTwapHistory.d.ts +6 -6
  165. package/esm/src/api/subscription/_methods/userTwapSliceFills.d.ts +6 -6
  166. package/esm/src/api/subscription/_methods/webData2.d.ts +11 -11
  167. package/esm/src/signing/_privateKeySigner.js +1 -1
  168. package/esm/src/signing/_privateKeySigner.js.map +1 -1
  169. package/esm/src/signing/mod.js +1 -1
  170. package/esm/src/signing/mod.js.map +1 -1
  171. package/package.json +2 -3
  172. package/script/_dnt.shims.d.ts +2 -0
  173. package/script/_dnt.shims.d.ts.map +1 -0
  174. package/script/_dnt.shims.js +61 -0
  175. package/script/_dnt.shims.js.map +1 -0
  176. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts +195 -0
  177. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.d.ts.map +1 -0
  178. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js +468 -0
  179. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.js.map +1 -0
  180. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts +90 -0
  181. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.d.ts.map +1 -0
  182. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js +215 -0
  183. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.js.map +1 -0
  184. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts +159 -0
  185. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.d.ts.map +1 -0
  186. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js +578 -0
  187. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.js.map +1 -0
  188. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts +325 -0
  189. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.d.ts.map +1 -0
  190. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js +1232 -0
  191. package/script/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.js.map +1 -0
  192. package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts +76 -0
  193. package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.d.ts.map +1 -0
  194. package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js +286 -0
  195. package/script/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.js.map +1 -0
  196. package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts +103 -0
  197. package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.d.ts.map +1 -0
  198. package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.js +273 -0
  199. package/script/deps/jsr.io/@noble/curves/2.0.1/src/utils.js.map +1 -0
  200. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts +49 -0
  201. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.d.ts.map +1 -0
  202. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js +153 -0
  203. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_md.js.map +1 -0
  204. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts +55 -0
  205. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.d.ts.map +1 -0
  206. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js +90 -0
  207. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.js.map +1 -0
  208. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts +36 -0
  209. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.d.ts.map +1 -0
  210. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js +95 -0
  211. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.js.map +1 -0
  212. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts +199 -0
  213. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.d.ts.map +1 -0
  214. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js +439 -0
  215. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.js.map +1 -0
  216. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts +58 -0
  217. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.d.ts.map +1 -0
  218. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js +259 -0
  219. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.js.map +1 -0
  220. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts +124 -0
  221. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.d.ts.map +1 -0
  222. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js +304 -0
  223. package/script/deps/jsr.io/@noble/hashes/2.0.1/src/utils.js.map +1 -0
  224. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts +44 -0
  225. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.d.ts.map +1 -0
  226. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js +182 -0
  227. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.js.map +1 -0
  228. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts +38 -0
  229. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.d.ts.map +1 -0
  230. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js +99 -0
  231. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.js.map +1 -0
  232. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts +23 -0
  233. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.d.ts.map +1 -0
  234. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js +134 -0
  235. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.js.map +1 -0
  236. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts +300 -0
  237. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.d.ts.map +1 -0
  238. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js +576 -0
  239. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.js.map +1 -0
  240. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts +98 -0
  241. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.d.ts.map +1 -0
  242. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js +211 -0
  243. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.js.map +1 -0
  244. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts +78 -0
  245. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.d.ts.map +1 -0
  246. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js +308 -0
  247. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.js.map +1 -0
  248. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts +6 -0
  249. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.d.ts.map +1 -0
  250. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js +21 -0
  251. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.js.map +1 -0
  252. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts +66 -0
  253. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.d.ts.map +1 -0
  254. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js +195 -0
  255. package/script/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.js.map +1 -0
  256. package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts +877 -0
  257. package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.d.ts.map +1 -0
  258. package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js +2032 -0
  259. package/script/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.js.map +1 -0
  260. package/script/deps/jsr.io/@scure/base/2.0.0/index.d.ts +294 -0
  261. package/script/deps/jsr.io/@scure/base/2.0.0/index.d.ts.map +1 -0
  262. package/script/deps/jsr.io/@scure/base/2.0.0/index.js +710 -0
  263. package/script/deps/jsr.io/@scure/base/2.0.0/index.js.map +1 -0
  264. package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts +93 -0
  265. package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.d.ts.map +1 -0
  266. package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js +141 -0
  267. package/script/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.js.map +1 -0
  268. package/script/src/api/exchange/_methods/_base/_nonce.d.ts +3 -2
  269. package/script/src/api/exchange/_methods/_base/_nonce.d.ts.map +1 -1
  270. package/script/src/api/exchange/_methods/_base/_nonce.js +4 -3
  271. package/script/src/api/exchange/_methods/_base/_nonce.js.map +1 -1
  272. package/script/src/api/exchange/_methods/_base/_semaphore.d.ts +7 -6
  273. package/script/src/api/exchange/_methods/_base/_semaphore.d.ts.map +1 -1
  274. package/script/src/api/exchange/_methods/_base/_semaphore.js +35 -50
  275. package/script/src/api/exchange/_methods/_base/_semaphore.js.map +1 -1
  276. package/script/src/api/exchange/_methods/_base/execute.d.ts +14 -3
  277. package/script/src/api/exchange/_methods/_base/execute.d.ts.map +1 -1
  278. package/script/src/api/exchange/_methods/_base/execute.js +43 -9
  279. package/script/src/api/exchange/_methods/_base/execute.js.map +1 -1
  280. package/script/src/api/exchange/_methods/batchModify.d.ts +6 -6
  281. package/script/src/api/exchange/_methods/createVault.d.ts +5 -5
  282. package/script/src/api/exchange/_methods/modify.d.ts +5 -5
  283. package/script/src/api/exchange/_methods/order.d.ts +13 -13
  284. package/script/src/api/exchange/_methods/order.d.ts.map +1 -1
  285. package/script/src/api/exchange/_methods/order.js +4 -2
  286. package/script/src/api/exchange/_methods/order.js.map +1 -1
  287. package/script/src/api/exchange/client.d.ts +1 -1
  288. package/script/src/api/exchange/client.d.ts.map +1 -1
  289. package/script/src/api/exchange/client.js.map +1 -1
  290. package/script/src/api/exchange/mod.d.ts +1 -1
  291. package/script/src/api/exchange/mod.d.ts.map +1 -1
  292. package/script/src/api/exchange/mod.js.map +1 -1
  293. package/script/src/api/info/_methods/_base/commonSchemas.d.ts +8 -8
  294. package/script/src/api/info/_methods/frontendOpenOrders.d.ts +3 -3
  295. package/script/src/api/info/_methods/historicalOrders.d.ts +4 -4
  296. package/script/src/api/info/_methods/l3Orders.d.ts +11 -11
  297. package/script/src/api/info/_methods/l4Orders.d.ts +6 -6
  298. package/script/src/api/info/_methods/openOrders.d.ts +3 -3
  299. package/script/src/api/info/_methods/orderStatus.d.ts +5 -5
  300. package/script/src/api/info/_methods/recentTrades.d.ts +2 -2
  301. package/script/src/api/info/_methods/twapHistory.d.ts +4 -4
  302. package/script/src/api/info/_methods/userFills.d.ts +3 -3
  303. package/script/src/api/info/_methods/userFillsByTime.d.ts +4 -4
  304. package/script/src/api/info/_methods/userFunding.d.ts +3 -3
  305. package/script/src/api/info/_methods/userFunding.js +2 -2
  306. package/script/src/api/info/_methods/userFunding.js.map +1 -1
  307. package/script/src/api/info/_methods/userTwapSliceFills.d.ts +4 -4
  308. package/script/src/api/info/_methods/userTwapSliceFillsByTime.d.ts +5 -5
  309. package/script/src/api/info/_methods/webData2.d.ts +9 -9
  310. package/script/src/api/subscription/_methods/assetCtxs.d.ts +2 -0
  311. package/script/src/api/subscription/_methods/assetCtxs.d.ts.map +1 -1
  312. package/script/src/api/subscription/_methods/assetCtxs.js.map +1 -1
  313. package/script/src/api/subscription/_methods/clearinghouseState.d.ts +2 -0
  314. package/script/src/api/subscription/_methods/clearinghouseState.d.ts.map +1 -1
  315. package/script/src/api/subscription/_methods/clearinghouseState.js +2 -0
  316. package/script/src/api/subscription/_methods/clearinghouseState.js.map +1 -1
  317. package/script/src/api/subscription/_methods/explorerBlock.d.ts +2 -0
  318. package/script/src/api/subscription/_methods/explorerBlock.d.ts.map +1 -1
  319. package/script/src/api/subscription/_methods/explorerBlock.js +2 -0
  320. package/script/src/api/subscription/_methods/explorerBlock.js.map +1 -1
  321. package/script/src/api/subscription/_methods/explorerTxs.d.ts +2 -0
  322. package/script/src/api/subscription/_methods/explorerTxs.d.ts.map +1 -1
  323. package/script/src/api/subscription/_methods/explorerTxs.js +2 -0
  324. package/script/src/api/subscription/_methods/explorerTxs.js.map +1 -1
  325. package/script/src/api/subscription/_methods/openOrders.d.ts +5 -5
  326. package/script/src/api/subscription/_methods/orderUpdates.d.ts +4 -4
  327. package/script/src/api/subscription/_methods/trades.d.ts +3 -3
  328. package/script/src/api/subscription/_methods/twapStates.d.ts +9 -4
  329. package/script/src/api/subscription/_methods/twapStates.d.ts.map +1 -1
  330. package/script/src/api/subscription/_methods/twapStates.js +6 -1
  331. package/script/src/api/subscription/_methods/twapStates.js.map +1 -1
  332. package/script/src/api/subscription/_methods/userEvents.d.ts +17 -17
  333. package/script/src/api/subscription/_methods/userFills.d.ts +5 -5
  334. package/script/src/api/subscription/_methods/userHistoricalOrders.d.ts +6 -6
  335. package/script/src/api/subscription/_methods/userTwapHistory.d.ts +6 -6
  336. package/script/src/api/subscription/_methods/userTwapSliceFills.d.ts +6 -6
  337. package/script/src/api/subscription/_methods/webData2.d.ts +11 -11
  338. package/script/src/signing/_privateKeySigner.js +3 -3
  339. package/script/src/signing/_privateKeySigner.js.map +1 -1
  340. package/script/src/signing/mod.js +2 -2
  341. package/script/src/signing/mod.js.map +1 -1
  342. package/src/_dnt.shims.ts +60 -0
  343. package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.ts +633 -0
  344. package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/hash-to-curve.ts +292 -0
  345. package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/modular.ts +621 -0
  346. package/src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/weierstrass.ts +1562 -0
  347. package/src/deps/jsr.io/@noble/curves/2.0.1/src/secp256k1.ts +327 -0
  348. package/src/deps/jsr.io/@noble/curves/2.0.1/src/utils.ts +306 -0
  349. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/_md.ts +156 -0
  350. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/_u64.ts +91 -0
  351. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/hmac.ts +94 -0
  352. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/sha2.ts +469 -0
  353. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/sha3.ts +295 -0
  354. package/src/deps/jsr.io/@noble/hashes/2.0.1/src/utils.ts +340 -0
  355. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/advanced/abi-mapper.ts +212 -0
  356. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/address.ts +100 -0
  357. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/rlp.ts +104 -0
  358. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx-internal.ts +626 -0
  359. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/tx.ts +274 -0
  360. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/core/typed-data.ts +391 -0
  361. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/index.ts +12 -0
  362. package/src/deps/jsr.io/@paulmillr/micro-eth-signer/0.18.1/src/utils.ts +233 -0
  363. package/src/deps/jsr.io/@paulmillr/micro-packed/0.8.0/src/index.ts +2196 -0
  364. package/src/deps/jsr.io/@scure/base/2.0.0/index.ts +857 -0
  365. package/src/deps/jsr.io/@std/async/1.0.16/unstable_semaphore.ts +146 -0
  366. package/src/src/api/exchange/_methods/_base/_nonce.ts +3 -2
  367. package/src/src/api/exchange/_methods/_base/_semaphore.ts +34 -59
  368. package/src/src/api/exchange/_methods/_base/execute.ts +60 -12
  369. package/src/src/api/exchange/_methods/order.ts +5 -3
  370. package/src/src/api/exchange/client.ts +5 -1
  371. package/src/src/api/exchange/mod.ts +5 -1
  372. package/src/src/api/info/_methods/userFunding.ts +2 -2
  373. package/src/src/api/subscription/_methods/assetCtxs.ts +2 -0
  374. package/src/src/api/subscription/_methods/clearinghouseState.ts +2 -0
  375. package/src/src/api/subscription/_methods/explorerBlock.ts +2 -0
  376. package/src/src/api/subscription/_methods/explorerTxs.ts +2 -0
  377. package/src/src/api/subscription/_methods/twapStates.ts +9 -1
  378. package/src/src/signing/_privateKeySigner.ts +1 -1
  379. package/src/src/signing/mod.ts +1 -1
  380. package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts +0 -21
  381. package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts.map +0 -1
  382. package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.js +0 -292
  383. package/esm/deps/jsr.io/@std/msgpack/1.0.3/decode.js.map +0 -1
  384. package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts +0 -44
  385. package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts.map +0 -1
  386. package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.js +0 -46
  387. package/esm/deps/jsr.io/@std/msgpack/1.0.3/mod.js.map +0 -1
  388. package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts +0 -21
  389. package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.d.ts.map +0 -1
  390. package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.js +0 -295
  391. package/script/deps/jsr.io/@std/msgpack/1.0.3/decode.js.map +0 -1
  392. package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts +0 -44
  393. package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.d.ts.map +0 -1
  394. package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.js +0 -62
  395. package/script/deps/jsr.io/@std/msgpack/1.0.3/mod.js.map +0 -1
  396. package/src/deps/jsr.io/@std/msgpack/1.0.3/decode.ts +0 -391
  397. package/src/deps/jsr.io/@std/msgpack/1.0.3/mod.ts +0 -47
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Methods for elliptic curve multiplication by scalars.
3
+ * Contains wNAF, pippenger.
4
+ * @module
5
+ */
6
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7
+ import { type Signer } from '../utils.js';
8
+ import { type IField } from './modular.js';
9
+ export type AffinePoint<T> = {
10
+ x: T;
11
+ y: T;
12
+ } & {
13
+ Z?: never;
14
+ };
15
+ /** Base interface for all elliptic curve Points. */
16
+ export interface CurvePoint<F, P extends CurvePoint<F, P>> {
17
+ /** Affine x coordinate. Different from projective / extended X coordinate. */
18
+ x: F;
19
+ /** Affine y coordinate. Different from projective / extended Y coordinate. */
20
+ y: F;
21
+ Z?: F;
22
+ double(): P;
23
+ negate(): P;
24
+ add(other: P): P;
25
+ subtract(other: P): P;
26
+ equals(other: P): boolean;
27
+ multiply(scalar: bigint): P;
28
+ assertValidity(): void;
29
+ clearCofactor(): P;
30
+ is0(): boolean;
31
+ isTorsionFree(): boolean;
32
+ isSmallOrder(): boolean;
33
+ multiplyUnsafe(scalar: bigint): P;
34
+ /**
35
+ * Massively speeds up `p.multiply(n)` by using precompute tables (caching). See {@link wNAF}.
36
+ * @param isLazy calculate cache now. Default (true) ensures it's deferred to first `multiply()`
37
+ */
38
+ precompute(windowSize?: number, isLazy?: boolean): P;
39
+ /** Converts point to 2D xy affine coordinates */
40
+ toAffine(invertedZ?: F): AffinePoint<F>;
41
+ toBytes(): Uint8Array;
42
+ toHex(): string;
43
+ }
44
+ /** Base interface for all elliptic curve Point constructors. */
45
+ export interface CurvePointCons<P extends CurvePoint<any, P>> {
46
+ [Symbol.hasInstance]: (item: unknown) => boolean;
47
+ BASE: P;
48
+ ZERO: P;
49
+ /** Field for basic curve math */
50
+ Fp: IField<P_F<P>>;
51
+ /** Scalar field, for scalars in multiply and others */
52
+ Fn: IField<bigint>;
53
+ /** Creates point from x, y. Does NOT validate if the point is valid. Use `.assertValidity()`. */
54
+ fromAffine(p: AffinePoint<P_F<P>>): P;
55
+ fromBytes(bytes: Uint8Array): P;
56
+ fromHex(hex: string): P;
57
+ }
58
+ /** Returns Fp type from Point (P_F<P> == P.F) */
59
+ export type P_F<P extends CurvePoint<any, P>> = P extends CurvePoint<infer F, P> ? F : never;
60
+ /** Returns Fp type from PointCons (PC_F<PC> == PC.P.F) */
61
+ export type PC_F<PC extends CurvePointCons<CurvePoint<any, any>>> = PC['Fp']['ZERO'];
62
+ /** Returns Point type from PointCons (PC_P<PC> == PC.P) */
63
+ export type PC_P<PC extends CurvePointCons<CurvePoint<any, any>>> = PC['ZERO'];
64
+ export type PC_ANY = CurvePointCons<CurvePoint<any, CurvePoint<any, CurvePoint<any, CurvePoint<any, CurvePoint<any, CurvePoint<any, CurvePoint<any, CurvePoint<any, CurvePoint<any, CurvePoint<any, any>>>>>>>>>>>;
65
+ export interface CurveLengths {
66
+ secretKey?: number;
67
+ publicKey?: number;
68
+ publicKeyUncompressed?: number;
69
+ publicKeyHasPrefix?: boolean;
70
+ signature?: number;
71
+ seed?: number;
72
+ }
73
+ export type Mapper<T> = (i: T[]) => T[];
74
+ export declare function negateCt<T extends {
75
+ negate: () => T;
76
+ }>(condition: boolean, item: T): T;
77
+ /**
78
+ * Takes a bunch of Projective Points but executes only one
79
+ * inversion on all of them. Inversion is very slow operation,
80
+ * so this improves performance massively.
81
+ * Optimization: converts a list of projective points to a list of identical points with Z=1.
82
+ */
83
+ export declare function normalizeZ<P extends CurvePoint<any, P>, PC extends CurvePointCons<P>>(c: PC, points: P[]): P[];
84
+ /**
85
+ * Elliptic curve multiplication of Point by scalar. Fragile.
86
+ * Table generation takes **30MB of ram and 10ms on high-end CPU**,
87
+ * but may take much longer on slow devices. Actual generation will happen on
88
+ * first call of `multiply()`. By default, `BASE` point is precomputed.
89
+ *
90
+ * Scalars should always be less than curve order: this should be checked inside of a curve itself.
91
+ * Creates precomputation tables for fast multiplication:
92
+ * - private scalar is split by fixed size windows of W bits
93
+ * - every window point is collected from window's table & added to accumulator
94
+ * - since windows are different, same point inside tables won't be accessed more than once per calc
95
+ * - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar)
96
+ * - +1 window is neccessary for wNAF
97
+ * - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication
98
+ *
99
+ * @todo Research returning 2d JS array of windows, instead of a single window.
100
+ * This would allow windows to be in different memory locations
101
+ */
102
+ export declare class wNAF<PC extends PC_ANY> {
103
+ private readonly BASE;
104
+ private readonly ZERO;
105
+ private readonly Fn;
106
+ readonly bits: number;
107
+ constructor(Point: PC, bits: number);
108
+ _unsafeLadder(elm: PC_P<PC>, n: bigint, p?: PC_P<PC>): PC_P<PC>;
109
+ /**
110
+ * Creates a wNAF precomputation window. Used for caching.
111
+ * Default window size is set by `utils.precompute()` and is equal to 8.
112
+ * Number of precomputed points depends on the curve size:
113
+ * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
114
+ * - 𝑊 is the window size
115
+ * - 𝑛 is the bitlength of the curve order.
116
+ * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
117
+ * @param point Point instance
118
+ * @param W window size
119
+ * @returns precomputed point tables flattened to a single array
120
+ */
121
+ private precomputeWindow;
122
+ /**
123
+ * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
124
+ * More compact implementation:
125
+ * https://github.com/paulmillr/noble-secp256k1/blob/47cb1669b6e506ad66b35fe7d76132ae97465da2/index.ts#L502-L541
126
+ * @returns real and fake (for const-time) points
127
+ */
128
+ private wNAF;
129
+ /**
130
+ * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
131
+ * @param acc accumulator point to add result of multiplication
132
+ * @returns point
133
+ */
134
+ private wNAFUnsafe;
135
+ private getPrecomputes;
136
+ cached(point: PC_P<PC>, scalar: bigint, transform?: Mapper<PC_P<PC>>): {
137
+ p: PC_P<PC>;
138
+ f: PC_P<PC>;
139
+ };
140
+ unsafe(point: PC_P<PC>, scalar: bigint, transform?: Mapper<PC_P<PC>>, prev?: PC_P<PC>): PC_P<PC>;
141
+ createCache(P: PC_P<PC>, W: number): void;
142
+ hasCache(elm: PC_P<PC>): boolean;
143
+ }
144
+ /**
145
+ * Endomorphism-specific multiplication for Koblitz curves.
146
+ * Cost: 128 dbl, 0-256 adds.
147
+ */
148
+ export declare function mulEndoUnsafe<P extends CurvePoint<any, P>, PC extends CurvePointCons<P>>(Point: PC, point: P, k1: bigint, k2: bigint): {
149
+ p1: P;
150
+ p2: P;
151
+ };
152
+ /**
153
+ * Pippenger algorithm for multi-scalar multiplication (MSM, Pa + Qb + Rc + ...).
154
+ * 30x faster vs naive addition on L=4096, 10x faster than precomputes.
155
+ * For N=254bit, L=1, it does: 1024 ADD + 254 DBL. For L=5: 1536 ADD + 254 DBL.
156
+ * Algorithmically constant-time (for same L), even when 1 point + scalar, or when scalar = 0.
157
+ * @param c Curve Point constructor
158
+ * @param fieldN field over CURVE.N - important that it's not over CURVE.P
159
+ * @param points array of L curve points
160
+ * @param scalars array of L scalars (aka secret keys / bigints)
161
+ */
162
+ export declare function pippenger<P extends CurvePoint<any, P>, PC extends CurvePointCons<P>>(c: PC, points: P[], scalars: bigint[]): P;
163
+ /**
164
+ * Precomputed multi-scalar multiplication (MSM, Pa + Qb + Rc + ...).
165
+ * @param c Curve Point constructor
166
+ * @param fieldN field over CURVE.N - important that it's not over CURVE.P
167
+ * @param points array of L curve points
168
+ * @returns function which multiplies points with scaars
169
+ */
170
+ export declare function precomputeMSMUnsafe<P extends CurvePoint<any, P>, PC extends CurvePointCons<P>>(c: PC, points: P[], windowSize: number): (scalars: bigint[]) => P;
171
+ export type ValidCurveParams<T> = {
172
+ p: bigint;
173
+ n: bigint;
174
+ h: bigint;
175
+ a: T;
176
+ b?: T;
177
+ d?: T;
178
+ Gx: T;
179
+ Gy: T;
180
+ };
181
+ export type FpFn<T> = {
182
+ Fp: IField<T>;
183
+ Fn: IField<bigint>;
184
+ };
185
+ /** Validates CURVE opts and creates fields */
186
+ export declare function createCurveFields<T>(type: 'weierstrass' | 'edwards', CURVE: ValidCurveParams<T>, curveOpts?: Partial<FpFn<T>>, FpFnLE?: boolean): FpFn<T> & {
187
+ CURVE: ValidCurveParams<T>;
188
+ };
189
+ type KeygenFn = (seed?: Uint8Array, isCompressed?: boolean) => {
190
+ secretKey: Uint8Array;
191
+ publicKey: Uint8Array;
192
+ };
193
+ export declare function createKeygen(randomSecretKey: Function, getPublicKey: Signer['getPublicKey']): KeygenFn;
194
+ export {};
195
+ //# sourceMappingURL=curve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curve.d.ts","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@noble/curves/2.0.1/src/abstract/curve.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,sEAAsE;AACtE,OAAO,EAAmB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAuC,KAAK,MAAM,EAAE,MAAM,cAA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I,CAAC,EAAE,UAAU,EACjB,YAAY,CAAC,EAAE,OAAO,KACnB;IAAE,SAAS,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,CAAC;AACtD,wBAAgB,YAAY,CAC1B,eAAe,EAAE,QAAQ,EACzB,YAAY,EAAE,MAAM,CAAC,cAAc,CAAC,GACnC,QAAQ,CAKV"}
@@ -0,0 +1,468 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wNAF = void 0;
4
+ exports.negateCt = negateCt;
5
+ exports.normalizeZ = normalizeZ;
6
+ exports.mulEndoUnsafe = mulEndoUnsafe;
7
+ exports.pippenger = pippenger;
8
+ exports.precomputeMSMUnsafe = precomputeMSMUnsafe;
9
+ exports.createCurveFields = createCurveFields;
10
+ exports.createKeygen = createKeygen;
11
+ /**
12
+ * Methods for elliptic curve multiplication by scalars.
13
+ * Contains wNAF, pippenger.
14
+ * @module
15
+ */
16
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
17
+ const utils_js_1 = require("../utils.js");
18
+ const modular_js_1 = require("./modular.js");
19
+ const _0n = /* @__PURE__ */ BigInt(0);
20
+ const _1n = /* @__PURE__ */ BigInt(1);
21
+ function negateCt(condition, item) {
22
+ const neg = item.negate();
23
+ return condition ? neg : item;
24
+ }
25
+ /**
26
+ * Takes a bunch of Projective Points but executes only one
27
+ * inversion on all of them. Inversion is very slow operation,
28
+ * so this improves performance massively.
29
+ * Optimization: converts a list of projective points to a list of identical points with Z=1.
30
+ */
31
+ function normalizeZ(c, points) {
32
+ const invertedZs = (0, modular_js_1.FpInvertBatch)(c.Fp, points.map((p) => p.Z));
33
+ return points.map((p, i) => c.fromAffine(p.toAffine(invertedZs[i])));
34
+ }
35
+ function validateW(W, bits) {
36
+ if (!Number.isSafeInteger(W) || W <= 0 || W > bits)
37
+ throw new Error('invalid window size, expected [1..' + bits + '], got W=' + W);
38
+ }
39
+ function calcWOpts(W, scalarBits) {
40
+ validateW(W, scalarBits);
41
+ const windows = Math.ceil(scalarBits / W) + 1; // W=8 33. Not 32, because we skip zero
42
+ const windowSize = 2 ** (W - 1); // W=8 128. Not 256, because we skip zero
43
+ const maxNumber = 2 ** W; // W=8 256
44
+ const mask = (0, utils_js_1.bitMask)(W); // W=8 255 == mask 0b11111111
45
+ const shiftBy = BigInt(W); // W=8 8
46
+ return { windows, windowSize, mask, maxNumber, shiftBy };
47
+ }
48
+ function calcOffsets(n, window, wOpts) {
49
+ const { windowSize, mask, maxNumber, shiftBy } = wOpts;
50
+ let wbits = Number(n & mask); // extract W bits.
51
+ let nextN = n >> shiftBy; // shift number by W bits.
52
+ // What actually happens here:
53
+ // const highestBit = Number(mask ^ (mask >> 1n));
54
+ // let wbits2 = wbits - 1; // skip zero
55
+ // if (wbits2 & highestBit) { wbits2 ^= Number(mask); // (~);
56
+ // split if bits > max: +224 => 256-32
57
+ if (wbits > windowSize) {
58
+ // we skip zero, which means instead of `>= size-1`, we do `> size`
59
+ wbits -= maxNumber; // -32, can be maxNumber - wbits, but then we need to set isNeg here.
60
+ nextN += _1n; // +256 (carry)
61
+ }
62
+ const offsetStart = window * windowSize;
63
+ const offset = offsetStart + Math.abs(wbits) - 1; // -1 because we skip zero
64
+ const isZero = wbits === 0; // is current window slice a 0?
65
+ const isNeg = wbits < 0; // is current window slice negative?
66
+ const isNegF = window % 2 !== 0; // fake random statement for noise
67
+ const offsetF = offsetStart; // fake offset for noise
68
+ return { nextN, offset, isZero, isNeg, isNegF, offsetF };
69
+ }
70
+ function validateMSMPoints(points, c) {
71
+ if (!Array.isArray(points))
72
+ throw new Error('array expected');
73
+ points.forEach((p, i) => {
74
+ if (!(p instanceof c))
75
+ throw new Error('invalid point at index ' + i);
76
+ });
77
+ }
78
+ function validateMSMScalars(scalars, field) {
79
+ if (!Array.isArray(scalars))
80
+ throw new Error('array of scalars expected');
81
+ scalars.forEach((s, i) => {
82
+ if (!field.isValid(s))
83
+ throw new Error('invalid scalar at index ' + i);
84
+ });
85
+ }
86
+ // Since points in different groups cannot be equal (different object constructor),
87
+ // we can have single place to store precomputes.
88
+ // Allows to make points frozen / immutable.
89
+ const pointPrecomputes = new WeakMap();
90
+ const pointWindowSizes = new WeakMap();
91
+ function getW(P) {
92
+ // To disable precomputes:
93
+ // return 1;
94
+ return pointWindowSizes.get(P) || 1;
95
+ }
96
+ function assert0(n) {
97
+ if (n !== _0n)
98
+ throw new Error('invalid wNAF');
99
+ }
100
+ /**
101
+ * Elliptic curve multiplication of Point by scalar. Fragile.
102
+ * Table generation takes **30MB of ram and 10ms on high-end CPU**,
103
+ * but may take much longer on slow devices. Actual generation will happen on
104
+ * first call of `multiply()`. By default, `BASE` point is precomputed.
105
+ *
106
+ * Scalars should always be less than curve order: this should be checked inside of a curve itself.
107
+ * Creates precomputation tables for fast multiplication:
108
+ * - private scalar is split by fixed size windows of W bits
109
+ * - every window point is collected from window's table & added to accumulator
110
+ * - since windows are different, same point inside tables won't be accessed more than once per calc
111
+ * - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar)
112
+ * - +1 window is neccessary for wNAF
113
+ * - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication
114
+ *
115
+ * @todo Research returning 2d JS array of windows, instead of a single window.
116
+ * This would allow windows to be in different memory locations
117
+ */
118
+ class wNAF {
119
+ BASE;
120
+ ZERO;
121
+ Fn;
122
+ bits;
123
+ // Parametrized with a given Point class (not individual point)
124
+ constructor(Point, bits) {
125
+ this.BASE = Point.BASE;
126
+ this.ZERO = Point.ZERO;
127
+ this.Fn = Point.Fn;
128
+ this.bits = bits;
129
+ }
130
+ // non-const time multiplication ladder
131
+ _unsafeLadder(elm, n, p = this.ZERO) {
132
+ let d = elm;
133
+ while (n > _0n) {
134
+ if (n & _1n)
135
+ p = p.add(d);
136
+ d = d.double();
137
+ n >>= _1n;
138
+ }
139
+ return p;
140
+ }
141
+ /**
142
+ * Creates a wNAF precomputation window. Used for caching.
143
+ * Default window size is set by `utils.precompute()` and is equal to 8.
144
+ * Number of precomputed points depends on the curve size:
145
+ * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
146
+ * - 𝑊 is the window size
147
+ * - 𝑛 is the bitlength of the curve order.
148
+ * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
149
+ * @param point Point instance
150
+ * @param W window size
151
+ * @returns precomputed point tables flattened to a single array
152
+ */
153
+ precomputeWindow(point, W) {
154
+ const { windows, windowSize } = calcWOpts(W, this.bits);
155
+ const points = [];
156
+ let p = point;
157
+ let base = p;
158
+ for (let window = 0; window < windows; window++) {
159
+ base = p;
160
+ points.push(base);
161
+ // i=1, bc we skip 0
162
+ for (let i = 1; i < windowSize; i++) {
163
+ base = base.add(p);
164
+ points.push(base);
165
+ }
166
+ p = base.double();
167
+ }
168
+ return points;
169
+ }
170
+ /**
171
+ * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
172
+ * More compact implementation:
173
+ * https://github.com/paulmillr/noble-secp256k1/blob/47cb1669b6e506ad66b35fe7d76132ae97465da2/index.ts#L502-L541
174
+ * @returns real and fake (for const-time) points
175
+ */
176
+ wNAF(W, precomputes, n) {
177
+ // Scalar should be smaller than field order
178
+ if (!this.Fn.isValid(n))
179
+ throw new Error('invalid scalar');
180
+ // Accumulators
181
+ let p = this.ZERO;
182
+ let f = this.BASE;
183
+ // This code was first written with assumption that 'f' and 'p' will never be infinity point:
184
+ // since each addition is multiplied by 2 ** W, it cannot cancel each other. However,
185
+ // there is negate now: it is possible that negated element from low value
186
+ // would be the same as high element, which will create carry into next window.
187
+ // It's not obvious how this can fail, but still worth investigating later.
188
+ const wo = calcWOpts(W, this.bits);
189
+ for (let window = 0; window < wo.windows; window++) {
190
+ // (n === _0n) is handled and not early-exited. isEven and offsetF are used for noise
191
+ const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets(n, window, wo);
192
+ n = nextN;
193
+ if (isZero) {
194
+ // bits are 0: add garbage to fake point
195
+ // Important part for const-time getPublicKey: add random "noise" point to f.
196
+ f = f.add(negateCt(isNegF, precomputes[offsetF]));
197
+ }
198
+ else {
199
+ // bits are 1: add to result point
200
+ p = p.add(negateCt(isNeg, precomputes[offset]));
201
+ }
202
+ }
203
+ assert0(n);
204
+ // Return both real and fake points: JIT won't eliminate f.
205
+ // At this point there is a way to F be infinity-point even if p is not,
206
+ // which makes it less const-time: around 1 bigint multiply.
207
+ return { p, f };
208
+ }
209
+ /**
210
+ * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
211
+ * @param acc accumulator point to add result of multiplication
212
+ * @returns point
213
+ */
214
+ wNAFUnsafe(W, precomputes, n, acc = this.ZERO) {
215
+ const wo = calcWOpts(W, this.bits);
216
+ for (let window = 0; window < wo.windows; window++) {
217
+ if (n === _0n)
218
+ break; // Early-exit, skip 0 value
219
+ const { nextN, offset, isZero, isNeg } = calcOffsets(n, window, wo);
220
+ n = nextN;
221
+ if (isZero) {
222
+ // Window bits are 0: skip processing.
223
+ // Move to next window.
224
+ continue;
225
+ }
226
+ else {
227
+ const item = precomputes[offset];
228
+ acc = acc.add(isNeg ? item.negate() : item); // Re-using acc allows to save adds in MSM
229
+ }
230
+ }
231
+ assert0(n);
232
+ return acc;
233
+ }
234
+ getPrecomputes(W, point, transform) {
235
+ // Calculate precomputes on a first run, reuse them after
236
+ let comp = pointPrecomputes.get(point);
237
+ if (!comp) {
238
+ comp = this.precomputeWindow(point, W);
239
+ if (W !== 1) {
240
+ // Doing transform outside of if brings 15% perf hit
241
+ if (typeof transform === 'function')
242
+ comp = transform(comp);
243
+ pointPrecomputes.set(point, comp);
244
+ }
245
+ }
246
+ return comp;
247
+ }
248
+ cached(point, scalar, transform) {
249
+ const W = getW(point);
250
+ return this.wNAF(W, this.getPrecomputes(W, point, transform), scalar);
251
+ }
252
+ unsafe(point, scalar, transform, prev) {
253
+ const W = getW(point);
254
+ if (W === 1)
255
+ return this._unsafeLadder(point, scalar, prev); // For W=1 ladder is ~x2 faster
256
+ return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform), scalar, prev);
257
+ }
258
+ // We calculate precomputes for elliptic curve point multiplication
259
+ // using windowed method. This specifies window size and
260
+ // stores precomputed values. Usually only base point would be precomputed.
261
+ createCache(P, W) {
262
+ validateW(W, this.bits);
263
+ pointWindowSizes.set(P, W);
264
+ pointPrecomputes.delete(P);
265
+ }
266
+ hasCache(elm) {
267
+ return getW(elm) !== 1;
268
+ }
269
+ }
270
+ exports.wNAF = wNAF;
271
+ /**
272
+ * Endomorphism-specific multiplication for Koblitz curves.
273
+ * Cost: 128 dbl, 0-256 adds.
274
+ */
275
+ function mulEndoUnsafe(Point, point, k1, k2) {
276
+ let acc = point;
277
+ let p1 = Point.ZERO;
278
+ let p2 = Point.ZERO;
279
+ while (k1 > _0n || k2 > _0n) {
280
+ if (k1 & _1n)
281
+ p1 = p1.add(acc);
282
+ if (k2 & _1n)
283
+ p2 = p2.add(acc);
284
+ acc = acc.double();
285
+ k1 >>= _1n;
286
+ k2 >>= _1n;
287
+ }
288
+ return { p1, p2 };
289
+ }
290
+ /**
291
+ * Pippenger algorithm for multi-scalar multiplication (MSM, Pa + Qb + Rc + ...).
292
+ * 30x faster vs naive addition on L=4096, 10x faster than precomputes.
293
+ * For N=254bit, L=1, it does: 1024 ADD + 254 DBL. For L=5: 1536 ADD + 254 DBL.
294
+ * Algorithmically constant-time (for same L), even when 1 point + scalar, or when scalar = 0.
295
+ * @param c Curve Point constructor
296
+ * @param fieldN field over CURVE.N - important that it's not over CURVE.P
297
+ * @param points array of L curve points
298
+ * @param scalars array of L scalars (aka secret keys / bigints)
299
+ */
300
+ function pippenger(c, points, scalars) {
301
+ // If we split scalars by some window (let's say 8 bits), every chunk will only
302
+ // take 256 buckets even if there are 4096 scalars, also re-uses double.
303
+ // TODO:
304
+ // - https://eprint.iacr.org/2024/750.pdf
305
+ // - https://tches.iacr.org/index.php/TCHES/article/view/10287
306
+ // 0 is accepted in scalars
307
+ const fieldN = c.Fn;
308
+ validateMSMPoints(points, c);
309
+ validateMSMScalars(scalars, fieldN);
310
+ const plength = points.length;
311
+ const slength = scalars.length;
312
+ if (plength !== slength)
313
+ throw new Error('arrays of points and scalars must have equal length');
314
+ // if (plength === 0) throw new Error('array must be of length >= 2');
315
+ const zero = c.ZERO;
316
+ const wbits = (0, utils_js_1.bitLen)(BigInt(plength));
317
+ let windowSize = 1; // bits
318
+ if (wbits > 12)
319
+ windowSize = wbits - 3;
320
+ else if (wbits > 4)
321
+ windowSize = wbits - 2;
322
+ else if (wbits > 0)
323
+ windowSize = 2;
324
+ const MASK = (0, utils_js_1.bitMask)(windowSize);
325
+ const buckets = new Array(Number(MASK) + 1).fill(zero); // +1 for zero array
326
+ const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;
327
+ let sum = zero;
328
+ for (let i = lastBits; i >= 0; i -= windowSize) {
329
+ buckets.fill(zero);
330
+ for (let j = 0; j < slength; j++) {
331
+ const scalar = scalars[j];
332
+ const wbits = Number((scalar >> BigInt(i)) & MASK);
333
+ buckets[wbits] = buckets[wbits].add(points[j]);
334
+ }
335
+ let resI = zero; // not using this will do small speed-up, but will lose ct
336
+ // Skip first bucket, because it is zero
337
+ for (let j = buckets.length - 1, sumI = zero; j > 0; j--) {
338
+ sumI = sumI.add(buckets[j]);
339
+ resI = resI.add(sumI);
340
+ }
341
+ sum = sum.add(resI);
342
+ if (i !== 0)
343
+ for (let j = 0; j < windowSize; j++)
344
+ sum = sum.double();
345
+ }
346
+ return sum;
347
+ }
348
+ /**
349
+ * Precomputed multi-scalar multiplication (MSM, Pa + Qb + Rc + ...).
350
+ * @param c Curve Point constructor
351
+ * @param fieldN field over CURVE.N - important that it's not over CURVE.P
352
+ * @param points array of L curve points
353
+ * @returns function which multiplies points with scaars
354
+ */
355
+ function precomputeMSMUnsafe(c, points, windowSize) {
356
+ /**
357
+ * Performance Analysis of Window-based Precomputation
358
+ *
359
+ * Base Case (256-bit scalar, 8-bit window):
360
+ * - Standard precomputation requires:
361
+ * - 31 additions per scalar × 256 scalars = 7,936 ops
362
+ * - Plus 255 summary additions = 8,191 total ops
363
+ * Note: Summary additions can be optimized via accumulator
364
+ *
365
+ * Chunked Precomputation Analysis:
366
+ * - Using 32 chunks requires:
367
+ * - 255 additions per chunk
368
+ * - 256 doublings
369
+ * - Total: (255 × 32) + 256 = 8,416 ops
370
+ *
371
+ * Memory Usage Comparison:
372
+ * Window Size | Standard Points | Chunked Points
373
+ * ------------|-----------------|---------------
374
+ * 4-bit | 520 | 15
375
+ * 8-bit | 4,224 | 255
376
+ * 10-bit | 13,824 | 1,023
377
+ * 16-bit | 557,056 | 65,535
378
+ *
379
+ * Key Advantages:
380
+ * 1. Enables larger window sizes due to reduced memory overhead
381
+ * 2. More efficient for smaller scalar counts:
382
+ * - 16 chunks: (16 × 255) + 256 = 4,336 ops
383
+ * - ~2x faster than standard 8,191 ops
384
+ *
385
+ * Limitations:
386
+ * - Not suitable for plain precomputes (requires 256 constant doublings)
387
+ * - Performance degrades with larger scalar counts:
388
+ * - Optimal for ~256 scalars
389
+ * - Less efficient for 4096+ scalars (Pippenger preferred)
390
+ */
391
+ const fieldN = c.Fn;
392
+ validateW(windowSize, fieldN.BITS);
393
+ validateMSMPoints(points, c);
394
+ const zero = c.ZERO;
395
+ const tableSize = 2 ** windowSize - 1; // table size (without zero)
396
+ const chunks = Math.ceil(fieldN.BITS / windowSize); // chunks of item
397
+ const MASK = (0, utils_js_1.bitMask)(windowSize);
398
+ const tables = points.map((p) => {
399
+ const res = [];
400
+ for (let i = 0, acc = p; i < tableSize; i++) {
401
+ res.push(acc);
402
+ acc = acc.add(p);
403
+ }
404
+ return res;
405
+ });
406
+ return (scalars) => {
407
+ validateMSMScalars(scalars, fieldN);
408
+ if (scalars.length > points.length)
409
+ throw new Error('array of scalars must be smaller than array of points');
410
+ let res = zero;
411
+ for (let i = 0; i < chunks; i++) {
412
+ // No need to double if accumulator is still zero.
413
+ if (res !== zero)
414
+ for (let j = 0; j < windowSize; j++)
415
+ res = res.double();
416
+ const shiftBy = BigInt(chunks * windowSize - (i + 1) * windowSize);
417
+ for (let j = 0; j < scalars.length; j++) {
418
+ const n = scalars[j];
419
+ const curr = Number((n >> shiftBy) & MASK);
420
+ if (!curr)
421
+ continue; // skip zero scalars chunks
422
+ res = res.add(tables[j][curr - 1]);
423
+ }
424
+ }
425
+ return res;
426
+ };
427
+ }
428
+ function createField(order, field, isLE) {
429
+ if (field) {
430
+ if (field.ORDER !== order)
431
+ throw new Error('Field.ORDER must match order: Fp == p, Fn == n');
432
+ (0, modular_js_1.validateField)(field);
433
+ return field;
434
+ }
435
+ else {
436
+ return (0, modular_js_1.Field)(order, { isLE });
437
+ }
438
+ }
439
+ /** Validates CURVE opts and creates fields */
440
+ function createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
441
+ if (FpFnLE === undefined)
442
+ FpFnLE = type === 'edwards';
443
+ if (!CURVE || typeof CURVE !== 'object')
444
+ throw new Error(`expected valid ${type} CURVE object`);
445
+ for (const p of ['p', 'n', 'h']) {
446
+ const val = CURVE[p];
447
+ if (!(typeof val === 'bigint' && val > _0n))
448
+ throw new Error(`CURVE.${p} must be positive bigint`);
449
+ }
450
+ const Fp = createField(CURVE.p, curveOpts.Fp, FpFnLE);
451
+ const Fn = createField(CURVE.n, curveOpts.Fn, FpFnLE);
452
+ const _b = type === 'weierstrass' ? 'b' : 'd';
453
+ const params = ['Gx', 'Gy', 'a', _b];
454
+ for (const p of params) {
455
+ // @ts-ignore
456
+ if (!Fp.isValid(CURVE[p]))
457
+ throw new Error(`CURVE.${p} must be valid field element of CURVE.Fp`);
458
+ }
459
+ CURVE = Object.freeze(Object.assign({}, CURVE));
460
+ return { CURVE, Fp, Fn };
461
+ }
462
+ function createKeygen(randomSecretKey, getPublicKey) {
463
+ return function keygen(seed) {
464
+ const secretKey = randomSecretKey(seed);
465
+ return { secretKey, publicKey: getPublicKey(secretKey) };
466
+ };
467
+ }
468
+ //# sourceMappingURL=curve.js.map