typenative 0.6.1 → 0.7.0

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 (1004) hide show
  1. package/CHANGELOG.md +412 -0
  2. package/README.md +1 -1
  3. package/bin/cli.js +18 -8
  4. package/bin/go/overrides.js +21 -1
  5. package/bin/index.js +48 -25
  6. package/bin/main.js +2 -1
  7. package/bin/node/assert.js +54 -15
  8. package/bin/node/async_hooks.js +69 -10
  9. package/bin/node/buffer.js +321 -7
  10. package/bin/node/child_process.js +154 -8
  11. package/bin/node/cluster.js +436 -32
  12. package/bin/node/crypto.js +814 -5
  13. package/bin/node/crypto_curves.js +142 -0
  14. package/bin/node/crypto_keys.js +1147 -48
  15. package/bin/node/crypto_pem.js +313 -0
  16. package/bin/node/crypto_pkcs12.js +17 -0
  17. package/bin/node/dgram.js +161 -10
  18. package/bin/node/diagnostics_channel.js +5 -1
  19. package/bin/node/events.js +358 -8
  20. package/bin/node/ffi.js +933 -0
  21. package/bin/node/fs.js +334 -6
  22. package/bin/node/http.js +630 -55
  23. package/bin/node/http2.js +1141 -88
  24. package/bin/node/intl.js +4576 -0
  25. package/bin/node/intl_data.js +65412 -0
  26. package/bin/node/module_v8.js +155 -16
  27. package/bin/node/net.js +59 -10
  28. package/bin/node/path.js +5 -1
  29. package/bin/node/process.js +342 -3
  30. package/bin/node/readline.js +558 -8
  31. package/bin/node/registry.js +2 -0
  32. package/bin/node/sqlite.js +51 -2
  33. package/bin/node/stream.js +370 -32
  34. package/bin/node/stream_web.js +422 -15
  35. package/bin/node/system_extra.js +154 -1
  36. package/bin/node/temporal.js +96 -0
  37. package/bin/node/temporal_runtime.js +5075 -0
  38. package/bin/node/temporal_zones.js +460 -0
  39. package/bin/node/test.js +153 -8
  40. package/bin/node/test_coverage.js +58 -0
  41. package/bin/node/test_report.js +3 -3
  42. package/bin/node/test_run.js +7 -1
  43. package/bin/node/timers.js +123 -0
  44. package/bin/node/tls.js +346 -12
  45. package/bin/node/tls_roots.js +122 -0
  46. package/bin/node/typed_arrays.js +867 -93
  47. package/bin/node/url.js +657 -0
  48. package/bin/node/util.js +441 -2
  49. package/bin/node/util_extra.js +6 -0
  50. package/bin/node/wasi.js +214 -0
  51. package/bin/node/webassembly.js +1122 -0
  52. package/bin/node/websocket.js +763 -0
  53. package/bin/node/worker_threads.js +434 -52
  54. package/bin/node/zlib.js +338 -9
  55. package/bin/node/zlib_zip.js +2392 -0
  56. package/bin/transpiler.js +2083 -254
  57. package/bin/typecheck-node.js +49 -17
  58. package/bin/version.js +1 -1
  59. package/conformance.md +160 -113
  60. package/examples/README.md +21 -20
  61. package/examples/angular-templates/README.md +12 -12
  62. package/examples/desktop-notes/README.md +7 -7
  63. package/examples/dupe-finder/README.md +4 -4
  64. package/examples/fibonacci/README.md +6 -6
  65. package/examples/hello-world/README.md +4 -4
  66. package/examples/json-server/README.md +13 -12
  67. package/examples/mandelbrot-png/README.md +4 -4
  68. package/examples/marked-cli/README.md +16 -17
  69. package/examples/openai-chat/README.md +5 -5
  70. package/examples/react-compiler/README.md +10 -10
  71. package/examples/todo-cli/README.md +8 -8
  72. package/examples/yaml-cli/README.md +10 -10
  73. package/govendor/github.com/cloudflare/circl/.golangci.yaml +64 -0
  74. package/govendor/github.com/cloudflare/circl/.semgrepignore +1 -0
  75. package/govendor/github.com/cloudflare/circl/AGENTS.md +91 -0
  76. package/govendor/github.com/cloudflare/circl/CITATION.cff +30 -0
  77. package/govendor/github.com/cloudflare/circl/LICENSE +57 -0
  78. package/govendor/github.com/cloudflare/circl/Makefile +70 -0
  79. package/govendor/github.com/cloudflare/circl/README.md +206 -0
  80. package/govendor/github.com/cloudflare/circl/REVIEW.md +83 -0
  81. package/govendor/github.com/cloudflare/circl/codecov.yml +21 -0
  82. package/govendor/github.com/cloudflare/circl/dh/x448/curve.go +104 -0
  83. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.go +30 -0
  84. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.h +111 -0
  85. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.s +194 -0
  86. package/govendor/github.com/cloudflare/circl/dh/x448/curve_generic.go +100 -0
  87. package/govendor/github.com/cloudflare/circl/dh/x448/curve_noasm.go +11 -0
  88. package/govendor/github.com/cloudflare/circl/dh/x448/doc.go +19 -0
  89. package/govendor/github.com/cloudflare/circl/dh/x448/key.go +46 -0
  90. package/govendor/github.com/cloudflare/circl/dh/x448/table.go +460 -0
  91. package/govendor/github.com/cloudflare/circl/doc.go +8 -0
  92. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/constants.go +71 -0
  93. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/curve.go +90 -0
  94. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/isogeny.go +52 -0
  95. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/point.go +181 -0
  96. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/scalar.go +203 -0
  97. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twist.go +138 -0
  98. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twistPoint.go +135 -0
  99. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twistTables.go +216 -0
  100. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twist_basemult.go +62 -0
  101. package/govendor/github.com/cloudflare/circl/go.mod +3 -0
  102. package/govendor/github.com/cloudflare/circl/internal/conv/conv.go +173 -0
  103. package/govendor/github.com/cloudflare/circl/internal/sha3/doc.go +62 -0
  104. package/govendor/github.com/cloudflare/circl/internal/sha3/hashes.go +69 -0
  105. package/govendor/github.com/cloudflare/circl/internal/sha3/keccakf.go +391 -0
  106. package/govendor/github.com/cloudflare/circl/internal/sha3/rc.go +29 -0
  107. package/govendor/github.com/cloudflare/circl/internal/sha3/sha3.go +200 -0
  108. package/govendor/github.com/cloudflare/circl/internal/sha3/sha3_s390x.s +33 -0
  109. package/govendor/github.com/cloudflare/circl/internal/sha3/shake.go +119 -0
  110. package/govendor/github.com/cloudflare/circl/internal/sha3/xor.go +15 -0
  111. package/govendor/github.com/cloudflare/circl/internal/sha3/xor_generic.go +33 -0
  112. package/govendor/github.com/cloudflare/circl/internal/sha3/xor_unaligned.go +61 -0
  113. package/govendor/github.com/cloudflare/circl/math/fp448/fp.go +164 -0
  114. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.go +43 -0
  115. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.h +591 -0
  116. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.s +75 -0
  117. package/govendor/github.com/cloudflare/circl/math/fp448/fp_generic.go +339 -0
  118. package/govendor/github.com/cloudflare/circl/math/fp448/fp_noasm.go +12 -0
  119. package/govendor/github.com/cloudflare/circl/math/fp448/fuzzer.go +75 -0
  120. package/govendor/github.com/cloudflare/circl/math/integer.go +16 -0
  121. package/govendor/github.com/cloudflare/circl/math/mlsbset/mlsbset.go +145 -0
  122. package/govendor/github.com/cloudflare/circl/math/mlsbset/power.go +64 -0
  123. package/govendor/github.com/cloudflare/circl/math/primes.go +34 -0
  124. package/govendor/github.com/cloudflare/circl/math/wnaf.go +84 -0
  125. package/govendor/github.com/cloudflare/circl/sign/ed448/ed448.go +417 -0
  126. package/govendor/github.com/cloudflare/circl/sign/ed448/signapi.go +89 -0
  127. package/govendor/github.com/cloudflare/circl/sign/sign.go +119 -0
  128. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/LICENSE +17 -0
  129. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/README.md +72 -0
  130. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/compressedbytepoints.go +18 -0
  131. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve.go +1310 -0
  132. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve_embedded.go +14 -0
  133. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve_precompute.go +14 -0
  134. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/doc.go +59 -0
  135. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdh.go +21 -0
  136. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/README.md +52 -0
  137. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/doc.go +42 -0
  138. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/error.go +134 -0
  139. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/signature.go +1001 -0
  140. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ellipticadaptor.go +296 -0
  141. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/error.go +67 -0
  142. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/field.go +1696 -0
  143. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/go.mod +3 -0
  144. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/loadprecomputed.go +91 -0
  145. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/modnscalar.go +1105 -0
  146. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/nonce.go +263 -0
  147. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/privkey.go +111 -0
  148. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/pubkey.go +236 -0
  149. package/govendor/github.com/ebitengine/purego/LICENSE +201 -0
  150. package/govendor/github.com/ebitengine/purego/README.md +124 -0
  151. package/govendor/github.com/ebitengine/purego/abi_amd64.h +99 -0
  152. package/govendor/github.com/ebitengine/purego/abi_arm64.h +39 -0
  153. package/govendor/github.com/ebitengine/purego/abi_loong64.h +60 -0
  154. package/govendor/github.com/ebitengine/purego/cdecl.go +11 -0
  155. package/govendor/github.com/ebitengine/purego/cgo.go +19 -0
  156. package/govendor/github.com/ebitengine/purego/dlerror.go +17 -0
  157. package/govendor/github.com/ebitengine/purego/dlfcn.go +99 -0
  158. package/govendor/github.com/ebitengine/purego/dlfcn_android.go +34 -0
  159. package/govendor/github.com/ebitengine/purego/dlfcn_darwin.go +20 -0
  160. package/govendor/github.com/ebitengine/purego/dlfcn_freebsd.go +14 -0
  161. package/govendor/github.com/ebitengine/purego/dlfcn_linux.go +16 -0
  162. package/govendor/github.com/ebitengine/purego/dlfcn_netbsd.go +15 -0
  163. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_freebsd.go +11 -0
  164. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_linux.go +19 -0
  165. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_netbsd.go +11 -0
  166. package/govendor/github.com/ebitengine/purego/dlfcn_playground.go +24 -0
  167. package/govendor/github.com/ebitengine/purego/dlfcn_stubs.s +22 -0
  168. package/govendor/github.com/ebitengine/purego/func.go +780 -0
  169. package/govendor/github.com/ebitengine/purego/gen.go +6 -0
  170. package/govendor/github.com/ebitengine/purego/go.mod +3 -0
  171. package/govendor/github.com/ebitengine/purego/go_runtime.go +19 -0
  172. package/govendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go +56 -0
  173. package/govendor/github.com/ebitengine/purego/internal/cgo/empty.go +6 -0
  174. package/govendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go +49 -0
  175. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h +99 -0
  176. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h +39 -0
  177. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_loong64.h +60 -0
  178. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_ppc64x.h +195 -0
  179. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_riscv64.h +72 -0
  180. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_386.s +29 -0
  181. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s +39 -0
  182. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm.s +58 -0
  183. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s +35 -0
  184. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_loong64.s +38 -0
  185. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_ppc64le.s +79 -0
  186. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_riscv64.s +36 -0
  187. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_s390x.s +52 -0
  188. package/govendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go +93 -0
  189. package/govendor/github.com/ebitengine/purego/internal/fakecgo/doc.go +32 -0
  190. package/govendor/github.com/ebitengine/purego/internal/fakecgo/fakecgo.go +14 -0
  191. package/govendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go +27 -0
  192. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin.go +86 -0
  193. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd.go +77 -0
  194. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go +72 -0
  195. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_linux.go +77 -0
  196. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_netbsd.go +83 -0
  197. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go +18 -0
  198. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go +38 -0
  199. package/govendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go +19 -0
  200. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go +37 -0
  201. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go +37 -0
  202. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go +27 -0
  203. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go +27 -0
  204. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_netbsd.go +36 -0
  205. package/govendor/github.com/ebitengine/purego/internal/fakecgo/linux.go +189 -0
  206. package/govendor/github.com/ebitengine/purego/internal/fakecgo/netbsd.go +23 -0
  207. package/govendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go +19 -0
  208. package/govendor/github.com/ebitengine/purego/internal/fakecgo/threadentry_amd64.go +15 -0
  209. package/govendor/github.com/ebitengine/purego/internal/fakecgo/threadentry_noasm.go +24 -0
  210. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_386.s +130 -0
  211. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s +124 -0
  212. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm.s +131 -0
  213. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s +81 -0
  214. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_386.s +78 -0
  215. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_amd64.s +69 -0
  216. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_arm.s +69 -0
  217. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_arm64.s +60 -0
  218. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_loong64.s +60 -0
  219. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_ppc64le.s +69 -0
  220. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_riscv64.s +60 -0
  221. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_s390x.s +51 -0
  222. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_loong64.s +78 -0
  223. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_ppc64le.s +132 -0
  224. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_riscv64.s +76 -0
  225. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_s390x.s +158 -0
  226. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols.go +165 -0
  227. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_darwin.go +59 -0
  228. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_freebsd.go +48 -0
  229. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_linux.go +158 -0
  230. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_netbsd.go +59 -0
  231. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_darwin.s +19 -0
  232. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_freebsd.s +16 -0
  233. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_linux.s +46 -0
  234. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_netbsd.s +19 -0
  235. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_stubs.s +55 -0
  236. package/govendor/github.com/ebitengine/purego/internal/strings/strings.go +40 -0
  237. package/govendor/github.com/ebitengine/purego/is_ios.go +13 -0
  238. package/govendor/github.com/ebitengine/purego/nocgo.go +25 -0
  239. package/govendor/github.com/ebitengine/purego/struct_amd64.go +518 -0
  240. package/govendor/github.com/ebitengine/purego/struct_arm.go +100 -0
  241. package/govendor/github.com/ebitengine/purego/struct_arm64.go +757 -0
  242. package/govendor/github.com/ebitengine/purego/struct_loong64.go +244 -0
  243. package/govendor/github.com/ebitengine/purego/struct_other.go +54 -0
  244. package/govendor/github.com/ebitengine/purego/struct_ppc64le.go +180 -0
  245. package/govendor/github.com/ebitengine/purego/struct_riscv64.go +158 -0
  246. package/govendor/github.com/ebitengine/purego/struct_s390x.go +158 -0
  247. package/govendor/github.com/ebitengine/purego/sys_386.s +153 -0
  248. package/govendor/github.com/ebitengine/purego/sys_amd64.s +206 -0
  249. package/govendor/github.com/ebitengine/purego/sys_arm.s +153 -0
  250. package/govendor/github.com/ebitengine/purego/sys_arm64.s +133 -0
  251. package/govendor/github.com/ebitengine/purego/sys_loong64.s +131 -0
  252. package/govendor/github.com/ebitengine/purego/sys_ppc64le.s +126 -0
  253. package/govendor/github.com/ebitengine/purego/sys_riscv64.s +135 -0
  254. package/govendor/github.com/ebitengine/purego/sys_s390x.s +148 -0
  255. package/govendor/github.com/ebitengine/purego/sys_unix_386.s +234 -0
  256. package/govendor/github.com/ebitengine/purego/sys_unix_arm.s +99 -0
  257. package/govendor/github.com/ebitengine/purego/sys_unix_arm64.s +75 -0
  258. package/govendor/github.com/ebitengine/purego/sys_unix_loong64.s +79 -0
  259. package/govendor/github.com/ebitengine/purego/sys_unix_ppc64le.s +114 -0
  260. package/govendor/github.com/ebitengine/purego/sys_unix_riscv64.s +79 -0
  261. package/govendor/github.com/ebitengine/purego/sys_unix_s390x.s +111 -0
  262. package/govendor/github.com/ebitengine/purego/syscall.go +95 -0
  263. package/govendor/github.com/ebitengine/purego/syscall_32bit.go +97 -0
  264. package/govendor/github.com/ebitengine/purego/syscall_cgo_linux.go +20 -0
  265. package/govendor/github.com/ebitengine/purego/syscall_notstackargs.go +55 -0
  266. package/govendor/github.com/ebitengine/purego/syscall_ppc64le.go +73 -0
  267. package/govendor/github.com/ebitengine/purego/syscall_stackargs_ppc64le.go +38 -0
  268. package/govendor/github.com/ebitengine/purego/syscall_stackargs_s390x.go +38 -0
  269. package/govendor/github.com/ebitengine/purego/syscall_unix.go +392 -0
  270. package/govendor/github.com/ebitengine/purego/syscall_windows.go +54 -0
  271. package/govendor/github.com/ebitengine/purego/zcallback_386.s +4014 -0
  272. package/govendor/github.com/ebitengine/purego/zcallback_amd64.s +2014 -0
  273. package/govendor/github.com/ebitengine/purego/zcallback_arm.s +4014 -0
  274. package/govendor/github.com/ebitengine/purego/zcallback_arm64.s +4014 -0
  275. package/govendor/github.com/ebitengine/purego/zcallback_loong64.s +4014 -0
  276. package/govendor/github.com/ebitengine/purego/zcallback_ppc64le.s +4014 -0
  277. package/govendor/github.com/ebitengine/purego/zcallback_riscv64.s +4051 -0
  278. package/govendor/github.com/ebitengine/purego/zcallback_s390x.s +4015 -0
  279. package/govendor/github.com/klauspost/compress/.gitattributes +3 -0
  280. package/govendor/github.com/klauspost/compress/.goreleaser.yml +132 -0
  281. package/govendor/github.com/klauspost/compress/AGENTS.md +106 -0
  282. package/govendor/github.com/klauspost/compress/LICENSE +304 -0
  283. package/govendor/github.com/klauspost/compress/README.md +766 -0
  284. package/govendor/github.com/klauspost/compress/SECURITY.md +25 -0
  285. package/govendor/github.com/klauspost/compress/compressible.go +85 -0
  286. package/govendor/github.com/klauspost/compress/fse/README.md +79 -0
  287. package/govendor/github.com/klauspost/compress/fse/bitreader.go +122 -0
  288. package/govendor/github.com/klauspost/compress/fse/bitwriter.go +167 -0
  289. package/govendor/github.com/klauspost/compress/fse/bytereader.go +47 -0
  290. package/govendor/github.com/klauspost/compress/fse/compress.go +685 -0
  291. package/govendor/github.com/klauspost/compress/fse/decompress.go +383 -0
  292. package/govendor/github.com/klauspost/compress/fse/fse.go +150 -0
  293. package/govendor/github.com/klauspost/compress/gen.sh +4 -0
  294. package/govendor/github.com/klauspost/compress/go.mod +3 -0
  295. package/govendor/github.com/klauspost/compress/huff0/README.md +89 -0
  296. package/govendor/github.com/klauspost/compress/huff0/bitreader.go +323 -0
  297. package/govendor/github.com/klauspost/compress/huff0/bitwriter.go +97 -0
  298. package/govendor/github.com/klauspost/compress/huff0/build_table.go +168 -0
  299. package/govendor/github.com/klauspost/compress/huff0/compress.go +747 -0
  300. package/govendor/github.com/klauspost/compress/huff0/decompress.go +1188 -0
  301. package/govendor/github.com/klauspost/compress/huff0/decompress_amd64.go +128 -0
  302. package/govendor/github.com/klauspost/compress/huff0/decompress_amd64.s +3476 -0
  303. package/govendor/github.com/klauspost/compress/huff0/decompress_arm64.go +72 -0
  304. package/govendor/github.com/klauspost/compress/huff0/decompress_arm64.s +1648 -0
  305. package/govendor/github.com/klauspost/compress/huff0/decompress_asm.go +252 -0
  306. package/govendor/github.com/klauspost/compress/huff0/decompress_generic.go +278 -0
  307. package/govendor/github.com/klauspost/compress/huff0/huff0.go +337 -0
  308. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo.go +34 -0
  309. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.go +10 -0
  310. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.s +34 -0
  311. package/govendor/github.com/klauspost/compress/internal/le/le.go +5 -0
  312. package/govendor/github.com/klauspost/compress/internal/le/unsafe_disabled.go +42 -0
  313. package/govendor/github.com/klauspost/compress/internal/le/unsafe_enabled.go +52 -0
  314. package/govendor/github.com/klauspost/compress/internal/regmask/regmask.go +50 -0
  315. package/govendor/github.com/klauspost/compress/internal/regmask/regmask_386.go +39 -0
  316. package/govendor/github.com/klauspost/compress/internal/snapref/LICENSE +27 -0
  317. package/govendor/github.com/klauspost/compress/internal/snapref/decode.go +264 -0
  318. package/govendor/github.com/klauspost/compress/internal/snapref/decode_other.go +113 -0
  319. package/govendor/github.com/klauspost/compress/internal/snapref/encode.go +291 -0
  320. package/govendor/github.com/klauspost/compress/internal/snapref/encode_other.go +250 -0
  321. package/govendor/github.com/klauspost/compress/internal/snapref/snappy.go +98 -0
  322. package/govendor/github.com/klauspost/compress/s2sx.mod +3 -0
  323. package/govendor/github.com/klauspost/compress/s2sx.sum +0 -0
  324. package/govendor/github.com/klauspost/compress/zstd/README.md +487 -0
  325. package/govendor/github.com/klauspost/compress/zstd/bitreader.go +176 -0
  326. package/govendor/github.com/klauspost/compress/zstd/bitwriter.go +151 -0
  327. package/govendor/github.com/klauspost/compress/zstd/blockdec.go +728 -0
  328. package/govendor/github.com/klauspost/compress/zstd/blockenc.go +923 -0
  329. package/govendor/github.com/klauspost/compress/zstd/blocktype_string.go +85 -0
  330. package/govendor/github.com/klauspost/compress/zstd/bytebuf.go +131 -0
  331. package/govendor/github.com/klauspost/compress/zstd/bytereader.go +82 -0
  332. package/govendor/github.com/klauspost/compress/zstd/decodeheader.go +261 -0
  333. package/govendor/github.com/klauspost/compress/zstd/decoder.go +995 -0
  334. package/govendor/github.com/klauspost/compress/zstd/decoder_options.go +213 -0
  335. package/govendor/github.com/klauspost/compress/zstd/dict.go +605 -0
  336. package/govendor/github.com/klauspost/compress/zstd/enc_base.go +200 -0
  337. package/govendor/github.com/klauspost/compress/zstd/enc_best.go +572 -0
  338. package/govendor/github.com/klauspost/compress/zstd/enc_better.go +1262 -0
  339. package/govendor/github.com/klauspost/compress/zstd/enc_dfast.go +1136 -0
  340. package/govendor/github.com/klauspost/compress/zstd/enc_fast.go +892 -0
  341. package/govendor/github.com/klauspost/compress/zstd/enc_jobs.go +352 -0
  342. package/govendor/github.com/klauspost/compress/zstd/encoder.go +881 -0
  343. package/govendor/github.com/klauspost/compress/zstd/encoder_options.go +422 -0
  344. package/govendor/github.com/klauspost/compress/zstd/framedec.go +404 -0
  345. package/govendor/github.com/klauspost/compress/zstd/frameenc.go +137 -0
  346. package/govendor/github.com/klauspost/compress/zstd/fse_decoder.go +333 -0
  347. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s +132 -0
  348. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_arm64.s +148 -0
  349. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_asm.go +70 -0
  350. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go +71 -0
  351. package/govendor/github.com/klauspost/compress/zstd/fse_encoder.go +701 -0
  352. package/govendor/github.com/klauspost/compress/zstd/fse_predefined.go +168 -0
  353. package/govendor/github.com/klauspost/compress/zstd/hash.go +57 -0
  354. package/govendor/github.com/klauspost/compress/zstd/history.go +119 -0
  355. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/LICENSE.txt +22 -0
  356. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/README.md +71 -0
  357. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash.go +242 -0
  358. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_amd64.s +210 -0
  359. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_arm64.s +184 -0
  360. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_asm.go +11 -0
  361. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_other.go +75 -0
  362. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_safe.go +11 -0
  363. package/govendor/github.com/klauspost/compress/zstd/matchlen_amd64.go +15 -0
  364. package/govendor/github.com/klauspost/compress/zstd/matchlen_amd64.s +66 -0
  365. package/govendor/github.com/klauspost/compress/zstd/matchlen_generic.go +37 -0
  366. package/govendor/github.com/klauspost/compress/zstd/seqdec.go +620 -0
  367. package/govendor/github.com/klauspost/compress/zstd/seqdec_amd64.go +115 -0
  368. package/govendor/github.com/klauspost/compress/zstd/seqdec_amd64.s +4762 -0
  369. package/govendor/github.com/klauspost/compress/zstd/seqdec_arm64.go +81 -0
  370. package/govendor/github.com/klauspost/compress/zstd/seqdec_arm64.s +2919 -0
  371. package/govendor/github.com/klauspost/compress/zstd/seqdec_asm.go +327 -0
  372. package/govendor/github.com/klauspost/compress/zstd/seqdec_generic.go +258 -0
  373. package/govendor/github.com/klauspost/compress/zstd/seqenc.go +159 -0
  374. package/govendor/github.com/klauspost/compress/zstd/simple.go +54 -0
  375. package/govendor/github.com/klauspost/compress/zstd/snappy.go +447 -0
  376. package/govendor/github.com/klauspost/compress/zstd/zip.go +141 -0
  377. package/govendor/github.com/klauspost/compress/zstd/zstd.go +126 -0
  378. package/govendor/github.com/tetratelabs/wazero/.editorconfig +7 -0
  379. package/govendor/github.com/tetratelabs/wazero/.gitattributes +2 -0
  380. package/govendor/github.com/tetratelabs/wazero/.gitmodules +3 -0
  381. package/govendor/github.com/tetratelabs/wazero/CONTRIBUTING.md +75 -0
  382. package/govendor/github.com/tetratelabs/wazero/LICENSE +201 -0
  383. package/govendor/github.com/tetratelabs/wazero/Makefile +385 -0
  384. package/govendor/github.com/tetratelabs/wazero/NOTICE +2 -0
  385. package/govendor/github.com/tetratelabs/wazero/RATIONALE.md +1577 -0
  386. package/govendor/github.com/tetratelabs/wazero/README.md +135 -0
  387. package/govendor/github.com/tetratelabs/wazero/api/features.go +228 -0
  388. package/govendor/github.com/tetratelabs/wazero/api/wasm.go +766 -0
  389. package/govendor/github.com/tetratelabs/wazero/builder.go +367 -0
  390. package/govendor/github.com/tetratelabs/wazero/cache.go +123 -0
  391. package/govendor/github.com/tetratelabs/wazero/codecov.yml +9 -0
  392. package/govendor/github.com/tetratelabs/wazero/config.go +899 -0
  393. package/govendor/github.com/tetratelabs/wazero/experimental/checkpoint.go +35 -0
  394. package/govendor/github.com/tetratelabs/wazero/experimental/close.go +63 -0
  395. package/govendor/github.com/tetratelabs/wazero/experimental/compilationworkers.go +19 -0
  396. package/govendor/github.com/tetratelabs/wazero/experimental/experimental.go +41 -0
  397. package/govendor/github.com/tetratelabs/wazero/experimental/features.go +39 -0
  398. package/govendor/github.com/tetratelabs/wazero/experimental/importresolver.go +19 -0
  399. package/govendor/github.com/tetratelabs/wazero/experimental/listener.go +324 -0
  400. package/govendor/github.com/tetratelabs/wazero/experimental/memory.go +52 -0
  401. package/govendor/github.com/tetratelabs/wazero/experimental/sys/dir.go +92 -0
  402. package/govendor/github.com/tetratelabs/wazero/experimental/sys/errno.go +98 -0
  403. package/govendor/github.com/tetratelabs/wazero/experimental/sys/error.go +45 -0
  404. package/govendor/github.com/tetratelabs/wazero/experimental/sys/file.go +356 -0
  405. package/govendor/github.com/tetratelabs/wazero/experimental/sys/fs.go +292 -0
  406. package/govendor/github.com/tetratelabs/wazero/experimental/sys/oflag.go +70 -0
  407. package/govendor/github.com/tetratelabs/wazero/experimental/sys/poll.go +48 -0
  408. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno.go +106 -0
  409. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_notwindows.go +13 -0
  410. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_unsupported.go +7 -0
  411. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_windows.go +37 -0
  412. package/govendor/github.com/tetratelabs/wazero/experimental/sys/time.go +10 -0
  413. package/govendor/github.com/tetratelabs/wazero/experimental/sys/unimplemented.go +160 -0
  414. package/govendor/github.com/tetratelabs/wazero/fsconfig.go +213 -0
  415. package/govendor/github.com/tetratelabs/wazero/go.mod +3 -0
  416. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/args.go +97 -0
  417. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/clock.go +116 -0
  418. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/environ.go +100 -0
  419. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/fs.go +2015 -0
  420. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/poll.go +247 -0
  421. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/proc.go +44 -0
  422. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/random.go +55 -0
  423. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sched.go +22 -0
  424. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sock.go +188 -0
  425. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/wasi.go +314 -0
  426. package/govendor/github.com/tetratelabs/wazero/internal/descriptor/table.go +149 -0
  427. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/compiler.go +3884 -0
  428. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/format.go +22 -0
  429. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/interpreter.go +4963 -0
  430. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/operations.go +2978 -0
  431. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/signature.go +825 -0
  432. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/abi.go +170 -0
  433. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/backend.go +3 -0
  434. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/compiler.go +402 -0
  435. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/compiler_lower.go +226 -0
  436. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/go_call.go +33 -0
  437. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi.go +186 -0
  438. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_amd64.go +9 -0
  439. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_amd64.s +29 -0
  440. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_preamble.go +248 -0
  441. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_go_call.go +440 -0
  442. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/cond.go +168 -0
  443. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/ext.go +35 -0
  444. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/instr.go +2495 -0
  445. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/instr_encoding.go +1714 -0
  446. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/lower_constant.go +71 -0
  447. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/lower_mem.go +187 -0
  448. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine.go +3782 -0
  449. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_pro_epi_logue.go +334 -0
  450. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_regalloc.go +352 -0
  451. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_vec.go +992 -0
  452. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/operands.go +336 -0
  453. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/reg.go +181 -0
  454. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/stack.go +130 -0
  455. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi.go +376 -0
  456. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_arm64.go +9 -0
  457. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_arm64.s +29 -0
  458. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_preamble.go +233 -0
  459. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_go_call.go +430 -0
  460. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/cond.go +215 -0
  461. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/instr.go +2562 -0
  462. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/instr_encoding.go +2357 -0
  463. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_constant.go +301 -0
  464. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_instr.go +2227 -0
  465. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_instr_operands.go +340 -0
  466. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_mem.go +451 -0
  467. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine.go +631 -0
  468. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_pro_epi_logue.go +486 -0
  469. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_regalloc.go +351 -0
  470. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_relocation.go +128 -0
  471. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/reg.go +397 -0
  472. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/unwind_stack.go +84 -0
  473. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/machine.go +119 -0
  474. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/api.go +124 -0
  475. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/reg.go +123 -0
  476. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/regalloc.go +1189 -0
  477. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/regset.go +96 -0
  478. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/vdef.go +19 -0
  479. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/call_engine.go +884 -0
  480. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine.go +1008 -0
  481. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine_cache.go +347 -0
  482. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_amd64.go +13 -0
  483. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_arm64.go +13 -0
  484. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_other.go +15 -0
  485. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/frontend.go +663 -0
  486. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/lower.go +5045 -0
  487. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/misc.go +10 -0
  488. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/sort_id.go +13 -0
  489. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/hostmodule.go +88 -0
  490. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_amd64.go +30 -0
  491. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_arm64.go +32 -0
  492. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_other.go +29 -0
  493. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/memmove.go +11 -0
  494. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/module_engine.go +403 -0
  495. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/basic_block.go +381 -0
  496. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/basic_block_sort.go +32 -0
  497. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/builder.go +790 -0
  498. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/cmp.go +107 -0
  499. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/funcref.go +12 -0
  500. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/instructions.go +3024 -0
  501. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass.go +393 -0
  502. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass_blk_layouts.go +334 -0
  503. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass_cfg.go +313 -0
  504. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/signature.go +49 -0
  505. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/ssa.go +14 -0
  506. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/type.go +115 -0
  507. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/vs.go +114 -0
  508. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/debug_options.go +189 -0
  509. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/exitcode.go +150 -0
  510. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/offsetdata.go +248 -0
  511. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap.go +96 -0
  512. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap_disabled.go +5 -0
  513. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap_enabled.go +5 -0
  514. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/pool.go +215 -0
  515. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/ptr.go +15 -0
  516. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/queue.go +26 -0
  517. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/resetmap.go +11 -0
  518. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/checkpoint.go +10 -0
  519. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/close.go +5 -0
  520. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/compilationworkers.go +6 -0
  521. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/expctxkeys.go +2 -0
  522. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/importresolver.go +6 -0
  523. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/listener.go +7 -0
  524. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/memory.go +4 -0
  525. package/govendor/github.com/tetratelabs/wazero/internal/filecache/compilationcache.go +42 -0
  526. package/govendor/github.com/tetratelabs/wazero/internal/filecache/file_cache.go +76 -0
  527. package/govendor/github.com/tetratelabs/wazero/internal/ieee754/ieee754.go +29 -0
  528. package/govendor/github.com/tetratelabs/wazero/internal/internalapi/internal.go +9 -0
  529. package/govendor/github.com/tetratelabs/wazero/internal/leb128/leb128.go +285 -0
  530. package/govendor/github.com/tetratelabs/wazero/internal/moremath/moremath.go +271 -0
  531. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid.go +26 -0
  532. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_amd64.go +22 -0
  533. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_arm64.go +13 -0
  534. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_unsupported.go +5 -0
  535. package/govendor/github.com/tetratelabs/wazero/internal/platform/crypto.go +17 -0
  536. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_linux.go +72 -0
  537. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_other.go +19 -0
  538. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_unix.go +14 -0
  539. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_unsupported.go +22 -0
  540. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_windows.go +31 -0
  541. package/govendor/github.com/tetratelabs/wazero/internal/platform/path.go +6 -0
  542. package/govendor/github.com/tetratelabs/wazero/internal/platform/path_windows.go +17 -0
  543. package/govendor/github.com/tetratelabs/wazero/internal/platform/platform.go +71 -0
  544. package/govendor/github.com/tetratelabs/wazero/internal/platform/time.go +76 -0
  545. package/govendor/github.com/tetratelabs/wazero/internal/platform/time_notwindows.go +11 -0
  546. package/govendor/github.com/tetratelabs/wazero/internal/platform/time_windows.go +40 -0
  547. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock.go +89 -0
  548. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock_supported.go +11 -0
  549. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock_unsupported.go +10 -0
  550. package/govendor/github.com/tetratelabs/wazero/internal/sys/fs.go +458 -0
  551. package/govendor/github.com/tetratelabs/wazero/internal/sys/lazy.go +135 -0
  552. package/govendor/github.com/tetratelabs/wazero/internal/sys/stdio.go +125 -0
  553. package/govendor/github.com/tetratelabs/wazero/internal/sys/sys.go +228 -0
  554. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/adapter.go +105 -0
  555. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_linux.go +12 -0
  556. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_unsupported.go +14 -0
  557. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/dir.go +24 -0
  558. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/dirfs.go +137 -0
  559. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file.go +576 -0
  560. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_unix.go +39 -0
  561. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_unsupported.go +28 -0
  562. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_windows.go +133 -0
  563. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens.go +29 -0
  564. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go +42 -0
  565. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.s +8 -0
  566. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_linux.go +38 -0
  567. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_unsupported.go +18 -0
  568. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_windows.go +42 -0
  569. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_unix.go +22 -0
  570. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_unsupported.go +17 -0
  571. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_windows.go +28 -0
  572. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unix.go +17 -0
  573. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unsupported.go +13 -0
  574. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_windows.go +23 -0
  575. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/oflag.go +38 -0
  576. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_bsd.go +26 -0
  577. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_darwin.go +26 -0
  578. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_supported.go +30 -0
  579. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_unix.go +20 -0
  580. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_unsupported.go +16 -0
  581. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_windows.go +163 -0
  582. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/osfile.go +318 -0
  583. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll.go +17 -0
  584. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_darwin.go +55 -0
  585. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_darwin.s +8 -0
  586. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_linux.go +57 -0
  587. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_unsupported.go +12 -0
  588. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_windows.go +224 -0
  589. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/readfs.go +117 -0
  590. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_unix.go +16 -0
  591. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_unsupported.go +16 -0
  592. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_windows.go +55 -0
  593. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock.go +186 -0
  594. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_supported.go +76 -0
  595. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go +48 -0
  596. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unsupported.go +79 -0
  597. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_windows.go +80 -0
  598. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat.go +16 -0
  599. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_supported.go +40 -0
  600. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_unsupported.go +40 -0
  601. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_windows.go +118 -0
  602. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sync.go +13 -0
  603. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sync_windows.go +20 -0
  604. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/syscall6_darwin.go +13 -0
  605. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sysfs.go +6 -0
  606. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_unix.go +17 -0
  607. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_unsupported.go +14 -0
  608. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_windows.go +25 -0
  609. package/govendor/github.com/tetratelabs/wazero/internal/u32/u32.go +11 -0
  610. package/govendor/github.com/tetratelabs/wazero/internal/u64/u64.go +15 -0
  611. package/govendor/github.com/tetratelabs/wazero/internal/version/version.go +52 -0
  612. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/args.go +6 -0
  613. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/clock.go +16 -0
  614. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/environ.go +6 -0
  615. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/errno.go +314 -0
  616. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/fs.go +164 -0
  617. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/poll.go +15 -0
  618. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/proc.go +6 -0
  619. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/random.go +3 -0
  620. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/rights.go +148 -0
  621. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/sched.go +3 -0
  622. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/sock.go +71 -0
  623. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/wasi.go +26 -0
  624. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/code.go +124 -0
  625. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/const_expr.go +116 -0
  626. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/custom.go +22 -0
  627. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/data.go +79 -0
  628. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/decoder.go +235 -0
  629. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/element.go +250 -0
  630. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/errors.go +11 -0
  631. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/export.go +32 -0
  632. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/function.go +56 -0
  633. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/global.go +50 -0
  634. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/header.go +9 -0
  635. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/import.go +68 -0
  636. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/limits.go +47 -0
  637. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/memory.go +42 -0
  638. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/names.go +151 -0
  639. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/section.go +309 -0
  640. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/table.go +79 -0
  641. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/value.go +97 -0
  642. package/govendor/github.com/tetratelabs/wazero/internal/wasm/const_expr.go +259 -0
  643. package/govendor/github.com/tetratelabs/wazero/internal/wasm/counts.go +53 -0
  644. package/govendor/github.com/tetratelabs/wazero/internal/wasm/engine.go +76 -0
  645. package/govendor/github.com/tetratelabs/wazero/internal/wasm/exception.go +9 -0
  646. package/govendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go +2804 -0
  647. package/govendor/github.com/tetratelabs/wazero/internal/wasm/function_definition.go +210 -0
  648. package/govendor/github.com/tetratelabs/wazero/internal/wasm/global.go +55 -0
  649. package/govendor/github.com/tetratelabs/wazero/internal/wasm/gofunc.go +279 -0
  650. package/govendor/github.com/tetratelabs/wazero/internal/wasm/host.go +179 -0
  651. package/govendor/github.com/tetratelabs/wazero/internal/wasm/instruction.go +1962 -0
  652. package/govendor/github.com/tetratelabs/wazero/internal/wasm/memory.go +475 -0
  653. package/govendor/github.com/tetratelabs/wazero/internal/wasm/memory_definition.go +128 -0
  654. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module.go +1359 -0
  655. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module_instance.go +251 -0
  656. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module_instance_lookup.go +73 -0
  657. package/govendor/github.com/tetratelabs/wazero/internal/wasm/store.go +726 -0
  658. package/govendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go +95 -0
  659. package/govendor/github.com/tetratelabs/wazero/internal/wasm/table.go +321 -0
  660. package/govendor/github.com/tetratelabs/wazero/internal/wasmdebug/debug.go +170 -0
  661. package/govendor/github.com/tetratelabs/wazero/internal/wasmdebug/dwarf.go +225 -0
  662. package/govendor/github.com/tetratelabs/wazero/internal/wasmruntime/errors.go +54 -0
  663. package/govendor/github.com/tetratelabs/wazero/netlify.toml +15 -0
  664. package/govendor/github.com/tetratelabs/wazero/runtime.go +399 -0
  665. package/govendor/github.com/tetratelabs/wazero/sys/clock.go +26 -0
  666. package/govendor/github.com/tetratelabs/wazero/sys/error.go +83 -0
  667. package/govendor/github.com/tetratelabs/wazero/sys/stat.go +105 -0
  668. package/govendor/github.com/tetratelabs/wazero/sys/stat_bsd.go +29 -0
  669. package/govendor/github.com/tetratelabs/wazero/sys/stat_posix.go +29 -0
  670. package/govendor/github.com/tetratelabs/wazero/sys/stat_unsupported.go +14 -0
  671. package/govendor/github.com/tetratelabs/wazero/sys/stat_windows.go +24 -0
  672. package/govendor/golang.org/x/crypto/LICENSE +27 -0
  673. package/govendor/golang.org/x/crypto/PATENTS +22 -0
  674. package/govendor/golang.org/x/crypto/cryptobyte/asn1/asn1.go +46 -0
  675. package/govendor/golang.org/x/crypto/cryptobyte/asn1.go +825 -0
  676. package/govendor/golang.org/x/crypto/cryptobyte/builder.go +350 -0
  677. package/govendor/golang.org/x/crypto/cryptobyte/string.go +183 -0
  678. package/govendor/golang.org/x/crypto/go.mod +3 -0
  679. package/govendor/golang.org/x/crypto/pbkdf2/pbkdf2.go +30 -0
  680. package/govendor/golang.org/x/net/LICENSE +27 -0
  681. package/govendor/golang.org/x/net/PATENTS +22 -0
  682. package/govendor/golang.org/x/net/dns/dnsmessage/message.go +2733 -0
  683. package/govendor/golang.org/x/net/dns/dnsmessage/svcb.go +333 -0
  684. package/govendor/golang.org/x/net/go.mod +3 -0
  685. package/govendor/golang.org/x/net/http/httpguts/guts.go +50 -0
  686. package/govendor/golang.org/x/net/http/httpguts/httplex.go +347 -0
  687. package/govendor/golang.org/x/net/http2/README.md +19 -0
  688. package/govendor/golang.org/x/net/http2/ascii.go +65 -0
  689. package/govendor/golang.org/x/net/http2/ciphers.go +641 -0
  690. package/govendor/golang.org/x/net/http2/client_conn_pool.go +301 -0
  691. package/govendor/golang.org/x/net/http2/client_priority_go126.go +20 -0
  692. package/govendor/golang.org/x/net/http2/client_priority_go127.go +13 -0
  693. package/govendor/golang.org/x/net/http2/clientconn.go +57 -0
  694. package/govendor/golang.org/x/net/http2/config.go +171 -0
  695. package/govendor/golang.org/x/net/http2/config_go125.go +15 -0
  696. package/govendor/golang.org/x/net/http2/config_go126.go +15 -0
  697. package/govendor/golang.org/x/net/http2/databuffer.go +146 -0
  698. package/govendor/golang.org/x/net/http2/errors.go +145 -0
  699. package/govendor/golang.org/x/net/http2/flow.go +175 -0
  700. package/govendor/golang.org/x/net/http2/frame.go +1887 -0
  701. package/govendor/golang.org/x/net/http2/gotrack.go +181 -0
  702. package/govendor/golang.org/x/net/http2/hpack/encode.go +244 -0
  703. package/govendor/golang.org/x/net/http2/hpack/hpack.go +522 -0
  704. package/govendor/golang.org/x/net/http2/hpack/huffman.go +226 -0
  705. package/govendor/golang.org/x/net/http2/hpack/static_table.go +188 -0
  706. package/govendor/golang.org/x/net/http2/hpack/tables.go +426 -0
  707. package/govendor/golang.org/x/net/http2/http2.go +415 -0
  708. package/govendor/golang.org/x/net/http2/pipe.go +184 -0
  709. package/govendor/golang.org/x/net/http2/server.go +3239 -0
  710. package/govendor/golang.org/x/net/http2/server_common.go +268 -0
  711. package/govendor/golang.org/x/net/http2/server_wrap.go +217 -0
  712. package/govendor/golang.org/x/net/http2/transport.go +3084 -0
  713. package/govendor/golang.org/x/net/http2/transport_common.go +516 -0
  714. package/govendor/golang.org/x/net/http2/transport_wrap.go +583 -0
  715. package/govendor/golang.org/x/net/http2/unencrypted.go +32 -0
  716. package/govendor/golang.org/x/net/http2/write.go +381 -0
  717. package/govendor/golang.org/x/net/http2/writesched.go +253 -0
  718. package/govendor/golang.org/x/net/http2/writesched_common.go +90 -0
  719. package/govendor/golang.org/x/net/http2/writesched_priority_rfc7540.go +420 -0
  720. package/govendor/golang.org/x/net/http2/writesched_priority_rfc9218.go +226 -0
  721. package/govendor/golang.org/x/net/http2/writesched_random.go +81 -0
  722. package/govendor/golang.org/x/net/http2/writesched_roundrobin.go +121 -0
  723. package/govendor/golang.org/x/net/idna/idna.go +884 -0
  724. package/govendor/golang.org/x/net/idna/punycode.go +220 -0
  725. package/govendor/golang.org/x/net/idna/tables15.0.0.go +5144 -0
  726. package/govendor/golang.org/x/net/idna/tables17.0.0.go +5302 -0
  727. package/govendor/golang.org/x/net/idna/trie.go +51 -0
  728. package/govendor/golang.org/x/net/idna/trieval.go +119 -0
  729. package/govendor/golang.org/x/net/internal/httpcommon/README.md +7 -0
  730. package/govendor/golang.org/x/net/internal/httpcommon/ascii.go +53 -0
  731. package/govendor/golang.org/x/net/internal/httpcommon/gzip.go +132 -0
  732. package/govendor/golang.org/x/net/internal/httpcommon/headermap.go +115 -0
  733. package/govendor/golang.org/x/net/internal/httpcommon/request.go +503 -0
  734. package/govendor/golang.org/x/net/internal/httpsfv/httpsfv.go +665 -0
  735. package/govendor/golang.org/x/sys/cpu/asm_aix_ppc64.s +17 -0
  736. package/govendor/golang.org/x/sys/cpu/asm_darwin_arm64_gc.s +12 -0
  737. package/govendor/golang.org/x/sys/cpu/asm_darwin_x86_gc.s +17 -0
  738. package/govendor/golang.org/x/sys/cpu/byteorder.go +66 -0
  739. package/govendor/golang.org/x/sys/cpu/cpu.go +357 -0
  740. package/govendor/golang.org/x/sys/cpu/cpu_aix.go +33 -0
  741. package/govendor/golang.org/x/sys/cpu/cpu_arm.go +73 -0
  742. package/govendor/golang.org/x/sys/cpu/cpu_arm64.go +191 -0
  743. package/govendor/golang.org/x/sys/cpu/cpu_arm64.s +35 -0
  744. package/govendor/golang.org/x/sys/cpu/cpu_darwin_arm64.go +67 -0
  745. package/govendor/golang.org/x/sys/cpu/cpu_darwin_arm64_other.go +31 -0
  746. package/govendor/golang.org/x/sys/cpu/cpu_darwin_x86.go +61 -0
  747. package/govendor/golang.org/x/sys/cpu/cpu_gc_arm64.go +12 -0
  748. package/govendor/golang.org/x/sys/cpu/cpu_gc_riscv64.go +11 -0
  749. package/govendor/golang.org/x/sys/cpu/cpu_gc_s390x.go +21 -0
  750. package/govendor/golang.org/x/sys/cpu/cpu_gc_x86.go +15 -0
  751. package/govendor/golang.org/x/sys/cpu/cpu_gc_x86.s +26 -0
  752. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +12 -0
  753. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go +22 -0
  754. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c +37 -0
  755. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go +25 -0
  756. package/govendor/golang.org/x/sys/cpu/cpu_linux.go +15 -0
  757. package/govendor/golang.org/x/sys/cpu/cpu_linux_arm.go +39 -0
  758. package/govendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +120 -0
  759. package/govendor/golang.org/x/sys/cpu/cpu_linux_loong64.go +22 -0
  760. package/govendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go +22 -0
  761. package/govendor/golang.org/x/sys/cpu/cpu_linux_noinit.go +9 -0
  762. package/govendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go +34 -0
  763. package/govendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go +173 -0
  764. package/govendor/golang.org/x/sys/cpu/cpu_linux_s390x.go +40 -0
  765. package/govendor/golang.org/x/sys/cpu/cpu_loong64.go +62 -0
  766. package/govendor/golang.org/x/sys/cpu/cpu_loong64.s +13 -0
  767. package/govendor/golang.org/x/sys/cpu/cpu_mips64x.go +15 -0
  768. package/govendor/golang.org/x/sys/cpu/cpu_mipsx.go +11 -0
  769. package/govendor/golang.org/x/sys/cpu/cpu_netbsd_amd64.go +47 -0
  770. package/govendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go +173 -0
  771. package/govendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go +65 -0
  772. package/govendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.s +11 -0
  773. package/govendor/golang.org/x/sys/cpu/cpu_other_arm.go +9 -0
  774. package/govendor/golang.org/x/sys/cpu/cpu_other_arm64.go +11 -0
  775. package/govendor/golang.org/x/sys/cpu/cpu_other_mips64x.go +11 -0
  776. package/govendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go +12 -0
  777. package/govendor/golang.org/x/sys/cpu/cpu_other_riscv64.go +11 -0
  778. package/govendor/golang.org/x/sys/cpu/cpu_other_x86.go +11 -0
  779. package/govendor/golang.org/x/sys/cpu/cpu_ppc64x.go +16 -0
  780. package/govendor/golang.org/x/sys/cpu/cpu_riscv64.go +33 -0
  781. package/govendor/golang.org/x/sys/cpu/cpu_riscv64.s +17 -0
  782. package/govendor/golang.org/x/sys/cpu/cpu_s390x.go +172 -0
  783. package/govendor/golang.org/x/sys/cpu/cpu_s390x.s +57 -0
  784. package/govendor/golang.org/x/sys/cpu/cpu_sparc64.go +12 -0
  785. package/govendor/golang.org/x/sys/cpu/cpu_wasm.go +17 -0
  786. package/govendor/golang.org/x/sys/cpu/cpu_windows.go +26 -0
  787. package/govendor/golang.org/x/sys/cpu/cpu_windows_arm64.go +38 -0
  788. package/govendor/golang.org/x/sys/cpu/cpu_x86.go +259 -0
  789. package/govendor/golang.org/x/sys/cpu/cpu_zos.go +10 -0
  790. package/govendor/golang.org/x/sys/cpu/cpu_zos_s390x.go +25 -0
  791. package/govendor/golang.org/x/sys/cpu/endian_big.go +10 -0
  792. package/govendor/golang.org/x/sys/cpu/endian_little.go +10 -0
  793. package/govendor/golang.org/x/sys/cpu/hwcap_linux.go +71 -0
  794. package/govendor/golang.org/x/sys/cpu/parse.go +55 -0
  795. package/govendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go +53 -0
  796. package/govendor/golang.org/x/sys/cpu/runtime_auxv.go +16 -0
  797. package/govendor/golang.org/x/sys/cpu/runtime_auxv_go121.go +18 -0
  798. package/govendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go +26 -0
  799. package/govendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go +35 -0
  800. package/govendor/golang.org/x/sys/cpu/syscall_darwin_arm64_gc.go +54 -0
  801. package/govendor/golang.org/x/sys/cpu/syscall_darwin_x86_gc.go +98 -0
  802. package/govendor/golang.org/x/sys/cpu/zcpu_windows.go +48 -0
  803. package/govendor/golang.org/x/sys/unix/asm_linux_ppc64x.s +20 -0
  804. package/govendor/golang.org/x/sys/unix/asm_linux_sparc64.s +48 -0
  805. package/govendor/golang.org/x/sys/unix/asm_zos_s390x.s +4 -186
  806. package/govendor/golang.org/x/sys/unix/bpxsvc_zos.s +9 -9
  807. package/govendor/golang.org/x/sys/unix/fcntl_darwin.go +2 -2
  808. package/govendor/golang.org/x/sys/unix/mkerrors.sh +1 -1
  809. package/govendor/golang.org/x/sys/unix/ptrace_zos.go +537 -0
  810. package/govendor/golang.org/x/sys/unix/ptrace_zos_singlestep.go +425 -0
  811. package/govendor/golang.org/x/sys/unix/syscall_darwin.go +1 -0
  812. package/govendor/golang.org/x/sys/unix/syscall_freebsd.go +9 -0
  813. package/govendor/golang.org/x/sys/unix/syscall_linux.go +20 -1
  814. package/govendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +3 -3
  815. package/govendor/golang.org/x/sys/unix/syscall_netbsd.go +9 -0
  816. package/govendor/golang.org/x/sys/unix/syscall_unix_gc.go +1 -1
  817. package/govendor/golang.org/x/sys/unix/syscall_zos_s390x.go +0 -4
  818. package/govendor/golang.org/x/sys/unix/xattr_bsd.go +12 -12
  819. package/govendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +6 -0
  820. package/govendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +6 -0
  821. package/govendor/golang.org/x/sys/unix/zerrors_linux.go +32 -0
  822. package/govendor/golang.org/x/sys/unix/zerrors_linux_386.go +2 -0
  823. package/govendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +2 -0
  824. package/govendor/golang.org/x/sys/unix/zerrors_linux_arm.go +2 -0
  825. package/govendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +2 -0
  826. package/govendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +2 -0
  827. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips.go +2 -0
  828. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +2 -0
  829. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +2 -0
  830. package/govendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +2 -0
  831. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +2 -0
  832. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +2 -0
  833. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +2 -0
  834. package/govendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +2 -0
  835. package/govendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +2 -0
  836. package/govendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +2 -0
  837. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +11 -0
  838. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +11 -0
  839. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +159 -0
  840. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +159 -0
  841. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +159 -0
  842. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +159 -0
  843. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go +159 -0
  844. package/govendor/golang.org/x/sys/unix/zsyscall_linux.go +28 -1
  845. package/govendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +3 -3
  846. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +159 -0
  847. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +159 -0
  848. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +159 -0
  849. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +159 -0
  850. package/govendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go +13 -0
  851. package/govendor/golang.org/x/sys/unix/ztypes_linux.go +65 -36
  852. package/govendor/golang.org/x/sys/unix/ztypes_linux_386.go +6 -0
  853. package/govendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +7 -0
  854. package/govendor/golang.org/x/sys/unix/ztypes_linux_arm.go +6 -0
  855. package/govendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +7 -0
  856. package/govendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +7 -0
  857. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips.go +6 -0
  858. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +7 -0
  859. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +7 -0
  860. package/govendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +6 -0
  861. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +6 -0
  862. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +7 -0
  863. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +7 -0
  864. package/govendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +7 -0
  865. package/govendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +7 -0
  866. package/govendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +10 -5
  867. package/govendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +78 -0
  868. package/govendor/golang.org/x/text/.gitattributes +10 -0
  869. package/govendor/golang.org/x/text/CONTRIBUTING.md +26 -0
  870. package/govendor/golang.org/x/text/LICENSE +27 -0
  871. package/govendor/golang.org/x/text/PATENTS +22 -0
  872. package/govendor/golang.org/x/text/README.md +81 -0
  873. package/govendor/golang.org/x/text/cases/cases.go +162 -0
  874. package/govendor/golang.org/x/text/cases/context.go +376 -0
  875. package/govendor/golang.org/x/text/cases/fold.go +34 -0
  876. package/govendor/golang.org/x/text/cases/icu.go +61 -0
  877. package/govendor/golang.org/x/text/cases/info.go +82 -0
  878. package/govendor/golang.org/x/text/cases/map.go +816 -0
  879. package/govendor/golang.org/x/text/cases/tables15.0.0.go +2527 -0
  880. package/govendor/golang.org/x/text/cases/tables17.0.0.go +2642 -0
  881. package/govendor/golang.org/x/text/cases/trieval.go +217 -0
  882. package/govendor/golang.org/x/text/codereview.cfg +1 -0
  883. package/govendor/golang.org/x/text/collate/collate.go +402 -0
  884. package/govendor/golang.org/x/text/collate/index.go +32 -0
  885. package/govendor/golang.org/x/text/collate/option.go +239 -0
  886. package/govendor/golang.org/x/text/collate/sort.go +81 -0
  887. package/govendor/golang.org/x/text/collate/tables.go +73789 -0
  888. package/govendor/golang.org/x/text/currency/common.go +67 -0
  889. package/govendor/golang.org/x/text/currency/currency.go +185 -0
  890. package/govendor/golang.org/x/text/currency/format.go +220 -0
  891. package/govendor/golang.org/x/text/currency/query.go +152 -0
  892. package/govendor/golang.org/x/text/currency/tables.go +2629 -0
  893. package/govendor/golang.org/x/text/doc.go +16 -0
  894. package/govendor/golang.org/x/text/feature/plural/common.go +70 -0
  895. package/govendor/golang.org/x/text/feature/plural/message.go +244 -0
  896. package/govendor/golang.org/x/text/feature/plural/plural.go +262 -0
  897. package/govendor/golang.org/x/text/feature/plural/tables.go +552 -0
  898. package/govendor/golang.org/x/text/go.mod +3 -0
  899. package/govendor/golang.org/x/text/internal/catmsg/catmsg.go +417 -0
  900. package/govendor/golang.org/x/text/internal/catmsg/codec.go +407 -0
  901. package/govendor/golang.org/x/text/internal/catmsg/varint.go +62 -0
  902. package/govendor/golang.org/x/text/internal/colltab/collelem.go +374 -0
  903. package/govendor/golang.org/x/text/internal/colltab/colltab.go +105 -0
  904. package/govendor/golang.org/x/text/internal/colltab/contract.go +145 -0
  905. package/govendor/golang.org/x/text/internal/colltab/iter.go +178 -0
  906. package/govendor/golang.org/x/text/internal/colltab/numeric.go +236 -0
  907. package/govendor/golang.org/x/text/internal/colltab/table.go +275 -0
  908. package/govendor/golang.org/x/text/internal/colltab/trie.go +159 -0
  909. package/govendor/golang.org/x/text/internal/colltab/weighter.go +31 -0
  910. package/govendor/golang.org/x/text/internal/format/format.go +41 -0
  911. package/govendor/golang.org/x/text/internal/format/parser.go +358 -0
  912. package/govendor/golang.org/x/text/internal/internal.go +49 -0
  913. package/govendor/golang.org/x/text/internal/language/common.go +16 -0
  914. package/govendor/golang.org/x/text/internal/language/compact/compact.go +61 -0
  915. package/govendor/golang.org/x/text/internal/language/compact/language.go +260 -0
  916. package/govendor/golang.org/x/text/internal/language/compact/parents.go +120 -0
  917. package/govendor/golang.org/x/text/internal/language/compact/tables.go +1015 -0
  918. package/govendor/golang.org/x/text/internal/language/compact/tags.go +91 -0
  919. package/govendor/golang.org/x/text/internal/language/compact.go +29 -0
  920. package/govendor/golang.org/x/text/internal/language/compose.go +167 -0
  921. package/govendor/golang.org/x/text/internal/language/coverage.go +28 -0
  922. package/govendor/golang.org/x/text/internal/language/language.go +627 -0
  923. package/govendor/golang.org/x/text/internal/language/lookup.go +412 -0
  924. package/govendor/golang.org/x/text/internal/language/match.go +226 -0
  925. package/govendor/golang.org/x/text/internal/language/parse.go +608 -0
  926. package/govendor/golang.org/x/text/internal/language/tables.go +3494 -0
  927. package/govendor/golang.org/x/text/internal/language/tags.go +48 -0
  928. package/govendor/golang.org/x/text/internal/match.go +67 -0
  929. package/govendor/golang.org/x/text/internal/number/common.go +55 -0
  930. package/govendor/golang.org/x/text/internal/number/decimal.go +500 -0
  931. package/govendor/golang.org/x/text/internal/number/format.go +533 -0
  932. package/govendor/golang.org/x/text/internal/number/number.go +152 -0
  933. package/govendor/golang.org/x/text/internal/number/pattern.go +485 -0
  934. package/govendor/golang.org/x/text/internal/number/roundingmode_string.go +30 -0
  935. package/govendor/golang.org/x/text/internal/number/tables.go +1219 -0
  936. package/govendor/golang.org/x/text/internal/stringset/set.go +86 -0
  937. package/govendor/golang.org/x/text/internal/tag/tag.go +100 -0
  938. package/govendor/golang.org/x/text/language/coverage.go +187 -0
  939. package/govendor/golang.org/x/text/language/display/dict.go +92 -0
  940. package/govendor/golang.org/x/text/language/display/display.go +420 -0
  941. package/govendor/golang.org/x/text/language/display/lookup.go +253 -0
  942. package/govendor/golang.org/x/text/language/display/tables.go +53114 -0
  943. package/govendor/golang.org/x/text/language/doc.go +98 -0
  944. package/govendor/golang.org/x/text/language/language.go +605 -0
  945. package/govendor/golang.org/x/text/language/match.go +735 -0
  946. package/govendor/golang.org/x/text/language/parse.go +258 -0
  947. package/govendor/golang.org/x/text/language/tables.go +298 -0
  948. package/govendor/golang.org/x/text/language/tags.go +145 -0
  949. package/govendor/golang.org/x/text/message/catalog/catalog.go +365 -0
  950. package/govendor/golang.org/x/text/message/catalog/dict.go +133 -0
  951. package/govendor/golang.org/x/text/secure/bidirule/bidirule.go +346 -0
  952. package/govendor/golang.org/x/text/transform/transform.go +709 -0
  953. package/govendor/golang.org/x/text/unicode/bidi/bidi.go +359 -0
  954. package/govendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
  955. package/govendor/golang.org/x/text/unicode/bidi/core.go +1050 -0
  956. package/govendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
  957. package/govendor/golang.org/x/text/unicode/bidi/tables15.0.0.go +2042 -0
  958. package/govendor/golang.org/x/text/unicode/bidi/tables17.0.0.go +2135 -0
  959. package/govendor/golang.org/x/text/unicode/bidi/trieval.go +48 -0
  960. package/govendor/golang.org/x/text/unicode/norm/composition.go +524 -0
  961. package/govendor/golang.org/x/text/unicode/norm/forminfo.go +296 -0
  962. package/govendor/golang.org/x/text/unicode/norm/input.go +109 -0
  963. package/govendor/golang.org/x/text/unicode/norm/iter.go +454 -0
  964. package/govendor/golang.org/x/text/unicode/norm/normalize.go +613 -0
  965. package/govendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
  966. package/govendor/golang.org/x/text/unicode/norm/tables15.0.0.go +7907 -0
  967. package/govendor/golang.org/x/text/unicode/norm/tables17.0.0.go +8104 -0
  968. package/govendor/golang.org/x/text/unicode/norm/transform.go +89 -0
  969. package/govendor/golang.org/x/text/unicode/norm/trie.go +54 -0
  970. package/govendor/manifest.txt +11 -2
  971. package/package.json +2 -1
  972. package/performance/README.md +87 -35
  973. package/performance/arr-for-of.ts +29 -0
  974. package/performance/arr-push-local.ts +39 -0
  975. package/performance/arr-slice-concat.ts +24 -0
  976. package/performance/async-promise-all.ts +38 -0
  977. package/performance/bigint-arith.ts +36 -0
  978. package/performance/buf-encode.ts +29 -0
  979. package/performance/class-accessors.ts +48 -0
  980. package/performance/date-format.ts +18 -0
  981. package/performance/fn-rest-spread.ts +43 -0
  982. package/performance/gen-next.ts +32 -0
  983. package/performance/iter-helpers.ts +38 -0
  984. package/performance/json-any.ts +30 -0
  985. package/performance/map-iterate.ts +26 -0
  986. package/performance/map-number-keys.ts +37 -0
  987. package/performance/num-hash-imul.ts +36 -0
  988. package/performance/obj-keys-entries.ts +44 -0
  989. package/performance/obj-optional-chain.ts +42 -0
  990. package/performance/obj-record-dict.ts +24 -0
  991. package/performance/obj-spread-destructure.ts +40 -0
  992. package/performance/regex-replace-fn.ts +24 -0
  993. package/performance/str-methods.ts +24 -0
  994. package/performance/str-switch-compare.ts +50 -0
  995. package/performance/str-unicode.ts +25 -0
  996. package/performance/typed-array.ts +30 -0
  997. package/performance/union-typeof.ts +40 -0
  998. package/performance/wasm-call.ts +63 -0
  999. package/tsparser/go.mod +1 -1
  1000. package/tsparser/go.sum +2 -2
  1001. package/types/typenative-npm.d.ts +836 -69
  1002. package/types/typenative.d.ts +1224 -23
  1003. package/govendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go +0 -22
  1004. package/govendor/golang.org/x/sys/windows/types_windows_arm.go +0 -35
@@ -0,0 +1,1310 @@
1
+ // Copyright (c) 2015-2024 The Decred developers
2
+ // Copyright 2013-2014 The btcsuite developers
3
+ // Use of this source code is governed by an ISC
4
+ // license that can be found in the LICENSE file.
5
+
6
+ package secp256k1
7
+
8
+ import (
9
+ "encoding/hex"
10
+ "math/bits"
11
+ )
12
+
13
+ // References:
14
+ // [SECG]: Recommended Elliptic Curve Domain Parameters
15
+ // https://www.secg.org/sec2-v2.pdf
16
+ //
17
+ // [GECC]: Guide to Elliptic Curve Cryptography (Hankerson, Menezes, Vanstone)
18
+ //
19
+ // [BRID]: On Binary Representations of Integers with Digits -1, 0, 1
20
+ // (Prodinger, Helmut)
21
+ //
22
+ // [STWS]: Secure-TWS: Authenticating Node to Multi-user Communication in
23
+ // Shared Sensor Networks (Oliveira, Leonardo B. et al)
24
+
25
+ // All group operations are performed using Jacobian coordinates. For a given
26
+ // (x, y) position on the curve, the Jacobian coordinates are (x1, y1, z1)
27
+ // where x = x1/z1^2 and y = y1/z1^3.
28
+
29
+ // hexToFieldVal converts the passed hex string into a FieldVal and will panic
30
+ // if there is an error. This is only provided for the hard-coded constants so
31
+ // errors in the source code can be detected. It will only (and must only) be
32
+ // called with hard-coded values.
33
+ func hexToFieldVal(s string) *FieldVal {
34
+ b, err := hex.DecodeString(s)
35
+ if err != nil {
36
+ panic("invalid hex in source file: " + s)
37
+ }
38
+ var f FieldVal
39
+ if overflow := f.SetByteSlice(b); overflow {
40
+ panic("hex in source file overflows mod P: " + s)
41
+ }
42
+ return &f
43
+ }
44
+
45
+ // hexToModNScalar converts the passed hex string into a ModNScalar and will
46
+ // panic if there is an error. This is only provided for the hard-coded
47
+ // constants so errors in the source code can be detected. It will only (and
48
+ // must only) be called with hard-coded values.
49
+ func hexToModNScalar(s string) *ModNScalar {
50
+ var isNegative bool
51
+ if len(s) > 0 && s[0] == '-' {
52
+ isNegative = true
53
+ s = s[1:]
54
+ }
55
+ if len(s)%2 != 0 {
56
+ s = "0" + s
57
+ }
58
+ b, err := hex.DecodeString(s)
59
+ if err != nil {
60
+ panic("invalid hex in source file: " + s)
61
+ }
62
+ var scalar ModNScalar
63
+ if overflow := scalar.SetByteSlice(b); overflow {
64
+ panic("hex in source file overflows mod N scalar: " + s)
65
+ }
66
+ if isNegative {
67
+ scalar.Negate()
68
+ }
69
+ return &scalar
70
+ }
71
+
72
+ var (
73
+ // The following constants are used to accelerate scalar point
74
+ // multiplication through the use of the endomorphism:
75
+ //
76
+ // φ(Q) ⟼ λ*Q = (β*Q.x mod p, Q.y)
77
+ //
78
+ // See the code in the deriveEndomorphismParams function in genprecomps.go
79
+ // for details on their derivation.
80
+ //
81
+ // Additionally, see the scalar multiplication function in this file for
82
+ // details on how they are used.
83
+ endoNegLambda = hexToModNScalar("-5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72")
84
+ endoBeta = hexToFieldVal("7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")
85
+ endoNegB1 = hexToModNScalar("e4437ed6010e88286f547fa90abfe4c3")
86
+ endoNegB2 = hexToModNScalar("-3086d221a7d46bcde86c90e49284eb15")
87
+ endoZ1 = hexToModNScalar("3086d221a7d46bcde86c90e49284eb153daa8a1471e8ca7f")
88
+ endoZ2 = hexToModNScalar("e4437ed6010e88286f547fa90abfe4c4221208ac9df506c6")
89
+
90
+ // Alternatively, the following parameters are valid as well, however,
91
+ // benchmarks show them to be about 2% slower in practice.
92
+ // endoNegLambda = hexToModNScalar("-ac9c52b33fa3cf1f5ad9e3fd77ed9ba4a880b9fc8ec739c2e0cfc810b51283ce")
93
+ // endoBeta = hexToFieldVal("851695d49a83f8ef919bb86153cbcb16630fb68aed0a766a3ec693d68e6afa40")
94
+ // endoNegB1 = hexToModNScalar("3086d221a7d46bcde86c90e49284eb15")
95
+ // endoNegB2 = hexToModNScalar("-114ca50f7a8e2f3f657c1108d9d44cfd8")
96
+ // endoZ1 = hexToModNScalar("114ca50f7a8e2f3f657c1108d9d44cfd95fbc92c10fddd145")
97
+ // endoZ2 = hexToModNScalar("3086d221a7d46bcde86c90e49284eb153daa8a1471e8ca7f")
98
+ )
99
+
100
+ // JacobianPoint is an element of the group formed by the secp256k1 curve in
101
+ // Jacobian projective coordinates and thus represents a point on the curve.
102
+ type JacobianPoint struct {
103
+ // The X coordinate in Jacobian projective coordinates. The affine point is
104
+ // X/z^2.
105
+ X FieldVal
106
+
107
+ // The Y coordinate in Jacobian projective coordinates. The affine point is
108
+ // Y/z^3.
109
+ Y FieldVal
110
+
111
+ // The Z coordinate in Jacobian projective coordinates.
112
+ Z FieldVal
113
+ }
114
+
115
+ // MakeJacobianPoint returns a Jacobian point with the provided X, Y, and Z
116
+ // coordinates.
117
+ func MakeJacobianPoint(x, y, z *FieldVal) JacobianPoint {
118
+ var p JacobianPoint
119
+ p.X.Set(x)
120
+ p.Y.Set(y)
121
+ p.Z.Set(z)
122
+ return p
123
+ }
124
+
125
+ // Set sets the Jacobian point to the provided point.
126
+ func (p *JacobianPoint) Set(other *JacobianPoint) {
127
+ p.X.Set(&other.X)
128
+ p.Y.Set(&other.Y)
129
+ p.Z.Set(&other.Z)
130
+ }
131
+
132
+ // ToAffine reduces the Z value of the existing point to 1 effectively
133
+ // making it an affine coordinate in constant time. The point will be
134
+ // normalized.
135
+ func (p *JacobianPoint) ToAffine() {
136
+ // Inversions are expensive and both point addition and point doubling
137
+ // are faster when working with points that have a z value of one. So,
138
+ // if the point needs to be converted to affine, go ahead and normalize
139
+ // the point itself at the same time as the calculation is the same.
140
+ var zInv, tempZ FieldVal
141
+ zInv.Set(&p.Z).Inverse() // zInv = Z^-1
142
+ tempZ.SquareVal(&zInv) // tempZ = Z^-2
143
+ p.X.Mul(&tempZ) // X = X/Z^2 (mag: 1)
144
+ p.Y.Mul(tempZ.Mul(&zInv)) // Y = Y/Z^3 (mag: 1)
145
+ p.Z.SetInt(1) // Z = 1 (mag: 1)
146
+
147
+ // Normalize the x and y values.
148
+ p.X.Normalize()
149
+ p.Y.Normalize()
150
+ }
151
+
152
+ // EquivalentNonConst returns whether or not two Jacobian points represent the
153
+ // same affine point in *non-constant* time.
154
+ func (p *JacobianPoint) EquivalentNonConst(other *JacobianPoint) bool {
155
+ // Since the point at infinity is the identity element for the group, note
156
+ // that P = P + ∞ trivially implies that P - P = ∞.
157
+ //
158
+ // Use that fact to determine if the points represent the same affine point.
159
+ var result JacobianPoint
160
+ result.Set(p)
161
+ result.Y.Normalize().Negate(1).Normalize()
162
+ AddNonConst(&result, other, &result)
163
+ return (result.X.IsZero() && result.Y.IsZero()) || result.Z.IsZero()
164
+ }
165
+
166
+ // addZ1AndZ2EqualsOne adds two Jacobian points that are already known to have
167
+ // z values of 1 and stores the result in the provided result param. That is to
168
+ // say result = p1 + p2. It performs faster addition than the generic add
169
+ // routine since less arithmetic is needed due to the ability to avoid the z
170
+ // value multiplications.
171
+ //
172
+ // NOTE: The points must be normalized for this function to return the correct
173
+ // result. The resulting point will be normalized.
174
+ func addZ1AndZ2EqualsOne(p1, p2, result *JacobianPoint) {
175
+ // To compute the point addition efficiently, this implementation splits
176
+ // the equation into intermediate elements which are used to minimize
177
+ // the number of field multiplications using the method shown at:
178
+ // https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-mmadd-2007-bl
179
+ //
180
+ // In particular it performs the calculations using the following:
181
+ // H = X2-X1, HH = H^2, I = 4*HH, J = H*I, r = 2*(Y2-Y1), V = X1*I
182
+ // X3 = r^2-J-2*V, Y3 = r*(V-X3)-2*Y1*J, Z3 = 2*H
183
+ //
184
+ // This results in a cost of 4 field multiplications, 2 field squarings,
185
+ // 6 field additions, and 5 integer multiplications.
186
+ x1, y1 := &p1.X, &p1.Y
187
+ x2, y2 := &p2.X, &p2.Y
188
+ x3, y3, z3 := &result.X, &result.Y, &result.Z
189
+
190
+ // When the x coordinates are the same for two points on the curve, the
191
+ // y coordinates either must be the same, in which case it is point
192
+ // doubling, or they are opposite and the result is the point at
193
+ // infinity per the group law for elliptic curve cryptography.
194
+ if x1.Equals(x2) {
195
+ if y1.Equals(y2) {
196
+ // Since x1 == x2 and y1 == y2, point doubling must be
197
+ // done, otherwise the addition would end up dividing
198
+ // by zero.
199
+ DoubleNonConst(p1, result)
200
+ return
201
+ }
202
+
203
+ // Since x1 == x2 and y1 == -y2, the sum is the point at
204
+ // infinity per the group law.
205
+ x3.SetInt(0)
206
+ y3.SetInt(0)
207
+ z3.SetInt(0)
208
+ return
209
+ }
210
+
211
+ // Calculate X3, Y3, and Z3 according to the intermediate elements
212
+ // breakdown above.
213
+ var h, i, j, r, v FieldVal
214
+ var negJ, neg2V, negX3 FieldVal
215
+ h.Set(x1).Negate(1).Add(x2) // H = X2-X1 (mag: 3)
216
+ i.SquareVal(&h).MulInt(4) // I = 4*H^2 (mag: 4)
217
+ j.Mul2(&h, &i) // J = H*I (mag: 1)
218
+ r.Set(y1).Negate(1).Add(y2).MulInt(2) // r = 2*(Y2-Y1) (mag: 6)
219
+ v.Mul2(x1, &i) // V = X1*I (mag: 1)
220
+ negJ.Set(&j).Negate(1) // negJ = -J (mag: 2)
221
+ neg2V.Set(&v).MulInt(2).Negate(2) // neg2V = -(2*V) (mag: 3)
222
+ x3.Set(&r).Square().Add(&negJ).Add(&neg2V) // X3 = r^2-J-2*V (mag: 6)
223
+ negX3.Set(x3).Negate(6) // negX3 = -X3 (mag: 7)
224
+ j.Mul(y1).MulInt(2).Negate(2) // J = -(2*Y1*J) (mag: 3)
225
+ y3.Set(&v).Add(&negX3).Mul(&r).Add(&j) // Y3 = r*(V-X3)-2*Y1*J (mag: 4)
226
+ z3.Set(&h).MulInt(2) // Z3 = 2*H (mag: 6)
227
+
228
+ // Normalize the resulting field values as needed.
229
+ x3.Normalize()
230
+ y3.Normalize()
231
+ z3.Normalize()
232
+ }
233
+
234
+ // addZ1EqualsZ2 adds two Jacobian points that are already known to have the
235
+ // same z value and stores the result in the provided result param. That is to
236
+ // say result = p1 + p2. It performs faster addition than the generic add
237
+ // routine since less arithmetic is needed due to the known equivalence.
238
+ //
239
+ // NOTE: The points must be normalized for this function to return the correct
240
+ // result. The resulting point will be normalized.
241
+ func addZ1EqualsZ2(p1, p2, result *JacobianPoint) {
242
+ // To compute the point addition efficiently, this implementation splits
243
+ // the equation into intermediate elements which are used to minimize
244
+ // the number of field multiplications using a slightly modified version
245
+ // of the method shown at:
246
+ // https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-zadd-2007-m
247
+ //
248
+ // In particular it performs the calculations using the following:
249
+ // A = X2-X1, B = A^2, C=Y2-Y1, D = C^2, E = X1*B, F = X2*B
250
+ // X3 = D-E-F, Y3 = C*(E-X3)-Y1*(F-E), Z3 = Z1*A
251
+ //
252
+ // This results in a cost of 5 field multiplications, 2 field squarings,
253
+ // 9 field additions, and 0 integer multiplications.
254
+ x1, y1, z1 := &p1.X, &p1.Y, &p1.Z
255
+ x2, y2 := &p2.X, &p2.Y
256
+ x3, y3, z3 := &result.X, &result.Y, &result.Z
257
+
258
+ // When the x coordinates are the same for two points on the curve, the
259
+ // y coordinates either must be the same, in which case it is point
260
+ // doubling, or they are opposite and the result is the point at
261
+ // infinity per the group law for elliptic curve cryptography.
262
+ if x1.Equals(x2) {
263
+ if y1.Equals(y2) {
264
+ // Since x1 == x2 and y1 == y2, point doubling must be
265
+ // done, otherwise the addition would end up dividing
266
+ // by zero.
267
+ DoubleNonConst(p1, result)
268
+ return
269
+ }
270
+
271
+ // Since x1 == x2 and y1 == -y2, the sum is the point at
272
+ // infinity per the group law.
273
+ x3.SetInt(0)
274
+ y3.SetInt(0)
275
+ z3.SetInt(0)
276
+ return
277
+ }
278
+
279
+ // Calculate X3, Y3, and Z3 according to the intermediate elements
280
+ // breakdown above.
281
+ var a, b, c, d, e, f FieldVal
282
+ var negX1, negY1, negE, negX3 FieldVal
283
+ negX1.Set(x1).Negate(1) // negX1 = -X1 (mag: 2)
284
+ negY1.Set(y1).Negate(1) // negY1 = -Y1 (mag: 2)
285
+ a.Set(&negX1).Add(x2) // A = X2-X1 (mag: 3)
286
+ b.SquareVal(&a) // B = A^2 (mag: 1)
287
+ c.Set(&negY1).Add(y2) // C = Y2-Y1 (mag: 3)
288
+ d.SquareVal(&c) // D = C^2 (mag: 1)
289
+ e.Mul2(x1, &b) // E = X1*B (mag: 1)
290
+ negE.Set(&e).Negate(1) // negE = -E (mag: 2)
291
+ f.Mul2(x2, &b) // F = X2*B (mag: 1)
292
+ x3.Add2(&e, &f).Negate(2).Add(&d) // X3 = D-E-F (mag: 4)
293
+ negX3.Set(x3).Negate(4) // negX3 = -X3 (mag: 5)
294
+ y3.Set(y1).Mul(f.Add(&negE)).Negate(1) // Y3 = -(Y1*(F-E)) (mag: 2)
295
+ y3.Add(e.Add(&negX3).Mul(&c)) // Y3 = C*(E-X3)+Y3 (mag: 3)
296
+ z3.Mul2(z1, &a) // Z3 = Z1*A (mag: 1)
297
+
298
+ // Normalize the resulting field values as needed.
299
+ x3.Normalize()
300
+ y3.Normalize()
301
+ z3.Normalize()
302
+ }
303
+
304
+ // addZ2EqualsOne adds two Jacobian points when the second point is already
305
+ // known to have a z value of 1 (and the z value for the first point is not 1)
306
+ // and stores the result in the provided result param. That is to say result =
307
+ // p1 + p2. It performs faster addition than the generic add routine since
308
+ // less arithmetic is needed due to the ability to avoid multiplications by the
309
+ // second point's z value.
310
+ //
311
+ // NOTE: The points must be normalized for this function to return the correct
312
+ // result. The resulting point will be normalized.
313
+ func addZ2EqualsOne(p1, p2, result *JacobianPoint) {
314
+ // To compute the point addition efficiently, this implementation splits
315
+ // the equation into intermediate elements which are used to minimize
316
+ // the number of field multiplications using the method shown at:
317
+ // https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-madd-2007-bl
318
+ //
319
+ // In particular it performs the calculations using the following:
320
+ // Z1Z1 = Z1^2, U2 = X2*Z1Z1, S2 = Y2*Z1*Z1Z1, H = U2-X1, HH = H^2,
321
+ // I = 4*HH, J = H*I, r = 2*(S2-Y1), V = X1*I
322
+ // X3 = r^2-J-2*V, Y3 = r*(V-X3)-2*Y1*J, Z3 = (Z1+H)^2-Z1Z1-HH
323
+ //
324
+ // This results in a cost of 7 field multiplications, 4 field squarings,
325
+ // 9 field additions, and 4 integer multiplications.
326
+ x1, y1, z1 := &p1.X, &p1.Y, &p1.Z
327
+ x2, y2 := &p2.X, &p2.Y
328
+ x3, y3, z3 := &result.X, &result.Y, &result.Z
329
+
330
+ // When the x coordinates are the same for two points on the curve, the
331
+ // y coordinates either must be the same, in which case it is point
332
+ // doubling, or they are opposite and the result is the point at
333
+ // infinity per the group law for elliptic curve cryptography. Since
334
+ // any number of Jacobian coordinates can represent the same affine
335
+ // point, the x and y values need to be converted to like terms. Due to
336
+ // the assumption made for this function that the second point has a z
337
+ // value of 1 (z2=1), the first point is already "converted".
338
+ var z1z1, u2, s2 FieldVal
339
+ z1z1.SquareVal(z1) // Z1Z1 = Z1^2 (mag: 1)
340
+ u2.Set(x2).Mul(&z1z1).Normalize() // U2 = X2*Z1Z1 (mag: 1)
341
+ s2.Set(y2).Mul(&z1z1).Mul(z1).Normalize() // S2 = Y2*Z1*Z1Z1 (mag: 1)
342
+ if x1.Equals(&u2) {
343
+ if y1.Equals(&s2) {
344
+ // Since x1 == x2 and y1 == y2, point doubling must be
345
+ // done, otherwise the addition would end up dividing
346
+ // by zero.
347
+ DoubleNonConst(p1, result)
348
+ return
349
+ }
350
+
351
+ // Since x1 == x2 and y1 == -y2, the sum is the point at
352
+ // infinity per the group law.
353
+ x3.SetInt(0)
354
+ y3.SetInt(0)
355
+ z3.SetInt(0)
356
+ return
357
+ }
358
+
359
+ // Calculate X3, Y3, and Z3 according to the intermediate elements
360
+ // breakdown above.
361
+ var h, hh, i, j, r, rr, v FieldVal
362
+ var negX1, negY1, negX3 FieldVal
363
+ negX1.Set(x1).Negate(1) // negX1 = -X1 (mag: 2)
364
+ h.Add2(&u2, &negX1) // H = U2-X1 (mag: 3)
365
+ hh.SquareVal(&h) // HH = H^2 (mag: 1)
366
+ i.Set(&hh).MulInt(4) // I = 4 * HH (mag: 4)
367
+ j.Mul2(&h, &i) // J = H*I (mag: 1)
368
+ negY1.Set(y1).Negate(1) // negY1 = -Y1 (mag: 2)
369
+ r.Set(&s2).Add(&negY1).MulInt(2) // r = 2*(S2-Y1) (mag: 6)
370
+ rr.SquareVal(&r) // rr = r^2 (mag: 1)
371
+ v.Mul2(x1, &i) // V = X1*I (mag: 1)
372
+ x3.Set(&v).MulInt(2).Add(&j).Negate(3) // X3 = -(J+2*V) (mag: 4)
373
+ x3.Add(&rr) // X3 = r^2+X3 (mag: 5)
374
+ negX3.Set(x3).Negate(5) // negX3 = -X3 (mag: 6)
375
+ y3.Set(y1).Mul(&j).MulInt(2).Negate(2) // Y3 = -(2*Y1*J) (mag: 3)
376
+ y3.Add(v.Add(&negX3).Mul(&r)) // Y3 = r*(V-X3)+Y3 (mag: 4)
377
+ z3.Add2(z1, &h).Square() // Z3 = (Z1+H)^2 (mag: 1)
378
+ z3.Add(z1z1.Add(&hh).Negate(2)) // Z3 = Z3-(Z1Z1+HH) (mag: 4)
379
+
380
+ // Normalize the resulting field values as needed.
381
+ x3.Normalize()
382
+ y3.Normalize()
383
+ z3.Normalize()
384
+ }
385
+
386
+ // addGeneric adds two Jacobian points without any assumptions about the z
387
+ // values of the two points and stores the result in the provided result param.
388
+ // That is to say result = p1 + p2. It is the slowest of the add routines due
389
+ // to requiring the most arithmetic.
390
+ //
391
+ // NOTE: The points must be normalized for this function to return the correct
392
+ // result. The resulting point will be normalized.
393
+ func addGeneric(p1, p2, result *JacobianPoint) {
394
+ // To compute the point addition efficiently, this implementation splits
395
+ // the equation into intermediate elements which are used to minimize
396
+ // the number of field multiplications using the method shown at:
397
+ // https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#addition-add-2007-bl
398
+ //
399
+ // In particular it performs the calculations using the following:
400
+ // Z1Z1 = Z1^2, Z2Z2 = Z2^2, U1 = X1*Z2Z2, U2 = X2*Z1Z1, S1 = Y1*Z2*Z2Z2
401
+ // S2 = Y2*Z1*Z1Z1, H = U2-U1, I = (2*H)^2, J = H*I, r = 2*(S2-S1)
402
+ // V = U1*I
403
+ // X3 = r^2-J-2*V, Y3 = r*(V-X3)-2*S1*J, Z3 = ((Z1+Z2)^2-Z1Z1-Z2Z2)*H
404
+ //
405
+ // This results in a cost of 11 field multiplications, 5 field squarings,
406
+ // 9 field additions, and 4 integer multiplications.
407
+ x1, y1, z1 := &p1.X, &p1.Y, &p1.Z
408
+ x2, y2, z2 := &p2.X, &p2.Y, &p2.Z
409
+ x3, y3, z3 := &result.X, &result.Y, &result.Z
410
+
411
+ // When the x coordinates are the same for two points on the curve, the
412
+ // y coordinates either must be the same, in which case it is point
413
+ // doubling, or they are opposite and the result is the point at
414
+ // infinity. Since any number of Jacobian coordinates can represent the
415
+ // same affine point, the x and y values need to be converted to like
416
+ // terms.
417
+ var z1z1, z2z2, u1, u2, s1, s2 FieldVal
418
+ z1z1.SquareVal(z1) // Z1Z1 = Z1^2 (mag: 1)
419
+ z2z2.SquareVal(z2) // Z2Z2 = Z2^2 (mag: 1)
420
+ u1.Set(x1).Mul(&z2z2).Normalize() // U1 = X1*Z2Z2 (mag: 1)
421
+ u2.Set(x2).Mul(&z1z1).Normalize() // U2 = X2*Z1Z1 (mag: 1)
422
+ s1.Set(y1).Mul(&z2z2).Mul(z2).Normalize() // S1 = Y1*Z2*Z2Z2 (mag: 1)
423
+ s2.Set(y2).Mul(&z1z1).Mul(z1).Normalize() // S2 = Y2*Z1*Z1Z1 (mag: 1)
424
+ if u1.Equals(&u2) {
425
+ if s1.Equals(&s2) {
426
+ // Since x1 == x2 and y1 == y2, point doubling must be
427
+ // done, otherwise the addition would end up dividing
428
+ // by zero.
429
+ DoubleNonConst(p1, result)
430
+ return
431
+ }
432
+
433
+ // Since x1 == x2 and y1 == -y2, the sum is the point at
434
+ // infinity per the group law.
435
+ x3.SetInt(0)
436
+ y3.SetInt(0)
437
+ z3.SetInt(0)
438
+ return
439
+ }
440
+
441
+ // Calculate X3, Y3, and Z3 according to the intermediate elements
442
+ // breakdown above.
443
+ var h, i, j, r, rr, v FieldVal
444
+ var negU1, negS1, negX3 FieldVal
445
+ negU1.Set(&u1).Negate(1) // negU1 = -U1 (mag: 2)
446
+ h.Add2(&u2, &negU1) // H = U2-U1 (mag: 3)
447
+ i.Set(&h).MulInt(2).Square() // I = (2*H)^2 (mag: 1)
448
+ j.Mul2(&h, &i) // J = H*I (mag: 1)
449
+ negS1.Set(&s1).Negate(1) // negS1 = -S1 (mag: 2)
450
+ r.Set(&s2).Add(&negS1).MulInt(2) // r = 2*(S2-S1) (mag: 6)
451
+ rr.SquareVal(&r) // rr = r^2 (mag: 1)
452
+ v.Mul2(&u1, &i) // V = U1*I (mag: 1)
453
+ x3.Set(&v).MulInt(2).Add(&j).Negate(3) // X3 = -(J+2*V) (mag: 4)
454
+ x3.Add(&rr) // X3 = r^2+X3 (mag: 5)
455
+ negX3.Set(x3).Negate(5) // negX3 = -X3 (mag: 6)
456
+ y3.Mul2(&s1, &j).MulInt(2).Negate(2) // Y3 = -(2*S1*J) (mag: 3)
457
+ y3.Add(v.Add(&negX3).Mul(&r)) // Y3 = r*(V-X3)+Y3 (mag: 4)
458
+ z3.Add2(z1, z2).Square() // Z3 = (Z1+Z2)^2 (mag: 1)
459
+ z3.Add(z1z1.Add(&z2z2).Negate(2)) // Z3 = Z3-(Z1Z1+Z2Z2) (mag: 4)
460
+ z3.Mul(&h) // Z3 = Z3*H (mag: 1)
461
+
462
+ // Normalize the resulting field values as needed.
463
+ x3.Normalize()
464
+ y3.Normalize()
465
+ z3.Normalize()
466
+ }
467
+
468
+ // AddNonConst adds the passed Jacobian points together and stores the result in
469
+ // the provided result param in *non-constant* time.
470
+ //
471
+ // NOTE: The points must be normalized for this function to return the correct
472
+ // result. The resulting point will be normalized.
473
+ func AddNonConst(p1, p2, result *JacobianPoint) {
474
+ // The point at infinity is the identity according to the group law for
475
+ // elliptic curve cryptography. Thus, ∞ + P = P and P + ∞ = P.
476
+ if (p1.X.IsZero() && p1.Y.IsZero()) || p1.Z.IsZero() {
477
+ result.Set(p2)
478
+ return
479
+ }
480
+ if (p2.X.IsZero() && p2.Y.IsZero()) || p2.Z.IsZero() {
481
+ result.Set(p1)
482
+ return
483
+ }
484
+
485
+ // Faster point addition can be achieved when certain assumptions are
486
+ // met. For example, when both points have the same z value, arithmetic
487
+ // on the z values can be avoided. This section thus checks for these
488
+ // conditions and calls an appropriate add function which is accelerated
489
+ // by using those assumptions.
490
+ isZ1One := p1.Z.IsOne()
491
+ isZ2One := p2.Z.IsOne()
492
+ switch {
493
+ case isZ1One && isZ2One:
494
+ addZ1AndZ2EqualsOne(p1, p2, result)
495
+ return
496
+ case p1.Z.Equals(&p2.Z):
497
+ addZ1EqualsZ2(p1, p2, result)
498
+ return
499
+ case isZ2One:
500
+ addZ2EqualsOne(p1, p2, result)
501
+ return
502
+ }
503
+
504
+ // None of the above assumptions are true, so fall back to generic
505
+ // point addition.
506
+ addGeneric(p1, p2, result)
507
+ }
508
+
509
+ // doubleZ1EqualsOne performs point doubling on the passed Jacobian point when
510
+ // the point is already known to have a z value of 1 and stores the result in
511
+ // the provided result param. That is to say result = 2*p. It performs faster
512
+ // point doubling than the generic routine since less arithmetic is needed due
513
+ // to the ability to avoid multiplication by the z value.
514
+ //
515
+ // NOTE: The resulting point will be normalized.
516
+ func doubleZ1EqualsOne(p, result *JacobianPoint) {
517
+ // This function uses the assumptions that z1 is 1, thus the point
518
+ // doubling formulas reduce to:
519
+ //
520
+ // X3 = (3*X1^2)^2 - 8*X1*Y1^2
521
+ // Y3 = (3*X1^2)*(4*X1*Y1^2 - X3) - 8*Y1^4
522
+ // Z3 = 2*Y1
523
+ //
524
+ // To compute the above efficiently, this implementation splits the
525
+ // equation into intermediate elements which are used to minimize the
526
+ // number of field multiplications in favor of field squarings which
527
+ // are roughly 35% faster than field multiplications with the current
528
+ // implementation at the time this was written.
529
+ //
530
+ // This uses a slightly modified version of the method shown at:
531
+ // https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#doubling-mdbl-2007-bl
532
+ //
533
+ // In particular it performs the calculations using the following:
534
+ // A = X1^2, B = Y1^2, C = B^2, D = 2*((X1+B)^2-A-C)
535
+ // E = 3*A, F = E^2, X3 = F-2*D, Y3 = E*(D-X3)-8*C
536
+ // Z3 = 2*Y1
537
+ //
538
+ // This results in a cost of 1 field multiplication, 5 field squarings,
539
+ // 6 field additions, and 5 integer multiplications.
540
+ x1, y1 := &p.X, &p.Y
541
+ x3, y3, z3 := &result.X, &result.Y, &result.Z
542
+ var a, b, c, d, e, f FieldVal
543
+ z3.Set(y1).MulInt(2) // Z3 = 2*Y1 (mag: 2)
544
+ a.SquareVal(x1) // A = X1^2 (mag: 1)
545
+ b.SquareVal(y1) // B = Y1^2 (mag: 1)
546
+ c.SquareVal(&b) // C = B^2 (mag: 1)
547
+ b.Add(x1).Square() // B = (X1+B)^2 (mag: 1)
548
+ d.Set(&a).Add(&c).Negate(2) // D = -(A+C) (mag: 3)
549
+ d.Add(&b).MulInt(2) // D = 2*(B+D)(mag: 8)
550
+ e.Set(&a).MulInt(3) // E = 3*A (mag: 3)
551
+ f.SquareVal(&e) // F = E^2 (mag: 1)
552
+ x3.Set(&d).MulInt(2).Negate(16) // X3 = -(2*D) (mag: 17)
553
+ x3.Add(&f) // X3 = F+X3 (mag: 18)
554
+ f.Set(x3).Negate(18).Add(&d).Normalize() // F = D-X3 (mag: 1)
555
+ y3.Set(&c).MulInt(8).Negate(8) // Y3 = -(8*C) (mag: 9)
556
+ y3.Add(f.Mul(&e)) // Y3 = E*F+Y3 (mag: 10)
557
+
558
+ // Normalize the resulting field values as needed.
559
+ x3.Normalize()
560
+ y3.Normalize()
561
+ z3.Normalize()
562
+ }
563
+
564
+ // doubleGeneric performs point doubling on the passed Jacobian point without
565
+ // any assumptions about the z value and stores the result in the provided
566
+ // result param. That is to say result = 2*p. It is the slowest of the point
567
+ // doubling routines due to requiring the most arithmetic.
568
+ //
569
+ // NOTE: The resulting point will be normalized.
570
+ func doubleGeneric(p, result *JacobianPoint) {
571
+ // Point doubling formula for Jacobian coordinates for the secp256k1
572
+ // curve:
573
+ //
574
+ // X3 = (3*X1^2)^2 - 8*X1*Y1^2
575
+ // Y3 = (3*X1^2)*(4*X1*Y1^2 - X3) - 8*Y1^4
576
+ // Z3 = 2*Y1*Z1
577
+ //
578
+ // To compute the above efficiently, this implementation splits the
579
+ // equation into intermediate elements which are used to minimize the
580
+ // number of field multiplications in favor of field squarings which
581
+ // are roughly 35% faster than field multiplications with the current
582
+ // implementation at the time this was written.
583
+ //
584
+ // This uses a slightly modified version of the method shown at:
585
+ // https://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#doubling-dbl-2009-l
586
+ //
587
+ // In particular it performs the calculations using the following:
588
+ // A = X1^2, B = Y1^2, C = B^2, D = 2*((X1+B)^2-A-C)
589
+ // E = 3*A, F = E^2, X3 = F-2*D, Y3 = E*(D-X3)-8*C
590
+ // Z3 = 2*Y1*Z1
591
+ //
592
+ // This results in a cost of 1 field multiplication, 5 field squarings,
593
+ // 6 field additions, and 5 integer multiplications.
594
+ x1, y1, z1 := &p.X, &p.Y, &p.Z
595
+ x3, y3, z3 := &result.X, &result.Y, &result.Z
596
+ var a, b, c, d, e, f FieldVal
597
+ z3.Mul2(y1, z1).MulInt(2) // Z3 = 2*Y1*Z1 (mag: 2)
598
+ a.SquareVal(x1) // A = X1^2 (mag: 1)
599
+ b.SquareVal(y1) // B = Y1^2 (mag: 1)
600
+ c.SquareVal(&b) // C = B^2 (mag: 1)
601
+ b.Add(x1).Square() // B = (X1+B)^2 (mag: 1)
602
+ d.Set(&a).Add(&c).Negate(2) // D = -(A+C) (mag: 3)
603
+ d.Add(&b).MulInt(2) // D = 2*(B+D)(mag: 8)
604
+ e.Set(&a).MulInt(3) // E = 3*A (mag: 3)
605
+ f.SquareVal(&e) // F = E^2 (mag: 1)
606
+ x3.Set(&d).MulInt(2).Negate(16) // X3 = -(2*D) (mag: 17)
607
+ x3.Add(&f) // X3 = F+X3 (mag: 18)
608
+ f.Set(x3).Negate(18).Add(&d).Normalize() // F = D-X3 (mag: 1)
609
+ y3.Set(&c).MulInt(8).Negate(8) // Y3 = -(8*C) (mag: 9)
610
+ y3.Add(f.Mul(&e)) // Y3 = E*F+Y3 (mag: 10)
611
+
612
+ // Normalize the resulting field values as needed.
613
+ x3.Normalize()
614
+ y3.Normalize()
615
+ z3.Normalize()
616
+ }
617
+
618
+ // DoubleNonConst doubles the passed Jacobian point and stores the result in the
619
+ // provided result parameter in *non-constant* time.
620
+ //
621
+ // NOTE: The point must be normalized for this function to return the correct
622
+ // result. The resulting point will be normalized.
623
+ func DoubleNonConst(p, result *JacobianPoint) {
624
+ // Doubling the point at infinity is still infinity.
625
+ if p.Y.IsZero() || p.Z.IsZero() {
626
+ result.X.SetInt(0)
627
+ result.Y.SetInt(0)
628
+ result.Z.SetInt(0)
629
+ return
630
+ }
631
+
632
+ // Slightly faster point doubling can be achieved when the z value is 1
633
+ // by avoiding the multiplication on the z value. This section calls
634
+ // a point doubling function which is accelerated by using that
635
+ // assumption when possible.
636
+ if p.Z.IsOne() {
637
+ doubleZ1EqualsOne(p, result)
638
+ return
639
+ }
640
+
641
+ // Fall back to generic point doubling which works with arbitrary z
642
+ // values.
643
+ doubleGeneric(p, result)
644
+ }
645
+
646
+ // mulAdd64 multiplies the two passed base 2^64 digits together, adds the given
647
+ // value to the result, and returns the 128-bit result via a (hi, lo) tuple
648
+ // where the upper half of the bits are returned in hi and the lower half in lo.
649
+ func mulAdd64(digit1, digit2, m uint64) (hi, lo uint64) {
650
+ // Note the carry on the final add is safe to discard because the maximum
651
+ // possible value is:
652
+ // (2^64 - 1)(2^64 - 1) + (2^64 - 1) = 2^128 - 2^64
653
+ // and:
654
+ // 2^128 - 2^64 < 2^128.
655
+ var c uint64
656
+ hi, lo = bits.Mul64(digit1, digit2)
657
+ lo, c = bits.Add64(lo, m, 0)
658
+ hi, _ = bits.Add64(hi, 0, c)
659
+ return hi, lo
660
+ }
661
+
662
+ // mulAdd64Carry multiplies the two passed base 2^64 digits together, adds both
663
+ // the given value and carry to the result, and returns the 128-bit result via a
664
+ // (hi, lo) tuple where the upper half of the bits are returned in hi and the
665
+ // lower half in lo.
666
+ func mulAdd64Carry(digit1, digit2, m, c uint64) (hi, lo uint64) {
667
+ // Note the carry on the high order add is safe to discard because the
668
+ // maximum possible value is:
669
+ // (2^64 - 1)(2^64 - 1) + 2*(2^64 - 1) = 2^128 - 1
670
+ // and:
671
+ // 2^128 - 1 < 2^128.
672
+ var c2 uint64
673
+ hi, lo = mulAdd64(digit1, digit2, m)
674
+ lo, c2 = bits.Add64(lo, c, 0)
675
+ hi, _ = bits.Add64(hi, 0, c2)
676
+ return hi, lo
677
+ }
678
+
679
+ // mul512Rsh320Round computes the full 512-bit product of the two given scalars,
680
+ // right shifts the result by 320 bits, rounds to the nearest integer, and
681
+ // returns the result in constant time.
682
+ //
683
+ // Note that despite the inputs and output being mod n scalars, the 512-bit
684
+ // product is NOT reduced mod N prior to the right shift. This is intentional
685
+ // because it is used for replacing division with multiplication and thus the
686
+ // intermediate results must be done via a field extension to a larger field.
687
+ func mul512Rsh320Round(n1, n2 *ModNScalar) ModNScalar {
688
+ // Convert n1 and n2 to base 2^64 digits.
689
+ n1Digit0 := uint64(n1.n[0]) | uint64(n1.n[1])<<32
690
+ n1Digit1 := uint64(n1.n[2]) | uint64(n1.n[3])<<32
691
+ n1Digit2 := uint64(n1.n[4]) | uint64(n1.n[5])<<32
692
+ n1Digit3 := uint64(n1.n[6]) | uint64(n1.n[7])<<32
693
+ n2Digit0 := uint64(n2.n[0]) | uint64(n2.n[1])<<32
694
+ n2Digit1 := uint64(n2.n[2]) | uint64(n2.n[3])<<32
695
+ n2Digit2 := uint64(n2.n[4]) | uint64(n2.n[5])<<32
696
+ n2Digit3 := uint64(n2.n[6]) | uint64(n2.n[7])<<32
697
+
698
+ // Compute the full 512-bit product n1*n2.
699
+ var r0, r1, r2, r3, r4, r5, r6, r7, c uint64
700
+
701
+ // Terms resulting from the product of the first digit of the second number
702
+ // by all digits of the first number.
703
+ //
704
+ // Note that r0 is ignored because it is not needed to compute the higher
705
+ // terms and it is shifted out below anyway.
706
+ c, _ = bits.Mul64(n2Digit0, n1Digit0)
707
+ c, r1 = mulAdd64(n2Digit0, n1Digit1, c)
708
+ c, r2 = mulAdd64(n2Digit0, n1Digit2, c)
709
+ r4, r3 = mulAdd64(n2Digit0, n1Digit3, c)
710
+
711
+ // Terms resulting from the product of the second digit of the second number
712
+ // by all digits of the first number.
713
+ //
714
+ // Note that r1 is ignored because it is no longer needed to compute the
715
+ // higher terms and it is shifted out below anyway.
716
+ c, _ = mulAdd64(n2Digit1, n1Digit0, r1)
717
+ c, r2 = mulAdd64Carry(n2Digit1, n1Digit1, r2, c)
718
+ c, r3 = mulAdd64Carry(n2Digit1, n1Digit2, r3, c)
719
+ r5, r4 = mulAdd64Carry(n2Digit1, n1Digit3, r4, c)
720
+
721
+ // Terms resulting from the product of the third digit of the second number
722
+ // by all digits of the first number.
723
+ //
724
+ // Note that r2 is ignored because it is no longer needed to compute the
725
+ // higher terms and it is shifted out below anyway.
726
+ c, _ = mulAdd64(n2Digit2, n1Digit0, r2)
727
+ c, r3 = mulAdd64Carry(n2Digit2, n1Digit1, r3, c)
728
+ c, r4 = mulAdd64Carry(n2Digit2, n1Digit2, r4, c)
729
+ r6, r5 = mulAdd64Carry(n2Digit2, n1Digit3, r5, c)
730
+
731
+ // Terms resulting from the product of the fourth digit of the second number
732
+ // by all digits of the first number.
733
+ //
734
+ // Note that r3 is ignored because it is no longer needed to compute the
735
+ // higher terms and it is shifted out below anyway.
736
+ c, _ = mulAdd64(n2Digit3, n1Digit0, r3)
737
+ c, r4 = mulAdd64Carry(n2Digit3, n1Digit1, r4, c)
738
+ c, r5 = mulAdd64Carry(n2Digit3, n1Digit2, r5, c)
739
+ r7, r6 = mulAdd64Carry(n2Digit3, n1Digit3, r6, c)
740
+
741
+ // At this point the upper 256 bits of the full 512-bit product n1*n2 are in
742
+ // r4..r7 (recall the low order results were discarded as noted above).
743
+ //
744
+ // Right shift the result 320 bits. Note that the MSB of r4 determines
745
+ // whether or not to round because it is the final bit that is shifted out.
746
+ //
747
+ // Also, notice that r3..r7 would also ordinarily be set to 0 as well for
748
+ // the full shift, but that is skipped since they are no longer used as
749
+ // their values are known to be zero.
750
+ roundBit := r4 >> 63
751
+ r2, r1, r0 = r7, r6, r5
752
+
753
+ // Conditionally add 1 depending on the round bit in constant time.
754
+ r0, c = bits.Add64(r0, roundBit, 0)
755
+ r1, c = bits.Add64(r1, 0, c)
756
+ r2, r3 = bits.Add64(r2, 0, c)
757
+
758
+ // Finally, convert the result to a mod n scalar.
759
+ //
760
+ // No modular reduction is needed because the result is guaranteed to be
761
+ // less than the group order given the group order is > 2^255 and the
762
+ // maximum possible value of the result is 2^192.
763
+ var result ModNScalar
764
+ result.n[0] = uint32(r0)
765
+ result.n[1] = uint32(r0 >> 32)
766
+ result.n[2] = uint32(r1)
767
+ result.n[3] = uint32(r1 >> 32)
768
+ result.n[4] = uint32(r2)
769
+ result.n[5] = uint32(r2 >> 32)
770
+ result.n[6] = uint32(r3)
771
+ result.n[7] = uint32(r3 >> 32)
772
+ return result
773
+ }
774
+
775
+ // splitK returns two scalars (k1 and k2) that are a balanced length-two
776
+ // representation of the provided scalar such that k ≡ k1 + k2*λ (mod N), where
777
+ // N is the secp256k1 group order.
778
+ func splitK(k *ModNScalar) (ModNScalar, ModNScalar) {
779
+ // The ultimate goal is to decompose k into two scalars that are around
780
+ // half the bit length of k such that the following equation is satisfied:
781
+ //
782
+ // k1 + k2*λ ≡ k (mod n)
783
+ //
784
+ // The strategy used here is based on algorithm 3.74 from [GECC] with a few
785
+ // modifications to make use of the more efficient mod n scalar type, avoid
786
+ // some costly long divisions, and minimize the number of calculations.
787
+ //
788
+ // Start by defining a function that takes a vector v = <a,b> ∈ ℤ⨯ℤ:
789
+ //
790
+ // f(v) = a + bλ (mod n)
791
+ //
792
+ // Then, find two vectors, v1 = <a1,b1>, and v2 = <a2,b2> in ℤ⨯ℤ such that:
793
+ // 1) v1 and v2 are linearly independent
794
+ // 2) f(v1) = f(v2) = 0
795
+ // 3) v1 and v2 have small Euclidean norm
796
+ //
797
+ // The vectors that satisfy these properties are found via the Euclidean
798
+ // algorithm and are precomputed since both n and λ are fixed values for the
799
+ // secp256k1 curve. See genprecomps.go for derivation details.
800
+ //
801
+ // Next, consider k as a vector <k, 0> in ℚ⨯ℚ and by linear algebra write:
802
+ //
803
+ // <k, 0> = g1*v1 + g2*v2, where g1, g2 ∈ ℚ
804
+ //
805
+ // Note that, per above, the components of vector v1 are a1 and b1 while the
806
+ // components of vector v2 are a2 and b2. Given the vectors v1 and v2 were
807
+ // generated such that a1*b2 - a2*b1 = n, solving the equation for g1 and g2
808
+ // yields:
809
+ //
810
+ // g1 = b2*k / n
811
+ // g2 = -b1*k / n
812
+ //
813
+ // Observe:
814
+ // <k, 0> = g1*v1 + g2*v2
815
+ // = (b2*k/n)*<a1,b1> + (-b1*k/n)*<a2,b2> | substitute
816
+ // = <a1*b2*k/n, b1*b2*k/n> + <-a2*b1*k/n, -b2*b1*k/n> | scalar mul
817
+ // = <a1*b2*k/n - a2*b1*k/n, b1*b2*k/n - b2*b1*k/n> | vector add
818
+ // = <[a1*b2*k - a2*b1*k]/n, 0> | simplify
819
+ // = <k*[a1*b2 - a2*b1]/n, 0> | factor out k
820
+ // = <k*n/n, 0> | substitute
821
+ // = <k, 0> | simplify
822
+ //
823
+ // Now, consider an integer-valued vector v:
824
+ //
825
+ // v = c1*v1 + c2*v2, where c1, c2 ∈ ℤ (mod n)
826
+ //
827
+ // Since vectors v1 and v2 are linearly independent and were generated such
828
+ // that f(v1) = f(v2) = 0, all possible scalars c1 and c2 also produce a
829
+ // vector v such that f(v) = 0.
830
+ //
831
+ // In other words, c1 and c2 can be any integers and the resulting
832
+ // decomposition will still satisfy the required equation. However, since
833
+ // the goal is to produce a balanced decomposition that provides a
834
+ // performance advantage by minimizing max(k1, k2), c1 and c2 need to be
835
+ // integers close to g1 and g2, respectively, so the resulting vector v is
836
+ // an integer-valued vector that is close to <k, 0>.
837
+ //
838
+ // Finally, consider the vector u:
839
+ //
840
+ // u = <k, 0> - v
841
+ //
842
+ // It follows that f(u) = k and thus the two components of vector u satisfy
843
+ // the required equation:
844
+ //
845
+ // k1 + k2*λ ≡ k (mod n)
846
+ //
847
+ // Choosing c1 and c2:
848
+ // -------------------
849
+ //
850
+ // As mentioned above, c1 and c2 need to be integers close to g1 and g2,
851
+ // respectively. The algorithm in [GECC] chooses the following values:
852
+ //
853
+ // c1 = round(g1) = round(b2*k / n)
854
+ // c2 = round(g2) = round(-b1*k / n)
855
+ //
856
+ // However, as section 3.4.2 of [STWS] notes, the aforementioned approach
857
+ // requires costly long divisions that can be avoided by precomputing
858
+ // rounded estimates as follows:
859
+ //
860
+ // t = bitlen(n) + 1
861
+ // z1 = round(2^t * b2 / n)
862
+ // z2 = round(2^t * -b1 / n)
863
+ //
864
+ // Then, use those precomputed estimates to perform a multiplication by k
865
+ // along with a floored division by 2^t, which is a simple right shift by t:
866
+ //
867
+ // c1 = floor(k * z1 / 2^t) = (k * z1) >> t
868
+ // c2 = floor(k * z2 / 2^t) = (k * z2) >> t
869
+ //
870
+ // Finally, round up if last bit discarded in the right shift by t is set by
871
+ // adding 1.
872
+ //
873
+ // As a further optimization, rather than setting t = bitlen(n) + 1 = 257 as
874
+ // stated by [STWS], this implementation uses a higher precision estimate of
875
+ // t = bitlen(n) + 64 = 320 because it allows simplification of the shifts
876
+ // in the internal calculations that are done via uint64s and also allows
877
+ // the use of floor in the precomputations.
878
+ //
879
+ // Thus, the calculations this implementation uses are:
880
+ //
881
+ // z1 = floor(b2<<320 / n) | precomputed
882
+ // z2 = floor((-b1)<<320) / n) | precomputed
883
+ // c1 = ((k * z1) >> 320) + (((k * z1) >> 319) & 1)
884
+ // c2 = ((k * z2) >> 320) + (((k * z2) >> 319) & 1)
885
+ //
886
+ // Putting it all together:
887
+ // ------------------------
888
+ //
889
+ // Calculate the following vectors using the values discussed above:
890
+ //
891
+ // v = c1*v1 + c2*v2
892
+ // u = <k, 0> - v
893
+ //
894
+ // The two components of the resulting vector v are:
895
+ // va = c1*a1 + c2*a2
896
+ // vb = c1*b1 + c2*b2
897
+ //
898
+ // Thus, the two components of the resulting vector u are:
899
+ // k1 = k - va
900
+ // k2 = 0 - vb = -vb
901
+ //
902
+ // As some final optimizations:
903
+ //
904
+ // 1) Note that k1 + k2*λ ≡ k (mod n) means that k1 ≡ k - k2*λ (mod n).
905
+ // Therefore, the computation of va can be avoided to save two
906
+ // field multiplications and a field addition.
907
+ //
908
+ // 2) Since k1 ≡ k - k2*λ ≡ k + k2*(-λ), an additional field negation is
909
+ // saved by storing and using the negative version of λ.
910
+ //
911
+ // 3) Since k2 ≡ -vb ≡ -(c1*b1 + c2*b2) ≡ c1*(-b1) + c2*(-b2), one more
912
+ // field negation is saved by storing and using the negative versions of
913
+ // b1 and b2.
914
+ //
915
+ // k2 = c1*(-b1) + c2*(-b2)
916
+ // k1 = k + k2*(-λ)
917
+ var k1, k2 ModNScalar
918
+ c1 := mul512Rsh320Round(k, endoZ1)
919
+ c2 := mul512Rsh320Round(k, endoZ2)
920
+ k2.Add2(c1.Mul(endoNegB1), c2.Mul(endoNegB2))
921
+ k1.Mul2(&k2, endoNegLambda).Add(k)
922
+ return k1, k2
923
+ }
924
+
925
+ // nafScalar represents a positive integer up to a maximum value of 2^256 - 1
926
+ // encoded in non-adjacent form.
927
+ //
928
+ // NAF is a signed-digit representation where each digit can be +1, 0, or -1.
929
+ //
930
+ // In order to efficiently encode that information, this type uses two arrays, a
931
+ // "positive" array where set bits represent the +1 signed digits and a
932
+ // "negative" array where set bits represent the -1 signed digits. 0 is
933
+ // represented by neither array having a bit set in that position.
934
+ //
935
+ // The Pos and Neg methods return the aforementioned positive and negative
936
+ // arrays, respectively.
937
+ type nafScalar struct {
938
+ // pos houses the positive portion of the representation. An additional
939
+ // byte is required for the positive portion because the NAF encoding can be
940
+ // up to 1 bit longer than the normal binary encoding of the value.
941
+ //
942
+ // neg houses the negative portion of the representation. Even though the
943
+ // additional byte is not required for the negative portion, since it can
944
+ // never exceed the length of the normal binary encoding of the value,
945
+ // keeping the same length for positive and negative portions simplifies
946
+ // working with the representation and allows extra conditional branches to
947
+ // be avoided.
948
+ //
949
+ // start and end specify the starting and ending index to use within the pos
950
+ // and neg arrays, respectively. This allows fixed size arrays to be used
951
+ // versus needing to dynamically allocate space on the heap.
952
+ //
953
+ // NOTE: The fields are defined in the order that they are to minimize the
954
+ // padding on 32-bit and 64-bit platforms.
955
+ pos [33]byte
956
+ start, end uint8
957
+ neg [33]byte
958
+ }
959
+
960
+ // Pos returns the bytes of the encoded value with bits set in the positions
961
+ // that represent a signed digit of +1.
962
+ func (s *nafScalar) Pos() []byte {
963
+ return s.pos[s.start:s.end]
964
+ }
965
+
966
+ // Neg returns the bytes of the encoded value with bits set in the positions
967
+ // that represent a signed digit of -1.
968
+ func (s *nafScalar) Neg() []byte {
969
+ return s.neg[s.start:s.end]
970
+ }
971
+
972
+ // naf takes a positive integer up to a maximum value of 2^256 - 1 and returns
973
+ // its non-adjacent form (NAF), which is a unique signed-digit representation
974
+ // such that no two consecutive digits are nonzero. See the documentation for
975
+ // the returned type for details on how the representation is encoded
976
+ // efficiently and how to interpret it
977
+ //
978
+ // NAF is useful in that it has the fewest nonzero digits of any signed digit
979
+ // representation, only 1/3rd of its digits are nonzero on average, and at least
980
+ // half of the digits will be 0.
981
+ //
982
+ // The aforementioned properties are particularly beneficial for optimizing
983
+ // elliptic curve point multiplication because they effectively minimize the
984
+ // number of required point additions in exchange for needing to perform a mix
985
+ // of fewer point additions and subtractions and possibly one additional point
986
+ // doubling. This is an excellent tradeoff because subtraction of points has
987
+ // the same computational complexity as addition of points and point doubling is
988
+ // faster than both.
989
+ func naf(k []byte) nafScalar {
990
+ // Strip leading zero bytes.
991
+ for len(k) > 0 && k[0] == 0x00 {
992
+ k = k[1:]
993
+ }
994
+
995
+ // The non-adjacent form (NAF) of a positive integer k is an expression
996
+ // k = ∑_(i=0, l-1) k_i * 2^i where k_i ∈ {0,±1}, k_(l-1) != 0, and no two
997
+ // consecutive digits k_i are nonzero.
998
+ //
999
+ // The traditional method of computing the NAF of a positive integer is
1000
+ // given by algorithm 3.30 in [GECC]. It consists of repeatedly dividing k
1001
+ // by 2 and choosing the remainder so that the quotient (k−r)/2 is even
1002
+ // which ensures the next NAF digit is 0. This requires log_2(k) steps.
1003
+ //
1004
+ // However, in [BRID], Prodinger notes that a closed form expression for the
1005
+ // NAF representation is the bitwise difference 3k/2 - k/2. This is more
1006
+ // efficient as it can be computed in O(1) versus the O(log(n)) of the
1007
+ // traditional approach.
1008
+ //
1009
+ // The following code makes use of that formula to compute the NAF more
1010
+ // efficiently.
1011
+ //
1012
+ // To understand the logic here, observe that the only way the NAF has a
1013
+ // nonzero digit at a given bit is when either 3k/2 or k/2 has a bit set in
1014
+ // that position, but not both. In other words, the result of a bitwise
1015
+ // xor. This can be seen simply by considering that when the bits are the
1016
+ // same, the subtraction is either 0-0 or 1-1, both of which are 0.
1017
+ //
1018
+ // Further, observe that the "+1" digits in the result are contributed by
1019
+ // 3k/2 while the "-1" digits are from k/2. So, they can be determined by
1020
+ // taking the bitwise and of each respective value with the result of the
1021
+ // xor which identifies which bits are nonzero.
1022
+ //
1023
+ // Using that information, this loops backwards from the least significant
1024
+ // byte to the most significant byte while performing the aforementioned
1025
+ // calculations by propagating the potential carry and high order bit from
1026
+ // the next word during the right shift.
1027
+ kLen := len(k)
1028
+ var result nafScalar
1029
+ var carry uint8
1030
+ for byteNum := kLen - 1; byteNum >= 0; byteNum-- {
1031
+ // Calculate k/2. Notice the carry from the previous word is added and
1032
+ // the low order bit from the next word is shifted in accordingly.
1033
+ kc := uint16(k[byteNum]) + uint16(carry)
1034
+ var nextWord uint8
1035
+ if byteNum > 0 {
1036
+ nextWord = k[byteNum-1]
1037
+ }
1038
+ halfK := kc>>1 | uint16(nextWord<<7)
1039
+
1040
+ // Calculate 3k/2 and determine the non-zero digits in the result.
1041
+ threeHalfK := kc + halfK
1042
+ nonZeroResultDigits := threeHalfK ^ halfK
1043
+
1044
+ // Determine the signed digits {0, ±1}.
1045
+ result.pos[byteNum+1] = uint8(threeHalfK & nonZeroResultDigits)
1046
+ result.neg[byteNum+1] = uint8(halfK & nonZeroResultDigits)
1047
+
1048
+ // Propagate the potential carry from the 3k/2 calculation.
1049
+ carry = uint8(threeHalfK >> 8)
1050
+ }
1051
+ result.pos[0] = carry
1052
+
1053
+ // Set the starting and ending positions within the fixed size arrays to
1054
+ // identify the bytes that are actually used. This is important since the
1055
+ // encoding is big endian and thus trailing zero bytes changes its value.
1056
+ result.start = 1 - carry
1057
+ result.end = uint8(kLen + 1)
1058
+ return result
1059
+ }
1060
+
1061
+ // ScalarMultNonConst multiplies k*P where k is a scalar modulo the curve order
1062
+ // and P is a point in Jacobian projective coordinates and stores the result in
1063
+ // the provided Jacobian point.
1064
+ //
1065
+ // NOTE: The point must be normalized for this function to return the correct
1066
+ // result. The resulting point will be normalized.
1067
+ func ScalarMultNonConst(k *ModNScalar, point, result *JacobianPoint) {
1068
+ // -------------------------------------------------------------------------
1069
+ // This makes use of the following efficiently-computable endomorphism to
1070
+ // accelerate the computation:
1071
+ //
1072
+ // φ(P) ⟼ λ*P = (β*P.x mod p, P.y)
1073
+ //
1074
+ // In other words, there is a special scalar λ that every point on the
1075
+ // elliptic curve can be multiplied by that will result in the same point as
1076
+ // performing a single field multiplication of the point's X coordinate by
1077
+ // the special value β.
1078
+ //
1079
+ // This is useful because scalar point multiplication is significantly more
1080
+ // expensive than a single field multiplication given the former involves a
1081
+ // series of point doublings and additions which themselves consist of a
1082
+ // combination of several field multiplications, squarings, and additions.
1083
+ //
1084
+ // So, the idea behind making use of the endomorphism is thus to decompose
1085
+ // the scalar into two scalars that are each about half the bit length of
1086
+ // the original scalar such that:
1087
+ //
1088
+ // k ≡ k1 + k2*λ (mod n)
1089
+ //
1090
+ // This in turn allows the scalar point multiplication to be performed as a
1091
+ // sum of two smaller half-length multiplications as follows:
1092
+ //
1093
+ // k*P = (k1 + k2*λ)*P
1094
+ // = k1*P + k2*λ*P
1095
+ // = k1*P + k2*φ(P)
1096
+ //
1097
+ // Thus, a speedup is achieved so long as it's faster to decompose the
1098
+ // scalar, compute φ(P), and perform a simultaneous multiply of the
1099
+ // half-length point multiplications than it is to compute a full width
1100
+ // point multiplication.
1101
+ //
1102
+ // In practice, benchmarks show the current implementation provides a
1103
+ // speedup of around 30-35% versus not using the endomorphism.
1104
+ //
1105
+ // See section 3.5 in [GECC] for a more rigorous treatment.
1106
+ // -------------------------------------------------------------------------
1107
+
1108
+ // Per above, the main equation here to remember is:
1109
+ // k*P = k1*P + k2*φ(P)
1110
+ //
1111
+ // p1 below is P in the equation while p2 is φ(P) in the equation.
1112
+ //
1113
+ // NOTE: φ(x,y) = (β*x,y). The Jacobian z coordinates are the same, so this
1114
+ // math goes through.
1115
+ //
1116
+ // Also, calculate -p1 and -p2 for use in the NAF optimization.
1117
+ p1, p1Neg := new(JacobianPoint), new(JacobianPoint)
1118
+ p1.Set(point)
1119
+ p1Neg.Set(p1)
1120
+ p1Neg.Y.Negate(1).Normalize()
1121
+ p2, p2Neg := new(JacobianPoint), new(JacobianPoint)
1122
+ p2.Set(p1)
1123
+ p2.X.Mul(endoBeta).Normalize()
1124
+ p2Neg.Set(p2)
1125
+ p2Neg.Y.Negate(1).Normalize()
1126
+
1127
+ // Decompose k into k1 and k2 such that k = k1 + k2*λ (mod n) where k1 and
1128
+ // k2 are around half the bit length of k in order to halve the number of EC
1129
+ // operations.
1130
+ //
1131
+ // Notice that this also flips the sign of the scalars and points as needed
1132
+ // to minimize the bit lengths of the scalars k1 and k2.
1133
+ //
1134
+ // This is done because the scalars are operating modulo the group order
1135
+ // which means that when they would otherwise be a small negative magnitude
1136
+ // they will instead be a large positive magnitude. Since the goal is for
1137
+ // the scalars to have a small magnitude to achieve a performance boost, use
1138
+ // their negation when they are greater than the half order of the group and
1139
+ // flip the positive and negative values of the corresponding point that
1140
+ // will be multiplied by to compensate.
1141
+ //
1142
+ // In other words, transform the calc when k1 is over the half order to:
1143
+ // k1*P = -k1*-P
1144
+ //
1145
+ // Similarly, transform the calc when k2 is over the half order to:
1146
+ // k2*φ(P) = -k2*-φ(P)
1147
+ k1, k2 := splitK(k)
1148
+ if k1.IsOverHalfOrder() {
1149
+ k1.Negate()
1150
+ p1, p1Neg = p1Neg, p1
1151
+ }
1152
+ if k2.IsOverHalfOrder() {
1153
+ k2.Negate()
1154
+ p2, p2Neg = p2Neg, p2
1155
+ }
1156
+
1157
+ // Convert k1 and k2 into their NAF representations since NAF has a lot more
1158
+ // zeros overall on average which minimizes the number of required point
1159
+ // additions in exchange for a mix of fewer point additions and subtractions
1160
+ // at the cost of one additional point doubling.
1161
+ //
1162
+ // This is an excellent tradeoff because subtraction of points has the same
1163
+ // computational complexity as addition of points and point doubling is
1164
+ // faster than both.
1165
+ //
1166
+ // Concretely, on average, 1/2 of all bits will be non-zero with the normal
1167
+ // binary representation whereas only 1/3rd of the bits will be non-zero
1168
+ // with NAF.
1169
+ //
1170
+ // The Pos version of the bytes contain the +1s and the Neg versions contain
1171
+ // the -1s.
1172
+ k1Bytes, k2Bytes := k1.Bytes(), k2.Bytes()
1173
+ k1NAF, k2NAF := naf(k1Bytes[:]), naf(k2Bytes[:])
1174
+ k1PosNAF, k1NegNAF := k1NAF.Pos(), k1NAF.Neg()
1175
+ k2PosNAF, k2NegNAF := k2NAF.Pos(), k2NAF.Neg()
1176
+ k1Len, k2Len := len(k1PosNAF), len(k2PosNAF)
1177
+
1178
+ // Add left-to-right using the NAF optimization. See algorithm 3.77 from
1179
+ // [GECC].
1180
+ //
1181
+ // Point Q = ∞ (point at infinity).
1182
+ var q JacobianPoint
1183
+ m := k1Len
1184
+ if m < k2Len {
1185
+ m = k2Len
1186
+ }
1187
+ for i := 0; i < m; i++ {
1188
+ // Since k1 and k2 are potentially different lengths and the calculation
1189
+ // is being done left to right, pad the front of the shorter one with
1190
+ // 0s.
1191
+ var k1BytePos, k1ByteNeg, k2BytePos, k2ByteNeg byte
1192
+ if i >= m-k1Len {
1193
+ k1BytePos, k1ByteNeg = k1PosNAF[i-(m-k1Len)], k1NegNAF[i-(m-k1Len)]
1194
+ }
1195
+ if i >= m-k2Len {
1196
+ k2BytePos, k2ByteNeg = k2PosNAF[i-(m-k2Len)], k2NegNAF[i-(m-k2Len)]
1197
+ }
1198
+
1199
+ for mask := uint8(1 << 7); mask > 0; mask >>= 1 {
1200
+ // Q = 2 * Q
1201
+ DoubleNonConst(&q, &q)
1202
+
1203
+ // Add or subtract the first point based on the signed digit of the
1204
+ // NAF representation of k1 at this bit position.
1205
+ //
1206
+ // +1: Q = Q + p1
1207
+ // -1: Q = Q - p1
1208
+ // 0: Q = Q (no change)
1209
+ if k1BytePos&mask == mask {
1210
+ AddNonConst(&q, p1, &q)
1211
+ } else if k1ByteNeg&mask == mask {
1212
+ AddNonConst(&q, p1Neg, &q)
1213
+ }
1214
+
1215
+ // Add or subtract the second point based on the signed digit of the
1216
+ // NAF representation of k2 at this bit position.
1217
+ //
1218
+ // +1: Q = Q + p2
1219
+ // -1: Q = Q - p2
1220
+ // 0: Q = Q (no change)
1221
+ if k2BytePos&mask == mask {
1222
+ AddNonConst(&q, p2, &q)
1223
+ } else if k2ByteNeg&mask == mask {
1224
+ AddNonConst(&q, p2Neg, &q)
1225
+ }
1226
+ }
1227
+ }
1228
+
1229
+ result.Set(&q)
1230
+ }
1231
+
1232
+ // ScalarBaseMultNonConst multiplies k*G where k is a scalar modulo the curve
1233
+ // order and G is the base point of the group and stores the result in the
1234
+ // provided Jacobian point.
1235
+ //
1236
+ // NOTE: The resulting point will be normalized.
1237
+ func ScalarBaseMultNonConst(k *ModNScalar, result *JacobianPoint) {
1238
+ scalarBaseMultNonConst(k, result)
1239
+ }
1240
+
1241
+ // jacobianG is the secp256k1 base point converted to Jacobian coordinates and
1242
+ // is defined here to avoid repeatedly converting it.
1243
+ var jacobianG = func() JacobianPoint {
1244
+ var G JacobianPoint
1245
+ bigAffineToJacobian(curveParams.Gx, curveParams.Gy, &G)
1246
+ return G
1247
+ }()
1248
+
1249
+ // scalarBaseMultNonConstSlow computes k*G through ScalarMultNonConst.
1250
+ func scalarBaseMultNonConstSlow(k *ModNScalar, result *JacobianPoint) {
1251
+ ScalarMultNonConst(k, &jacobianG, result)
1252
+ }
1253
+
1254
+ // scalarBaseMultNonConstFast computes k*G through the precomputed lookup
1255
+ // tables.
1256
+ func scalarBaseMultNonConstFast(k *ModNScalar, result *JacobianPoint) {
1257
+ bytePoints := s256BytePoints()
1258
+
1259
+ // Start with the point at infinity.
1260
+ result.X.Zero()
1261
+ result.Y.Zero()
1262
+ result.Z.Zero()
1263
+
1264
+ // bytePoints has all 256 byte points for each 8-bit window. The strategy
1265
+ // is to add up the byte points. This is best understood by expressing k in
1266
+ // base-256 which it already sort of is. Each "digit" in the 8-bit window
1267
+ // can be looked up using bytePoints and added together.
1268
+ kb := k.Bytes()
1269
+ for i := 0; i < len(kb); i++ {
1270
+ pt := &bytePoints[i][kb[i]]
1271
+ AddNonConst(result, pt, result)
1272
+ }
1273
+ }
1274
+
1275
+ // isOnCurve returns whether or not the affine point (x,y) is on the curve.
1276
+ func isOnCurve(fx, fy *FieldVal) bool {
1277
+ // Elliptic curve equation for secp256k1 is: y^2 = x^3 + 7
1278
+ y2 := new(FieldVal).SquareVal(fy).Normalize()
1279
+ result := new(FieldVal).SquareVal(fx).Mul(fx).AddInt(7).Normalize()
1280
+ return y2.Equals(result)
1281
+ }
1282
+
1283
+ // DecompressY attempts to calculate the Y coordinate for the given X coordinate
1284
+ // such that the result pair is a point on the secp256k1 curve. It adjusts Y
1285
+ // based on the desired oddness and returns whether or not it was successful
1286
+ // since not all X coordinates are valid.
1287
+ //
1288
+ // The magnitude of the provided X coordinate field value must be a max of 8 for
1289
+ // a correct result. The resulting Y field value will have a magnitude of 1.
1290
+ //
1291
+ // Preconditions:
1292
+ // - The input field value MUST have a max magnitude of 8
1293
+ // Output Normalized: Yes if the func returns true, no otherwise
1294
+ // Output Max Magnitude: 1
1295
+ func DecompressY(x *FieldVal, odd bool, resultY *FieldVal) bool {
1296
+ // The curve equation for secp256k1 is: y^2 = x^3 + 7. Thus
1297
+ // y = +-sqrt(x^3 + 7).
1298
+ //
1299
+ // The x coordinate must be invalid if there is no square root for the
1300
+ // calculated rhs because it means the X coordinate is not for a point on
1301
+ // the curve.
1302
+ x3PlusB := new(FieldVal).SquareVal(x).Mul(x).AddInt(7)
1303
+ if hasSqrt := resultY.SquareRootVal(x3PlusB); !hasSqrt {
1304
+ return false
1305
+ }
1306
+ if resultY.Normalize().IsOdd() != odd {
1307
+ resultY.Negate(1).Normalize()
1308
+ }
1309
+ return true
1310
+ }