@argent/x-shared 1.79.0 → 1.79.1

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 (501) hide show
  1. package/dist/.ts-temp/tsconfig.tsbuildinfo +1 -1
  2. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/dist/_virtual/_rolldown/runtime.js +20 -0
  4. package/dist/index.cjs +1 -1
  5. package/dist/index.js +112 -488
  6. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/_shortw_utils.cjs +1 -1
  7. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/_shortw_utils.js +11 -11
  8. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/curve.cjs +1 -1
  9. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/curve.js +62 -85
  10. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/modular.cjs +1 -1
  11. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/modular.js +153 -190
  12. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/poseidon.cjs +1 -1
  13. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/poseidon.js +56 -65
  14. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/utils.cjs +1 -1
  15. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/utils.js +125 -151
  16. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/weierstrass.cjs +1 -1
  17. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/weierstrass.js +470 -575
  18. package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/_assert.cjs +1 -1
  19. package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/_assert.js +26 -40
  20. package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/crypto.cjs +1 -1
  21. package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/crypto.js +4 -4
  22. package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/hmac.cjs +1 -1
  23. package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/hmac.js +38 -42
  24. package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/utils.cjs +1 -1
  25. package/dist/node_modules/.pnpm/@noble_hashes@1.3.0/node_modules/@noble/hashes/esm/utils.js +28 -42
  26. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_assert.cjs +1 -1
  27. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_assert.js +17 -26
  28. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_sha2.cjs +1 -1
  29. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_sha2.js +52 -59
  30. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_u64.cjs +1 -1
  31. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/_u64.js +20 -19
  32. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/sha256.cjs +1 -1
  33. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/sha256.js +118 -113
  34. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/sha3.cjs +1 -1
  35. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/sha3.js +95 -105
  36. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/utils.cjs +1 -1
  37. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/utils.js +26 -32
  38. package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/_md.cjs +1 -1
  39. package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/_md.js +71 -82
  40. package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/_u64.cjs +1 -1
  41. package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/_u64.js +20 -20
  42. package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/sha2.cjs +1 -1
  43. package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/sha2.js +125 -124
  44. package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/sha3.cjs +1 -1
  45. package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/sha3.js +102 -116
  46. package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/utils.cjs +1 -1
  47. package/dist/node_modules/.pnpm/@noble_hashes@2.0.0/node_modules/@noble/hashes/utils.js +62 -76
  48. package/dist/node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.cjs +1 -1
  49. package/dist/node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.js +519 -614
  50. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Hash.cjs +1 -1
  51. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Hash.js +15 -19
  52. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_ListCache.cjs +1 -1
  53. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_ListCache.js +15 -19
  54. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.cjs +1 -1
  55. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.js +6 -6
  56. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_MapCache.cjs +1 -1
  57. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_MapCache.js +15 -19
  58. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Set.cjs +1 -1
  59. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Set.js +5 -5
  60. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_SetCache.cjs +1 -1
  61. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_SetCache.js +10 -12
  62. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.cjs +1 -1
  63. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js +5 -5
  64. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayIncludes.cjs +1 -1
  65. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayIncludes.js +6 -7
  66. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayIncludesWith.cjs +1 -1
  67. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayIncludesWith.js +6 -8
  68. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_assocIndexOf.cjs +1 -1
  69. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_assocIndexOf.js +7 -9
  70. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseFindIndex.cjs +1 -1
  71. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseFindIndex.js +6 -8
  72. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.cjs +1 -1
  73. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js +9 -9
  74. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIndexOf.cjs +1 -1
  75. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIndexOf.js +7 -7
  76. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNaN.cjs +1 -1
  77. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNaN.js +5 -5
  78. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNative.cjs +1 -1
  79. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNative.js +10 -15
  80. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseUniq.cjs +1 -1
  81. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseUniq.js +26 -32
  82. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cacheHas.cjs +1 -1
  83. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cacheHas.js +5 -5
  84. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_coreJsData.cjs +1 -1
  85. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_coreJsData.js +5 -5
  86. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createSet.cjs +1 -1
  87. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createSet.js +7 -7
  88. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.cjs +1 -1
  89. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js +4 -4
  90. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getMapData.cjs +1 -1
  91. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getMapData.js +6 -6
  92. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getNative.cjs +1 -1
  93. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getNative.js +8 -8
  94. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.cjs +1 -1
  95. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js +12 -13
  96. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getValue.cjs +1 -1
  97. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getValue.js +5 -5
  98. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashClear.cjs +1 -1
  99. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashClear.js +6 -6
  100. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashDelete.cjs +1 -1
  101. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashDelete.js +6 -6
  102. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashGet.cjs +1 -1
  103. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashGet.js +11 -11
  104. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashHas.cjs +1 -1
  105. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashHas.js +8 -8
  106. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashSet.cjs +1 -1
  107. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashSet.js +7 -7
  108. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isKeyable.cjs +1 -1
  109. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isKeyable.js +6 -6
  110. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isMasked.cjs +1 -1
  111. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isMasked.js +9 -9
  112. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheClear.cjs +1 -1
  113. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheClear.js +5 -5
  114. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheDelete.cjs +1 -1
  115. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheDelete.js +8 -11
  116. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheGet.cjs +1 -1
  117. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheGet.js +7 -7
  118. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheHas.cjs +1 -1
  119. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheHas.js +6 -6
  120. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheSet.cjs +1 -1
  121. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheSet.js +6 -6
  122. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.cjs +1 -1
  123. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.js +11 -11
  124. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheDelete.cjs +1 -1
  125. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheDelete.js +7 -7
  126. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheGet.cjs +1 -1
  127. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheGet.js +6 -6
  128. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheHas.cjs +1 -1
  129. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheHas.js +6 -6
  130. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheSet.cjs +1 -1
  131. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheSet.js +7 -7
  132. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeCreate.cjs +1 -1
  133. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeCreate.js +4 -4
  134. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.cjs +1 -1
  135. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js +6 -6
  136. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.cjs +1 -1
  137. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js +4 -4
  138. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheAdd.cjs +1 -1
  139. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheAdd.js +6 -6
  140. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheHas.cjs +1 -1
  141. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheHas.js +5 -5
  142. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setToArray.cjs +1 -1
  143. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setToArray.js +8 -8
  144. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_strictIndexOf.cjs +1 -1
  145. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_strictIndexOf.js +6 -8
  146. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_toSource.cjs +1 -1
  147. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_toSource.js +14 -16
  148. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/eq.cjs +1 -1
  149. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/eq.js +5 -5
  150. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.cjs +1 -1
  151. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.js +10 -11
  152. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.cjs +1 -1
  153. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js +6 -6
  154. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/noop.cjs +1 -1
  155. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/noop.js +4 -5
  156. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/uniqWith.cjs +1 -1
  157. package/dist/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/uniqWith.js +6 -6
  158. package/dist/node_modules/.pnpm/micro-starknet@0.2.3/node_modules/micro-starknet/lib/esm/index.cjs +1 -1
  159. package/dist/node_modules/.pnpm/micro-starknet@0.2.3/node_modules/micro-starknet/lib/esm/index.js +121 -118
  160. package/dist/node_modules/.pnpm/numeral@2.0.6/node_modules/numeral/numeral.cjs +1 -1
  161. package/dist/node_modules/.pnpm/numeral@2.0.6/node_modules/numeral/numeral.js +377 -417
  162. package/dist/node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.cjs +1 -1
  163. package/dist/node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js +546 -635
  164. package/dist/paymaster.cjs +1 -1
  165. package/dist/paymaster.js +2 -11
  166. package/dist/simulation.cjs +1 -1
  167. package/dist/simulation.js +22 -90
  168. package/dist/src/account/account.model.cjs +1 -1
  169. package/dist/src/account/account.model.js +58 -52
  170. package/dist/src/account/accountv4.cjs +1 -1
  171. package/dist/src/account/accountv4.js +9 -11
  172. package/dist/src/account/preferences.model.cjs +1 -1
  173. package/dist/src/account/preferences.model.js +12 -10
  174. package/dist/src/accountNameGenerator/colors.cjs +1 -1
  175. package/dist/src/accountNameGenerator/colors.js +24 -24
  176. package/dist/src/accountNameGenerator/index.cjs +1 -1
  177. package/dist/src/accountNameGenerator/index.js +23 -23
  178. package/dist/src/accountNameGenerator/x-names.json.cjs +1 -1
  179. package/dist/src/accountNameGenerator/x-names.json.js +1922 -7
  180. package/dist/src/assets/tokens.json.cjs +1 -1
  181. package/dist/src/assets/tokens.json.js +180 -180
  182. package/dist/src/backend/schema.cjs +1 -1
  183. package/dist/src/backend/schema.js +9 -12
  184. package/dist/src/backend/sessionKeys/schema.cjs +1 -1
  185. package/dist/src/backend/sessionKeys/schema.js +27 -30
  186. package/dist/src/bigdecimal/constants.cjs +1 -1
  187. package/dist/src/bigdecimal/constants.js +6 -3
  188. package/dist/src/bigdecimal/createUnitsSchema.cjs +1 -1
  189. package/dist/src/bigdecimal/createUnitsSchema.js +7 -7
  190. package/dist/src/bigdecimal/formatUnits.cjs +1 -1
  191. package/dist/src/bigdecimal/formatUnits.js +9 -10
  192. package/dist/src/bigdecimal/index.cjs +1 -1
  193. package/dist/src/bigdecimal/index.js +45 -41
  194. package/dist/src/bigdecimal/lib.cjs +1 -1
  195. package/dist/src/bigdecimal/lib.js +105 -117
  196. package/dist/src/bigdecimal/parseUnits.cjs +1 -1
  197. package/dist/src/bigdecimal/parseUnits.js +18 -21
  198. package/dist/src/bigdecimal/utils.cjs +1 -1
  199. package/dist/src/bigdecimal/utils.js +33 -30
  200. package/dist/src/cache/CacheService.cjs +1 -1
  201. package/dist/src/cache/CacheService.js +32 -36
  202. package/dist/src/chains/starknet/address.cjs +1 -1
  203. package/dist/src/chains/starknet/address.js +73 -117
  204. package/dist/src/chains/starknet/addressDomain.cjs +1 -1
  205. package/dist/src/chains/starknet/addressDomain.js +14 -29
  206. package/dist/src/chains/starknet/addressInput.cjs +1 -1
  207. package/dist/src/chains/starknet/addressInput.js +6 -7
  208. package/dist/src/chains/starknet/argentName.cjs +1 -1
  209. package/dist/src/chains/starknet/argentName.js +10 -14
  210. package/dist/src/chains/starknet/cairoVersionSchema.cjs +1 -1
  211. package/dist/src/chains/starknet/cairoVersionSchema.js +5 -5
  212. package/dist/src/chains/starknet/constants.cjs +1 -1
  213. package/dist/src/chains/starknet/constants.js +4 -10
  214. package/dist/src/chains/starknet/getAddressFromArgentName.cjs +1 -1
  215. package/dist/src/chains/starknet/getAddressFromArgentName.js +38 -46
  216. package/dist/src/chains/starknet/getAddressFromStarkName.cjs +1 -1
  217. package/dist/src/chains/starknet/getAddressFromStarkName.js +59 -66
  218. package/dist/src/chains/starknet/network.cjs +1 -1
  219. package/dist/src/chains/starknet/network.js +20 -26
  220. package/dist/src/chains/starknet/services/address/StarknetAddressService.cjs +1 -1
  221. package/dist/src/chains/starknet/services/address/StarknetAddressService.js +31 -36
  222. package/dist/src/chains/starknet/services/deploymentData/constants.cjs +1 -1
  223. package/dist/src/chains/starknet/services/deploymentData/constants.js +14 -21
  224. package/dist/src/chains/starknet/services/deploymentData/deploymentData.schema.cjs +1 -1
  225. package/dist/src/chains/starknet/services/deploymentData/deploymentData.schema.js +15 -17
  226. package/dist/src/chains/starknet/services/deploymentData/findImplementationForAccount.cjs +1 -1
  227. package/dist/src/chains/starknet/services/deploymentData/findImplementationForAccount.js +61 -65
  228. package/dist/src/chains/starknet/services/deploymentData/getAccountClassHash.cjs +1 -1
  229. package/dist/src/chains/starknet/services/deploymentData/getAccountClassHash.js +46 -65
  230. package/dist/src/chains/starknet/starknetId.cjs +1 -1
  231. package/dist/src/chains/starknet/starknetId.js +10 -14
  232. package/dist/src/currencyFetchService/CurrencyFetchService.cjs +1 -1
  233. package/dist/src/currencyFetchService/CurrencyFetchService.js +13 -18
  234. package/dist/src/currencyFetchService/types.ts.cjs +1 -1
  235. package/dist/src/currencyFetchService/types.ts.js +9 -12
  236. package/dist/src/errors/account.cjs +1 -1
  237. package/dist/src/errors/account.js +12 -13
  238. package/dist/src/errors/address.cjs +1 -1
  239. package/dist/src/errors/address.js +11 -12
  240. package/dist/src/errors/baseErrors.cjs +1 -1
  241. package/dist/src/errors/baseErrors.js +14 -14
  242. package/dist/src/errors/call.cjs +1 -1
  243. package/dist/src/errors/call.js +12 -13
  244. package/dist/src/errors/network.cjs +1 -1
  245. package/dist/src/errors/network.js +11 -12
  246. package/dist/src/errors/review.cjs +1 -1
  247. package/dist/src/errors/review.js +11 -12
  248. package/dist/src/errors/swap.cjs +1 -1
  249. package/dist/src/errors/swap.js +12 -13
  250. package/dist/src/features/paymaster/PaymasterService.cjs +1 -1
  251. package/dist/src/features/paymaster/PaymasterService.js +73 -87
  252. package/dist/src/features/paymaster/types.cjs +1 -1
  253. package/dist/src/features/paymaster/types.js +41 -51
  254. package/dist/src/features/simulation/activity/normalize.cjs +1 -1
  255. package/dist/src/features/simulation/activity/normalize.js +36 -38
  256. package/dist/src/features/simulation/activity/schema.cjs +1 -1
  257. package/dist/src/features/simulation/activity/schema.js +224 -250
  258. package/dist/src/features/simulation/activity/utils/createNativeActivity.cjs +1 -1
  259. package/dist/src/features/simulation/activity/utils/createNativeActivity.js +23 -27
  260. package/dist/src/features/simulation/activity/utils/getAnyActivityTitle.cjs +1 -1
  261. package/dist/src/features/simulation/activity/utils/getAnyActivityTitle.js +14 -21
  262. package/dist/src/features/simulation/activity/utils/getOverallLastModified.cjs +1 -1
  263. package/dist/src/features/simulation/activity/utils/getOverallLastModified.js +5 -5
  264. package/dist/src/features/simulation/activity/utils/hasDelegationActivity.cjs +1 -1
  265. package/dist/src/features/simulation/activity/utils/hasDelegationActivity.js +4 -4
  266. package/dist/src/features/simulation/activity/utils/isAddMultisigSignersActivity.cjs +1 -1
  267. package/dist/src/features/simulation/activity/utils/isAddMultisigSignersActivity.js +15 -19
  268. package/dist/src/features/simulation/activity/utils/isChangeMultisigThresholdActivity.cjs +1 -1
  269. package/dist/src/features/simulation/activity/utils/isChangeMultisigThresholdActivity.js +15 -19
  270. package/dist/src/features/simulation/activity/utils/isMulticallWithDeploymentActivity.cjs +1 -1
  271. package/dist/src/features/simulation/activity/utils/isMulticallWithDeploymentActivity.js +5 -5
  272. package/dist/src/features/simulation/activity/utils/isRejectOnChainActivity.cjs +1 -1
  273. package/dist/src/features/simulation/activity/utils/isRejectOnChainActivity.js +19 -21
  274. package/dist/src/features/simulation/activity/utils/isRemoveMultisigSignersActivity.cjs +1 -1
  275. package/dist/src/features/simulation/activity/utils/isRemoveMultisigSignersActivity.js +15 -19
  276. package/dist/src/features/simulation/activity/utils/isSwapActivity.cjs +1 -1
  277. package/dist/src/features/simulation/activity/utils/isSwapActivity.js +17 -18
  278. package/dist/src/features/simulation/activity/utils/isUpgradeActivity.cjs +1 -1
  279. package/dist/src/features/simulation/activity/utils/isUpgradeActivity.js +15 -19
  280. package/dist/src/features/simulation/activity/utils/parseAccountActivities.cjs +1 -1
  281. package/dist/src/features/simulation/activity/utils/parseAccountActivities.js +12 -12
  282. package/dist/src/features/simulation/activity/utils/parseFinanceActivities.cjs +1 -1
  283. package/dist/src/features/simulation/activity/utils/parseFinanceActivities.js +32 -32
  284. package/dist/src/features/simulation/fees/schema.cjs +1 -1
  285. package/dist/src/features/simulation/fees/schema.js +33 -47
  286. package/dist/src/features/simulation/transactionReview/getErrorMessageAndLabelFromSimulation.cjs +1 -1
  287. package/dist/src/features/simulation/transactionReview/getErrorMessageAndLabelFromSimulation.js +15 -17
  288. package/dist/src/features/simulation/transactionReview/getMessageFromSimulationError.cjs +1 -1
  289. package/dist/src/features/simulation/transactionReview/getMessageFromSimulationError.js +5 -5
  290. package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
  291. package/dist/src/features/simulation/transactionReview/schema.js +221 -242
  292. package/dist/src/features/simulation/warning/helper.cjs +1 -1
  293. package/dist/src/features/simulation/warning/helper.js +12 -11
  294. package/dist/src/features/simulation/warning/schema.cjs +1 -1
  295. package/dist/src/features/simulation/warning/schema.js +10 -11
  296. package/dist/src/features/swap/models/order.model.cjs +1 -1
  297. package/dist/src/features/swap/models/order.model.js +16 -19
  298. package/dist/src/features/swap/models/quote.model.cjs +1 -1
  299. package/dist/src/features/swap/models/quote.model.js +31 -35
  300. package/dist/src/features/swap/models/trade.model.cjs +1 -1
  301. package/dist/src/features/swap/models/trade.model.js +25 -27
  302. package/dist/src/features/swap/services/SwapSharedService.cjs +1 -1
  303. package/dist/src/features/swap/services/SwapSharedService.js +71 -75
  304. package/dist/src/features/swap/services/SwapTransactionService.cjs +1 -1
  305. package/dist/src/features/swap/services/SwapTransactionService.js +57 -63
  306. package/dist/src/features/swap/utils/slippage.cjs +1 -1
  307. package/dist/src/features/swap/utils/slippage.js +18 -25
  308. package/dist/src/features/swap/utils/totalFee.cjs +1 -1
  309. package/dist/src/features/swap/utils/totalFee.js +12 -12
  310. package/dist/src/http/DateService.cjs +1 -1
  311. package/dist/src/http/DateService.js +15 -18
  312. package/dist/src/http/HttpError.cjs +1 -1
  313. package/dist/src/http/HttpError.js +7 -7
  314. package/dist/src/http/HttpService.cjs +1 -1
  315. package/dist/src/http/HttpService.js +117 -134
  316. package/dist/src/http/IHttpService.cjs +1 -1
  317. package/dist/src/http/IHttpService.js +6 -6
  318. package/dist/src/http/SWRService.cjs +1 -1
  319. package/dist/src/http/SWRService.js +50 -57
  320. package/dist/src/http/fetcher.cjs +1 -1
  321. package/dist/src/http/fetcher.js +29 -35
  322. package/dist/src/http/time.cjs +1 -1
  323. package/dist/src/http/time.js +15 -18
  324. package/dist/src/knownDapps/KnownDappsBackendService.cjs +1 -1
  325. package/dist/src/knownDapps/KnownDappsBackendService.js +13 -14
  326. package/dist/src/knownDapps/schema.cjs +1 -1
  327. package/dist/src/knownDapps/schema.js +41 -44
  328. package/dist/src/knownDapps/utils/getDapplandUrl.cjs +1 -1
  329. package/dist/src/knownDapps/utils/getDapplandUrl.js +7 -8
  330. package/dist/src/nameResolution/ResolveNameService.cjs +1 -1
  331. package/dist/src/nameResolution/ResolveNameService.js +34 -41
  332. package/dist/src/nameResolution/schema.cjs +1 -1
  333. package/dist/src/nameResolution/schema.js +20 -25
  334. package/dist/src/nfts/BackendNftService.cjs +1 -1
  335. package/dist/src/nfts/BackendNftService.js +103 -116
  336. package/dist/src/nfts/BackendPaginationError.cjs +1 -1
  337. package/dist/src/nfts/BackendPaginationError.js +11 -12
  338. package/dist/src/nfts/utils.cjs +1 -1
  339. package/dist/src/nfts/utils.js +11 -14
  340. package/dist/src/onchainRecovery/OnchainRecoveryService.cjs +1 -1
  341. package/dist/src/onchainRecovery/OnchainRecoveryService.js +38 -68
  342. package/dist/src/onchainRecovery/schema.cjs +1 -1
  343. package/dist/src/onchainRecovery/schema.js +35 -49
  344. package/dist/src/platform/isBraveBrowser.cjs +1 -1
  345. package/dist/src/platform/isBraveBrowser.js +8 -10
  346. package/dist/src/platform/isBrowser.cjs +1 -1
  347. package/dist/src/platform/isBrowser.js +17 -22
  348. package/dist/src/signer/mergeOwnerGuardianSignatures.cjs +1 -1
  349. package/dist/src/signer/mergeOwnerGuardianSignatures.js +28 -30
  350. package/dist/src/signer/multisigner.cjs +1 -1
  351. package/dist/src/signer/multisigner.js +16 -17
  352. package/dist/src/signer/seedphrase.cjs +1 -1
  353. package/dist/src/signer/seedphrase.js +7 -7
  354. package/dist/src/staking/schema.cjs +1 -1
  355. package/dist/src/staking/schema.js +146 -162
  356. package/dist/src/storage/base.cjs +1 -1
  357. package/dist/src/storage/base.js +33 -34
  358. package/dist/src/storage/utils.cjs +1 -1
  359. package/dist/src/storage/utils.js +19 -28
  360. package/dist/src/tokens/balances.cjs +1 -1
  361. package/dist/src/tokens/balances.js +34 -38
  362. package/dist/src/tokens/constants.cjs +1 -1
  363. package/dist/src/tokens/constants.js +4 -4
  364. package/dist/src/tokens/convertCurrencyValueToTokenAmount.cjs +1 -1
  365. package/dist/src/tokens/convertCurrencyValueToTokenAmount.js +8 -9
  366. package/dist/src/tokens/convertTokenAmountToCurrencyValue.cjs +1 -1
  367. package/dist/src/tokens/convertTokenAmountToCurrencyValue.js +14 -15
  368. package/dist/src/tokens/convertTokenUnitAmountWithDecimals.cjs +1 -1
  369. package/dist/src/tokens/convertTokenUnitAmountWithDecimals.js +8 -9
  370. package/dist/src/tokens/ensureDecimals.cjs +1 -1
  371. package/dist/src/tokens/ensureDecimals.js +4 -4
  372. package/dist/src/tokens/getCurrencySymbol.cjs +1 -1
  373. package/dist/src/tokens/getCurrencySymbol.js +14 -14
  374. package/dist/src/tokens/isUnlimitedAmount.cjs +1 -1
  375. package/dist/src/tokens/isUnlimitedAmount.js +5 -5
  376. package/dist/src/tokens/prettifyCurrencyValue.cjs +1 -1
  377. package/dist/src/tokens/prettifyCurrencyValue.js +13 -14
  378. package/dist/src/tokens/prettifyTokenAmount.cjs +1 -1
  379. package/dist/src/tokens/prettifyTokenAmount.js +22 -22
  380. package/dist/src/tokens/service/implementation.cjs +1 -1
  381. package/dist/src/tokens/service/implementation.js +28 -40
  382. package/dist/src/tokens/service/tokenError.cjs +1 -1
  383. package/dist/src/tokens/service/tokenError.js +11 -12
  384. package/dist/src/tokens/service/types/backend.model.cjs +1 -1
  385. package/dist/src/tokens/service/types/backend.model.js +128 -163
  386. package/dist/src/tokens/service/types/defiPosition.model.cjs +1 -1
  387. package/dist/src/tokens/service/types/defiPosition.model.js +83 -99
  388. package/dist/src/tokens/service/types/defiPositionType.model.cjs +1 -1
  389. package/dist/src/tokens/service/types/defiPositionType.model.js +9 -9
  390. package/dist/src/tokens/service/types/unclaimedRewards.model.cjs +1 -1
  391. package/dist/src/tokens/service/types/unclaimedRewards.model.js +15 -16
  392. package/dist/src/tokens/service/types/webToken.model.cjs +1 -1
  393. package/dist/src/tokens/service/types/webToken.model.js +28 -51
  394. package/dist/src/tokens/utils.cjs +1 -1
  395. package/dist/src/tokens/utils.js +5 -9
  396. package/dist/src/transactions/amount.cjs +1 -1
  397. package/dist/src/transactions/amount.js +17 -24
  398. package/dist/src/transactions/buildTransactions.cjs +1 -1
  399. package/dist/src/transactions/buildTransactions.js +30 -33
  400. package/dist/src/transactions/errors.cjs +1 -1
  401. package/dist/src/transactions/errors.js +11 -18
  402. package/dist/src/transactions/estimate/adjustment.cjs +1 -1
  403. package/dist/src/transactions/estimate/adjustment.js +6 -6
  404. package/dist/src/transactions/estimate/argentMaxFee.cjs +1 -1
  405. package/dist/src/transactions/estimate/argentMaxFee.js +10 -13
  406. package/dist/src/transactions/estimate/error.cjs +1 -1
  407. package/dist/src/transactions/estimate/error.js +12 -13
  408. package/dist/src/transactions/estimate/model.cjs +1 -1
  409. package/dist/src/transactions/estimate/model.js +18 -13
  410. package/dist/src/transactions/estimate/utils.cjs +1 -1
  411. package/dist/src/transactions/estimate/utils.js +139 -172
  412. package/dist/src/transactions/findTransfersAndApprovals.cjs +1 -1
  413. package/dist/src/transactions/findTransfersAndApprovals.js +34 -30
  414. package/dist/src/transactions/getPrettyRcpError.cjs +1 -1
  415. package/dist/src/transactions/getPrettyRcpError.js +8 -10
  416. package/dist/src/transactions/service/implementation.cjs +1 -1
  417. package/dist/src/transactions/service/implementation.js +187 -208
  418. package/dist/src/transactions/service/types.cjs +1 -1
  419. package/dist/src/transactions/service/types.js +9 -9
  420. package/dist/src/transactions/service/utils.cjs +1 -1
  421. package/dist/src/transactions/service/utils.js +24 -25
  422. package/dist/src/transactions/transactionExecuteTypes.cjs +1 -1
  423. package/dist/src/transactions/transactionExecuteTypes.js +8 -9
  424. package/dist/src/transactions/transactionReviewTypes.cjs +1 -1
  425. package/dist/src/transactions/transactionReviewTypes.js +9 -9
  426. package/dist/src/transactions/transactionVersion.cjs +1 -1
  427. package/dist/src/transactions/transactionVersion.js +8 -13
  428. package/dist/src/transactions/txv3.cjs +1 -1
  429. package/dist/src/transactions/txv3.js +10 -11
  430. package/dist/src/utils/address.cjs +1 -1
  431. package/dist/src/utils/address.js +4 -4
  432. package/dist/src/utils/arrays.cjs +1 -1
  433. package/dist/src/utils/arrays.js +4 -4
  434. package/dist/src/utils/avatarImage.cjs +4 -4
  435. package/dist/src/utils/avatarImage.js +35 -40
  436. package/dist/src/utils/base58.cjs +1 -1
  437. package/dist/src/utils/base58.js +12 -15
  438. package/dist/src/utils/bigNumber.cjs +1 -1
  439. package/dist/src/utils/bigNumber.d.ts +1 -1
  440. package/dist/src/utils/bigNumber.js +5 -7
  441. package/dist/src/utils/bips.cjs +1 -1
  442. package/dist/src/utils/bips.js +12 -10
  443. package/dist/src/utils/daysBetween.cjs +1 -1
  444. package/dist/src/utils/daysBetween.js +6 -6
  445. package/dist/src/utils/env.cjs +1 -1
  446. package/dist/src/utils/env.js +4 -4
  447. package/dist/src/utils/hex.cjs +1 -1
  448. package/dist/src/utils/hex.js +7 -8
  449. package/dist/src/utils/id.cjs +1 -1
  450. package/dist/src/utils/id.js +7 -7
  451. package/dist/src/utils/initials.cjs +1 -1
  452. package/dist/src/utils/initials.js +12 -15
  453. package/dist/src/utils/isContractDeployed.cjs +1 -1
  454. package/dist/src/utils/isContractDeployed.js +9 -9
  455. package/dist/src/utils/nonNullable.cjs +1 -1
  456. package/dist/src/utils/nonNullable.js +6 -6
  457. package/dist/src/utils/number/abbreviateNumber.cjs +1 -1
  458. package/dist/src/utils/number/abbreviateNumber.js +13 -14
  459. package/dist/src/utils/number/isAllowedAddressHexInputValue.cjs +1 -1
  460. package/dist/src/utils/number/isAllowedAddressHexInputValue.js +4 -7
  461. package/dist/src/utils/number/isAllowedNumericInputValue.cjs +1 -1
  462. package/dist/src/utils/number/isAllowedNumericInputValue.js +5 -5
  463. package/dist/src/utils/number/isNumeric.cjs +1 -1
  464. package/dist/src/utils/number/isNumeric.js +4 -4
  465. package/dist/src/utils/number/prettifyNumber.cjs +1 -1
  466. package/dist/src/utils/number/prettifyNumber.js +65 -75
  467. package/dist/src/utils/parseAmount.cjs +1 -1
  468. package/dist/src/utils/parseAmount.js +10 -11
  469. package/dist/src/utils/pluralise.cjs +1 -1
  470. package/dist/src/utils/pluralise.js +4 -4
  471. package/dist/src/utils/readFileAsString.cjs +1 -1
  472. package/dist/src/utils/readFileAsString.js +6 -6
  473. package/dist/src/utils/retryUntilInitialised.cjs +1 -1
  474. package/dist/src/utils/retryUntilInitialised.js +21 -20
  475. package/dist/src/utils/schemas.cjs +1 -1
  476. package/dist/src/utils/schemas.js +29 -26
  477. package/dist/src/utils/starknet/starknet.cjs +1 -1
  478. package/dist/src/utils/starknet/starknet.js +64 -77
  479. package/dist/src/utils/starknet/starknetLibTypes.cjs +1 -1
  480. package/dist/src/utils/starknet/starknetLibTypes.js +7 -7
  481. package/dist/src/utils/starknet/starknetSchemas.cjs +1 -1
  482. package/dist/src/utils/starknet/starknetSchemas.js +84 -99
  483. package/dist/src/utils/transactions.cjs +1 -1
  484. package/dist/src/utils/transactions.js +10 -10
  485. package/dist/src/utils/url/urlWithQuery.cjs +1 -1
  486. package/dist/src/utils/url/urlWithQuery.js +8 -8
  487. package/dist/src/utils/voidify.cjs +1 -1
  488. package/dist/src/utils/voidify.js +7 -7
  489. package/dist/swap.cjs +1 -1
  490. package/dist/swap.js +8 -22
  491. package/package.json +15 -15
  492. package/dist/_virtual/_commonjsHelpers.cjs +0 -1
  493. package/dist/_virtual/_commonjsHelpers.js +0 -6
  494. package/dist/_virtual/numeral.cjs +0 -1
  495. package/dist/_virtual/numeral.js +0 -7
  496. package/dist/_virtual/numeral2.cjs +0 -1
  497. package/dist/_virtual/numeral2.js +0 -4
  498. package/dist/_virtual/semver.cjs +0 -1
  499. package/dist/_virtual/semver.js +0 -7
  500. package/dist/_virtual/semver2.cjs +0 -1
  501. package/dist/_virtual/semver2.js +0 -4
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./modular.cjs");function c(r){const{Fp:e}=r;h.validateField(e);for(const n of["t","roundsFull","roundsPartial"])if(typeof r[n]!="number"||!Number.isSafeInteger(r[n]))throw new Error(`Poseidon: invalid param ${n}=${r[n]} (${typeof r[n]})`);if(r.reversePartialPowIdx!==void 0&&typeof r.reversePartialPowIdx!="boolean")throw new Error(`Poseidon: invalid param reversePartialPowIdx=${r.reversePartialPowIdx}`);let t=r.sboxPower;if(t===void 0&&(t=5),typeof t!="number"||!Number.isSafeInteger(t))throw new Error(`Poseidon wrong sboxPower=${t}`);const f=BigInt(t);let u=n=>h.FpPow(e,n,f);if(t===3?u=n=>e.mul(e.sqrN(n),n):t===5&&(u=n=>e.mul(e.sqrN(e.sqrN(n)),n)),r.roundsFull%2!==0)throw new Error(`Poseidon roundsFull is not even: ${r.roundsFull}`);const w=r.roundsFull+r.roundsPartial;if(!Array.isArray(r.roundConstants)||r.roundConstants.length!==w)throw new Error("Poseidon: wrong round constants");const l=r.roundConstants.map(n=>{if(!Array.isArray(n)||n.length!==r.t)throw new Error(`Poseidon wrong round constants: ${n}`);return n.map(d=>{if(typeof d!="bigint"||!e.isValid(d))throw new Error(`Poseidon wrong round constant=${d}`);return e.create(d)})});if(!Array.isArray(r.mds)||r.mds.length!==r.t)throw new Error("Poseidon: wrong MDS matrix");const P=r.mds.map(n=>{if(!Array.isArray(n)||n.length!==r.t)throw new Error(`Poseidon MDS matrix row: ${n}`);return n.map(d=>{if(typeof d!="bigint")throw new Error(`Poseidon MDS matrix value=${d}`);return e.create(d)})});return Object.freeze({...r,rounds:w,sboxFn:u,roundConstants:l,mds:P})}function b(r){const{t:e,Fp:t,rounds:f,sboxFn:u,reversePartialPowIdx:w}=c(r),l=Math.floor(r.roundsFull/2),P=w?e-1:0,n=(a,i,s)=>(a=a.map((o,m)=>t.add(o,r.roundConstants[s][m])),i?a=a.map(o=>u(o)):a[P]=u(a[P]),a=r.mds.map(o=>o.reduce((m,g,y)=>t.add(m,t.mulN(g,a[y])),t.ZERO)),a),d=function(i){if(!Array.isArray(i)||i.length!==e)throw new Error(`Poseidon: wrong values (expected array of bigints with length ${e})`);i=i.map(o=>{if(typeof o!="bigint")throw new Error(`Poseidon: wrong value=${o} (${typeof o})`);return t.create(o)});let s=0;for(let o=0;o<l;o++)i=n(i,!0,s++);for(let o=0;o<r.roundsPartial;o++)i=n(i,!1,s++);for(let o=0;o<l;o++)i=n(i,!0,s++);if(s!==f)throw new Error(`Poseidon: wrong number of rounds: last round=${s}, total=${f}`);return i};return d.roundConstants=r.roundConstants,d}exports.poseidon=b;exports.validateOpts=c;
1
+ const e=require(`./modular.cjs`);function t(t){let{Fp:n}=t;e.validateField(n);for(let e of[`t`,`roundsFull`,`roundsPartial`])if(typeof t[e]!=`number`||!Number.isSafeInteger(t[e]))throw Error(`Poseidon: invalid param ${e}=${t[e]} (${typeof t[e]})`);if(t.reversePartialPowIdx!==void 0&&typeof t.reversePartialPowIdx!=`boolean`)throw Error(`Poseidon: invalid param reversePartialPowIdx=${t.reversePartialPowIdx}`);let r=t.sboxPower;if(r===void 0&&(r=5),typeof r!=`number`||!Number.isSafeInteger(r))throw Error(`Poseidon wrong sboxPower=${r}`);let i=BigInt(r),a=t=>e.FpPow(n,t,i);if(r===3?a=e=>n.mul(n.sqrN(e),e):r===5&&(a=e=>n.mul(n.sqrN(n.sqrN(e)),e)),t.roundsFull%2!=0)throw Error(`Poseidon roundsFull is not even: ${t.roundsFull}`);let o=t.roundsFull+t.roundsPartial;if(!Array.isArray(t.roundConstants)||t.roundConstants.length!==o)throw Error(`Poseidon: wrong round constants`);let s=t.roundConstants.map(e=>{if(!Array.isArray(e)||e.length!==t.t)throw Error(`Poseidon wrong round constants: ${e}`);return e.map(e=>{if(typeof e!=`bigint`||!n.isValid(e))throw Error(`Poseidon wrong round constant=${e}`);return n.create(e)})});if(!Array.isArray(t.mds)||t.mds.length!==t.t)throw Error(`Poseidon: wrong MDS matrix`);let c=t.mds.map(e=>{if(!Array.isArray(e)||e.length!==t.t)throw Error(`Poseidon MDS matrix row: ${e}`);return e.map(e=>{if(typeof e!=`bigint`)throw Error(`Poseidon MDS matrix value=${e}`);return n.create(e)})});return Object.freeze({...t,rounds:o,sboxFn:a,roundConstants:s,mds:c})}function n(e){let{t:n,Fp:r,rounds:i,sboxFn:a,reversePartialPowIdx:o}=t(e),s=Math.floor(e.roundsFull/2),c=o?n-1:0,l=(t,n,i)=>(t=t.map((t,n)=>r.add(t,e.roundConstants[i][n])),n?t=t.map(e=>a(e)):t[c]=a(t[c]),t=e.mds.map(e=>e.reduce((e,n,i)=>r.add(e,r.mulN(n,t[i])),r.ZERO)),t),u=function(t){if(!Array.isArray(t)||t.length!==n)throw Error(`Poseidon: wrong values (expected array of bigints with length ${n})`);t=t.map(e=>{if(typeof e!=`bigint`)throw Error(`Poseidon: wrong value=${e} (${typeof e})`);return r.create(e)});let a=0;for(let e=0;e<s;e++)t=l(t,!0,a++);for(let n=0;n<e.roundsPartial;n++)t=l(t,!1,a++);for(let e=0;e<s;e++)t=l(t,!0,a++);if(a!==i)throw Error(`Poseidon: wrong number of rounds: last round=${a}, total=${i}`);return t};return u.roundConstants=e.roundConstants,u}exports.poseidon=n;
@@ -1,67 +1,58 @@
1
- import { validateField as c, FpPow as y } from "./modular.js";
2
- function b(r) {
3
- const { Fp: e } = r;
4
- c(e);
5
- for (const n of ["t", "roundsFull", "roundsPartial"])
6
- if (typeof r[n] != "number" || !Number.isSafeInteger(r[n]))
7
- throw new Error(`Poseidon: invalid param ${n}=${r[n]} (${typeof r[n]})`);
8
- if (r.reversePartialPowIdx !== void 0 && typeof r.reversePartialPowIdx != "boolean")
9
- throw new Error(`Poseidon: invalid param reversePartialPowIdx=${r.reversePartialPowIdx}`);
10
- let t = r.sboxPower;
11
- if (t === void 0 && (t = 5), typeof t != "number" || !Number.isSafeInteger(t))
12
- throw new Error(`Poseidon wrong sboxPower=${t}`);
13
- const u = BigInt(t);
14
- let f = (n) => y(e, n, u);
15
- if (t === 3 ? f = (n) => e.mul(e.sqrN(n), n) : t === 5 && (f = (n) => e.mul(e.sqrN(e.sqrN(n)), n)), r.roundsFull % 2 !== 0)
16
- throw new Error(`Poseidon roundsFull is not even: ${r.roundsFull}`);
17
- const w = r.roundsFull + r.roundsPartial;
18
- if (!Array.isArray(r.roundConstants) || r.roundConstants.length !== w)
19
- throw new Error("Poseidon: wrong round constants");
20
- const l = r.roundConstants.map((n) => {
21
- if (!Array.isArray(n) || n.length !== r.t)
22
- throw new Error(`Poseidon wrong round constants: ${n}`);
23
- return n.map((d) => {
24
- if (typeof d != "bigint" || !e.isValid(d))
25
- throw new Error(`Poseidon wrong round constant=${d}`);
26
- return e.create(d);
27
- });
28
- });
29
- if (!Array.isArray(r.mds) || r.mds.length !== r.t)
30
- throw new Error("Poseidon: wrong MDS matrix");
31
- const P = r.mds.map((n) => {
32
- if (!Array.isArray(n) || n.length !== r.t)
33
- throw new Error(`Poseidon MDS matrix row: ${n}`);
34
- return n.map((d) => {
35
- if (typeof d != "bigint")
36
- throw new Error(`Poseidon MDS matrix value=${d}`);
37
- return e.create(d);
38
- });
39
- });
40
- return Object.freeze({ ...r, rounds: w, sboxFn: f, roundConstants: l, mds: P });
1
+ import { FpPow as e, validateField as t } from "./modular.js";
2
+ //#region node_modules/.pnpm/@noble+curves@1.0.0/node_modules/@noble/curves/esm/abstract/poseidon.js
3
+ function n(n) {
4
+ let { Fp: r } = n;
5
+ t(r);
6
+ for (let e of [
7
+ "t",
8
+ "roundsFull",
9
+ "roundsPartial"
10
+ ]) if (typeof n[e] != "number" || !Number.isSafeInteger(n[e])) throw Error(`Poseidon: invalid param ${e}=${n[e]} (${typeof n[e]})`);
11
+ if (n.reversePartialPowIdx !== void 0 && typeof n.reversePartialPowIdx != "boolean") throw Error(`Poseidon: invalid param reversePartialPowIdx=${n.reversePartialPowIdx}`);
12
+ let i = n.sboxPower;
13
+ if (i === void 0 && (i = 5), typeof i != "number" || !Number.isSafeInteger(i)) throw Error(`Poseidon wrong sboxPower=${i}`);
14
+ let a = BigInt(i), o = (t) => e(r, t, a);
15
+ if (i === 3 ? o = (e) => r.mul(r.sqrN(e), e) : i === 5 && (o = (e) => r.mul(r.sqrN(r.sqrN(e)), e)), n.roundsFull % 2 != 0) throw Error(`Poseidon roundsFull is not even: ${n.roundsFull}`);
16
+ let s = n.roundsFull + n.roundsPartial;
17
+ if (!Array.isArray(n.roundConstants) || n.roundConstants.length !== s) throw Error("Poseidon: wrong round constants");
18
+ let c = n.roundConstants.map((e) => {
19
+ if (!Array.isArray(e) || e.length !== n.t) throw Error(`Poseidon wrong round constants: ${e}`);
20
+ return e.map((e) => {
21
+ if (typeof e != "bigint" || !r.isValid(e)) throw Error(`Poseidon wrong round constant=${e}`);
22
+ return r.create(e);
23
+ });
24
+ });
25
+ if (!Array.isArray(n.mds) || n.mds.length !== n.t) throw Error("Poseidon: wrong MDS matrix");
26
+ let l = n.mds.map((e) => {
27
+ if (!Array.isArray(e) || e.length !== n.t) throw Error(`Poseidon MDS matrix row: ${e}`);
28
+ return e.map((e) => {
29
+ if (typeof e != "bigint") throw Error(`Poseidon MDS matrix value=${e}`);
30
+ return r.create(e);
31
+ });
32
+ });
33
+ return Object.freeze({
34
+ ...n,
35
+ rounds: s,
36
+ sboxFn: o,
37
+ roundConstants: c,
38
+ mds: l
39
+ });
41
40
  }
42
- function $(r) {
43
- const { t: e, Fp: t, rounds: u, sboxFn: f, reversePartialPowIdx: w } = b(r), l = Math.floor(r.roundsFull / 2), P = w ? e - 1 : 0, n = (a, i, s) => (a = a.map((o, m) => t.add(o, r.roundConstants[s][m])), i ? a = a.map((o) => f(o)) : a[P] = f(a[P]), a = r.mds.map((o) => o.reduce((m, h, g) => t.add(m, t.mulN(h, a[g])), t.ZERO)), a), d = function(i) {
44
- if (!Array.isArray(i) || i.length !== e)
45
- throw new Error(`Poseidon: wrong values (expected array of bigints with length ${e})`);
46
- i = i.map((o) => {
47
- if (typeof o != "bigint")
48
- throw new Error(`Poseidon: wrong value=${o} (${typeof o})`);
49
- return t.create(o);
50
- });
51
- let s = 0;
52
- for (let o = 0; o < l; o++)
53
- i = n(i, !0, s++);
54
- for (let o = 0; o < r.roundsPartial; o++)
55
- i = n(i, !1, s++);
56
- for (let o = 0; o < l; o++)
57
- i = n(i, !0, s++);
58
- if (s !== u)
59
- throw new Error(`Poseidon: wrong number of rounds: last round=${s}, total=${u}`);
60
- return i;
61
- };
62
- return d.roundConstants = r.roundConstants, d;
41
+ function r(e) {
42
+ let { t, Fp: r, rounds: i, sboxFn: a, reversePartialPowIdx: o } = n(e), s = Math.floor(e.roundsFull / 2), c = o ? t - 1 : 0, l = (t, n, i) => (t = t.map((t, n) => r.add(t, e.roundConstants[i][n])), n ? t = t.map((e) => a(e)) : t[c] = a(t[c]), t = e.mds.map((e) => e.reduce((e, n, i) => r.add(e, r.mulN(n, t[i])), r.ZERO)), t), u = function(n) {
43
+ if (!Array.isArray(n) || n.length !== t) throw Error(`Poseidon: wrong values (expected array of bigints with length ${t})`);
44
+ n = n.map((e) => {
45
+ if (typeof e != "bigint") throw Error(`Poseidon: wrong value=${e} (${typeof e})`);
46
+ return r.create(e);
47
+ });
48
+ let a = 0;
49
+ for (let e = 0; e < s; e++) n = l(n, !0, a++);
50
+ for (let t = 0; t < e.roundsPartial; t++) n = l(n, !1, a++);
51
+ for (let e = 0; e < s; e++) n = l(n, !0, a++);
52
+ if (a !== i) throw Error(`Poseidon: wrong number of rounds: last round=${a}, total=${i}`);
53
+ return n;
54
+ };
55
+ return u.roundConstants = e.roundConstants, u;
63
56
  }
64
- export {
65
- $ as poseidon,
66
- b as validateOpts
67
- };
57
+ //#endregion
58
+ export { r as poseidon };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=BigInt(0),y=BigInt(1),v=BigInt(2),g=t=>t instanceof Uint8Array,U=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function w(t){if(!g(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=U[t[r]];return e}function B(t){const e=t.toString(16);return e.length&1?`0${e}`:e}function h(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function b(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(t.length%2)throw new Error("hex string is invalid: unpadded "+t.length);const e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){const n=r*2,o=t.slice(n,n+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("invalid byte sequence");e[r]=i}return e}function $(t){return h(w(t))}function A(t){if(!g(t))throw new Error("Uint8Array expected");return h(w(Uint8Array.from(t).reverse()))}const E=(t,e)=>b(t.toString(16).padStart(e*2,"0")),I=(t,e)=>E(t,e).reverse(),N=t=>b(B(t));function S(t,e,r){let n;if(typeof e=="string")try{n=b(e)}catch(i){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`)}else if(g(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const o=n.length;if(typeof r=="number"&&o!==r)throw new Error(`${t} expected ${r} bytes, got ${o}`);return n}function T(...t){const e=new Uint8Array(t.reduce((n,o)=>n+o.length,0));let r=0;return t.forEach(n=>{if(!g(n))throw new Error("Uint8Array expected");e.set(n,r),r+=n.length}),e}function H(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function k(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new TextEncoder().encode(t)}function O(t){let e;for(e=0;t>p;t>>=y,e+=1);return e}const j=(t,e)=>t>>BigInt(e)&y,V=(t,e,r)=>t|(r?y:p)<<BigInt(e),F=t=>(v<<BigInt(t-1))-y,d=t=>new Uint8Array(t),m=t=>Uint8Array.from(t);function M(t,e,r){if(typeof t!="number"||t<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 r!="function")throw new Error("hmacFn must be a function");let n=d(t),o=d(t),i=0;const c=()=>{n.fill(1),o.fill(0),i=0},u=(...s)=>r(o,n,...s),f=(s=d())=>{o=u(m([0]),s),n=u(),s.length!==0&&(o=u(m([1]),s),n=u())},x=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let s=0;const a=[];for(;s<e;){n=u();const l=n.slice();a.push(l),s+=n.length}return T(...a)};return(s,a)=>{c(),f(s);let l;for(;!(l=a(x()));)f();return c(),l}}const _={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function q(t,e,r={}){const n=(o,i,c)=>{const u=_[i];if(typeof u!="function")throw new Error(`Invalid validator "${i}", expected function`);const f=t[o];if(!(c&&f===void 0)&&!u(f,t))throw new Error(`Invalid param ${String(o)}=${f} (${typeof f}), expected ${i}`)};for(const[o,i]of Object.entries(e))n(o,i,!1);for(const[o,i]of Object.entries(r))n(o,i,!0);return t}exports.bitGet=j;exports.bitLen=O;exports.bitMask=F;exports.bitSet=V;exports.bytesToHex=w;exports.bytesToNumberBE=$;exports.bytesToNumberLE=A;exports.concatBytes=T;exports.createHmacDrbg=M;exports.ensureBytes=S;exports.equalBytes=H;exports.hexToBytes=b;exports.hexToNumber=h;exports.numberToBytesBE=E;exports.numberToBytesLE=I;exports.numberToHexUnpadded=B;exports.numberToVarBytesBE=N;exports.utf8ToBytes=k;exports.validateObject=q;
1
+ var e=require(`../../../../../../../../_virtual/_rolldown/runtime.cjs`).__exportAll({bitGet:()=>b,bitLen:()=>y,bitMask:()=>S,bitSet:()=>x,bytesToHex:()=>o,bytesToNumberBE:()=>u,bytesToNumberLE:()=>d,concatBytes:()=>g,createHmacDrbg:()=>T,ensureBytes:()=>h,equalBytes:()=>_,hexToBytes:()=>l,hexToNumber:()=>c,numberToBytesBE:()=>f,numberToBytesLE:()=>p,numberToHexUnpadded:()=>s,numberToVarBytesBE:()=>m,utf8ToBytes:()=>v,validateObject:()=>D}),t=BigInt(0),n=BigInt(1),r=BigInt(2),i=e=>e instanceof Uint8Array,a=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function o(e){if(!i(e))throw Error(`Uint8Array expected`);let t=``;for(let n=0;n<e.length;n++)t+=a[e[n]];return t}function s(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function c(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);return BigInt(e===``?`0`:`0x${e}`)}function l(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(e.length%2)throw Error(`hex string is invalid: unpadded `+e.length);let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){let r=n*2,i=e.slice(r,r+2),a=Number.parseInt(i,16);if(Number.isNaN(a)||a<0)throw Error(`invalid byte sequence`);t[n]=a}return t}function u(e){return c(o(e))}function d(e){if(!i(e))throw Error(`Uint8Array expected`);return c(o(Uint8Array.from(e).reverse()))}var f=(e,t)=>l(e.toString(16).padStart(t*2,`0`)),p=(e,t)=>f(e,t).reverse(),m=e=>l(s(e));function h(e,t,n){let r;if(typeof t==`string`)try{r=l(t)}catch(n){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else if(i(t))r=Uint8Array.from(t);else throw Error(`${e} must be hex string or Uint8Array`);let a=r.length;if(typeof n==`number`&&a!==n)throw Error(`${e} expected ${n} bytes, got ${a}`);return r}function g(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;return e.forEach(e=>{if(!i(e))throw Error(`Uint8Array expected`);t.set(e,n),n+=e.length}),t}function _(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function v(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function y(e){let r;for(r=0;e>t;e>>=n,r+=1);return r}var b=(e,t)=>e>>BigInt(t)&n,x=(e,r,i)=>e|(i?n:t)<<BigInt(r),S=e=>(r<<BigInt(e-1))-n,C=e=>new Uint8Array(e),w=e=>Uint8Array.from(e);function T(e,t,n){if(typeof e!=`number`||e<2)throw Error(`hashLen must be a number`);if(typeof t!=`number`||t<2)throw Error(`qByteLen must be a number`);if(typeof n!=`function`)throw Error(`hmacFn must be a function`);let r=C(e),i=C(e),a=0,o=()=>{r.fill(1),i.fill(0),a=0},s=(...e)=>n(i,r,...e),c=(e=C())=>{i=s(w([0]),e),r=s(),e.length!==0&&(i=s(w([1]),e),r=s())},l=()=>{if(a++>=1e3)throw Error(`drbg: tried 1000 values`);let e=0,n=[];for(;e<t;){r=s();let t=r.slice();n.push(t),e+=r.length}return g(...n)};return(e,t)=>{o(),c(e);let n;for(;!(n=t(l()));)c();return o(),n}}var E={bigint:e=>typeof e==`bigint`,function:e=>typeof e==`function`,boolean:e=>typeof e==`boolean`,string:e=>typeof e==`string`,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e==`function`&&Number.isSafeInteger(e.outputLen)};function D(e,t,n={}){let r=(t,n,r)=>{let i=E[n];if(typeof i!=`function`)throw Error(`Invalid validator "${n}", expected function`);let a=e[t];if(!(r&&a===void 0)&&!i(a,e))throw Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${n}`)};for(let[e,n]of Object.entries(t))r(e,n,!1);for(let[e,t]of Object.entries(n))r(e,t,!0);return e}exports.bitMask=S,exports.bytesToHex=o,exports.bytesToNumberBE=u,exports.bytesToNumberLE=d,exports.concatBytes=g,exports.createHmacDrbg=T,exports.ensureBytes=h,exports.hexToBytes=l,exports.numberToBytesBE=f,exports.numberToBytesLE=p,Object.defineProperty(exports,`utils_exports`,{enumerable:!0,get:function(){return e}}),exports.validateObject=D;
@@ -1,165 +1,139 @@
1
- const h = BigInt(0), g = BigInt(1), B = BigInt(2), y = (t) => t instanceof Uint8Array, $ = Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0"));
2
- function b(t) {
3
- if (!y(t))
4
- throw new Error("Uint8Array expected");
5
- let e = "";
6
- for (let r = 0; r < t.length; r++)
7
- e += $[t[r]];
8
- return e;
1
+ import { __exportAll as e } from "../../../../../../../../_virtual/_rolldown/runtime.js";
2
+ //#region node_modules/.pnpm/@noble+curves@1.0.0/node_modules/@noble/curves/esm/abstract/utils.js
3
+ var t = /* @__PURE__ */ e({
4
+ bitGet: () => x,
5
+ bitLen: () => b,
6
+ bitMask: () => C,
7
+ bitSet: () => S,
8
+ bytesToHex: () => s,
9
+ bytesToNumberBE: () => d,
10
+ bytesToNumberLE: () => f,
11
+ concatBytes: () => _,
12
+ createHmacDrbg: () => E,
13
+ ensureBytes: () => g,
14
+ equalBytes: () => v,
15
+ hexToBytes: () => u,
16
+ hexToNumber: () => l,
17
+ numberToBytesBE: () => p,
18
+ numberToBytesLE: () => m,
19
+ numberToHexUnpadded: () => c,
20
+ numberToVarBytesBE: () => h,
21
+ utf8ToBytes: () => y,
22
+ validateObject: () => O
23
+ }), n = BigInt(0), r = BigInt(1), i = BigInt(2), a = (e) => e instanceof Uint8Array, o = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
24
+ function s(e) {
25
+ if (!a(e)) throw Error("Uint8Array expected");
26
+ let t = "";
27
+ for (let n = 0; n < e.length; n++) t += o[e[n]];
28
+ return t;
9
29
  }
10
- function A(t) {
11
- const e = t.toString(16);
12
- return e.length & 1 ? `0${e}` : e;
30
+ function c(e) {
31
+ let t = e.toString(16);
32
+ return t.length & 1 ? `0${t}` : t;
13
33
  }
14
- function m(t) {
15
- if (typeof t != "string")
16
- throw new Error("hex string expected, got " + typeof t);
17
- return BigInt(t === "" ? "0" : `0x${t}`);
34
+ function l(e) {
35
+ if (typeof e != "string") throw Error("hex string expected, got " + typeof e);
36
+ return BigInt(e === "" ? "0" : `0x${e}`);
18
37
  }
19
- function d(t) {
20
- if (typeof t != "string")
21
- throw new Error("hex string expected, got " + typeof t);
22
- if (t.length % 2)
23
- throw new Error("hex string is invalid: unpadded " + t.length);
24
- const e = new Uint8Array(t.length / 2);
25
- for (let r = 0; r < e.length; r++) {
26
- const n = r * 2, o = t.slice(n, n + 2), i = Number.parseInt(o, 16);
27
- if (Number.isNaN(i) || i < 0)
28
- throw new Error("invalid byte sequence");
29
- e[r] = i;
30
- }
31
- return e;
38
+ function u(e) {
39
+ if (typeof e != "string") throw Error("hex string expected, got " + typeof e);
40
+ if (e.length % 2) throw Error("hex string is invalid: unpadded " + e.length);
41
+ let t = new Uint8Array(e.length / 2);
42
+ for (let n = 0; n < t.length; n++) {
43
+ let r = n * 2, i = e.slice(r, r + 2), a = Number.parseInt(i, 16);
44
+ if (Number.isNaN(a) || a < 0) throw Error("invalid byte sequence");
45
+ t[n] = a;
46
+ }
47
+ return t;
32
48
  }
33
- function T(t) {
34
- return m(b(t));
49
+ function d(e) {
50
+ return l(s(e));
35
51
  }
36
- function N(t) {
37
- if (!y(t))
38
- throw new Error("Uint8Array expected");
39
- return m(b(Uint8Array.from(t).reverse()));
52
+ function f(e) {
53
+ if (!a(e)) throw Error("Uint8Array expected");
54
+ return l(s(Uint8Array.from(e).reverse()));
40
55
  }
41
- const U = (t, e) => d(t.toString(16).padStart(e * 2, "0")), S = (t, e) => U(t, e).reverse(), k = (t) => d(A(t));
42
- function F(t, e, r) {
43
- let n;
44
- if (typeof e == "string")
45
- try {
46
- n = d(e);
47
- } catch (i) {
48
- throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`);
49
- }
50
- else if (y(e))
51
- n = Uint8Array.from(e);
52
- else
53
- throw new Error(`${t} must be hex string or Uint8Array`);
54
- const o = n.length;
55
- if (typeof r == "number" && o !== r)
56
- throw new Error(`${t} expected ${r} bytes, got ${o}`);
57
- return n;
56
+ var p = (e, t) => u(e.toString(16).padStart(t * 2, "0")), m = (e, t) => p(e, t).reverse(), h = (e) => u(c(e));
57
+ function g(e, t, n) {
58
+ let r;
59
+ if (typeof t == "string") try {
60
+ r = u(t);
61
+ } catch (n) {
62
+ throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`);
63
+ }
64
+ else if (a(t)) r = Uint8Array.from(t);
65
+ else throw Error(`${e} must be hex string or Uint8Array`);
66
+ let i = r.length;
67
+ if (typeof n == "number" && i !== n) throw Error(`${e} expected ${n} bytes, got ${i}`);
68
+ return r;
58
69
  }
59
- function v(...t) {
60
- const e = new Uint8Array(t.reduce((n, o) => n + o.length, 0));
61
- let r = 0;
62
- return t.forEach((n) => {
63
- if (!y(n))
64
- throw new Error("Uint8Array expected");
65
- e.set(n, r), r += n.length;
66
- }), e;
70
+ function _(...e) {
71
+ let t = new Uint8Array(e.reduce((e, t) => e + t.length, 0)), n = 0;
72
+ return e.forEach((e) => {
73
+ if (!a(e)) throw Error("Uint8Array expected");
74
+ t.set(e, n), n += e.length;
75
+ }), t;
67
76
  }
68
- function H(t, e) {
69
- if (t.length !== e.length)
70
- return !1;
71
- for (let r = 0; r < t.length; r++)
72
- if (t[r] !== e[r])
73
- return !1;
74
- return !0;
77
+ function v(e, t) {
78
+ if (e.length !== t.length) return !1;
79
+ for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
80
+ return !0;
75
81
  }
76
- function O(t) {
77
- if (typeof t != "string")
78
- throw new Error(`utf8ToBytes expected string, got ${typeof t}`);
79
- return new TextEncoder().encode(t);
82
+ function y(e) {
83
+ if (typeof e != "string") throw Error(`utf8ToBytes expected string, got ${typeof e}`);
84
+ return new TextEncoder().encode(e);
80
85
  }
81
- function V(t) {
82
- let e;
83
- for (e = 0; t > h; t >>= g, e += 1)
84
- ;
85
- return e;
86
+ function b(e) {
87
+ let t;
88
+ for (t = 0; e > n; e >>= r, t += 1);
89
+ return t;
86
90
  }
87
- const _ = (t, e) => t >> BigInt(e) & g, j = (t, e, r) => t | (r ? g : h) << BigInt(e), q = (t) => (B << BigInt(t - 1)) - g, w = (t) => new Uint8Array(t), p = (t) => Uint8Array.from(t);
88
- function C(t, e, r) {
89
- if (typeof t != "number" || t < 2)
90
- throw new Error("hashLen must be a number");
91
- if (typeof e != "number" || e < 2)
92
- throw new Error("qByteLen must be a number");
93
- if (typeof r != "function")
94
- throw new Error("hmacFn must be a function");
95
- let n = w(t), o = w(t), i = 0;
96
- const c = () => {
97
- n.fill(1), o.fill(0), i = 0;
98
- }, s = (...f) => r(o, n, ...f), u = (f = w()) => {
99
- o = s(p([0]), f), n = s(), f.length !== 0 && (o = s(p([1]), f), n = s());
100
- }, E = () => {
101
- if (i++ >= 1e3)
102
- throw new Error("drbg: tried 1000 values");
103
- let f = 0;
104
- const a = [];
105
- for (; f < e; ) {
106
- n = s();
107
- const l = n.slice();
108
- a.push(l), f += n.length;
109
- }
110
- return v(...a);
111
- };
112
- return (f, a) => {
113
- c(), u(f);
114
- let l;
115
- for (; !(l = a(E())); )
116
- u();
117
- return c(), l;
118
- };
91
+ var x = (e, t) => e >> BigInt(t) & r, S = (e, t, i) => e | (i ? r : n) << BigInt(t), C = (e) => (i << BigInt(e - 1)) - r, w = (e) => new Uint8Array(e), T = (e) => Uint8Array.from(e);
92
+ function E(e, t, n) {
93
+ if (typeof e != "number" || e < 2) throw Error("hashLen must be a number");
94
+ if (typeof t != "number" || t < 2) throw Error("qByteLen must be a number");
95
+ if (typeof n != "function") throw Error("hmacFn must be a function");
96
+ let r = w(e), i = w(e), a = 0, o = () => {
97
+ r.fill(1), i.fill(0), a = 0;
98
+ }, s = (...e) => n(i, r, ...e), c = (e = w()) => {
99
+ i = s(T([0]), e), r = s(), e.length !== 0 && (i = s(T([1]), e), r = s());
100
+ }, l = () => {
101
+ if (a++ >= 1e3) throw Error("drbg: tried 1000 values");
102
+ let e = 0, n = [];
103
+ for (; e < t;) {
104
+ r = s();
105
+ let t = r.slice();
106
+ n.push(t), e += r.length;
107
+ }
108
+ return _(...n);
109
+ };
110
+ return (e, t) => {
111
+ o(), c(e);
112
+ let n;
113
+ for (; !(n = t(l()));) c();
114
+ return o(), n;
115
+ };
119
116
  }
120
- const x = {
121
- bigint: (t) => typeof t == "bigint",
122
- function: (t) => typeof t == "function",
123
- boolean: (t) => typeof t == "boolean",
124
- string: (t) => typeof t == "string",
125
- isSafeInteger: (t) => Number.isSafeInteger(t),
126
- array: (t) => Array.isArray(t),
127
- field: (t, e) => e.Fp.isValid(t),
128
- hash: (t) => typeof t == "function" && Number.isSafeInteger(t.outputLen)
117
+ var D = {
118
+ bigint: (e) => typeof e == "bigint",
119
+ function: (e) => typeof e == "function",
120
+ boolean: (e) => typeof e == "boolean",
121
+ string: (e) => typeof e == "string",
122
+ isSafeInteger: (e) => Number.isSafeInteger(e),
123
+ array: (e) => Array.isArray(e),
124
+ field: (e, t) => t.Fp.isValid(e),
125
+ hash: (e) => typeof e == "function" && Number.isSafeInteger(e.outputLen)
129
126
  };
130
- function D(t, e, r = {}) {
131
- const n = (o, i, c) => {
132
- const s = x[i];
133
- if (typeof s != "function")
134
- throw new Error(`Invalid validator "${i}", expected function`);
135
- const u = t[o];
136
- if (!(c && u === void 0) && !s(u, t))
137
- throw new Error(`Invalid param ${String(o)}=${u} (${typeof u}), expected ${i}`);
138
- };
139
- for (const [o, i] of Object.entries(e))
140
- n(o, i, !1);
141
- for (const [o, i] of Object.entries(r))
142
- n(o, i, !0);
143
- return t;
127
+ function O(e, t, n = {}) {
128
+ let r = (t, n, r) => {
129
+ let i = D[n];
130
+ if (typeof i != "function") throw Error(`Invalid validator "${n}", expected function`);
131
+ let a = e[t];
132
+ if (!(r && a === void 0) && !i(a, e)) throw Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${n}`);
133
+ };
134
+ for (let [e, n] of Object.entries(t)) r(e, n, !1);
135
+ for (let [e, t] of Object.entries(n)) r(e, t, !0);
136
+ return e;
144
137
  }
145
- export {
146
- _ as bitGet,
147
- V as bitLen,
148
- q as bitMask,
149
- j as bitSet,
150
- b as bytesToHex,
151
- T as bytesToNumberBE,
152
- N as bytesToNumberLE,
153
- v as concatBytes,
154
- C as createHmacDrbg,
155
- F as ensureBytes,
156
- H as equalBytes,
157
- d as hexToBytes,
158
- m as hexToNumber,
159
- U as numberToBytesBE,
160
- S as numberToBytesLE,
161
- A as numberToHexUnpadded,
162
- k as numberToVarBytesBE,
163
- O as utf8ToBytes,
164
- D as validateObject
165
- };
138
+ //#endregion
139
+ export { C as bitMask, s as bytesToHex, d as bytesToNumberBE, f as bytesToNumberLE, _ as concatBytes, E as createHmacDrbg, g as ensureBytes, u as hexToBytes, p as numberToBytesBE, m as numberToBytesLE, t as utils_exports, O as validateObject };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./modular.cjs"),m=require("./utils.cjs"),et=require("./curve.cjs");function at(v){const n=et.validateBasic(v);m.validateObject(n,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:x,a:O}=n;if(t){if(!x.eql(O,x.ZERO))throw new Error("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("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...n})}const{bytesToNumberBE:ct,hexToBytes:ut}=m,$={Err:class extends Error{constructor(n=""){super(n)}},_parseInt(v){const{Err:n}=$;if(v.length<2||v[0]!==2)throw new n("Invalid signature integer tag");const t=v[1],x=v.subarray(2,t+2);if(!t||x.length!==t)throw new n("Invalid signature integer: wrong length");if(x[0]&128)throw new n("Invalid signature integer: negative");if(x[0]===0&&!(x[1]&128))throw new n("Invalid signature integer: unnecessary leading zero");return{d:ct(x),l:v.subarray(t+2)}},toSig(v){const{Err:n}=$,t=typeof v=="string"?ut(v):v;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let x=t.length;if(x<2||t[0]!=48)throw new n("Invalid signature tag");if(t[1]!==x-2)throw new n("Invalid signature: incorrect length");const{d:O,l:T}=$._parseInt(t.subarray(2)),{d:F,l:R}=$._parseInt(T);if(R.length)throw new n("Invalid signature: left bytes after parsing");return{r:O,s:F}},hexFromSig(v){const n=S=>Number.parseInt(S[0],16)&8?"00"+S:S,t=S=>{const V=S.toString(16);return V.length&1?`0${V}`:V},x=n(t(v.s)),O=n(t(v.r)),T=x.length/2,F=O.length/2,R=t(T),L=t(F);return`30${t(F+T+4)}02${L}${O}02${R}${x}`}},P=BigInt(0),U=BigInt(1);BigInt(2);const ot=BigInt(3);BigInt(4);function it(v){const n=at(v),{Fp:t}=n,x=n.toBytes||((y,r,i)=>{const o=r.toAffine();return m.concatBytes(Uint8Array.from([4]),t.toBytes(o.x),t.toBytes(o.y))}),O=n.fromBytes||(y=>{const r=y.subarray(1),i=t.fromBytes(r.subarray(0,t.BYTES)),o=t.fromBytes(r.subarray(t.BYTES,2*t.BYTES));return{x:i,y:o}});function T(y){const{a:r,b:i}=n,o=t.sqr(y),u=t.mul(o,y);return t.add(t.add(u,t.mul(y,r)),i)}if(!t.eql(t.sqr(n.Gy),T(n.Gx)))throw new Error("bad generator point: equation left != right");function F(y){return typeof y=="bigint"&&P<y&&y<n.n}function R(y){if(!F(y))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function L(y){const{allowedPrivateKeyLengths:r,nByteLength:i,wrapPrivateKey:o,n:u}=n;if(r&&typeof y!="bigint"){if(y instanceof Uint8Array&&(y=m.bytesToHex(y)),typeof y!="string"||!r.includes(y.length))throw new Error("Invalid key");y=y.padStart(i*2,"0")}let f;try{f=typeof y=="bigint"?y:m.bytesToNumberBE(m.ensureBytes("private key",y,i))}catch{throw new Error(`private key must be ${i} bytes, hex or bigint, not ${typeof y}`)}return o&&(f=_.mod(f,u)),R(f),f}const S=new Map;function V(y){if(!(y instanceof w))throw new Error("ProjectivePoint expected")}class w{constructor(r,i,o){if(this.px=r,this.py=i,this.pz=o,r==null||!t.isValid(r))throw new Error("x required");if(i==null||!t.isValid(i))throw new Error("y required");if(o==null||!t.isValid(o))throw new Error("z required")}static fromAffine(r){const{x:i,y:o}=r||{};if(!r||!t.isValid(i)||!t.isValid(o))throw new Error("invalid affine point");if(r instanceof w)throw new Error("projective point not allowed");const u=f=>t.eql(f,t.ZERO);return u(i)&&u(o)?w.ZERO:new w(i,o,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(r){const i=t.invertBatch(r.map(o=>o.pz));return r.map((o,u)=>o.toAffine(i[u])).map(w.fromAffine)}static fromHex(r){const i=w.fromAffine(O(m.ensureBytes("pointHex",r)));return i.assertValidity(),i}static fromPrivateKey(r){return w.BASE.multiply(L(r))}_setWindowSize(r){this._WINDOW_SIZE=r,S.delete(this)}assertValidity(){if(this.is0()){if(n.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:r,y:i}=this.toAffine();if(!t.isValid(r)||!t.isValid(i))throw new Error("bad point: x or y not FE");const o=t.sqr(i),u=T(r);if(!t.eql(o,u))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:r}=this.toAffine();if(t.isOdd)return!t.isOdd(r);throw new Error("Field doesn't support isOdd")}equals(r){V(r);const{px:i,py:o,pz:u}=this,{px:f,py:g,pz:h}=r,a=t.eql(t.mul(i,h),t.mul(f,u)),c=t.eql(t.mul(o,h),t.mul(g,u));return a&&c}negate(){return new w(this.px,t.neg(this.py),this.pz)}double(){const{a:r,b:i}=n,o=t.mul(i,ot),{px:u,py:f,pz:g}=this;let h=t.ZERO,a=t.ZERO,c=t.ZERO,d=t.mul(u,u),q=t.mul(f,f),B=t.mul(g,g),p=t.mul(u,f);return p=t.add(p,p),c=t.mul(u,g),c=t.add(c,c),h=t.mul(r,c),a=t.mul(o,B),a=t.add(h,a),h=t.sub(q,a),a=t.add(q,a),a=t.mul(h,a),h=t.mul(p,h),c=t.mul(o,c),B=t.mul(r,B),p=t.sub(d,B),p=t.mul(r,p),p=t.add(p,c),c=t.add(d,d),d=t.add(c,d),d=t.add(d,B),d=t.mul(d,p),a=t.add(a,d),B=t.mul(f,g),B=t.add(B,B),d=t.mul(B,p),h=t.sub(h,d),c=t.mul(B,q),c=t.add(c,c),c=t.add(c,c),new w(h,a,c)}add(r){V(r);const{px:i,py:o,pz:u}=this,{px:f,py:g,pz:h}=r;let a=t.ZERO,c=t.ZERO,d=t.ZERO;const q=n.a,B=t.mul(n.b,ot);let p=t.mul(i,f),N=t.mul(o,g),Z=t.mul(u,h),H=t.add(i,o),e=t.add(f,g);H=t.mul(H,e),e=t.add(p,N),H=t.sub(H,e),e=t.add(i,u);let s=t.add(f,h);return e=t.mul(e,s),s=t.add(p,Z),e=t.sub(e,s),s=t.add(o,u),a=t.add(g,h),s=t.mul(s,a),a=t.add(N,Z),s=t.sub(s,a),d=t.mul(q,e),a=t.mul(B,Z),d=t.add(a,d),a=t.sub(N,d),d=t.add(N,d),c=t.mul(a,d),N=t.add(p,p),N=t.add(N,p),Z=t.mul(q,Z),e=t.mul(B,e),N=t.add(N,Z),Z=t.sub(p,Z),Z=t.mul(q,Z),e=t.add(e,Z),p=t.mul(N,e),c=t.add(c,p),p=t.mul(s,e),a=t.mul(H,a),a=t.sub(a,p),p=t.mul(H,N),d=t.mul(s,d),d=t.add(d,p),new w(a,c,d)}subtract(r){return this.add(r.negate())}is0(){return this.equals(w.ZERO)}wNAF(r){return C.wNAFCached(this,S,r,i=>{const o=t.invertBatch(i.map(u=>u.pz));return i.map((u,f)=>u.toAffine(o[f])).map(w.fromAffine)})}multiplyUnsafe(r){const i=w.ZERO;if(r===P)return i;if(R(r),r===U)return this;const{endo:o}=n;if(!o)return C.unsafeLadder(this,r);let{k1neg:u,k1:f,k2neg:g,k2:h}=o.splitScalar(r),a=i,c=i,d=this;for(;f>P||h>P;)f&U&&(a=a.add(d)),h&U&&(c=c.add(d)),d=d.double(),f>>=U,h>>=U;return u&&(a=a.negate()),g&&(c=c.negate()),c=new w(t.mul(c.px,o.beta),c.py,c.pz),a.add(c)}multiply(r){R(r);let i=r,o,u;const{endo:f}=n;if(f){const{k1neg:g,k1:h,k2neg:a,k2:c}=f.splitScalar(i);let{p:d,f:q}=this.wNAF(h),{p:B,f:p}=this.wNAF(c);d=C.constTimeNegate(g,d),B=C.constTimeNegate(a,B),B=new w(t.mul(B.px,f.beta),B.py,B.pz),o=d.add(B),u=q.add(p)}else{const{p:g,f:h}=this.wNAF(i);o=g,u=h}return w.normalizeZ([o,u])[0]}multiplyAndAddUnsafe(r,i,o){const u=w.BASE,f=(h,a)=>a===P||a===U||!h.equals(u)?h.multiplyUnsafe(a):h.multiply(a),g=f(this,i).add(f(r,o));return g.is0()?void 0:g}toAffine(r){const{px:i,py:o,pz:u}=this,f=this.is0();r==null&&(r=f?t.ONE:t.inv(u));const g=t.mul(i,r),h=t.mul(o,r),a=t.mul(u,r);if(f)return{x:t.ZERO,y:t.ZERO};if(!t.eql(a,t.ONE))throw new Error("invZ was invalid");return{x:g,y:h}}isTorsionFree(){const{h:r,isTorsionFree:i}=n;if(r===U)return!0;if(i)return i(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:r,clearCofactor:i}=n;return r===U?this:i?i(w,this):this.multiplyUnsafe(n.h)}toRawBytes(r=!0){return this.assertValidity(),x(w,this,r)}toHex(r=!0){return m.bytesToHex(this.toRawBytes(r))}}w.BASE=new w(n.Gx,n.Gy,t.ONE),w.ZERO=new w(t.ZERO,t.ONE,t.ZERO);const W=n.nBitLength,C=et.wNAF(w,n.endo?Math.ceil(W/2):W);return{CURVE:n,ProjectivePoint:w,normPrivateKeyToScalar:L,weierstrassEquation:T,isWithinCurveOrder:F}}function lt(v){const n=et.validateBasic(v);return m.validateObject(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}function ft(v){const n=lt(v),{Fp:t,n:x}=n,O=t.BYTES+1,T=2*t.BYTES+1;function F(e){return P<e&&e<t.ORDER}function R(e){return _.mod(e,x)}function L(e){return _.invert(e,x)}const{ProjectivePoint:S,normPrivateKeyToScalar:V,weierstrassEquation:w,isWithinCurveOrder:W}=it({...n,toBytes(e,s,l){const b=s.toAffine(),E=t.toBytes(b.x),A=m.concatBytes;return l?A(Uint8Array.from([s.hasEvenY()?2:3]),E):A(Uint8Array.from([4]),E,t.toBytes(b.y))},fromBytes(e){const s=e.length,l=e[0],b=e.subarray(1);if(s===O&&(l===2||l===3)){const E=m.bytesToNumberBE(b);if(!F(E))throw new Error("Point is not on curve");const A=w(E);let z=t.sqrt(A);const I=(z&U)===U;return(l&1)===1!==I&&(z=t.neg(z)),{x:E,y:z}}else if(s===T&&l===4){const E=t.fromBytes(b.subarray(0,t.BYTES)),A=t.fromBytes(b.subarray(t.BYTES,2*t.BYTES));return{x:E,y:A}}else throw new Error(`Point of length ${s} was invalid. Expected ${O} compressed bytes or ${T} uncompressed bytes`)}}),C=e=>m.bytesToHex(m.numberToBytesBE(e,n.nByteLength));function y(e){const s=x>>U;return e>s}function r(e){return y(e)?R(-e):e}const i=(e,s,l)=>m.bytesToNumberBE(e.slice(s,l));class o{constructor(s,l,b){this.r=s,this.s=l,this.recovery=b,this.assertValidity()}static fromCompact(s){const l=n.nByteLength;return s=m.ensureBytes("compactSignature",s,l*2),new o(i(s,0,l),i(s,l,2*l))}static fromDER(s){const{r:l,s:b}=$.toSig(m.ensureBytes("DER",s));return new o(l,b)}assertValidity(){if(!W(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!W(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(s){return new o(this.r,this.s,s)}recoverPublicKey(s){const{r:l,s:b,recovery:E}=this,A=c(m.ensureBytes("msgHash",s));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");const z=E===2||E===3?l+n.n:l;if(z>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const I=(E&1)===0?"02":"03",D=S.fromHex(I+C(z)),j=L(z),X=R(-A*j),Q=R(b*j),K=S.BASE.multiplyAndAddUnsafe(D,X,Q);if(!K)throw new Error("point at infinify");return K.assertValidity(),K}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new o(this.r,R(-this.s),this.recovery):this}toDERRawBytes(){return m.hexToBytes(this.toDERHex())}toDERHex(){return $.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return m.hexToBytes(this.toCompactHex())}toCompactHex(){return C(this.r)+C(this.s)}}const u={isValidPrivateKey(e){try{return V(e),!0}catch{return!1}},normPrivateKeyToScalar:V,randomPrivateKey:()=>{const e=n.randomBytes(t.BYTES+8),s=_.hashToPrivateScalar(e,x);return m.numberToBytesBE(s,n.nByteLength)},precompute(e=8,s=S.BASE){return s._setWindowSize(e),s.multiply(BigInt(3)),s}};function f(e,s=!0){return S.fromPrivateKey(e).toRawBytes(s)}function g(e){const s=e instanceof Uint8Array,l=typeof e=="string",b=(s||l)&&e.length;return s?b===O||b===T:l?b===2*O||b===2*T:e instanceof S}function h(e,s,l=!0){if(g(e))throw new Error("first arg must be private key");if(!g(s))throw new Error("second arg must be public key");return S.fromHex(s).multiply(V(e)).toRawBytes(l)}const a=n.bits2int||function(e){const s=m.bytesToNumberBE(e),l=e.length*8-n.nBitLength;return l>0?s>>BigInt(l):s},c=n.bits2int_modN||function(e){return R(a(e))},d=m.bitMask(n.nBitLength);function q(e){if(typeof e!="bigint")throw new Error("bigint expected");if(!(P<=e&&e<d))throw new Error(`bigint expected < 2^${n.nBitLength}`);return m.numberToBytesBE(e,n.nByteLength)}function B(e,s,l=p){if(["recovered","canonical"].some(k=>k in l))throw new Error("sign() legacy options not supported");const{hash:b,randomBytes:E}=n;let{lowS:A,prehash:z,extraEntropy:I}=l;A==null&&(A=!0),e=m.ensureBytes("msgHash",e),z&&(e=m.ensureBytes("prehashed msgHash",b(e)));const D=c(e),j=V(s),X=[q(j),q(D)];if(I!=null){const k=I===!0?E(t.BYTES):I;X.push(m.ensureBytes("extraEntropy",k,t.BYTES))}const Q=m.concatBytes(...X),K=D;function tt(k){const G=a(k);if(!W(G))return;const rt=L(G),Y=S.BASE.multiply(G).toAffine(),M=R(Y.x);if(M===P)return;const J=R(rt*R(K+M*j));if(J===P)return;let nt=(Y.x===M?0:2)|Number(Y.y&U),st=J;return A&&y(J)&&(st=r(J),nt^=1),new o(M,st,nt)}return{seed:Q,k2sig:tt}}const p={lowS:n.lowS,prehash:!1},N={lowS:n.lowS,prehash:!1};function Z(e,s,l=p){const{seed:b,k2sig:E}=B(e,s,l);return m.createHmacDrbg(n.hash.outputLen,n.nByteLength,n.hmac)(b,E)}S.BASE._setWindowSize(8);function H(e,s,l,b=N){const E=e;if(s=m.ensureBytes("msgHash",s),l=m.ensureBytes("publicKey",l),"strict"in b)throw new Error("options.strict was renamed to lowS");const{lowS:A,prehash:z}=b;let I,D;try{if(typeof E=="string"||E instanceof Uint8Array)try{I=o.fromDER(E)}catch(Y){if(!(Y instanceof $.Err))throw Y;I=o.fromCompact(E)}else if(typeof E=="object"&&typeof E.r=="bigint"&&typeof E.s=="bigint"){const{r:Y,s:M}=E;I=new o(Y,M)}else throw new Error("PARSE");D=S.fromHex(l)}catch(Y){if(Y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(A&&I.hasHighS())return!1;z&&(s=n.hash(s));const{r:j,s:X}=I,Q=c(s),K=L(X),tt=R(Q*K),k=R(j*K),G=S.BASE.multiplyAndAddUnsafe(D,tt,k)?.toAffine();return G?R(G.x)===j:!1}return{CURVE:n,getPublicKey:f,getSharedSecret:h,sign:Z,verify:H,ProjectivePoint:S,Signature:o,utils:u}}exports.DER=$;exports.weierstrass=ft;exports.weierstrassPoints=it;
1
+ const e=require(`./utils.cjs`),t=require(`./modular.cjs`),n=require(`./curve.cjs`);function r(t){let r=n.validateBasic(t);e.validateObject(r,{a:`field`,b:`field`},{allowedPrivateKeyLengths:`array`,wrapPrivateKey:`boolean`,isTorsionFree:`function`,clearCofactor:`function`,allowInfinityPoint:`boolean`,fromBytes:`function`,toBytes:`function`});let{endo:i,Fp:a,a:o}=r;if(i){if(!a.eql(o,a.ZERO))throw Error(`Endomorphism can only be defined for Koblitz curves that have a=0`);if(typeof i!=`object`||typeof i.beta!=`bigint`||typeof i.splitScalar!=`function`)throw Error(`Expected endomorphism with beta: bigint and splitScalar: function`)}return Object.freeze({...r})}var{bytesToNumberBE:i,hexToBytes:a}=e.utils_exports,o={Err:class extends Error{constructor(e=``){super(e)}},_parseInt(e){let{Err:t}=o;if(e.length<2||e[0]!==2)throw new t(`Invalid signature integer tag`);let n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t(`Invalid signature integer: wrong length`);if(r[0]&128)throw new t(`Invalid signature integer: negative`);if(r[0]===0&&!(r[1]&128))throw new t(`Invalid signature integer: unnecessary leading zero`);return{d:i(r),l:e.subarray(n+2)}},toSig(e){let{Err:t}=o,n=typeof e==`string`?a(e):e;if(!(n instanceof Uint8Array))throw Error(`ui8a expected`);let r=n.length;if(r<2||n[0]!=48)throw new t(`Invalid signature tag`);if(n[1]!==r-2)throw new t(`Invalid signature: incorrect length`);let{d:i,l:s}=o._parseInt(n.subarray(2)),{d:c,l}=o._parseInt(s);if(l.length)throw new t(`Invalid signature: left bytes after parsing`);return{r:i,s:c}},hexFromSig(e){let t=e=>Number.parseInt(e[0],16)&8?`00`+e:e,n=e=>{let t=e.toString(16);return t.length&1?`0${t}`:t},r=t(n(e.s)),i=t(n(e.r)),a=r.length/2,o=i.length/2,s=n(a),c=n(o);return`30${n(o+a+4)}02${c}${i}02${s}${r}`}},s=BigInt(0),c=BigInt(1),l=BigInt(3);function u(i){let a=r(i),{Fp:o}=a,u=a.toBytes||((t,n,r)=>{let i=n.toAffine();return e.concatBytes(Uint8Array.from([4]),o.toBytes(i.x),o.toBytes(i.y))}),d=a.fromBytes||(e=>{let t=e.subarray(1);return{x:o.fromBytes(t.subarray(0,o.BYTES)),y:o.fromBytes(t.subarray(o.BYTES,2*o.BYTES))}});function f(e){let{a:t,b:n}=a,r=o.sqr(e),i=o.mul(r,e);return o.add(o.add(i,o.mul(e,t)),n)}if(!o.eql(o.sqr(a.Gy),f(a.Gx)))throw Error(`bad generator point: equation left != right`);function p(e){return typeof e==`bigint`&&s<e&&e<a.n}function m(e){if(!p(e))throw Error(`Expected valid bigint: 0 < bigint < curve.n`)}function h(n){let{allowedPrivateKeyLengths:r,nByteLength:i,wrapPrivateKey:o,n:s}=a;if(r&&typeof n!=`bigint`){if(n instanceof Uint8Array&&(n=e.bytesToHex(n)),typeof n!=`string`||!r.includes(n.length))throw Error(`Invalid key`);n=n.padStart(i*2,`0`)}let c;try{c=typeof n==`bigint`?n:e.bytesToNumberBE(e.ensureBytes(`private key`,n,i))}catch{throw Error(`private key must be ${i} bytes, hex or bigint, not ${typeof n}`)}return o&&(c=t.mod(c,s)),m(c),c}let g=new Map;function _(e){if(!(e instanceof v))throw Error(`ProjectivePoint expected`)}class v{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,e==null||!o.isValid(e))throw Error(`x required`);if(t==null||!o.isValid(t))throw Error(`y required`);if(n==null||!o.isValid(n))throw Error(`z required`)}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!o.isValid(t)||!o.isValid(n))throw Error(`invalid affine point`);if(e instanceof v)throw Error(`projective point not allowed`);let r=e=>o.eql(e,o.ZERO);return r(t)&&r(n)?v.ZERO:new v(t,n,o.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=o.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(v.fromAffine)}static fromHex(t){let n=v.fromAffine(d(e.ensureBytes(`pointHex`,t)));return n.assertValidity(),n}static fromPrivateKey(e){return v.BASE.multiply(h(e))}_setWindowSize(e){this._WINDOW_SIZE=e,g.delete(this)}assertValidity(){if(this.is0()){if(a.allowInfinityPoint)return;throw Error(`bad point: ZERO`)}let{x:e,y:t}=this.toAffine();if(!o.isValid(e)||!o.isValid(t))throw Error(`bad point: x or y not FE`);let n=o.sqr(t),r=f(e);if(!o.eql(n,r))throw Error(`bad point: equation left != right`);if(!this.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`)}hasEvenY(){let{y:e}=this.toAffine();if(o.isOdd)return!o.isOdd(e);throw Error(`Field doesn't support isOdd`)}equals(e){_(e);let{px:t,py:n,pz:r}=this,{px:i,py:a,pz:s}=e,c=o.eql(o.mul(t,s),o.mul(i,r)),l=o.eql(o.mul(n,s),o.mul(a,r));return c&&l}negate(){return new v(this.px,o.neg(this.py),this.pz)}double(){let{a:e,b:t}=a,n=o.mul(t,l),{px:r,py:i,pz:s}=this,c=o.ZERO,u=o.ZERO,d=o.ZERO,f=o.mul(r,r),p=o.mul(i,i),m=o.mul(s,s),h=o.mul(r,i);return h=o.add(h,h),d=o.mul(r,s),d=o.add(d,d),c=o.mul(e,d),u=o.mul(n,m),u=o.add(c,u),c=o.sub(p,u),u=o.add(p,u),u=o.mul(c,u),c=o.mul(h,c),d=o.mul(n,d),m=o.mul(e,m),h=o.sub(f,m),h=o.mul(e,h),h=o.add(h,d),d=o.add(f,f),f=o.add(d,f),f=o.add(f,m),f=o.mul(f,h),u=o.add(u,f),m=o.mul(i,s),m=o.add(m,m),f=o.mul(m,h),c=o.sub(c,f),d=o.mul(m,p),d=o.add(d,d),d=o.add(d,d),new v(c,u,d)}add(e){_(e);let{px:t,py:n,pz:r}=this,{px:i,py:s,pz:c}=e,u=o.ZERO,d=o.ZERO,f=o.ZERO,p=a.a,m=o.mul(a.b,l),h=o.mul(t,i),g=o.mul(n,s),y=o.mul(r,c),b=o.add(t,n),x=o.add(i,s);b=o.mul(b,x),x=o.add(h,g),b=o.sub(b,x),x=o.add(t,r);let S=o.add(i,c);return x=o.mul(x,S),S=o.add(h,y),x=o.sub(x,S),S=o.add(n,r),u=o.add(s,c),S=o.mul(S,u),u=o.add(g,y),S=o.sub(S,u),f=o.mul(p,x),u=o.mul(m,y),f=o.add(u,f),u=o.sub(g,f),f=o.add(g,f),d=o.mul(u,f),g=o.add(h,h),g=o.add(g,h),y=o.mul(p,y),x=o.mul(m,x),g=o.add(g,y),y=o.sub(h,y),y=o.mul(p,y),x=o.add(x,y),h=o.mul(g,x),d=o.add(d,h),h=o.mul(S,x),u=o.mul(b,u),u=o.sub(u,h),h=o.mul(b,g),f=o.mul(S,f),f=o.add(f,h),new v(u,d,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(v.ZERO)}wNAF(e){return b.wNAFCached(this,g,e,e=>{let t=o.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(v.fromAffine)})}multiplyUnsafe(e){let t=v.ZERO;if(e===s)return t;if(m(e),e===c)return this;let{endo:n}=a;if(!n)return b.unsafeLadder(this,e);let{k1neg:r,k1:i,k2neg:l,k2:u}=n.splitScalar(e),d=t,f=t,p=this;for(;i>s||u>s;)i&c&&(d=d.add(p)),u&c&&(f=f.add(p)),p=p.double(),i>>=c,u>>=c;return r&&(d=d.negate()),l&&(f=f.negate()),f=new v(o.mul(f.px,n.beta),f.py,f.pz),d.add(f)}multiply(e){m(e);let t=e,n,r,{endo:i}=a;if(i){let{k1neg:e,k1:a,k2neg:s,k2:c}=i.splitScalar(t),{p:l,f:u}=this.wNAF(a),{p:d,f}=this.wNAF(c);l=b.constTimeNegate(e,l),d=b.constTimeNegate(s,d),d=new v(o.mul(d.px,i.beta),d.py,d.pz),n=l.add(d),r=u.add(f)}else{let{p:e,f:i}=this.wNAF(t);n=e,r=i}return v.normalizeZ([n,r])[0]}multiplyAndAddUnsafe(e,t,n){let r=v.BASE,i=(e,t)=>t===s||t===c||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),a=i(this,t).add(i(e,n));return a.is0()?void 0:a}toAffine(e){let{px:t,py:n,pz:r}=this,i=this.is0();e??=i?o.ONE:o.inv(r);let a=o.mul(t,e),s=o.mul(n,e),c=o.mul(r,e);if(i)return{x:o.ZERO,y:o.ZERO};if(!o.eql(c,o.ONE))throw Error(`invZ was invalid`);return{x:a,y:s}}isTorsionFree(){let{h:e,isTorsionFree:t}=a;if(e===c)return!0;if(t)return t(v,this);throw Error(`isTorsionFree() has not been declared for the elliptic curve`)}clearCofactor(){let{h:e,clearCofactor:t}=a;return e===c?this:t?t(v,this):this.multiplyUnsafe(a.h)}toRawBytes(e=!0){return this.assertValidity(),u(v,this,e)}toHex(t=!0){return e.bytesToHex(this.toRawBytes(t))}}v.BASE=new v(a.Gx,a.Gy,o.ONE),v.ZERO=new v(o.ZERO,o.ONE,o.ZERO);let y=a.nBitLength,b=n.wNAF(v,a.endo?Math.ceil(y/2):y);return{CURVE:a,ProjectivePoint:v,normPrivateKeyToScalar:h,weierstrassEquation:f,isWithinCurveOrder:p}}function d(t){let r=n.validateBasic(t);return e.validateObject(r,{hash:`hash`,hmac:`function`,randomBytes:`function`},{bits2int:`function`,bits2int_modN:`function`,lowS:`boolean`}),Object.freeze({lowS:!0,...r})}function f(n){let r=d(n),{Fp:i,n:a}=r,l=i.BYTES+1,f=2*i.BYTES+1;function p(e){return s<e&&e<i.ORDER}function m(e){return t.mod(e,a)}function h(e){return t.invert(e,a)}let{ProjectivePoint:g,normPrivateKeyToScalar:_,weierstrassEquation:v,isWithinCurveOrder:y}=u({...r,toBytes(t,n,r){let a=n.toAffine(),o=i.toBytes(a.x),s=e.concatBytes;return r?s(Uint8Array.from([n.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,i.toBytes(a.y))},fromBytes(t){let n=t.length,r=t[0],a=t.subarray(1);if(n===l&&(r===2||r===3)){let t=e.bytesToNumberBE(a);if(!p(t))throw Error(`Point is not on curve`);let n=v(t),o=i.sqrt(n),s=(o&c)===c;return(r&1)==1!==s&&(o=i.neg(o)),{x:t,y:o}}else if(n===f&&r===4)return{x:i.fromBytes(a.subarray(0,i.BYTES)),y:i.fromBytes(a.subarray(i.BYTES,2*i.BYTES))};else throw Error(`Point of length ${n} was invalid. Expected ${l} compressed bytes or ${f} uncompressed bytes`)}}),b=t=>e.bytesToHex(e.numberToBytesBE(t,r.nByteLength));function x(e){return e>a>>c}function S(e){return x(e)?m(-e):e}let C=(t,n,r)=>e.bytesToNumberBE(t.slice(n,r));class w{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(t){let n=r.nByteLength;return t=e.ensureBytes(`compactSignature`,t,n*2),new w(C(t,0,n),C(t,n,2*n))}static fromDER(t){let{r:n,s:r}=o.toSig(e.ensureBytes(`DER`,t));return new w(n,r)}assertValidity(){if(!y(this.r))throw Error(`r must be 0 < r < CURVE.n`);if(!y(this.s))throw Error(`s must be 0 < s < CURVE.n`)}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:a,recovery:o}=this,s=A(e.ensureBytes(`msgHash`,t));if(o==null||![0,1,2,3].includes(o))throw Error(`recovery id invalid`);let c=o===2||o===3?n+r.n:n;if(c>=i.ORDER)throw Error(`recovery id 2 or 3 invalid`);let l=o&1?`03`:`02`,u=g.fromHex(l+b(c)),d=h(c),f=m(-s*d),p=m(a*d),_=g.BASE.multiplyAndAddUnsafe(u,f,p);if(!_)throw Error(`point at infinify`);return _.assertValidity(),_}hasHighS(){return x(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,m(-this.s),this.recovery):this}toDERRawBytes(){return e.hexToBytes(this.toDERHex())}toDERHex(){return o.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return e.hexToBytes(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}let T={isValidPrivateKey(e){try{return _(e),!0}catch{return!1}},normPrivateKeyToScalar:_,randomPrivateKey:()=>{let n=r.randomBytes(i.BYTES+8),o=t.hashToPrivateScalar(n,a);return e.numberToBytesBE(o,r.nByteLength)},precompute(e=8,t=g.BASE){return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function E(e,t=!0){return g.fromPrivateKey(e).toRawBytes(t)}function D(e){let t=e instanceof Uint8Array,n=typeof e==`string`,r=(t||n)&&e.length;return t?r===l||r===f:n?r===2*l||r===2*f:e instanceof g}function O(e,t,n=!0){if(D(e))throw Error(`first arg must be private key`);if(!D(t))throw Error(`second arg must be public key`);return g.fromHex(t).multiply(_(e)).toRawBytes(n)}let k=r.bits2int||function(t){let n=e.bytesToNumberBE(t),i=t.length*8-r.nBitLength;return i>0?n>>BigInt(i):n},A=r.bits2int_modN||function(e){return m(k(e))},j=e.bitMask(r.nBitLength);function M(t){if(typeof t!=`bigint`)throw Error(`bigint expected`);if(!(s<=t&&t<j))throw Error(`bigint expected < 2^${r.nBitLength}`);return e.numberToBytesBE(t,r.nByteLength)}function N(t,n,a=P){if([`recovered`,`canonical`].some(e=>e in a))throw Error(`sign() legacy options not supported`);let{hash:o,randomBytes:l}=r,{lowS:u,prehash:d,extraEntropy:f}=a;u??=!0,t=e.ensureBytes(`msgHash`,t),d&&(t=e.ensureBytes(`prehashed msgHash`,o(t)));let p=A(t),v=_(n),b=[M(v),M(p)];if(f!=null){let t=f===!0?l(i.BYTES):f;b.push(e.ensureBytes(`extraEntropy`,t,i.BYTES))}let C=e.concatBytes(...b),T=p;function E(e){let t=k(e);if(!y(t))return;let n=h(t),r=g.BASE.multiply(t).toAffine(),i=m(r.x);if(i===s)return;let a=m(n*m(T+i*v));if(a===s)return;let o=(r.x===i?0:2)|Number(r.y&c),l=a;return u&&x(a)&&(l=S(a),o^=1),new w(i,l,o)}return{seed:C,k2sig:E}}let P={lowS:r.lowS,prehash:!1},F={lowS:r.lowS,prehash:!1};function I(t,n,i=P){let{seed:a,k2sig:o}=N(t,n,i);return e.createHmacDrbg(r.hash.outputLen,r.nByteLength,r.hmac)(a,o)}g.BASE._setWindowSize(8);function L(t,n,i,a=F){let s=t;if(n=e.ensureBytes(`msgHash`,n),i=e.ensureBytes(`publicKey`,i),`strict`in a)throw Error(`options.strict was renamed to lowS`);let{lowS:c,prehash:l}=a,u,d;try{if(typeof s==`string`||s instanceof Uint8Array)try{u=w.fromDER(s)}catch(e){if(!(e instanceof o.Err))throw e;u=w.fromCompact(s)}else if(typeof s==`object`&&typeof s.r==`bigint`&&typeof s.s==`bigint`){let{r:e,s:t}=s;u=new w(e,t)}else throw Error(`PARSE`);d=g.fromHex(i)}catch(e){if(e.message===`PARSE`)throw Error(`signature must be Signature instance, Uint8Array or hex string`);return!1}if(c&&u.hasHighS())return!1;l&&(n=r.hash(n));let{r:f,s:p}=u,_=A(n),v=h(p),y=m(_*v),b=m(f*v),x=g.BASE.multiplyAndAddUnsafe(d,y,b)?.toAffine();return x?m(x.x)===f:!1}return{CURVE:r,getPublicKey:E,getSharedSecret:O,sign:I,verify:L,ProjectivePoint:g,Signature:w,utils:T}}exports.weierstrass=f;