typenative 0.6.2 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1131) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +18 -8
  3. package/bin/go/overrides.js +21 -1
  4. package/bin/index.js +48 -25
  5. package/bin/main.js +2 -1
  6. package/bin/node/assert.js +56 -17
  7. package/bin/node/async_hooks.js +69 -10
  8. package/bin/node/buffer.js +321 -7
  9. package/bin/node/child_process.js +220 -16
  10. package/bin/node/cluster.js +436 -32
  11. package/bin/node/crypto.js +814 -5
  12. package/bin/node/crypto_curves.js +142 -0
  13. package/bin/node/crypto_keys.js +1147 -48
  14. package/bin/node/crypto_pem.js +313 -0
  15. package/bin/node/crypto_pkcs12.js +17 -0
  16. package/bin/node/dgram.js +161 -10
  17. package/bin/node/diagnostics_channel.js +5 -1
  18. package/bin/node/events.js +358 -8
  19. package/bin/node/ffi.js +933 -0
  20. package/bin/node/fs.js +1346 -10
  21. package/bin/node/histogram.js +1991 -0
  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 +355 -4
  30. package/bin/node/readline.js +558 -8
  31. package/bin/node/registry.js +2 -0
  32. package/bin/node/sqlite.js +1539 -7
  33. package/bin/node/stream.js +371 -32
  34. package/bin/node/stream_web.js +422 -15
  35. package/bin/node/system_extra.js +40 -154
  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 +191 -8
  40. package/bin/node/test_coverage.js +58 -0
  41. package/bin/node/test_report.js +50 -4
  42. package/bin/node/test_run.js +64 -3
  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 +449 -7
  49. package/bin/node/util_extra.js +6 -0
  50. package/bin/node/wasi.js +214 -0
  51. package/bin/node/webassembly.js +1137 -0
  52. package/bin/node/websocket.js +763 -0
  53. package/bin/node/webview.js +3257 -244
  54. package/bin/node/worker_threads.js +434 -52
  55. package/bin/node/zlib.js +455 -22
  56. package/bin/node/zlib_iter.js +585 -0
  57. package/bin/node/zlib_zip.js +2392 -0
  58. package/bin/transpiler.js +3417 -501
  59. package/bin/typecheck-node.js +49 -17
  60. package/bin/version.js +1 -1
  61. package/govendor/github.com/cloudflare/circl/.golangci.yaml +64 -0
  62. package/govendor/github.com/cloudflare/circl/.semgrepignore +1 -0
  63. package/govendor/github.com/cloudflare/circl/AGENTS.md +91 -0
  64. package/govendor/github.com/cloudflare/circl/CITATION.cff +30 -0
  65. package/govendor/github.com/cloudflare/circl/LICENSE +57 -0
  66. package/govendor/github.com/cloudflare/circl/Makefile +70 -0
  67. package/govendor/github.com/cloudflare/circl/README.md +206 -0
  68. package/govendor/github.com/cloudflare/circl/REVIEW.md +83 -0
  69. package/govendor/github.com/cloudflare/circl/codecov.yml +21 -0
  70. package/govendor/github.com/cloudflare/circl/dh/x448/curve.go +104 -0
  71. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.go +30 -0
  72. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.h +111 -0
  73. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.s +194 -0
  74. package/govendor/github.com/cloudflare/circl/dh/x448/curve_generic.go +100 -0
  75. package/govendor/github.com/cloudflare/circl/dh/x448/curve_noasm.go +11 -0
  76. package/govendor/github.com/cloudflare/circl/dh/x448/doc.go +19 -0
  77. package/govendor/github.com/cloudflare/circl/dh/x448/key.go +46 -0
  78. package/govendor/github.com/cloudflare/circl/dh/x448/table.go +460 -0
  79. package/govendor/github.com/cloudflare/circl/doc.go +8 -0
  80. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/constants.go +71 -0
  81. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/curve.go +90 -0
  82. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/isogeny.go +52 -0
  83. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/point.go +181 -0
  84. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/scalar.go +203 -0
  85. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twist.go +138 -0
  86. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twistPoint.go +135 -0
  87. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twistTables.go +216 -0
  88. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twist_basemult.go +62 -0
  89. package/govendor/github.com/cloudflare/circl/go.mod +3 -0
  90. package/govendor/github.com/cloudflare/circl/internal/conv/conv.go +173 -0
  91. package/govendor/github.com/cloudflare/circl/internal/sha3/doc.go +62 -0
  92. package/govendor/github.com/cloudflare/circl/internal/sha3/hashes.go +69 -0
  93. package/govendor/github.com/cloudflare/circl/internal/sha3/keccakf.go +391 -0
  94. package/govendor/github.com/cloudflare/circl/internal/sha3/rc.go +29 -0
  95. package/govendor/github.com/cloudflare/circl/internal/sha3/sha3.go +200 -0
  96. package/govendor/github.com/cloudflare/circl/internal/sha3/sha3_s390x.s +33 -0
  97. package/govendor/github.com/cloudflare/circl/internal/sha3/shake.go +119 -0
  98. package/govendor/github.com/cloudflare/circl/internal/sha3/xor.go +15 -0
  99. package/govendor/github.com/cloudflare/circl/internal/sha3/xor_generic.go +33 -0
  100. package/govendor/github.com/cloudflare/circl/internal/sha3/xor_unaligned.go +61 -0
  101. package/govendor/github.com/cloudflare/circl/math/fp448/fp.go +164 -0
  102. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.go +43 -0
  103. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.h +591 -0
  104. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.s +75 -0
  105. package/govendor/github.com/cloudflare/circl/math/fp448/fp_generic.go +339 -0
  106. package/govendor/github.com/cloudflare/circl/math/fp448/fp_noasm.go +12 -0
  107. package/govendor/github.com/cloudflare/circl/math/fp448/fuzzer.go +75 -0
  108. package/govendor/github.com/cloudflare/circl/math/integer.go +16 -0
  109. package/govendor/github.com/cloudflare/circl/math/mlsbset/mlsbset.go +145 -0
  110. package/govendor/github.com/cloudflare/circl/math/mlsbset/power.go +64 -0
  111. package/govendor/github.com/cloudflare/circl/math/primes.go +34 -0
  112. package/govendor/github.com/cloudflare/circl/math/wnaf.go +84 -0
  113. package/govendor/github.com/cloudflare/circl/sign/ed448/ed448.go +417 -0
  114. package/govendor/github.com/cloudflare/circl/sign/ed448/signapi.go +89 -0
  115. package/govendor/github.com/cloudflare/circl/sign/sign.go +119 -0
  116. package/{examples/react-compiler/vendor/picocolors → govendor/github.com/decred/dcrd/dcrec/secp256k1/v4}/LICENSE +4 -2
  117. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/README.md +72 -0
  118. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/compressedbytepoints.go +18 -0
  119. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve.go +1310 -0
  120. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve_embedded.go +14 -0
  121. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve_precompute.go +14 -0
  122. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/doc.go +59 -0
  123. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdh.go +21 -0
  124. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/README.md +52 -0
  125. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/doc.go +42 -0
  126. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/error.go +134 -0
  127. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/signature.go +1001 -0
  128. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ellipticadaptor.go +296 -0
  129. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/error.go +67 -0
  130. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/field.go +1696 -0
  131. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/go.mod +3 -0
  132. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/loadprecomputed.go +91 -0
  133. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/modnscalar.go +1105 -0
  134. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/nonce.go +263 -0
  135. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/privkey.go +111 -0
  136. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/pubkey.go +236 -0
  137. package/govendor/github.com/ebitengine/purego/LICENSE +201 -0
  138. package/govendor/github.com/ebitengine/purego/README.md +124 -0
  139. package/govendor/github.com/ebitengine/purego/abi_amd64.h +99 -0
  140. package/govendor/github.com/ebitengine/purego/abi_arm64.h +39 -0
  141. package/govendor/github.com/ebitengine/purego/abi_loong64.h +60 -0
  142. package/govendor/github.com/ebitengine/purego/cdecl.go +11 -0
  143. package/govendor/github.com/ebitengine/purego/cgo.go +19 -0
  144. package/govendor/github.com/ebitengine/purego/dlerror.go +17 -0
  145. package/govendor/github.com/ebitengine/purego/dlfcn.go +99 -0
  146. package/govendor/github.com/ebitengine/purego/dlfcn_android.go +34 -0
  147. package/govendor/github.com/ebitengine/purego/dlfcn_darwin.go +20 -0
  148. package/govendor/github.com/ebitengine/purego/dlfcn_freebsd.go +14 -0
  149. package/govendor/github.com/ebitengine/purego/dlfcn_linux.go +16 -0
  150. package/govendor/github.com/ebitengine/purego/dlfcn_netbsd.go +15 -0
  151. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_freebsd.go +11 -0
  152. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_linux.go +19 -0
  153. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_netbsd.go +11 -0
  154. package/govendor/github.com/ebitengine/purego/dlfcn_playground.go +24 -0
  155. package/govendor/github.com/ebitengine/purego/dlfcn_stubs.s +22 -0
  156. package/govendor/github.com/ebitengine/purego/func.go +780 -0
  157. package/govendor/github.com/ebitengine/purego/gen.go +6 -0
  158. package/govendor/github.com/ebitengine/purego/go.mod +3 -0
  159. package/govendor/github.com/ebitengine/purego/go_runtime.go +19 -0
  160. package/govendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go +56 -0
  161. package/govendor/github.com/ebitengine/purego/internal/cgo/empty.go +6 -0
  162. package/govendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go +49 -0
  163. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h +99 -0
  164. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h +39 -0
  165. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_loong64.h +60 -0
  166. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_ppc64x.h +195 -0
  167. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_riscv64.h +72 -0
  168. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_386.s +29 -0
  169. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s +39 -0
  170. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm.s +58 -0
  171. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s +35 -0
  172. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_loong64.s +38 -0
  173. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_ppc64le.s +79 -0
  174. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_riscv64.s +36 -0
  175. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_s390x.s +52 -0
  176. package/govendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go +93 -0
  177. package/govendor/github.com/ebitengine/purego/internal/fakecgo/doc.go +32 -0
  178. package/govendor/github.com/ebitengine/purego/internal/fakecgo/fakecgo.go +14 -0
  179. package/govendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go +27 -0
  180. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin.go +86 -0
  181. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd.go +77 -0
  182. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go +72 -0
  183. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_linux.go +77 -0
  184. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_netbsd.go +83 -0
  185. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go +18 -0
  186. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go +38 -0
  187. package/govendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go +19 -0
  188. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go +37 -0
  189. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go +37 -0
  190. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go +27 -0
  191. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go +27 -0
  192. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_netbsd.go +36 -0
  193. package/govendor/github.com/ebitengine/purego/internal/fakecgo/linux.go +189 -0
  194. package/govendor/github.com/ebitengine/purego/internal/fakecgo/netbsd.go +23 -0
  195. package/govendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go +19 -0
  196. package/govendor/github.com/ebitengine/purego/internal/fakecgo/threadentry_amd64.go +15 -0
  197. package/govendor/github.com/ebitengine/purego/internal/fakecgo/threadentry_noasm.go +24 -0
  198. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_386.s +130 -0
  199. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s +124 -0
  200. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm.s +131 -0
  201. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s +81 -0
  202. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_386.s +78 -0
  203. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_amd64.s +69 -0
  204. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_arm.s +69 -0
  205. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_arm64.s +60 -0
  206. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_loong64.s +60 -0
  207. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_ppc64le.s +69 -0
  208. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_riscv64.s +60 -0
  209. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_s390x.s +51 -0
  210. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_loong64.s +78 -0
  211. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_ppc64le.s +132 -0
  212. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_riscv64.s +76 -0
  213. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_s390x.s +158 -0
  214. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols.go +165 -0
  215. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_darwin.go +59 -0
  216. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_freebsd.go +48 -0
  217. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_linux.go +158 -0
  218. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_netbsd.go +59 -0
  219. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_darwin.s +19 -0
  220. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_freebsd.s +16 -0
  221. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_linux.s +46 -0
  222. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_netbsd.s +19 -0
  223. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_stubs.s +55 -0
  224. package/govendor/github.com/ebitengine/purego/internal/strings/strings.go +40 -0
  225. package/govendor/github.com/ebitengine/purego/is_ios.go +13 -0
  226. package/govendor/github.com/ebitengine/purego/nocgo.go +25 -0
  227. package/govendor/github.com/ebitengine/purego/struct_amd64.go +518 -0
  228. package/govendor/github.com/ebitengine/purego/struct_arm.go +100 -0
  229. package/govendor/github.com/ebitengine/purego/struct_arm64.go +757 -0
  230. package/govendor/github.com/ebitengine/purego/struct_loong64.go +244 -0
  231. package/govendor/github.com/ebitengine/purego/struct_other.go +54 -0
  232. package/govendor/github.com/ebitengine/purego/struct_ppc64le.go +180 -0
  233. package/govendor/github.com/ebitengine/purego/struct_riscv64.go +158 -0
  234. package/govendor/github.com/ebitengine/purego/struct_s390x.go +158 -0
  235. package/govendor/github.com/ebitengine/purego/sys_386.s +153 -0
  236. package/govendor/github.com/ebitengine/purego/sys_amd64.s +206 -0
  237. package/govendor/github.com/ebitengine/purego/sys_arm.s +153 -0
  238. package/govendor/github.com/ebitengine/purego/sys_arm64.s +133 -0
  239. package/govendor/github.com/ebitengine/purego/sys_loong64.s +131 -0
  240. package/govendor/github.com/ebitengine/purego/sys_ppc64le.s +126 -0
  241. package/govendor/github.com/ebitengine/purego/sys_riscv64.s +135 -0
  242. package/govendor/github.com/ebitengine/purego/sys_s390x.s +148 -0
  243. package/govendor/github.com/ebitengine/purego/sys_unix_386.s +234 -0
  244. package/govendor/github.com/ebitengine/purego/sys_unix_arm.s +99 -0
  245. package/govendor/github.com/ebitengine/purego/sys_unix_arm64.s +75 -0
  246. package/govendor/github.com/ebitengine/purego/sys_unix_loong64.s +79 -0
  247. package/govendor/github.com/ebitengine/purego/sys_unix_ppc64le.s +114 -0
  248. package/govendor/github.com/ebitengine/purego/sys_unix_riscv64.s +79 -0
  249. package/govendor/github.com/ebitengine/purego/sys_unix_s390x.s +111 -0
  250. package/govendor/github.com/ebitengine/purego/syscall.go +95 -0
  251. package/govendor/github.com/ebitengine/purego/syscall_32bit.go +97 -0
  252. package/govendor/github.com/ebitengine/purego/syscall_cgo_linux.go +20 -0
  253. package/govendor/github.com/ebitengine/purego/syscall_notstackargs.go +55 -0
  254. package/govendor/github.com/ebitengine/purego/syscall_ppc64le.go +73 -0
  255. package/govendor/github.com/ebitengine/purego/syscall_stackargs_ppc64le.go +38 -0
  256. package/govendor/github.com/ebitengine/purego/syscall_stackargs_s390x.go +38 -0
  257. package/govendor/github.com/ebitengine/purego/syscall_unix.go +392 -0
  258. package/govendor/github.com/ebitengine/purego/syscall_windows.go +54 -0
  259. package/govendor/github.com/ebitengine/purego/zcallback_386.s +4014 -0
  260. package/govendor/github.com/ebitengine/purego/zcallback_amd64.s +2014 -0
  261. package/govendor/github.com/ebitengine/purego/zcallback_arm.s +4014 -0
  262. package/govendor/github.com/ebitengine/purego/zcallback_arm64.s +4014 -0
  263. package/govendor/github.com/ebitengine/purego/zcallback_loong64.s +4014 -0
  264. package/govendor/github.com/ebitengine/purego/zcallback_ppc64le.s +4014 -0
  265. package/govendor/github.com/ebitengine/purego/zcallback_riscv64.s +4051 -0
  266. package/govendor/github.com/ebitengine/purego/zcallback_s390x.s +4015 -0
  267. package/govendor/github.com/klauspost/compress/.gitattributes +3 -0
  268. package/govendor/github.com/klauspost/compress/.goreleaser.yml +132 -0
  269. package/govendor/github.com/klauspost/compress/AGENTS.md +106 -0
  270. package/govendor/github.com/klauspost/compress/LICENSE +304 -0
  271. package/govendor/github.com/klauspost/compress/README.md +766 -0
  272. package/govendor/github.com/klauspost/compress/SECURITY.md +25 -0
  273. package/govendor/github.com/klauspost/compress/compressible.go +85 -0
  274. package/govendor/github.com/klauspost/compress/fse/README.md +79 -0
  275. package/govendor/github.com/klauspost/compress/fse/bitreader.go +122 -0
  276. package/govendor/github.com/klauspost/compress/fse/bitwriter.go +167 -0
  277. package/govendor/github.com/klauspost/compress/fse/bytereader.go +47 -0
  278. package/govendor/github.com/klauspost/compress/fse/compress.go +685 -0
  279. package/govendor/github.com/klauspost/compress/fse/decompress.go +383 -0
  280. package/govendor/github.com/klauspost/compress/fse/fse.go +150 -0
  281. package/govendor/github.com/klauspost/compress/gen.sh +4 -0
  282. package/govendor/github.com/klauspost/compress/go.mod +3 -0
  283. package/govendor/github.com/klauspost/compress/huff0/README.md +89 -0
  284. package/govendor/github.com/klauspost/compress/huff0/bitreader.go +323 -0
  285. package/govendor/github.com/klauspost/compress/huff0/bitwriter.go +97 -0
  286. package/govendor/github.com/klauspost/compress/huff0/build_table.go +168 -0
  287. package/govendor/github.com/klauspost/compress/huff0/compress.go +747 -0
  288. package/govendor/github.com/klauspost/compress/huff0/decompress.go +1188 -0
  289. package/govendor/github.com/klauspost/compress/huff0/decompress_amd64.go +128 -0
  290. package/govendor/github.com/klauspost/compress/huff0/decompress_amd64.s +3476 -0
  291. package/govendor/github.com/klauspost/compress/huff0/decompress_arm64.go +72 -0
  292. package/govendor/github.com/klauspost/compress/huff0/decompress_arm64.s +1648 -0
  293. package/govendor/github.com/klauspost/compress/huff0/decompress_asm.go +252 -0
  294. package/govendor/github.com/klauspost/compress/huff0/decompress_generic.go +278 -0
  295. package/govendor/github.com/klauspost/compress/huff0/huff0.go +337 -0
  296. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo.go +34 -0
  297. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.go +10 -0
  298. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.s +34 -0
  299. package/govendor/github.com/klauspost/compress/internal/le/le.go +5 -0
  300. package/govendor/github.com/klauspost/compress/internal/le/unsafe_disabled.go +42 -0
  301. package/govendor/github.com/klauspost/compress/internal/le/unsafe_enabled.go +52 -0
  302. package/govendor/github.com/klauspost/compress/internal/regmask/regmask.go +50 -0
  303. package/govendor/github.com/klauspost/compress/internal/regmask/regmask_386.go +39 -0
  304. package/govendor/github.com/klauspost/compress/internal/snapref/LICENSE +27 -0
  305. package/govendor/github.com/klauspost/compress/internal/snapref/decode.go +264 -0
  306. package/govendor/github.com/klauspost/compress/internal/snapref/decode_other.go +113 -0
  307. package/govendor/github.com/klauspost/compress/internal/snapref/encode.go +291 -0
  308. package/govendor/github.com/klauspost/compress/internal/snapref/encode_other.go +250 -0
  309. package/govendor/github.com/klauspost/compress/internal/snapref/snappy.go +98 -0
  310. package/govendor/github.com/klauspost/compress/s2sx.mod +3 -0
  311. package/govendor/github.com/klauspost/compress/s2sx.sum +0 -0
  312. package/govendor/github.com/klauspost/compress/zstd/README.md +487 -0
  313. package/govendor/github.com/klauspost/compress/zstd/bitreader.go +176 -0
  314. package/govendor/github.com/klauspost/compress/zstd/bitwriter.go +151 -0
  315. package/govendor/github.com/klauspost/compress/zstd/blockdec.go +728 -0
  316. package/govendor/github.com/klauspost/compress/zstd/blockenc.go +923 -0
  317. package/govendor/github.com/klauspost/compress/zstd/blocktype_string.go +85 -0
  318. package/govendor/github.com/klauspost/compress/zstd/bytebuf.go +131 -0
  319. package/govendor/github.com/klauspost/compress/zstd/bytereader.go +82 -0
  320. package/govendor/github.com/klauspost/compress/zstd/decodeheader.go +261 -0
  321. package/govendor/github.com/klauspost/compress/zstd/decoder.go +995 -0
  322. package/govendor/github.com/klauspost/compress/zstd/decoder_options.go +213 -0
  323. package/govendor/github.com/klauspost/compress/zstd/dict.go +605 -0
  324. package/govendor/github.com/klauspost/compress/zstd/enc_base.go +200 -0
  325. package/govendor/github.com/klauspost/compress/zstd/enc_best.go +572 -0
  326. package/govendor/github.com/klauspost/compress/zstd/enc_better.go +1262 -0
  327. package/govendor/github.com/klauspost/compress/zstd/enc_dfast.go +1136 -0
  328. package/govendor/github.com/klauspost/compress/zstd/enc_fast.go +892 -0
  329. package/govendor/github.com/klauspost/compress/zstd/enc_jobs.go +352 -0
  330. package/govendor/github.com/klauspost/compress/zstd/encoder.go +881 -0
  331. package/govendor/github.com/klauspost/compress/zstd/encoder_options.go +422 -0
  332. package/govendor/github.com/klauspost/compress/zstd/framedec.go +404 -0
  333. package/govendor/github.com/klauspost/compress/zstd/frameenc.go +137 -0
  334. package/govendor/github.com/klauspost/compress/zstd/fse_decoder.go +333 -0
  335. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s +132 -0
  336. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_arm64.s +148 -0
  337. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_asm.go +70 -0
  338. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go +71 -0
  339. package/govendor/github.com/klauspost/compress/zstd/fse_encoder.go +701 -0
  340. package/govendor/github.com/klauspost/compress/zstd/fse_predefined.go +168 -0
  341. package/govendor/github.com/klauspost/compress/zstd/hash.go +57 -0
  342. package/govendor/github.com/klauspost/compress/zstd/history.go +119 -0
  343. package/{examples/react-compiler/vendor/jsesc/LICENSE-MIT.txt → govendor/github.com/klauspost/compress/zstd/internal/xxhash/LICENSE.txt} +3 -1
  344. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/README.md +71 -0
  345. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash.go +242 -0
  346. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_amd64.s +210 -0
  347. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_arm64.s +184 -0
  348. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_asm.go +11 -0
  349. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_other.go +75 -0
  350. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_safe.go +11 -0
  351. package/govendor/github.com/klauspost/compress/zstd/matchlen_amd64.go +15 -0
  352. package/govendor/github.com/klauspost/compress/zstd/matchlen_amd64.s +66 -0
  353. package/govendor/github.com/klauspost/compress/zstd/matchlen_generic.go +37 -0
  354. package/govendor/github.com/klauspost/compress/zstd/seqdec.go +620 -0
  355. package/govendor/github.com/klauspost/compress/zstd/seqdec_amd64.go +115 -0
  356. package/govendor/github.com/klauspost/compress/zstd/seqdec_amd64.s +4762 -0
  357. package/govendor/github.com/klauspost/compress/zstd/seqdec_arm64.go +81 -0
  358. package/govendor/github.com/klauspost/compress/zstd/seqdec_arm64.s +2919 -0
  359. package/govendor/github.com/klauspost/compress/zstd/seqdec_asm.go +327 -0
  360. package/govendor/github.com/klauspost/compress/zstd/seqdec_generic.go +258 -0
  361. package/govendor/github.com/klauspost/compress/zstd/seqenc.go +159 -0
  362. package/govendor/github.com/klauspost/compress/zstd/simple.go +54 -0
  363. package/govendor/github.com/klauspost/compress/zstd/snappy.go +447 -0
  364. package/govendor/github.com/klauspost/compress/zstd/zip.go +141 -0
  365. package/govendor/github.com/klauspost/compress/zstd/zstd.go +126 -0
  366. package/govendor/github.com/tetratelabs/wazero/.editorconfig +7 -0
  367. package/govendor/github.com/tetratelabs/wazero/.gitattributes +2 -0
  368. package/govendor/github.com/tetratelabs/wazero/.gitmodules +3 -0
  369. package/govendor/github.com/tetratelabs/wazero/CONTRIBUTING.md +75 -0
  370. package/govendor/github.com/tetratelabs/wazero/LICENSE +201 -0
  371. package/govendor/github.com/tetratelabs/wazero/Makefile +385 -0
  372. package/govendor/github.com/tetratelabs/wazero/NOTICE +2 -0
  373. package/govendor/github.com/tetratelabs/wazero/RATIONALE.md +1577 -0
  374. package/govendor/github.com/tetratelabs/wazero/README.md +135 -0
  375. package/govendor/github.com/tetratelabs/wazero/api/features.go +228 -0
  376. package/govendor/github.com/tetratelabs/wazero/api/wasm.go +766 -0
  377. package/govendor/github.com/tetratelabs/wazero/builder.go +367 -0
  378. package/govendor/github.com/tetratelabs/wazero/cache.go +123 -0
  379. package/govendor/github.com/tetratelabs/wazero/codecov.yml +9 -0
  380. package/govendor/github.com/tetratelabs/wazero/config.go +899 -0
  381. package/govendor/github.com/tetratelabs/wazero/experimental/checkpoint.go +35 -0
  382. package/govendor/github.com/tetratelabs/wazero/experimental/close.go +63 -0
  383. package/govendor/github.com/tetratelabs/wazero/experimental/compilationworkers.go +19 -0
  384. package/govendor/github.com/tetratelabs/wazero/experimental/experimental.go +41 -0
  385. package/govendor/github.com/tetratelabs/wazero/experimental/features.go +39 -0
  386. package/govendor/github.com/tetratelabs/wazero/experimental/importresolver.go +19 -0
  387. package/govendor/github.com/tetratelabs/wazero/experimental/listener.go +324 -0
  388. package/govendor/github.com/tetratelabs/wazero/experimental/memory.go +52 -0
  389. package/govendor/github.com/tetratelabs/wazero/experimental/sys/dir.go +92 -0
  390. package/govendor/github.com/tetratelabs/wazero/experimental/sys/errno.go +98 -0
  391. package/govendor/github.com/tetratelabs/wazero/experimental/sys/error.go +45 -0
  392. package/govendor/github.com/tetratelabs/wazero/experimental/sys/file.go +356 -0
  393. package/govendor/github.com/tetratelabs/wazero/experimental/sys/fs.go +292 -0
  394. package/govendor/github.com/tetratelabs/wazero/experimental/sys/oflag.go +70 -0
  395. package/govendor/github.com/tetratelabs/wazero/experimental/sys/poll.go +48 -0
  396. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno.go +106 -0
  397. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_notwindows.go +13 -0
  398. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_unsupported.go +7 -0
  399. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_windows.go +37 -0
  400. package/govendor/github.com/tetratelabs/wazero/experimental/sys/time.go +10 -0
  401. package/govendor/github.com/tetratelabs/wazero/experimental/sys/unimplemented.go +160 -0
  402. package/govendor/github.com/tetratelabs/wazero/fsconfig.go +213 -0
  403. package/govendor/github.com/tetratelabs/wazero/go.mod +3 -0
  404. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/args.go +97 -0
  405. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/clock.go +116 -0
  406. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/environ.go +100 -0
  407. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/fs.go +2015 -0
  408. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/poll.go +247 -0
  409. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/proc.go +44 -0
  410. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/random.go +55 -0
  411. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sched.go +22 -0
  412. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sock.go +188 -0
  413. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/wasi.go +314 -0
  414. package/govendor/github.com/tetratelabs/wazero/internal/descriptor/table.go +149 -0
  415. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/compiler.go +3884 -0
  416. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/format.go +22 -0
  417. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/interpreter.go +4963 -0
  418. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/operations.go +2978 -0
  419. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/signature.go +825 -0
  420. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/abi.go +170 -0
  421. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/backend.go +3 -0
  422. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/compiler.go +402 -0
  423. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/compiler_lower.go +226 -0
  424. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/go_call.go +33 -0
  425. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi.go +186 -0
  426. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_amd64.go +9 -0
  427. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_amd64.s +29 -0
  428. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_preamble.go +248 -0
  429. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_go_call.go +440 -0
  430. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/cond.go +168 -0
  431. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/ext.go +35 -0
  432. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/instr.go +2495 -0
  433. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/instr_encoding.go +1714 -0
  434. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/lower_constant.go +71 -0
  435. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/lower_mem.go +187 -0
  436. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine.go +3782 -0
  437. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_pro_epi_logue.go +334 -0
  438. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_regalloc.go +352 -0
  439. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_vec.go +992 -0
  440. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/operands.go +336 -0
  441. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/reg.go +181 -0
  442. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/stack.go +130 -0
  443. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi.go +376 -0
  444. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_arm64.go +9 -0
  445. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_arm64.s +29 -0
  446. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_preamble.go +233 -0
  447. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_go_call.go +430 -0
  448. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/cond.go +215 -0
  449. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/instr.go +2562 -0
  450. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/instr_encoding.go +2357 -0
  451. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_constant.go +301 -0
  452. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_instr.go +2227 -0
  453. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_instr_operands.go +340 -0
  454. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_mem.go +451 -0
  455. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine.go +631 -0
  456. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_pro_epi_logue.go +486 -0
  457. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_regalloc.go +351 -0
  458. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_relocation.go +128 -0
  459. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/reg.go +397 -0
  460. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/unwind_stack.go +84 -0
  461. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/machine.go +119 -0
  462. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/api.go +124 -0
  463. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/reg.go +123 -0
  464. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/regalloc.go +1189 -0
  465. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/regset.go +96 -0
  466. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/vdef.go +19 -0
  467. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/call_engine.go +884 -0
  468. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine.go +1008 -0
  469. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine_cache.go +347 -0
  470. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_amd64.go +13 -0
  471. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_arm64.go +13 -0
  472. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_other.go +15 -0
  473. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/frontend.go +663 -0
  474. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/lower.go +5045 -0
  475. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/misc.go +10 -0
  476. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/sort_id.go +13 -0
  477. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/hostmodule.go +88 -0
  478. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_amd64.go +30 -0
  479. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_arm64.go +32 -0
  480. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_other.go +29 -0
  481. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/memmove.go +11 -0
  482. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/module_engine.go +403 -0
  483. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/basic_block.go +381 -0
  484. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/basic_block_sort.go +32 -0
  485. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/builder.go +790 -0
  486. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/cmp.go +107 -0
  487. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/funcref.go +12 -0
  488. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/instructions.go +3024 -0
  489. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass.go +393 -0
  490. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass_blk_layouts.go +334 -0
  491. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass_cfg.go +313 -0
  492. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/signature.go +49 -0
  493. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/ssa.go +14 -0
  494. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/type.go +115 -0
  495. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/vs.go +114 -0
  496. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/debug_options.go +189 -0
  497. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/exitcode.go +150 -0
  498. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/offsetdata.go +248 -0
  499. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap.go +96 -0
  500. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap_disabled.go +5 -0
  501. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap_enabled.go +5 -0
  502. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/pool.go +215 -0
  503. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/ptr.go +15 -0
  504. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/queue.go +26 -0
  505. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/resetmap.go +11 -0
  506. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/checkpoint.go +10 -0
  507. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/close.go +5 -0
  508. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/compilationworkers.go +6 -0
  509. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/expctxkeys.go +2 -0
  510. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/importresolver.go +6 -0
  511. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/listener.go +7 -0
  512. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/memory.go +4 -0
  513. package/govendor/github.com/tetratelabs/wazero/internal/filecache/compilationcache.go +42 -0
  514. package/govendor/github.com/tetratelabs/wazero/internal/filecache/file_cache.go +76 -0
  515. package/govendor/github.com/tetratelabs/wazero/internal/ieee754/ieee754.go +29 -0
  516. package/govendor/github.com/tetratelabs/wazero/internal/internalapi/internal.go +9 -0
  517. package/govendor/github.com/tetratelabs/wazero/internal/leb128/leb128.go +285 -0
  518. package/govendor/github.com/tetratelabs/wazero/internal/moremath/moremath.go +271 -0
  519. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid.go +26 -0
  520. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_amd64.go +22 -0
  521. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_arm64.go +13 -0
  522. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_unsupported.go +5 -0
  523. package/govendor/github.com/tetratelabs/wazero/internal/platform/crypto.go +17 -0
  524. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_linux.go +72 -0
  525. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_other.go +19 -0
  526. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_unix.go +14 -0
  527. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_unsupported.go +22 -0
  528. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_windows.go +31 -0
  529. package/govendor/github.com/tetratelabs/wazero/internal/platform/path.go +6 -0
  530. package/govendor/github.com/tetratelabs/wazero/internal/platform/path_windows.go +17 -0
  531. package/govendor/github.com/tetratelabs/wazero/internal/platform/platform.go +71 -0
  532. package/govendor/github.com/tetratelabs/wazero/internal/platform/time.go +76 -0
  533. package/govendor/github.com/tetratelabs/wazero/internal/platform/time_notwindows.go +11 -0
  534. package/govendor/github.com/tetratelabs/wazero/internal/platform/time_windows.go +40 -0
  535. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock.go +89 -0
  536. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock_supported.go +11 -0
  537. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock_unsupported.go +10 -0
  538. package/govendor/github.com/tetratelabs/wazero/internal/sys/fs.go +458 -0
  539. package/govendor/github.com/tetratelabs/wazero/internal/sys/lazy.go +135 -0
  540. package/govendor/github.com/tetratelabs/wazero/internal/sys/stdio.go +125 -0
  541. package/govendor/github.com/tetratelabs/wazero/internal/sys/sys.go +228 -0
  542. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/adapter.go +105 -0
  543. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_linux.go +12 -0
  544. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_unsupported.go +14 -0
  545. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/dir.go +24 -0
  546. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/dirfs.go +137 -0
  547. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file.go +576 -0
  548. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_unix.go +39 -0
  549. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_unsupported.go +28 -0
  550. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_windows.go +133 -0
  551. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens.go +29 -0
  552. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go +42 -0
  553. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.s +8 -0
  554. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_linux.go +38 -0
  555. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_unsupported.go +18 -0
  556. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_windows.go +42 -0
  557. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_unix.go +22 -0
  558. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_unsupported.go +17 -0
  559. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_windows.go +28 -0
  560. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unix.go +17 -0
  561. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unsupported.go +13 -0
  562. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_windows.go +23 -0
  563. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/oflag.go +38 -0
  564. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_bsd.go +26 -0
  565. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_darwin.go +26 -0
  566. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_supported.go +30 -0
  567. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_unix.go +20 -0
  568. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_unsupported.go +16 -0
  569. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_windows.go +163 -0
  570. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/osfile.go +318 -0
  571. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll.go +17 -0
  572. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_darwin.go +55 -0
  573. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_darwin.s +8 -0
  574. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_linux.go +57 -0
  575. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_unsupported.go +12 -0
  576. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_windows.go +224 -0
  577. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/readfs.go +117 -0
  578. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_unix.go +16 -0
  579. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_unsupported.go +16 -0
  580. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_windows.go +55 -0
  581. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock.go +186 -0
  582. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_supported.go +76 -0
  583. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go +48 -0
  584. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unsupported.go +79 -0
  585. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_windows.go +80 -0
  586. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat.go +16 -0
  587. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_supported.go +40 -0
  588. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_unsupported.go +40 -0
  589. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_windows.go +118 -0
  590. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sync.go +13 -0
  591. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sync_windows.go +20 -0
  592. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/syscall6_darwin.go +13 -0
  593. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sysfs.go +6 -0
  594. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_unix.go +17 -0
  595. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_unsupported.go +14 -0
  596. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_windows.go +25 -0
  597. package/govendor/github.com/tetratelabs/wazero/internal/u32/u32.go +11 -0
  598. package/govendor/github.com/tetratelabs/wazero/internal/u64/u64.go +15 -0
  599. package/govendor/github.com/tetratelabs/wazero/internal/version/version.go +52 -0
  600. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/args.go +6 -0
  601. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/clock.go +16 -0
  602. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/environ.go +6 -0
  603. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/errno.go +314 -0
  604. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/fs.go +164 -0
  605. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/poll.go +15 -0
  606. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/proc.go +6 -0
  607. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/random.go +3 -0
  608. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/rights.go +148 -0
  609. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/sched.go +3 -0
  610. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/sock.go +71 -0
  611. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/wasi.go +26 -0
  612. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/code.go +124 -0
  613. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/const_expr.go +116 -0
  614. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/custom.go +22 -0
  615. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/data.go +79 -0
  616. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/decoder.go +235 -0
  617. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/element.go +250 -0
  618. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/errors.go +11 -0
  619. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/export.go +32 -0
  620. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/function.go +56 -0
  621. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/global.go +50 -0
  622. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/header.go +9 -0
  623. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/import.go +68 -0
  624. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/limits.go +47 -0
  625. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/memory.go +42 -0
  626. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/names.go +151 -0
  627. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/section.go +309 -0
  628. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/table.go +79 -0
  629. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/value.go +97 -0
  630. package/govendor/github.com/tetratelabs/wazero/internal/wasm/const_expr.go +259 -0
  631. package/govendor/github.com/tetratelabs/wazero/internal/wasm/counts.go +53 -0
  632. package/govendor/github.com/tetratelabs/wazero/internal/wasm/engine.go +76 -0
  633. package/govendor/github.com/tetratelabs/wazero/internal/wasm/exception.go +9 -0
  634. package/govendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go +2804 -0
  635. package/govendor/github.com/tetratelabs/wazero/internal/wasm/function_definition.go +210 -0
  636. package/govendor/github.com/tetratelabs/wazero/internal/wasm/global.go +55 -0
  637. package/govendor/github.com/tetratelabs/wazero/internal/wasm/gofunc.go +279 -0
  638. package/govendor/github.com/tetratelabs/wazero/internal/wasm/host.go +179 -0
  639. package/govendor/github.com/tetratelabs/wazero/internal/wasm/instruction.go +1962 -0
  640. package/govendor/github.com/tetratelabs/wazero/internal/wasm/memory.go +475 -0
  641. package/govendor/github.com/tetratelabs/wazero/internal/wasm/memory_definition.go +128 -0
  642. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module.go +1359 -0
  643. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module_instance.go +251 -0
  644. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module_instance_lookup.go +73 -0
  645. package/govendor/github.com/tetratelabs/wazero/internal/wasm/store.go +726 -0
  646. package/govendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go +95 -0
  647. package/govendor/github.com/tetratelabs/wazero/internal/wasm/table.go +321 -0
  648. package/govendor/github.com/tetratelabs/wazero/internal/wasmdebug/debug.go +170 -0
  649. package/govendor/github.com/tetratelabs/wazero/internal/wasmdebug/dwarf.go +225 -0
  650. package/govendor/github.com/tetratelabs/wazero/internal/wasmruntime/errors.go +54 -0
  651. package/govendor/github.com/tetratelabs/wazero/netlify.toml +15 -0
  652. package/govendor/github.com/tetratelabs/wazero/runtime.go +399 -0
  653. package/govendor/github.com/tetratelabs/wazero/sys/clock.go +26 -0
  654. package/govendor/github.com/tetratelabs/wazero/sys/error.go +83 -0
  655. package/govendor/github.com/tetratelabs/wazero/sys/stat.go +105 -0
  656. package/govendor/github.com/tetratelabs/wazero/sys/stat_bsd.go +29 -0
  657. package/govendor/github.com/tetratelabs/wazero/sys/stat_posix.go +29 -0
  658. package/govendor/github.com/tetratelabs/wazero/sys/stat_unsupported.go +14 -0
  659. package/govendor/github.com/tetratelabs/wazero/sys/stat_windows.go +24 -0
  660. package/govendor/golang.org/x/crypto/LICENSE +27 -0
  661. package/govendor/golang.org/x/crypto/PATENTS +22 -0
  662. package/govendor/golang.org/x/crypto/cryptobyte/asn1/asn1.go +46 -0
  663. package/govendor/golang.org/x/crypto/cryptobyte/asn1.go +825 -0
  664. package/govendor/golang.org/x/crypto/cryptobyte/builder.go +350 -0
  665. package/govendor/golang.org/x/crypto/cryptobyte/string.go +183 -0
  666. package/govendor/golang.org/x/crypto/go.mod +3 -0
  667. package/govendor/golang.org/x/crypto/pbkdf2/pbkdf2.go +30 -0
  668. package/govendor/golang.org/x/net/LICENSE +27 -0
  669. package/govendor/golang.org/x/net/PATENTS +22 -0
  670. package/govendor/golang.org/x/net/dns/dnsmessage/message.go +2733 -0
  671. package/govendor/golang.org/x/net/dns/dnsmessage/svcb.go +333 -0
  672. package/govendor/golang.org/x/net/go.mod +3 -0
  673. package/govendor/golang.org/x/net/http/httpguts/guts.go +50 -0
  674. package/govendor/golang.org/x/net/http/httpguts/httplex.go +347 -0
  675. package/govendor/golang.org/x/net/http2/README.md +19 -0
  676. package/govendor/golang.org/x/net/http2/ascii.go +65 -0
  677. package/govendor/golang.org/x/net/http2/ciphers.go +641 -0
  678. package/govendor/golang.org/x/net/http2/client_conn_pool.go +301 -0
  679. package/govendor/golang.org/x/net/http2/client_priority_go126.go +20 -0
  680. package/govendor/golang.org/x/net/http2/client_priority_go127.go +13 -0
  681. package/govendor/golang.org/x/net/http2/clientconn.go +57 -0
  682. package/govendor/golang.org/x/net/http2/config.go +171 -0
  683. package/govendor/golang.org/x/net/http2/config_go125.go +15 -0
  684. package/govendor/golang.org/x/net/http2/config_go126.go +15 -0
  685. package/govendor/golang.org/x/net/http2/databuffer.go +146 -0
  686. package/govendor/golang.org/x/net/http2/errors.go +145 -0
  687. package/govendor/golang.org/x/net/http2/flow.go +175 -0
  688. package/govendor/golang.org/x/net/http2/frame.go +1887 -0
  689. package/govendor/golang.org/x/net/http2/gotrack.go +181 -0
  690. package/govendor/golang.org/x/net/http2/hpack/encode.go +244 -0
  691. package/govendor/golang.org/x/net/http2/hpack/hpack.go +522 -0
  692. package/govendor/golang.org/x/net/http2/hpack/huffman.go +226 -0
  693. package/govendor/golang.org/x/net/http2/hpack/static_table.go +188 -0
  694. package/govendor/golang.org/x/net/http2/hpack/tables.go +426 -0
  695. package/govendor/golang.org/x/net/http2/http2.go +415 -0
  696. package/govendor/golang.org/x/net/http2/pipe.go +184 -0
  697. package/govendor/golang.org/x/net/http2/server.go +3239 -0
  698. package/govendor/golang.org/x/net/http2/server_common.go +268 -0
  699. package/govendor/golang.org/x/net/http2/server_wrap.go +217 -0
  700. package/govendor/golang.org/x/net/http2/transport.go +3084 -0
  701. package/govendor/golang.org/x/net/http2/transport_common.go +516 -0
  702. package/govendor/golang.org/x/net/http2/transport_wrap.go +583 -0
  703. package/govendor/golang.org/x/net/http2/unencrypted.go +32 -0
  704. package/govendor/golang.org/x/net/http2/write.go +381 -0
  705. package/govendor/golang.org/x/net/http2/writesched.go +253 -0
  706. package/govendor/golang.org/x/net/http2/writesched_common.go +90 -0
  707. package/govendor/golang.org/x/net/http2/writesched_priority_rfc7540.go +420 -0
  708. package/govendor/golang.org/x/net/http2/writesched_priority_rfc9218.go +226 -0
  709. package/govendor/golang.org/x/net/http2/writesched_random.go +81 -0
  710. package/govendor/golang.org/x/net/http2/writesched_roundrobin.go +121 -0
  711. package/govendor/golang.org/x/net/idna/idna.go +884 -0
  712. package/govendor/golang.org/x/net/idna/punycode.go +220 -0
  713. package/govendor/golang.org/x/net/idna/tables15.0.0.go +5144 -0
  714. package/govendor/golang.org/x/net/idna/tables17.0.0.go +5302 -0
  715. package/govendor/golang.org/x/net/idna/trie.go +51 -0
  716. package/govendor/golang.org/x/net/idna/trieval.go +119 -0
  717. package/govendor/golang.org/x/net/internal/httpcommon/README.md +7 -0
  718. package/govendor/golang.org/x/net/internal/httpcommon/ascii.go +53 -0
  719. package/govendor/golang.org/x/net/internal/httpcommon/gzip.go +132 -0
  720. package/govendor/golang.org/x/net/internal/httpcommon/headermap.go +115 -0
  721. package/govendor/golang.org/x/net/internal/httpcommon/request.go +503 -0
  722. package/govendor/golang.org/x/net/internal/httpsfv/httpsfv.go +665 -0
  723. package/govendor/golang.org/x/sys/cpu/asm_aix_ppc64.s +17 -0
  724. package/govendor/golang.org/x/sys/cpu/asm_darwin_arm64_gc.s +12 -0
  725. package/govendor/golang.org/x/sys/cpu/asm_darwin_x86_gc.s +17 -0
  726. package/govendor/golang.org/x/sys/cpu/byteorder.go +66 -0
  727. package/govendor/golang.org/x/sys/cpu/cpu.go +357 -0
  728. package/govendor/golang.org/x/sys/cpu/cpu_aix.go +33 -0
  729. package/govendor/golang.org/x/sys/cpu/cpu_arm.go +73 -0
  730. package/govendor/golang.org/x/sys/cpu/cpu_arm64.go +191 -0
  731. package/govendor/golang.org/x/sys/cpu/cpu_arm64.s +35 -0
  732. package/govendor/golang.org/x/sys/cpu/cpu_darwin_arm64.go +67 -0
  733. package/govendor/golang.org/x/sys/cpu/cpu_darwin_arm64_other.go +31 -0
  734. package/govendor/golang.org/x/sys/cpu/cpu_darwin_x86.go +61 -0
  735. package/govendor/golang.org/x/sys/cpu/cpu_gc_arm64.go +12 -0
  736. package/govendor/golang.org/x/sys/cpu/cpu_gc_riscv64.go +11 -0
  737. package/govendor/golang.org/x/sys/cpu/cpu_gc_s390x.go +21 -0
  738. package/govendor/golang.org/x/sys/cpu/cpu_gc_x86.go +15 -0
  739. package/govendor/golang.org/x/sys/cpu/cpu_gc_x86.s +26 -0
  740. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +12 -0
  741. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go +22 -0
  742. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c +37 -0
  743. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go +25 -0
  744. package/govendor/golang.org/x/sys/cpu/cpu_linux.go +15 -0
  745. package/govendor/golang.org/x/sys/cpu/cpu_linux_arm.go +39 -0
  746. package/govendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +120 -0
  747. package/govendor/golang.org/x/sys/cpu/cpu_linux_loong64.go +22 -0
  748. package/govendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go +22 -0
  749. package/govendor/golang.org/x/sys/cpu/cpu_linux_noinit.go +9 -0
  750. package/govendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go +34 -0
  751. package/govendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go +173 -0
  752. package/govendor/golang.org/x/sys/cpu/cpu_linux_s390x.go +40 -0
  753. package/govendor/golang.org/x/sys/cpu/cpu_loong64.go +62 -0
  754. package/govendor/golang.org/x/sys/cpu/cpu_loong64.s +13 -0
  755. package/govendor/golang.org/x/sys/cpu/cpu_mips64x.go +15 -0
  756. package/govendor/golang.org/x/sys/cpu/cpu_mipsx.go +11 -0
  757. package/govendor/golang.org/x/sys/cpu/cpu_netbsd_amd64.go +47 -0
  758. package/govendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go +173 -0
  759. package/govendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go +65 -0
  760. package/govendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.s +11 -0
  761. package/govendor/golang.org/x/sys/cpu/cpu_other_arm.go +9 -0
  762. package/govendor/golang.org/x/sys/cpu/cpu_other_arm64.go +11 -0
  763. package/govendor/golang.org/x/sys/cpu/cpu_other_mips64x.go +11 -0
  764. package/govendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go +12 -0
  765. package/govendor/golang.org/x/sys/cpu/cpu_other_riscv64.go +11 -0
  766. package/govendor/golang.org/x/sys/cpu/cpu_other_x86.go +11 -0
  767. package/govendor/golang.org/x/sys/cpu/cpu_ppc64x.go +16 -0
  768. package/govendor/golang.org/x/sys/cpu/cpu_riscv64.go +33 -0
  769. package/govendor/golang.org/x/sys/cpu/cpu_riscv64.s +17 -0
  770. package/govendor/golang.org/x/sys/cpu/cpu_s390x.go +172 -0
  771. package/govendor/golang.org/x/sys/cpu/cpu_s390x.s +57 -0
  772. package/govendor/golang.org/x/sys/cpu/cpu_sparc64.go +12 -0
  773. package/govendor/golang.org/x/sys/cpu/cpu_wasm.go +17 -0
  774. package/govendor/golang.org/x/sys/cpu/cpu_windows.go +26 -0
  775. package/govendor/golang.org/x/sys/cpu/cpu_windows_arm64.go +38 -0
  776. package/govendor/golang.org/x/sys/cpu/cpu_x86.go +259 -0
  777. package/govendor/golang.org/x/sys/cpu/cpu_zos.go +10 -0
  778. package/govendor/golang.org/x/sys/cpu/cpu_zos_s390x.go +25 -0
  779. package/govendor/golang.org/x/sys/cpu/endian_big.go +10 -0
  780. package/govendor/golang.org/x/sys/cpu/endian_little.go +10 -0
  781. package/govendor/golang.org/x/sys/cpu/hwcap_linux.go +71 -0
  782. package/govendor/golang.org/x/sys/cpu/parse.go +55 -0
  783. package/govendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go +53 -0
  784. package/govendor/golang.org/x/sys/cpu/runtime_auxv.go +16 -0
  785. package/govendor/golang.org/x/sys/cpu/runtime_auxv_go121.go +18 -0
  786. package/govendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go +26 -0
  787. package/govendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go +35 -0
  788. package/govendor/golang.org/x/sys/cpu/syscall_darwin_arm64_gc.go +54 -0
  789. package/govendor/golang.org/x/sys/cpu/syscall_darwin_x86_gc.go +98 -0
  790. package/govendor/golang.org/x/sys/cpu/zcpu_windows.go +48 -0
  791. package/govendor/golang.org/x/sys/unix/asm_linux_ppc64x.s +20 -0
  792. package/govendor/golang.org/x/sys/unix/asm_linux_sparc64.s +48 -0
  793. package/govendor/golang.org/x/sys/unix/asm_zos_s390x.s +4 -186
  794. package/govendor/golang.org/x/sys/unix/bpxsvc_zos.s +9 -9
  795. package/govendor/golang.org/x/sys/unix/fcntl_darwin.go +2 -2
  796. package/govendor/golang.org/x/sys/unix/mkerrors.sh +1 -1
  797. package/govendor/golang.org/x/sys/unix/ptrace_zos.go +537 -0
  798. package/govendor/golang.org/x/sys/unix/ptrace_zos_singlestep.go +425 -0
  799. package/govendor/golang.org/x/sys/unix/syscall_darwin.go +1 -0
  800. package/govendor/golang.org/x/sys/unix/syscall_freebsd.go +9 -0
  801. package/govendor/golang.org/x/sys/unix/syscall_linux.go +20 -1
  802. package/govendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +3 -3
  803. package/govendor/golang.org/x/sys/unix/syscall_netbsd.go +9 -0
  804. package/govendor/golang.org/x/sys/unix/syscall_unix_gc.go +1 -1
  805. package/govendor/golang.org/x/sys/unix/syscall_zos_s390x.go +0 -4
  806. package/govendor/golang.org/x/sys/unix/xattr_bsd.go +12 -12
  807. package/govendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +6 -0
  808. package/govendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +6 -0
  809. package/govendor/golang.org/x/sys/unix/zerrors_linux.go +32 -0
  810. package/govendor/golang.org/x/sys/unix/zerrors_linux_386.go +2 -0
  811. package/govendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +2 -0
  812. package/govendor/golang.org/x/sys/unix/zerrors_linux_arm.go +2 -0
  813. package/govendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +2 -0
  814. package/govendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +2 -0
  815. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips.go +2 -0
  816. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +2 -0
  817. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +2 -0
  818. package/govendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +2 -0
  819. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +2 -0
  820. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +2 -0
  821. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +2 -0
  822. package/govendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +2 -0
  823. package/govendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +2 -0
  824. package/govendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +2 -0
  825. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +11 -0
  826. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +11 -0
  827. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +159 -0
  828. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +159 -0
  829. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +159 -0
  830. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +159 -0
  831. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go +159 -0
  832. package/govendor/golang.org/x/sys/unix/zsyscall_linux.go +28 -1
  833. package/govendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +3 -3
  834. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +159 -0
  835. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +159 -0
  836. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +159 -0
  837. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +159 -0
  838. package/govendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go +13 -0
  839. package/govendor/golang.org/x/sys/unix/ztypes_linux.go +65 -36
  840. package/govendor/golang.org/x/sys/unix/ztypes_linux_386.go +6 -0
  841. package/govendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +7 -0
  842. package/govendor/golang.org/x/sys/unix/ztypes_linux_arm.go +6 -0
  843. package/govendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +7 -0
  844. package/govendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +7 -0
  845. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips.go +6 -0
  846. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +7 -0
  847. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +7 -0
  848. package/govendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +6 -0
  849. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +6 -0
  850. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +7 -0
  851. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +7 -0
  852. package/govendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +7 -0
  853. package/govendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +7 -0
  854. package/govendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +10 -5
  855. package/govendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +78 -0
  856. package/govendor/golang.org/x/text/.gitattributes +10 -0
  857. package/govendor/golang.org/x/text/CONTRIBUTING.md +26 -0
  858. package/govendor/golang.org/x/text/LICENSE +27 -0
  859. package/govendor/golang.org/x/text/PATENTS +22 -0
  860. package/govendor/golang.org/x/text/README.md +81 -0
  861. package/govendor/golang.org/x/text/cases/cases.go +162 -0
  862. package/govendor/golang.org/x/text/cases/context.go +376 -0
  863. package/govendor/golang.org/x/text/cases/fold.go +34 -0
  864. package/govendor/golang.org/x/text/cases/icu.go +61 -0
  865. package/govendor/golang.org/x/text/cases/info.go +82 -0
  866. package/govendor/golang.org/x/text/cases/map.go +816 -0
  867. package/govendor/golang.org/x/text/cases/tables15.0.0.go +2527 -0
  868. package/govendor/golang.org/x/text/cases/tables17.0.0.go +2642 -0
  869. package/govendor/golang.org/x/text/cases/trieval.go +217 -0
  870. package/govendor/golang.org/x/text/codereview.cfg +1 -0
  871. package/govendor/golang.org/x/text/collate/collate.go +402 -0
  872. package/govendor/golang.org/x/text/collate/index.go +32 -0
  873. package/govendor/golang.org/x/text/collate/option.go +239 -0
  874. package/govendor/golang.org/x/text/collate/sort.go +81 -0
  875. package/govendor/golang.org/x/text/collate/tables.go +73789 -0
  876. package/govendor/golang.org/x/text/currency/common.go +67 -0
  877. package/govendor/golang.org/x/text/currency/currency.go +185 -0
  878. package/govendor/golang.org/x/text/currency/format.go +220 -0
  879. package/govendor/golang.org/x/text/currency/query.go +152 -0
  880. package/govendor/golang.org/x/text/currency/tables.go +2629 -0
  881. package/govendor/golang.org/x/text/doc.go +16 -0
  882. package/govendor/golang.org/x/text/feature/plural/common.go +70 -0
  883. package/govendor/golang.org/x/text/feature/plural/message.go +244 -0
  884. package/govendor/golang.org/x/text/feature/plural/plural.go +262 -0
  885. package/govendor/golang.org/x/text/feature/plural/tables.go +552 -0
  886. package/govendor/golang.org/x/text/go.mod +3 -0
  887. package/govendor/golang.org/x/text/internal/catmsg/catmsg.go +417 -0
  888. package/govendor/golang.org/x/text/internal/catmsg/codec.go +407 -0
  889. package/govendor/golang.org/x/text/internal/catmsg/varint.go +62 -0
  890. package/govendor/golang.org/x/text/internal/colltab/collelem.go +374 -0
  891. package/govendor/golang.org/x/text/internal/colltab/colltab.go +105 -0
  892. package/govendor/golang.org/x/text/internal/colltab/contract.go +145 -0
  893. package/govendor/golang.org/x/text/internal/colltab/iter.go +178 -0
  894. package/govendor/golang.org/x/text/internal/colltab/numeric.go +236 -0
  895. package/govendor/golang.org/x/text/internal/colltab/table.go +275 -0
  896. package/govendor/golang.org/x/text/internal/colltab/trie.go +159 -0
  897. package/govendor/golang.org/x/text/internal/colltab/weighter.go +31 -0
  898. package/govendor/golang.org/x/text/internal/format/format.go +41 -0
  899. package/govendor/golang.org/x/text/internal/format/parser.go +358 -0
  900. package/govendor/golang.org/x/text/internal/internal.go +49 -0
  901. package/govendor/golang.org/x/text/internal/language/common.go +16 -0
  902. package/govendor/golang.org/x/text/internal/language/compact/compact.go +61 -0
  903. package/govendor/golang.org/x/text/internal/language/compact/language.go +260 -0
  904. package/govendor/golang.org/x/text/internal/language/compact/parents.go +120 -0
  905. package/govendor/golang.org/x/text/internal/language/compact/tables.go +1015 -0
  906. package/govendor/golang.org/x/text/internal/language/compact/tags.go +91 -0
  907. package/govendor/golang.org/x/text/internal/language/compact.go +29 -0
  908. package/govendor/golang.org/x/text/internal/language/compose.go +167 -0
  909. package/govendor/golang.org/x/text/internal/language/coverage.go +28 -0
  910. package/govendor/golang.org/x/text/internal/language/language.go +627 -0
  911. package/govendor/golang.org/x/text/internal/language/lookup.go +412 -0
  912. package/govendor/golang.org/x/text/internal/language/match.go +226 -0
  913. package/govendor/golang.org/x/text/internal/language/parse.go +608 -0
  914. package/govendor/golang.org/x/text/internal/language/tables.go +3494 -0
  915. package/govendor/golang.org/x/text/internal/language/tags.go +48 -0
  916. package/govendor/golang.org/x/text/internal/match.go +67 -0
  917. package/govendor/golang.org/x/text/internal/number/common.go +55 -0
  918. package/govendor/golang.org/x/text/internal/number/decimal.go +500 -0
  919. package/govendor/golang.org/x/text/internal/number/format.go +533 -0
  920. package/govendor/golang.org/x/text/internal/number/number.go +152 -0
  921. package/govendor/golang.org/x/text/internal/number/pattern.go +485 -0
  922. package/govendor/golang.org/x/text/internal/number/roundingmode_string.go +30 -0
  923. package/govendor/golang.org/x/text/internal/number/tables.go +1219 -0
  924. package/govendor/golang.org/x/text/internal/stringset/set.go +86 -0
  925. package/govendor/golang.org/x/text/internal/tag/tag.go +100 -0
  926. package/govendor/golang.org/x/text/language/coverage.go +187 -0
  927. package/govendor/golang.org/x/text/language/display/dict.go +92 -0
  928. package/govendor/golang.org/x/text/language/display/display.go +420 -0
  929. package/govendor/golang.org/x/text/language/display/lookup.go +253 -0
  930. package/govendor/golang.org/x/text/language/display/tables.go +53114 -0
  931. package/govendor/golang.org/x/text/language/doc.go +98 -0
  932. package/govendor/golang.org/x/text/language/language.go +605 -0
  933. package/govendor/golang.org/x/text/language/match.go +735 -0
  934. package/govendor/golang.org/x/text/language/parse.go +258 -0
  935. package/govendor/golang.org/x/text/language/tables.go +298 -0
  936. package/govendor/golang.org/x/text/language/tags.go +145 -0
  937. package/govendor/golang.org/x/text/message/catalog/catalog.go +365 -0
  938. package/govendor/golang.org/x/text/message/catalog/dict.go +133 -0
  939. package/govendor/golang.org/x/text/secure/bidirule/bidirule.go +346 -0
  940. package/govendor/golang.org/x/text/transform/transform.go +709 -0
  941. package/govendor/golang.org/x/text/unicode/bidi/bidi.go +359 -0
  942. package/govendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
  943. package/govendor/golang.org/x/text/unicode/bidi/core.go +1050 -0
  944. package/govendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
  945. package/govendor/golang.org/x/text/unicode/bidi/tables15.0.0.go +2042 -0
  946. package/govendor/golang.org/x/text/unicode/bidi/tables17.0.0.go +2135 -0
  947. package/govendor/golang.org/x/text/unicode/bidi/trieval.go +48 -0
  948. package/govendor/golang.org/x/text/unicode/norm/composition.go +524 -0
  949. package/govendor/golang.org/x/text/unicode/norm/forminfo.go +296 -0
  950. package/govendor/golang.org/x/text/unicode/norm/input.go +109 -0
  951. package/govendor/golang.org/x/text/unicode/norm/iter.go +454 -0
  952. package/govendor/golang.org/x/text/unicode/norm/normalize.go +613 -0
  953. package/govendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
  954. package/govendor/golang.org/x/text/unicode/norm/tables15.0.0.go +7907 -0
  955. package/govendor/golang.org/x/text/unicode/norm/tables17.0.0.go +8104 -0
  956. package/govendor/golang.org/x/text/unicode/norm/transform.go +89 -0
  957. package/govendor/golang.org/x/text/unicode/norm/trie.go +54 -0
  958. package/govendor/manifest.txt +11 -2
  959. package/govendor/software.sslmate.com/src/go-pkcs12/.gitattributes +10 -0
  960. package/govendor/software.sslmate.com/src/go-pkcs12/LICENSE +28 -0
  961. package/govendor/software.sslmate.com/src/go-pkcs12/README.md +31 -0
  962. package/govendor/software.sslmate.com/src/go-pkcs12/bmp-string.go +63 -0
  963. package/govendor/software.sslmate.com/src/go-pkcs12/crypto.go +331 -0
  964. package/govendor/software.sslmate.com/src/go-pkcs12/errors.go +23 -0
  965. package/govendor/software.sslmate.com/src/go-pkcs12/go.mod +3 -0
  966. package/govendor/software.sslmate.com/src/go-pkcs12/internal/rc2/rc2.go +271 -0
  967. package/govendor/software.sslmate.com/src/go-pkcs12/mac.go +202 -0
  968. package/govendor/software.sslmate.com/src/go-pkcs12/pbkdf.go +184 -0
  969. package/govendor/software.sslmate.com/src/go-pkcs12/pkcs12.go +1000 -0
  970. package/govendor/software.sslmate.com/src/go-pkcs12/safebags.go +107 -0
  971. package/package.json +11 -1
  972. package/types/tsconfig.json +17 -0
  973. package/types/typenative-npm.d.ts +1327 -80
  974. package/types/typenative.d.ts +1312 -25
  975. package/.gitattributes +0 -1
  976. package/.github/workflows/ci.yml +0 -68
  977. package/.github/workflows/npm-publish-github-packages.yml +0 -88
  978. package/CHANGELOG.md +0 -1358
  979. package/CONTRIBUTION.md +0 -133
  980. package/conformance.md +0 -1450
  981. package/examples/README.md +0 -113
  982. package/examples/angular-templates/README.md +0 -141
  983. package/examples/angular-templates/bench.mjs +0 -173
  984. package/examples/angular-templates/dom-type-globals.d.ts +0 -21
  985. package/examples/angular-templates/dom-type-stubs.ts +0 -21
  986. package/examples/angular-templates/main.ts +0 -135
  987. package/examples/angular-templates/parity.mjs +0 -157
  988. package/examples/angular-templates/run-node.mjs +0 -69
  989. package/examples/angular-templates/vendor/angular/compiler/LICENSE +0 -21
  990. package/examples/desktop-notes/README.md +0 -106
  991. package/examples/desktop-notes/bench.mjs +0 -125
  992. package/examples/desktop-notes/main.ts +0 -131
  993. package/examples/desktop-notes/package-lock.json +0 -726
  994. package/examples/desktop-notes/package.json +0 -9
  995. package/examples/desktop-notes/ui.ts +0 -176
  996. package/examples/dupe-finder/README.md +0 -78
  997. package/examples/dupe-finder/bench.mjs +0 -120
  998. package/examples/dupe-finder/main.ts +0 -87
  999. package/examples/fibonacci/README.md +0 -89
  1000. package/examples/fibonacci/bench.mjs +0 -87
  1001. package/examples/fibonacci/main.ts +0 -21
  1002. package/examples/hello-world/README.md +0 -62
  1003. package/examples/hello-world/bench.mjs +0 -66
  1004. package/examples/hello-world/main.ts +0 -7
  1005. package/examples/json-server/README.md +0 -131
  1006. package/examples/json-server/bench.mjs +0 -263
  1007. package/examples/json-server/main.ts +0 -67
  1008. package/examples/mandelbrot-png/README.md +0 -63
  1009. package/examples/mandelbrot-png/bench.mjs +0 -95
  1010. package/examples/mandelbrot-png/main.ts +0 -98
  1011. package/examples/mandelbrot-png/preview.png +0 -0
  1012. package/examples/marked-cli/README.md +0 -175
  1013. package/examples/marked-cli/bench.mjs +0 -178
  1014. package/examples/marked-cli/main.ts +0 -410
  1015. package/examples/marked-cli/parity.mjs +0 -185
  1016. package/examples/marked-cli/vendor/marked/LICENSE +0 -44
  1017. package/examples/marked-cli/vendor/marked/VENDOR.md +0 -26
  1018. package/examples/openai-chat/README.md +0 -148
  1019. package/examples/openai-chat/bench.mjs +0 -175
  1020. package/examples/openai-chat/main.ts +0 -488
  1021. package/examples/react-compiler/README.md +0 -185
  1022. package/examples/react-compiler/bench.mjs +0 -181
  1023. package/examples/react-compiler/main.ts +0 -324
  1024. package/examples/react-compiler/parity.mjs +0 -362
  1025. package/examples/react-compiler/run-node.mjs +0 -90
  1026. package/examples/react-compiler/vendor/babel/LICENSE +0 -22
  1027. package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-lower.json +0 -15
  1028. package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-upper.json +0 -51
  1029. package/examples/react-compiler/vendor/charcodes/package.json +0 -25
  1030. package/examples/react-compiler/vendor/invariant/LICENSE +0 -21
  1031. package/examples/react-compiler/vendor/invariant/invariant.cjs +0 -51
  1032. package/examples/react-compiler/vendor/invariant/invariant.d.cts +0 -11
  1033. package/examples/react-compiler/vendor/invariant/types/LICENSE +0 -21
  1034. package/examples/react-compiler/vendor/jridgewell/gen-mapping/LICENSE +0 -19
  1035. package/examples/react-compiler/vendor/jridgewell/resolve-uri/LICENSE +0 -19
  1036. package/examples/react-compiler/vendor/jridgewell/sourcemap-codec/LICENSE +0 -19
  1037. package/examples/react-compiler/vendor/jridgewell/trace-mapping/LICENSE +0 -19
  1038. package/examples/react-compiler/vendor/js-tokens/LICENSE +0 -21
  1039. package/examples/react-compiler/vendor/js-tokens/index.cjs +0 -23
  1040. package/examples/react-compiler/vendor/js-tokens/index.d.cts +0 -13
  1041. package/examples/react-compiler/vendor/jsesc/jsesc.cjs +0 -337
  1042. package/examples/react-compiler/vendor/jsesc/jsesc.d.cts +0 -384
  1043. package/examples/react-compiler/vendor/jsesc/types/LICENSE +0 -21
  1044. package/examples/react-compiler/vendor/picocolors/picocolors.cjs +0 -75
  1045. package/examples/react-compiler/vendor/picocolors/picocolors.d.cts +0 -5
  1046. package/examples/react-compiler/vendor/picocolors/types.d.ts +0 -51
  1047. package/examples/react-compiler/vendor/react-compiler/LICENSE +0 -21
  1048. package/examples/react-compiler/vendor/stubs/babel-core.ts +0 -31
  1049. package/examples/react-compiler/vendor/stubs/debug.ts +0 -18
  1050. package/examples/react-compiler/vendor/stubs/js-tokens.d.ts +0 -13
  1051. package/examples/react-compiler/vendor/stubs/pretty-format.ts +0 -18
  1052. package/examples/react-compiler/vendor/zod/LICENSE +0 -21
  1053. package/examples/react-compiler/vendor/zod-validation-error/LICENSE +0 -9
  1054. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/NonEmptyArray.ts +0 -5
  1055. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinPath.ts +0 -49
  1056. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinValues.ts +0 -48
  1057. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/stringify.ts +0 -50
  1058. package/examples/react-compiler/vendor/zod-validation-error/lib/utils/titleCase.ts +0 -6
  1059. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/MessageBuilder.ts +0 -126
  1060. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/ValidationError.ts +0 -39
  1061. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/custom.ts +0 -12
  1062. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/errorMap.ts +0 -78
  1063. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/index.ts +0 -2
  1064. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidElement.ts +0 -12
  1065. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidKey.ts +0 -12
  1066. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidStringFormat.ts +0 -131
  1067. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidType.ts +0 -54
  1068. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidUnion.ts +0 -12
  1069. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidValue.ts +0 -40
  1070. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/notMultipleOf.ts +0 -12
  1071. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooBig.ts +0 -76
  1072. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooSmall.ts +0 -76
  1073. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/types.ts +0 -27
  1074. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/unrecognizedKeys.ts +0 -27
  1075. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromError.ts +0 -13
  1076. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodError.ts +0 -61
  1077. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodIssue.ts +0 -38
  1078. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/index.ts +0 -20
  1079. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationError.ts +0 -5
  1080. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationErrorLike.ts +0 -8
  1081. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isZodErrorLike.ts +0 -11
  1082. package/examples/react-compiler/vendor/zod-validation-error/lib/v4/toValidationError.ts +0 -20
  1083. package/examples/react-compiler/vendor.mjs +0 -688
  1084. package/examples/todo-cli/README.md +0 -69
  1085. package/examples/todo-cli/bench.mjs +0 -89
  1086. package/examples/todo-cli/main.ts +0 -92
  1087. package/examples/yaml-cli/README.md +0 -152
  1088. package/examples/yaml-cli/bench.mjs +0 -265
  1089. package/examples/yaml-cli/main.ts +0 -251
  1090. package/examples/yaml-cli/parity.mjs +0 -156
  1091. package/examples/yaml-cli/vendor/yaml/LICENSE +0 -13
  1092. package/examples/yaml-cli/vendor/yaml/VENDOR.md +0 -25
  1093. package/govendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go +0 -22
  1094. package/govendor/golang.org/x/sys/windows/types_windows_arm.go +0 -35
  1095. package/performance/README.md +0 -196
  1096. package/performance/any-dynamic.ts +0 -21
  1097. package/performance/any-record-view.ts +0 -20
  1098. package/performance/arr-hof.ts +0 -21
  1099. package/performance/arr-push-index.ts +0 -15
  1100. package/performance/arr-sort.ts +0 -21
  1101. package/performance/async-await.ts +0 -24
  1102. package/performance/class-dispatch.ts +0 -52
  1103. package/performance/events-emit.ts +0 -27
  1104. package/performance/exc-throw-rare.ts +0 -25
  1105. package/performance/exc-try-catch.ts +0 -26
  1106. package/performance/fn-closures.ts +0 -29
  1107. package/performance/fn-recursion-tree.ts +0 -31
  1108. package/performance/gen-for-of.ts +0 -46
  1109. package/performance/json-roundtrip.ts +0 -27
  1110. package/performance/map-delete.ts +0 -24
  1111. package/performance/map-string-keys.ts +0 -22
  1112. package/performance/num-arith-loop.ts +0 -14
  1113. package/performance/num-bitwise.ts +0 -21
  1114. package/performance/num-mod-int.ts +0 -16
  1115. package/performance/num-to-string.ts +0 -16
  1116. package/performance/obj-alloc.ts +0 -32
  1117. package/performance/regex-exec.ts +0 -29
  1118. package/performance/regex-site.ts +0 -28
  1119. package/performance/set-ops.ts +0 -20
  1120. package/performance/str-char-scan.ts +0 -35
  1121. package/performance/str-concat-plus.ts +0 -18
  1122. package/performance/str-concat.ts +0 -24
  1123. package/performance/str-short-scan.ts +0 -26
  1124. package/performance/str-split-join.ts +0 -23
  1125. package/performance/str-template.ts +0 -16
  1126. package/performance/union-switch.ts +0 -57
  1127. package/tsparser/check.go +0 -158
  1128. package/tsparser/go.mod +0 -14
  1129. package/tsparser/go.sum +0 -22
  1130. package/tsparser/main.go +0 -363
  1131. package/tsparser/tsparser.exe +0 -4
@@ -0,0 +1,1696 @@
1
+ // Copyright (c) 2013-2014 The btcsuite developers
2
+ // Copyright (c) 2015-2024 The Decred developers
3
+ // Copyright (c) 2013-2024 Dave Collins
4
+ // Use of this source code is governed by an ISC
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package secp256k1
8
+
9
+ // References:
10
+ // [HAC]: Handbook of Applied Cryptography Menezes, van Oorschot, Vanstone.
11
+ // http://cacr.uwaterloo.ca/hac/
12
+
13
+ // All elliptic curve operations for secp256k1 are done in a finite field
14
+ // characterized by a 256-bit prime. Given this precision is larger than the
15
+ // biggest available native type, obviously some form of bignum math is needed.
16
+ // This package implements specialized fixed-precision field arithmetic rather
17
+ // than relying on an arbitrary-precision arithmetic package such as math/big
18
+ // for dealing with the field math since the size is known. As a result, rather
19
+ // large performance gains are achieved by taking advantage of many
20
+ // optimizations not available to arbitrary-precision arithmetic and generic
21
+ // modular arithmetic algorithms.
22
+ //
23
+ // There are various ways to internally represent each finite field element.
24
+ // For example, the most obvious representation would be to use an array of 4
25
+ // uint64s (64 bits * 4 = 256 bits). However, that representation suffers from
26
+ // a couple of issues. First, there is no native Go type large enough to handle
27
+ // the intermediate results while adding or multiplying two 64-bit numbers, and
28
+ // second there is no space left for overflows when performing the intermediate
29
+ // arithmetic between each array element which would lead to expensive carry
30
+ // propagation.
31
+ //
32
+ // Given the above, this implementation represents the field elements as
33
+ // 10 uint32s with each word (array entry) treated as base 2^26. This was
34
+ // chosen for the following reasons:
35
+ // 1) Most systems at the current time are 64-bit (or at least have 64-bit
36
+ // registers available for specialized purposes such as MMX) so the
37
+ // intermediate results can typically be done using a native register (and
38
+ // using uint64s to avoid the need for additional half-word arithmetic)
39
+ // 2) In order to allow addition of the internal words without having to
40
+ // propagate the carry, the max normalized value for each register must
41
+ // be less than the number of bits available in the register
42
+ // 3) Since we're dealing with 32-bit values, 64-bits of overflow is a
43
+ // reasonable choice for #2
44
+ // 4) Given the need for 256-bits of precision and the properties stated in #1,
45
+ // #2, and #3, the representation which best accommodates this is 10 uint32s
46
+ // with base 2^26 (26 bits * 10 = 260 bits, so the final word only needs 22
47
+ // bits) which leaves the desired 64 bits (32 * 10 = 320, 320 - 256 = 64) for
48
+ // overflow
49
+ //
50
+ // Since it is so important that the field arithmetic is extremely fast for high
51
+ // performance crypto, this type does not perform any validation where it
52
+ // ordinarily would. See the documentation for FieldVal for more details.
53
+
54
+ import (
55
+ "encoding/hex"
56
+ )
57
+
58
+ // Constants used to make the code more readable.
59
+ const (
60
+ twoBitsMask = 0x3
61
+ fourBitsMask = 0xf
62
+ sixBitsMask = 0x3f
63
+ eightBitsMask = 0xff
64
+ )
65
+
66
+ // Constants related to the field representation.
67
+ const (
68
+ // fieldWords is the number of words used to internally represent the
69
+ // 256-bit value.
70
+ fieldWords = 10
71
+
72
+ // fieldBase is the exponent used to form the numeric base of each word.
73
+ // 2^(fieldBase*i) where i is the word position.
74
+ fieldBase = 26
75
+
76
+ // fieldBaseMask is the mask for the bits in each word needed to
77
+ // represent the numeric base of each word (except the most significant
78
+ // word).
79
+ fieldBaseMask = (1 << fieldBase) - 1
80
+
81
+ // fieldMSBBits is the number of bits in the most significant word used
82
+ // to represent the value.
83
+ fieldMSBBits = 256 - (fieldBase * (fieldWords - 1))
84
+
85
+ // fieldMSBMask is the mask for the bits in the most significant word
86
+ // needed to represent the value.
87
+ fieldMSBMask = (1 << fieldMSBBits) - 1
88
+
89
+ // These fields provide convenient access to each of the words of the
90
+ // secp256k1 prime in the internal field representation to improve code
91
+ // readability.
92
+ fieldPrimeWordZero = 0x03fffc2f
93
+ fieldPrimeWordOne = 0x03ffffbf
94
+ fieldPrimeWordTwo = 0x03ffffff
95
+ fieldPrimeWordThree = 0x03ffffff
96
+ fieldPrimeWordFour = 0x03ffffff
97
+ fieldPrimeWordFive = 0x03ffffff
98
+ fieldPrimeWordSix = 0x03ffffff
99
+ fieldPrimeWordSeven = 0x03ffffff
100
+ fieldPrimeWordEight = 0x03ffffff
101
+ fieldPrimeWordNine = 0x003fffff
102
+ )
103
+
104
+ // FieldVal implements optimized fixed-precision arithmetic over the
105
+ // secp256k1 finite field. This means all arithmetic is performed modulo
106
+ //
107
+ // 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f.
108
+ //
109
+ // WARNING: Since it is so important for the field arithmetic to be extremely
110
+ // fast for high performance crypto, this type does not perform any validation
111
+ // of documented preconditions where it ordinarily would. As a result, it is
112
+ // IMPERATIVE for callers to understand some key concepts that are described
113
+ // below and ensure the methods are called with the necessary preconditions that
114
+ // each method is documented with. For example, some methods only give the
115
+ // correct result if the field value is normalized and others require the field
116
+ // values involved to have a maximum magnitude and THERE ARE NO EXPLICIT CHECKS
117
+ // TO ENSURE THOSE PRECONDITIONS ARE SATISFIED. This does, unfortunately, make
118
+ // the type more difficult to use correctly and while I typically prefer to
119
+ // ensure all state and input is valid for most code, this is a bit of an
120
+ // exception because those extra checks really add up in what ends up being
121
+ // critical hot paths.
122
+ //
123
+ // The first key concept when working with this type is normalization. In order
124
+ // to avoid the need to propagate a ton of carries, the internal representation
125
+ // provides additional overflow bits for each word of the overall 256-bit value.
126
+ // This means that there are multiple internal representations for the same
127
+ // value and, as a result, any methods that rely on comparison of the value,
128
+ // such as equality and oddness determination, require the caller to provide a
129
+ // normalized value.
130
+ //
131
+ // The second key concept when working with this type is magnitude. As
132
+ // previously mentioned, the internal representation provides additional
133
+ // overflow bits which means that the more math operations that are performed on
134
+ // the field value between normalizations, the more those overflow bits
135
+ // accumulate. The magnitude is effectively that maximum possible number of
136
+ // those overflow bits that could possibly be required as a result of a given
137
+ // operation. Since there are only a limited number of overflow bits available,
138
+ // this implies that the max possible magnitude MUST be tracked by the caller
139
+ // and the caller MUST normalize the field value if a given operation would
140
+ // cause the magnitude of the result to exceed the max allowed value.
141
+ //
142
+ // IMPORTANT: The max allowed magnitude of a field value is 32.
143
+ type FieldVal struct {
144
+ // Each 256-bit value is represented as 10 32-bit integers in base 2^26.
145
+ // This provides 6 bits of overflow in each word (10 bits in the most
146
+ // significant word) for a total of 64 bits of overflow (9*6 + 10 = 64). It
147
+ // only implements the arithmetic needed for elliptic curve operations.
148
+ //
149
+ // The following depicts the internal representation:
150
+ // -----------------------------------------------------------------
151
+ // | n[9] | n[8] | ... | n[0] |
152
+ // | 32 bits available | 32 bits available | ... | 32 bits available |
153
+ // | 22 bits for value | 26 bits for value | ... | 26 bits for value |
154
+ // | 10 bits overflow | 6 bits overflow | ... | 6 bits overflow |
155
+ // | Mult: 2^(26*9) | Mult: 2^(26*8) | ... | Mult: 2^(26*0) |
156
+ // -----------------------------------------------------------------
157
+ //
158
+ // For example, consider the number 2^49 + 1. It would be represented as:
159
+ // n[0] = 1
160
+ // n[1] = 2^23
161
+ // n[2..9] = 0
162
+ //
163
+ // The full 256-bit value is then calculated by looping i from 9..0 and
164
+ // doing sum(n[i] * 2^(26i)) like so:
165
+ // n[9] * 2^(26*9) = 0 * 2^234 = 0
166
+ // n[8] * 2^(26*8) = 0 * 2^208 = 0
167
+ // ...
168
+ // n[1] * 2^(26*1) = 2^23 * 2^26 = 2^49
169
+ // n[0] * 2^(26*0) = 1 * 2^0 = 1
170
+ // Sum: 0 + 0 + ... + 2^49 + 1 = 2^49 + 1
171
+ n [10]uint32
172
+ }
173
+
174
+ // String returns the field value as a normalized human-readable hex string.
175
+ //
176
+ // Preconditions: None
177
+ // Output Normalized: Field is not modified -- same as input value
178
+ // Output Max Magnitude: Field is not modified -- same as input value
179
+ func (f FieldVal) String() string {
180
+ // f is a copy, so it's safe to normalize it without mutating the original.
181
+ f.Normalize()
182
+ return hex.EncodeToString(f.Bytes()[:])
183
+ }
184
+
185
+ // Zero sets the field value to zero in constant time. A newly created field
186
+ // value is already set to zero. This function can be useful to clear an
187
+ // existing field value for reuse.
188
+ //
189
+ // Preconditions: None
190
+ // Output Normalized: Yes
191
+ // Output Max Magnitude: 1
192
+ func (f *FieldVal) Zero() {
193
+ f.n[0] = 0
194
+ f.n[1] = 0
195
+ f.n[2] = 0
196
+ f.n[3] = 0
197
+ f.n[4] = 0
198
+ f.n[5] = 0
199
+ f.n[6] = 0
200
+ f.n[7] = 0
201
+ f.n[8] = 0
202
+ f.n[9] = 0
203
+ }
204
+
205
+ // Set sets the field value equal to the passed value in constant time. The
206
+ // normalization and magnitude of the two fields will be identical.
207
+ //
208
+ // The field value is returned to support chaining. This enables syntax like:
209
+ // f := new(FieldVal).Set(f2).Add(1) so that f = f2 + 1 where f2 is not
210
+ // modified.
211
+ //
212
+ // Preconditions: None
213
+ // Output Normalized: Same as input value
214
+ // Output Max Magnitude: Same as input value
215
+ func (f *FieldVal) Set(val *FieldVal) *FieldVal {
216
+ *f = *val
217
+ return f
218
+ }
219
+
220
+ // SetInt sets the field value to the passed integer in constant time. This is
221
+ // a convenience function since it is fairly common to perform some arithmetic
222
+ // with small native integers.
223
+ //
224
+ // The field value is returned to support chaining. This enables syntax such
225
+ // as f := new(FieldVal).SetInt(2).Mul(f2) so that f = 2 * f2.
226
+ //
227
+ // Preconditions: None
228
+ // Output Normalized: Yes
229
+ // Output Max Magnitude: 1
230
+ func (f *FieldVal) SetInt(ui uint16) *FieldVal {
231
+ f.Zero()
232
+ f.n[0] = uint32(ui)
233
+ return f
234
+ }
235
+
236
+ // SetBytes packs the passed 32-byte big-endian value into the internal field
237
+ // value representation in constant time. SetBytes interprets the provided
238
+ // array as a 256-bit big-endian unsigned integer, packs it into the internal
239
+ // field value representation, and returns either 1 if it is greater than or
240
+ // equal to the field prime (aka it overflowed) or 0 otherwise in constant time.
241
+ //
242
+ // Note that a bool is not used here because it is not possible in Go to convert
243
+ // from a bool to numeric value in constant time and many constant-time
244
+ // operations require a numeric value.
245
+ //
246
+ // Preconditions: None
247
+ // Output Normalized: Yes if no overflow, no otherwise
248
+ // Output Max Magnitude: 1
249
+ func (f *FieldVal) SetBytes(b *[32]byte) uint32 {
250
+ // Pack the 256 total bits across the 10 uint32 words with a max of
251
+ // 26-bits per word. This could be done with a couple of for loops,
252
+ // but this unrolled version is significantly faster. Benchmarks show
253
+ // this is about 34 times faster than the variant which uses loops.
254
+ f.n[0] = uint32(b[31]) | uint32(b[30])<<8 | uint32(b[29])<<16 |
255
+ (uint32(b[28])&twoBitsMask)<<24
256
+ f.n[1] = uint32(b[28])>>2 | uint32(b[27])<<6 | uint32(b[26])<<14 |
257
+ (uint32(b[25])&fourBitsMask)<<22
258
+ f.n[2] = uint32(b[25])>>4 | uint32(b[24])<<4 | uint32(b[23])<<12 |
259
+ (uint32(b[22])&sixBitsMask)<<20
260
+ f.n[3] = uint32(b[22])>>6 | uint32(b[21])<<2 | uint32(b[20])<<10 |
261
+ uint32(b[19])<<18
262
+ f.n[4] = uint32(b[18]) | uint32(b[17])<<8 | uint32(b[16])<<16 |
263
+ (uint32(b[15])&twoBitsMask)<<24
264
+ f.n[5] = uint32(b[15])>>2 | uint32(b[14])<<6 | uint32(b[13])<<14 |
265
+ (uint32(b[12])&fourBitsMask)<<22
266
+ f.n[6] = uint32(b[12])>>4 | uint32(b[11])<<4 | uint32(b[10])<<12 |
267
+ (uint32(b[9])&sixBitsMask)<<20
268
+ f.n[7] = uint32(b[9])>>6 | uint32(b[8])<<2 | uint32(b[7])<<10 |
269
+ uint32(b[6])<<18
270
+ f.n[8] = uint32(b[5]) | uint32(b[4])<<8 | uint32(b[3])<<16 |
271
+ (uint32(b[2])&twoBitsMask)<<24
272
+ f.n[9] = uint32(b[2])>>2 | uint32(b[1])<<6 | uint32(b[0])<<14
273
+
274
+ // The intuition here is that the field value is greater than the prime if
275
+ // one of the higher individual words is greater than corresponding word of
276
+ // the prime and all higher words in the field value are equal to their
277
+ // corresponding word of the prime. Since this type is modulo the prime,
278
+ // being equal is also an overflow back to 0.
279
+ //
280
+ // Note that because the input is 32 bytes and it was just packed into the
281
+ // field representation, the only words that can possibly be greater are
282
+ // zero and one, because ceil(log_2(2^256 - 1 - P)) = 33 bits max and the
283
+ // internal field representation encodes 26 bits with each word.
284
+ //
285
+ // Thus, there is no need to test if the upper words of the field value
286
+ // exceeds them, hence, only equality is checked for them.
287
+ highWordsEq := constantTimeEq(f.n[9], fieldPrimeWordNine)
288
+ highWordsEq &= constantTimeEq(f.n[8], fieldPrimeWordEight)
289
+ highWordsEq &= constantTimeEq(f.n[7], fieldPrimeWordSeven)
290
+ highWordsEq &= constantTimeEq(f.n[6], fieldPrimeWordSix)
291
+ highWordsEq &= constantTimeEq(f.n[5], fieldPrimeWordFive)
292
+ highWordsEq &= constantTimeEq(f.n[4], fieldPrimeWordFour)
293
+ highWordsEq &= constantTimeEq(f.n[3], fieldPrimeWordThree)
294
+ highWordsEq &= constantTimeEq(f.n[2], fieldPrimeWordTwo)
295
+ overflow := highWordsEq & constantTimeGreater(f.n[1], fieldPrimeWordOne)
296
+ highWordsEq &= constantTimeEq(f.n[1], fieldPrimeWordOne)
297
+ overflow |= highWordsEq & constantTimeGreaterOrEq(f.n[0], fieldPrimeWordZero)
298
+
299
+ return overflow
300
+ }
301
+
302
+ // SetByteSlice interprets the provided slice as a 256-bit big-endian unsigned
303
+ // integer (meaning it is truncated to the first 32 bytes), packs it into the
304
+ // internal field value representation, and returns whether or not the resulting
305
+ // truncated 256-bit integer is greater than or equal to the field prime (aka it
306
+ // overflowed) in constant time.
307
+ //
308
+ // Note that since passing a slice with more than 32 bytes is truncated, it is
309
+ // possible that the truncated value is less than the field prime and hence it
310
+ // will not be reported as having overflowed in that case. It is up to the
311
+ // caller to decide whether it needs to provide numbers of the appropriate size
312
+ // or it if is acceptable to use this function with the described truncation and
313
+ // overflow behavior.
314
+ //
315
+ // Preconditions: None
316
+ // Output Normalized: Yes if no overflow, no otherwise
317
+ // Output Max Magnitude: 1
318
+ func (f *FieldVal) SetByteSlice(b []byte) bool {
319
+ var b32 [32]byte
320
+ b = b[:constantTimeMin(uint32(len(b)), 32)]
321
+ copy(b32[:], b32[:32-len(b)])
322
+ copy(b32[32-len(b):], b)
323
+ result := f.SetBytes(&b32)
324
+ zeroArray32(&b32)
325
+ return result != 0
326
+ }
327
+
328
+ // Normalize normalizes the internal field words into the desired range and
329
+ // performs fast modular reduction over the secp256k1 prime by making use of the
330
+ // special form of the prime in constant time.
331
+ //
332
+ // Preconditions: None
333
+ // Output Normalized: Yes
334
+ // Output Max Magnitude: 1
335
+ func (f *FieldVal) Normalize() *FieldVal {
336
+ // The field representation leaves 6 bits of overflow in each word so
337
+ // intermediate calculations can be performed without needing to
338
+ // propagate the carry to each higher word during the calculations. In
339
+ // order to normalize, we need to "compact" the full 256-bit value to
340
+ // the right while propagating any carries through to the high order
341
+ // word.
342
+ //
343
+ // Since this field is doing arithmetic modulo the secp256k1 prime, we
344
+ // also need to perform modular reduction over the prime.
345
+ //
346
+ // Per [HAC] section 14.3.4: Reduction method of moduli of special form,
347
+ // when the modulus is of the special form m = b^t - c, highly efficient
348
+ // reduction can be achieved.
349
+ //
350
+ // The secp256k1 prime is equivalent to 2^256 - 4294968273, so it fits
351
+ // this criteria.
352
+ //
353
+ // 4294968273 in field representation (base 2^26) is:
354
+ // n[0] = 977
355
+ // n[1] = 64
356
+ // That is to say (2^26 * 64) + 977 = 4294968273
357
+ //
358
+ // The algorithm presented in the referenced section typically repeats
359
+ // until the quotient is zero. However, due to our field representation
360
+ // we already know to within one reduction how many times we would need
361
+ // to repeat as it's the uppermost bits of the high order word. Thus we
362
+ // can simply multiply the magnitude by the field representation of the
363
+ // prime and do a single iteration. After this step there might be an
364
+ // additional carry to bit 256 (bit 22 of the high order word).
365
+ t9 := f.n[9]
366
+ m := t9 >> fieldMSBBits
367
+ t9 &= fieldMSBMask
368
+ t0 := f.n[0] + m*977
369
+ t1 := (t0 >> fieldBase) + f.n[1] + (m << 6)
370
+ t0 &= fieldBaseMask
371
+ t2 := (t1 >> fieldBase) + f.n[2]
372
+ t1 &= fieldBaseMask
373
+ t3 := (t2 >> fieldBase) + f.n[3]
374
+ t2 &= fieldBaseMask
375
+ t4 := (t3 >> fieldBase) + f.n[4]
376
+ t3 &= fieldBaseMask
377
+ t5 := (t4 >> fieldBase) + f.n[5]
378
+ t4 &= fieldBaseMask
379
+ t6 := (t5 >> fieldBase) + f.n[6]
380
+ t5 &= fieldBaseMask
381
+ t7 := (t6 >> fieldBase) + f.n[7]
382
+ t6 &= fieldBaseMask
383
+ t8 := (t7 >> fieldBase) + f.n[8]
384
+ t7 &= fieldBaseMask
385
+ t9 = (t8 >> fieldBase) + t9
386
+ t8 &= fieldBaseMask
387
+
388
+ // At this point, the magnitude is guaranteed to be one, however, the
389
+ // value could still be greater than the prime if there was either a
390
+ // carry through to bit 256 (bit 22 of the higher order word) or the
391
+ // value is greater than or equal to the field characteristic. The
392
+ // following determines if either or these conditions are true and does
393
+ // the final reduction in constant time.
394
+ //
395
+ // Also note that 'm' will be zero when neither of the aforementioned
396
+ // conditions are true and the value will not be changed when 'm' is zero.
397
+ m = constantTimeEq(t9, fieldMSBMask)
398
+ m &= constantTimeEq(t8&t7&t6&t5&t4&t3&t2, fieldBaseMask)
399
+ m &= constantTimeGreater(t1+64+((t0+977)>>fieldBase), fieldBaseMask)
400
+ m |= t9 >> fieldMSBBits
401
+ t0 += m * 977
402
+ t1 = (t0 >> fieldBase) + t1 + (m << 6)
403
+ t0 &= fieldBaseMask
404
+ t2 = (t1 >> fieldBase) + t2
405
+ t1 &= fieldBaseMask
406
+ t3 = (t2 >> fieldBase) + t3
407
+ t2 &= fieldBaseMask
408
+ t4 = (t3 >> fieldBase) + t4
409
+ t3 &= fieldBaseMask
410
+ t5 = (t4 >> fieldBase) + t5
411
+ t4 &= fieldBaseMask
412
+ t6 = (t5 >> fieldBase) + t6
413
+ t5 &= fieldBaseMask
414
+ t7 = (t6 >> fieldBase) + t7
415
+ t6 &= fieldBaseMask
416
+ t8 = (t7 >> fieldBase) + t8
417
+ t7 &= fieldBaseMask
418
+ t9 = (t8 >> fieldBase) + t9
419
+ t8 &= fieldBaseMask
420
+ t9 &= fieldMSBMask // Remove potential multiple of 2^256.
421
+
422
+ // Finally, set the normalized and reduced words.
423
+ f.n[0] = t0
424
+ f.n[1] = t1
425
+ f.n[2] = t2
426
+ f.n[3] = t3
427
+ f.n[4] = t4
428
+ f.n[5] = t5
429
+ f.n[6] = t6
430
+ f.n[7] = t7
431
+ f.n[8] = t8
432
+ f.n[9] = t9
433
+ return f
434
+ }
435
+
436
+ // PutBytesUnchecked unpacks the field value to a 32-byte big-endian value
437
+ // directly into the passed byte slice in constant time. The target slice must
438
+ // have at least 32 bytes available or it will panic.
439
+ //
440
+ // There is a similar function, PutBytes, which unpacks the field value into a
441
+ // 32-byte array directly. This version is provided since it can be useful
442
+ // to write directly into part of a larger buffer without needing a separate
443
+ // allocation.
444
+ //
445
+ // Preconditions:
446
+ // - The field value MUST be normalized
447
+ // - The target slice MUST have at least 32 bytes available
448
+ func (f *FieldVal) PutBytesUnchecked(b []byte) {
449
+ // Unpack the 256 total bits from the 10 uint32 words with a max of
450
+ // 26-bits per word. This could be done with a couple of for loops,
451
+ // but this unrolled version is a bit faster. Benchmarks show this is
452
+ // about 10 times faster than the variant which uses loops.
453
+ b[31] = byte(f.n[0] & eightBitsMask)
454
+ b[30] = byte((f.n[0] >> 8) & eightBitsMask)
455
+ b[29] = byte((f.n[0] >> 16) & eightBitsMask)
456
+ b[28] = byte((f.n[0]>>24)&twoBitsMask | (f.n[1]&sixBitsMask)<<2)
457
+ b[27] = byte((f.n[1] >> 6) & eightBitsMask)
458
+ b[26] = byte((f.n[1] >> 14) & eightBitsMask)
459
+ b[25] = byte((f.n[1]>>22)&fourBitsMask | (f.n[2]&fourBitsMask)<<4)
460
+ b[24] = byte((f.n[2] >> 4) & eightBitsMask)
461
+ b[23] = byte((f.n[2] >> 12) & eightBitsMask)
462
+ b[22] = byte((f.n[2]>>20)&sixBitsMask | (f.n[3]&twoBitsMask)<<6)
463
+ b[21] = byte((f.n[3] >> 2) & eightBitsMask)
464
+ b[20] = byte((f.n[3] >> 10) & eightBitsMask)
465
+ b[19] = byte((f.n[3] >> 18) & eightBitsMask)
466
+ b[18] = byte(f.n[4] & eightBitsMask)
467
+ b[17] = byte((f.n[4] >> 8) & eightBitsMask)
468
+ b[16] = byte((f.n[4] >> 16) & eightBitsMask)
469
+ b[15] = byte((f.n[4]>>24)&twoBitsMask | (f.n[5]&sixBitsMask)<<2)
470
+ b[14] = byte((f.n[5] >> 6) & eightBitsMask)
471
+ b[13] = byte((f.n[5] >> 14) & eightBitsMask)
472
+ b[12] = byte((f.n[5]>>22)&fourBitsMask | (f.n[6]&fourBitsMask)<<4)
473
+ b[11] = byte((f.n[6] >> 4) & eightBitsMask)
474
+ b[10] = byte((f.n[6] >> 12) & eightBitsMask)
475
+ b[9] = byte((f.n[6]>>20)&sixBitsMask | (f.n[7]&twoBitsMask)<<6)
476
+ b[8] = byte((f.n[7] >> 2) & eightBitsMask)
477
+ b[7] = byte((f.n[7] >> 10) & eightBitsMask)
478
+ b[6] = byte((f.n[7] >> 18) & eightBitsMask)
479
+ b[5] = byte(f.n[8] & eightBitsMask)
480
+ b[4] = byte((f.n[8] >> 8) & eightBitsMask)
481
+ b[3] = byte((f.n[8] >> 16) & eightBitsMask)
482
+ b[2] = byte((f.n[8]>>24)&twoBitsMask | (f.n[9]&sixBitsMask)<<2)
483
+ b[1] = byte((f.n[9] >> 6) & eightBitsMask)
484
+ b[0] = byte((f.n[9] >> 14) & eightBitsMask)
485
+ }
486
+
487
+ // PutBytes unpacks the field value to a 32-byte big-endian value using the
488
+ // passed byte array in constant time.
489
+ //
490
+ // There is a similar function, PutBytesUnchecked, which unpacks the field value
491
+ // into a slice that must have at least 32 bytes available. This version is
492
+ // provided since it can be useful to write directly into an array that is type
493
+ // checked.
494
+ //
495
+ // Alternatively, there is also Bytes, which unpacks the field value into a new
496
+ // array and returns that which can sometimes be more ergonomic in applications
497
+ // that aren't concerned about an additional copy.
498
+ //
499
+ // Preconditions:
500
+ // - The field value MUST be normalized
501
+ func (f *FieldVal) PutBytes(b *[32]byte) {
502
+ f.PutBytesUnchecked(b[:])
503
+ }
504
+
505
+ // Bytes unpacks the field value to a 32-byte big-endian value in constant time.
506
+ //
507
+ // See PutBytes and PutBytesUnchecked for variants that allow an array or slice
508
+ // to be passed which can be useful to cut down on the number of allocations by
509
+ // allowing the caller to reuse a buffer or write directly into part of a larger
510
+ // buffer.
511
+ //
512
+ // Preconditions:
513
+ // - The field value MUST be normalized
514
+ func (f *FieldVal) Bytes() *[32]byte {
515
+ b := new([32]byte)
516
+ f.PutBytesUnchecked(b[:])
517
+ return b
518
+ }
519
+
520
+ // IsZeroBit returns 1 when the field value is equal to zero or 0 otherwise in
521
+ // constant time.
522
+ //
523
+ // Note that a bool is not used here because it is not possible in Go to convert
524
+ // from a bool to numeric value in constant time and many constant-time
525
+ // operations require a numeric value. See IsZero for the version that returns
526
+ // a bool.
527
+ //
528
+ // Preconditions:
529
+ // - The field value MUST be normalized
530
+ func (f *FieldVal) IsZeroBit() uint32 {
531
+ // The value can only be zero if no bits are set in any of the words.
532
+ // This is a constant time implementation.
533
+ bits := f.n[0] | f.n[1] | f.n[2] | f.n[3] | f.n[4] |
534
+ f.n[5] | f.n[6] | f.n[7] | f.n[8] | f.n[9]
535
+
536
+ return constantTimeEq(bits, 0)
537
+ }
538
+
539
+ // IsZero returns whether or not the field value is equal to zero in constant
540
+ // time.
541
+ //
542
+ // Preconditions:
543
+ // - The field value MUST be normalized
544
+ func (f *FieldVal) IsZero() bool {
545
+ // The value can only be zero if no bits are set in any of the words.
546
+ // This is a constant time implementation.
547
+ bits := f.n[0] | f.n[1] | f.n[2] | f.n[3] | f.n[4] |
548
+ f.n[5] | f.n[6] | f.n[7] | f.n[8] | f.n[9]
549
+
550
+ return bits == 0
551
+ }
552
+
553
+ // IsOneBit returns 1 when the field value is equal to one or 0 otherwise in
554
+ // constant time.
555
+ //
556
+ // Note that a bool is not used here because it is not possible in Go to convert
557
+ // from a bool to numeric value in constant time and many constant-time
558
+ // operations require a numeric value. See IsOne for the version that returns a
559
+ // bool.
560
+ //
561
+ // Preconditions:
562
+ // - The field value MUST be normalized
563
+ func (f *FieldVal) IsOneBit() uint32 {
564
+ // The value can only be one if the single lowest significant bit is set in
565
+ // the first word and no other bits are set in any of the other words.
566
+ // This is a constant time implementation.
567
+ bits := (f.n[0] ^ 1) | f.n[1] | f.n[2] | f.n[3] | f.n[4] | f.n[5] |
568
+ f.n[6] | f.n[7] | f.n[8] | f.n[9]
569
+
570
+ return constantTimeEq(bits, 0)
571
+ }
572
+
573
+ // IsOne returns whether or not the field value is equal to one in constant
574
+ // time.
575
+ //
576
+ // Preconditions:
577
+ // - The field value MUST be normalized
578
+ func (f *FieldVal) IsOne() bool {
579
+ // The value can only be one if the single lowest significant bit is set in
580
+ // the first word and no other bits are set in any of the other words.
581
+ // This is a constant time implementation.
582
+ bits := (f.n[0] ^ 1) | f.n[1] | f.n[2] | f.n[3] | f.n[4] | f.n[5] |
583
+ f.n[6] | f.n[7] | f.n[8] | f.n[9]
584
+
585
+ return bits == 0
586
+ }
587
+
588
+ // IsOddBit returns 1 when the field value is an odd number or 0 otherwise in
589
+ // constant time.
590
+ //
591
+ // Note that a bool is not used here because it is not possible in Go to convert
592
+ // from a bool to numeric value in constant time and many constant-time
593
+ // operations require a numeric value. See IsOdd for the version that returns a
594
+ // bool.
595
+ //
596
+ // Preconditions:
597
+ // - The field value MUST be normalized
598
+ func (f *FieldVal) IsOddBit() uint32 {
599
+ // Only odd numbers have the bottom bit set.
600
+ return f.n[0] & 1
601
+ }
602
+
603
+ // IsOdd returns whether or not the field value is an odd number in constant
604
+ // time.
605
+ //
606
+ // Preconditions:
607
+ // - The field value MUST be normalized
608
+ func (f *FieldVal) IsOdd() bool {
609
+ // Only odd numbers have the bottom bit set.
610
+ return f.n[0]&1 == 1
611
+ }
612
+
613
+ // Equals returns whether or not the two field values are the same in constant
614
+ // time.
615
+ //
616
+ // Preconditions:
617
+ // - Both field values being compared MUST be normalized
618
+ func (f *FieldVal) Equals(val *FieldVal) bool {
619
+ // Xor only sets bits when they are different, so the two field values
620
+ // can only be the same if no bits are set after xoring each word.
621
+ // This is a constant time implementation.
622
+ bits := (f.n[0] ^ val.n[0]) | (f.n[1] ^ val.n[1]) | (f.n[2] ^ val.n[2]) |
623
+ (f.n[3] ^ val.n[3]) | (f.n[4] ^ val.n[4]) | (f.n[5] ^ val.n[5]) |
624
+ (f.n[6] ^ val.n[6]) | (f.n[7] ^ val.n[7]) | (f.n[8] ^ val.n[8]) |
625
+ (f.n[9] ^ val.n[9])
626
+
627
+ return bits == 0
628
+ }
629
+
630
+ // NegateVal negates the passed value and stores the result in f in constant
631
+ // time. The caller must provide the maximum magnitude of the passed value for
632
+ // a correct result.
633
+ //
634
+ // The field value is returned to support chaining. This enables syntax like:
635
+ // f.NegateVal(f2).AddInt(1) so that f = -f2 + 1.
636
+ //
637
+ // Preconditions:
638
+ // - The max magnitude MUST be 31
639
+ // Output Normalized: No
640
+ // Output Max Magnitude: Input magnitude + 1
641
+ func (f *FieldVal) NegateVal(val *FieldVal, magnitude uint32) *FieldVal {
642
+ // Negation in the field is just the prime minus the value. However,
643
+ // in order to allow negation against a field value without having to
644
+ // normalize/reduce it first, multiply by the magnitude (that is how
645
+ // "far" away it is from the normalized value) to adjust. Also, since
646
+ // negating a value pushes it one more order of magnitude away from the
647
+ // normalized range, add 1 to compensate.
648
+ //
649
+ // For some intuition here, imagine you're performing mod 12 arithmetic
650
+ // (picture a clock) and you are negating the number 7. So you start at
651
+ // 12 (which is of course 0 under mod 12) and count backwards (left on
652
+ // the clock) 7 times to arrive at 5. Notice this is just 12-7 = 5.
653
+ // Now, assume you're starting with 19, which is a number that is
654
+ // already larger than the modulus and congruent to 7 (mod 12). When a
655
+ // value is already in the desired range, its magnitude is 1. Since 19
656
+ // is an additional "step", its magnitude (mod 12) is 2. Since any
657
+ // multiple of the modulus is congruent to zero (mod m), the answer can
658
+ // be shortcut by simply multiplying the magnitude by the modulus and
659
+ // subtracting. Keeping with the example, this would be (2*12)-19 = 5.
660
+ f.n[0] = (magnitude+1)*fieldPrimeWordZero - val.n[0]
661
+ f.n[1] = (magnitude+1)*fieldPrimeWordOne - val.n[1]
662
+ f.n[2] = (magnitude+1)*fieldBaseMask - val.n[2]
663
+ f.n[3] = (magnitude+1)*fieldBaseMask - val.n[3]
664
+ f.n[4] = (magnitude+1)*fieldBaseMask - val.n[4]
665
+ f.n[5] = (magnitude+1)*fieldBaseMask - val.n[5]
666
+ f.n[6] = (magnitude+1)*fieldBaseMask - val.n[6]
667
+ f.n[7] = (magnitude+1)*fieldBaseMask - val.n[7]
668
+ f.n[8] = (magnitude+1)*fieldBaseMask - val.n[8]
669
+ f.n[9] = (magnitude+1)*fieldMSBMask - val.n[9]
670
+
671
+ return f
672
+ }
673
+
674
+ // Negate negates the field value in constant time. The existing field value is
675
+ // modified. The caller must provide the maximum magnitude of the field value
676
+ // for a correct result.
677
+ //
678
+ // The field value is returned to support chaining. This enables syntax like:
679
+ // f.Negate().AddInt(1) so that f = -f + 1.
680
+ //
681
+ // Preconditions:
682
+ // - The max magnitude MUST be 31
683
+ // Output Normalized: No
684
+ // Output Max Magnitude: Input magnitude + 1
685
+ func (f *FieldVal) Negate(magnitude uint32) *FieldVal {
686
+ return f.NegateVal(f, magnitude)
687
+ }
688
+
689
+ // AddInt adds the passed integer to the existing field value and stores the
690
+ // result in f in constant time. This is a convenience function since it is
691
+ // fairly common to perform some arithmetic with small native integers.
692
+ //
693
+ // The field value is returned to support chaining. This enables syntax like:
694
+ // f.AddInt(1).Add(f2) so that f = f + 1 + f2.
695
+ //
696
+ // Preconditions:
697
+ // - The field value MUST have a max magnitude of 31
698
+ // - The integer MUST be a max of 32767
699
+ // Output Normalized: No
700
+ // Output Max Magnitude: Existing field magnitude + 1
701
+ func (f *FieldVal) AddInt(ui uint16) *FieldVal {
702
+ // Since the field representation intentionally provides overflow bits,
703
+ // it's ok to use carryless addition as the carry bit is safely part of
704
+ // the word and will be normalized out.
705
+ f.n[0] += uint32(ui)
706
+
707
+ return f
708
+ }
709
+
710
+ // Add adds the passed value to the existing field value and stores the result
711
+ // in f in constant time.
712
+ //
713
+ // The field value is returned to support chaining. This enables syntax like:
714
+ // f.Add(f2).AddInt(1) so that f = f + f2 + 1.
715
+ //
716
+ // Preconditions:
717
+ // - The sum of the magnitudes of the two field values MUST be a max of 32
718
+ // Output Normalized: No
719
+ // Output Max Magnitude: Sum of the magnitude of the two individual field values
720
+ func (f *FieldVal) Add(val *FieldVal) *FieldVal {
721
+ // Since the field representation intentionally provides overflow bits,
722
+ // it's ok to use carryless addition as the carry bit is safely part of
723
+ // each word and will be normalized out. This could obviously be done
724
+ // in a loop, but the unrolled version is faster.
725
+ f.n[0] += val.n[0]
726
+ f.n[1] += val.n[1]
727
+ f.n[2] += val.n[2]
728
+ f.n[3] += val.n[3]
729
+ f.n[4] += val.n[4]
730
+ f.n[5] += val.n[5]
731
+ f.n[6] += val.n[6]
732
+ f.n[7] += val.n[7]
733
+ f.n[8] += val.n[8]
734
+ f.n[9] += val.n[9]
735
+
736
+ return f
737
+ }
738
+
739
+ // Add2 adds the passed two field values together and stores the result in f in
740
+ // constant time.
741
+ //
742
+ // The field value is returned to support chaining. This enables syntax like:
743
+ // f3.Add2(f, f2).AddInt(1) so that f3 = f + f2 + 1.
744
+ //
745
+ // Preconditions:
746
+ // - The sum of the magnitudes of the two field values MUST be a max of 32
747
+ // Output Normalized: No
748
+ // Output Max Magnitude: Sum of the magnitude of the two field values
749
+ func (f *FieldVal) Add2(val *FieldVal, val2 *FieldVal) *FieldVal {
750
+ // Since the field representation intentionally provides overflow bits,
751
+ // it's ok to use carryless addition as the carry bit is safely part of
752
+ // each word and will be normalized out. This could obviously be done
753
+ // in a loop, but the unrolled version is faster.
754
+ f.n[0] = val.n[0] + val2.n[0]
755
+ f.n[1] = val.n[1] + val2.n[1]
756
+ f.n[2] = val.n[2] + val2.n[2]
757
+ f.n[3] = val.n[3] + val2.n[3]
758
+ f.n[4] = val.n[4] + val2.n[4]
759
+ f.n[5] = val.n[5] + val2.n[5]
760
+ f.n[6] = val.n[6] + val2.n[6]
761
+ f.n[7] = val.n[7] + val2.n[7]
762
+ f.n[8] = val.n[8] + val2.n[8]
763
+ f.n[9] = val.n[9] + val2.n[9]
764
+
765
+ return f
766
+ }
767
+
768
+ // MulInt multiplies the field value by the passed int and stores the result in
769
+ // f in constant time. Note that this function can overflow if multiplying the
770
+ // value by any of the individual words exceeds a max uint32. Therefore it is
771
+ // important that the caller ensures no overflows will occur before using this
772
+ // function.
773
+ //
774
+ // The field value is returned to support chaining. This enables syntax like:
775
+ // f.MulInt(2).Add(f2) so that f = 2 * f + f2.
776
+ //
777
+ // Preconditions:
778
+ // - The field value magnitude multiplied by given val MUST be a max of 32
779
+ // Output Normalized: No
780
+ // Output Max Magnitude: Existing field magnitude times the provided integer val
781
+ func (f *FieldVal) MulInt(val uint8) *FieldVal {
782
+ // Since each word of the field representation can hold up to
783
+ // 32 - fieldBase extra bits which will be normalized out, it's safe
784
+ // to multiply each word without using a larger type or carry
785
+ // propagation so long as the values won't overflow a uint32. This
786
+ // could obviously be done in a loop, but the unrolled version is
787
+ // faster.
788
+ ui := uint32(val)
789
+ f.n[0] *= ui
790
+ f.n[1] *= ui
791
+ f.n[2] *= ui
792
+ f.n[3] *= ui
793
+ f.n[4] *= ui
794
+ f.n[5] *= ui
795
+ f.n[6] *= ui
796
+ f.n[7] *= ui
797
+ f.n[8] *= ui
798
+ f.n[9] *= ui
799
+
800
+ return f
801
+ }
802
+
803
+ // Mul multiplies the passed value to the existing field value and stores the
804
+ // result in f in constant time. Note that this function can overflow if
805
+ // multiplying any of the individual words exceeds a max uint32. In practice,
806
+ // this means the magnitude of either value involved in the multiplication must
807
+ // be a max of 8.
808
+ //
809
+ // The field value is returned to support chaining. This enables syntax like:
810
+ // f.Mul(f2).AddInt(1) so that f = (f * f2) + 1.
811
+ //
812
+ // Preconditions:
813
+ // - Both field values MUST have a max magnitude of 8
814
+ // Output Normalized: No
815
+ // Output Max Magnitude: 1
816
+ func (f *FieldVal) Mul(val *FieldVal) *FieldVal {
817
+ return f.Mul2(f, val)
818
+ }
819
+
820
+ // Mul2 multiplies the passed two field values together and stores the result in
821
+ // f in constant time. Note that this function can overflow if multiplying any
822
+ // of the individual words exceeds a max uint32. In practice, this means the
823
+ // magnitude of either value involved in the multiplication must be a max of 8.
824
+ //
825
+ // The field value is returned to support chaining. This enables syntax like:
826
+ // f3.Mul2(f, f2).AddInt(1) so that f3 = (f * f2) + 1.
827
+ //
828
+ // Preconditions:
829
+ // - Both input field values MUST have a max magnitude of 8
830
+ // Output Normalized: No
831
+ // Output Max Magnitude: 1
832
+ func (f *FieldVal) Mul2(val *FieldVal, val2 *FieldVal) *FieldVal {
833
+ // This could be done with a couple of for loops and an array to store
834
+ // the intermediate terms, but this unrolled version is significantly
835
+ // faster.
836
+
837
+ // Terms for 2^(fieldBase*0).
838
+ m := uint64(val.n[0]) * uint64(val2.n[0])
839
+ t0 := m & fieldBaseMask
840
+
841
+ // Terms for 2^(fieldBase*1).
842
+ m = (m >> fieldBase) +
843
+ uint64(val.n[0])*uint64(val2.n[1]) +
844
+ uint64(val.n[1])*uint64(val2.n[0])
845
+ t1 := m & fieldBaseMask
846
+
847
+ // Terms for 2^(fieldBase*2).
848
+ m = (m >> fieldBase) +
849
+ uint64(val.n[0])*uint64(val2.n[2]) +
850
+ uint64(val.n[1])*uint64(val2.n[1]) +
851
+ uint64(val.n[2])*uint64(val2.n[0])
852
+ t2 := m & fieldBaseMask
853
+
854
+ // Terms for 2^(fieldBase*3).
855
+ m = (m >> fieldBase) +
856
+ uint64(val.n[0])*uint64(val2.n[3]) +
857
+ uint64(val.n[1])*uint64(val2.n[2]) +
858
+ uint64(val.n[2])*uint64(val2.n[1]) +
859
+ uint64(val.n[3])*uint64(val2.n[0])
860
+ t3 := m & fieldBaseMask
861
+
862
+ // Terms for 2^(fieldBase*4).
863
+ m = (m >> fieldBase) +
864
+ uint64(val.n[0])*uint64(val2.n[4]) +
865
+ uint64(val.n[1])*uint64(val2.n[3]) +
866
+ uint64(val.n[2])*uint64(val2.n[2]) +
867
+ uint64(val.n[3])*uint64(val2.n[1]) +
868
+ uint64(val.n[4])*uint64(val2.n[0])
869
+ t4 := m & fieldBaseMask
870
+
871
+ // Terms for 2^(fieldBase*5).
872
+ m = (m >> fieldBase) +
873
+ uint64(val.n[0])*uint64(val2.n[5]) +
874
+ uint64(val.n[1])*uint64(val2.n[4]) +
875
+ uint64(val.n[2])*uint64(val2.n[3]) +
876
+ uint64(val.n[3])*uint64(val2.n[2]) +
877
+ uint64(val.n[4])*uint64(val2.n[1]) +
878
+ uint64(val.n[5])*uint64(val2.n[0])
879
+ t5 := m & fieldBaseMask
880
+
881
+ // Terms for 2^(fieldBase*6).
882
+ m = (m >> fieldBase) +
883
+ uint64(val.n[0])*uint64(val2.n[6]) +
884
+ uint64(val.n[1])*uint64(val2.n[5]) +
885
+ uint64(val.n[2])*uint64(val2.n[4]) +
886
+ uint64(val.n[3])*uint64(val2.n[3]) +
887
+ uint64(val.n[4])*uint64(val2.n[2]) +
888
+ uint64(val.n[5])*uint64(val2.n[1]) +
889
+ uint64(val.n[6])*uint64(val2.n[0])
890
+ t6 := m & fieldBaseMask
891
+
892
+ // Terms for 2^(fieldBase*7).
893
+ m = (m >> fieldBase) +
894
+ uint64(val.n[0])*uint64(val2.n[7]) +
895
+ uint64(val.n[1])*uint64(val2.n[6]) +
896
+ uint64(val.n[2])*uint64(val2.n[5]) +
897
+ uint64(val.n[3])*uint64(val2.n[4]) +
898
+ uint64(val.n[4])*uint64(val2.n[3]) +
899
+ uint64(val.n[5])*uint64(val2.n[2]) +
900
+ uint64(val.n[6])*uint64(val2.n[1]) +
901
+ uint64(val.n[7])*uint64(val2.n[0])
902
+ t7 := m & fieldBaseMask
903
+
904
+ // Terms for 2^(fieldBase*8).
905
+ m = (m >> fieldBase) +
906
+ uint64(val.n[0])*uint64(val2.n[8]) +
907
+ uint64(val.n[1])*uint64(val2.n[7]) +
908
+ uint64(val.n[2])*uint64(val2.n[6]) +
909
+ uint64(val.n[3])*uint64(val2.n[5]) +
910
+ uint64(val.n[4])*uint64(val2.n[4]) +
911
+ uint64(val.n[5])*uint64(val2.n[3]) +
912
+ uint64(val.n[6])*uint64(val2.n[2]) +
913
+ uint64(val.n[7])*uint64(val2.n[1]) +
914
+ uint64(val.n[8])*uint64(val2.n[0])
915
+ t8 := m & fieldBaseMask
916
+
917
+ // Terms for 2^(fieldBase*9).
918
+ m = (m >> fieldBase) +
919
+ uint64(val.n[0])*uint64(val2.n[9]) +
920
+ uint64(val.n[1])*uint64(val2.n[8]) +
921
+ uint64(val.n[2])*uint64(val2.n[7]) +
922
+ uint64(val.n[3])*uint64(val2.n[6]) +
923
+ uint64(val.n[4])*uint64(val2.n[5]) +
924
+ uint64(val.n[5])*uint64(val2.n[4]) +
925
+ uint64(val.n[6])*uint64(val2.n[3]) +
926
+ uint64(val.n[7])*uint64(val2.n[2]) +
927
+ uint64(val.n[8])*uint64(val2.n[1]) +
928
+ uint64(val.n[9])*uint64(val2.n[0])
929
+ t9 := m & fieldBaseMask
930
+
931
+ // Terms for 2^(fieldBase*10).
932
+ m = (m >> fieldBase) +
933
+ uint64(val.n[1])*uint64(val2.n[9]) +
934
+ uint64(val.n[2])*uint64(val2.n[8]) +
935
+ uint64(val.n[3])*uint64(val2.n[7]) +
936
+ uint64(val.n[4])*uint64(val2.n[6]) +
937
+ uint64(val.n[5])*uint64(val2.n[5]) +
938
+ uint64(val.n[6])*uint64(val2.n[4]) +
939
+ uint64(val.n[7])*uint64(val2.n[3]) +
940
+ uint64(val.n[8])*uint64(val2.n[2]) +
941
+ uint64(val.n[9])*uint64(val2.n[1])
942
+ t10 := m & fieldBaseMask
943
+
944
+ // Terms for 2^(fieldBase*11).
945
+ m = (m >> fieldBase) +
946
+ uint64(val.n[2])*uint64(val2.n[9]) +
947
+ uint64(val.n[3])*uint64(val2.n[8]) +
948
+ uint64(val.n[4])*uint64(val2.n[7]) +
949
+ uint64(val.n[5])*uint64(val2.n[6]) +
950
+ uint64(val.n[6])*uint64(val2.n[5]) +
951
+ uint64(val.n[7])*uint64(val2.n[4]) +
952
+ uint64(val.n[8])*uint64(val2.n[3]) +
953
+ uint64(val.n[9])*uint64(val2.n[2])
954
+ t11 := m & fieldBaseMask
955
+
956
+ // Terms for 2^(fieldBase*12).
957
+ m = (m >> fieldBase) +
958
+ uint64(val.n[3])*uint64(val2.n[9]) +
959
+ uint64(val.n[4])*uint64(val2.n[8]) +
960
+ uint64(val.n[5])*uint64(val2.n[7]) +
961
+ uint64(val.n[6])*uint64(val2.n[6]) +
962
+ uint64(val.n[7])*uint64(val2.n[5]) +
963
+ uint64(val.n[8])*uint64(val2.n[4]) +
964
+ uint64(val.n[9])*uint64(val2.n[3])
965
+ t12 := m & fieldBaseMask
966
+
967
+ // Terms for 2^(fieldBase*13).
968
+ m = (m >> fieldBase) +
969
+ uint64(val.n[4])*uint64(val2.n[9]) +
970
+ uint64(val.n[5])*uint64(val2.n[8]) +
971
+ uint64(val.n[6])*uint64(val2.n[7]) +
972
+ uint64(val.n[7])*uint64(val2.n[6]) +
973
+ uint64(val.n[8])*uint64(val2.n[5]) +
974
+ uint64(val.n[9])*uint64(val2.n[4])
975
+ t13 := m & fieldBaseMask
976
+
977
+ // Terms for 2^(fieldBase*14).
978
+ m = (m >> fieldBase) +
979
+ uint64(val.n[5])*uint64(val2.n[9]) +
980
+ uint64(val.n[6])*uint64(val2.n[8]) +
981
+ uint64(val.n[7])*uint64(val2.n[7]) +
982
+ uint64(val.n[8])*uint64(val2.n[6]) +
983
+ uint64(val.n[9])*uint64(val2.n[5])
984
+ t14 := m & fieldBaseMask
985
+
986
+ // Terms for 2^(fieldBase*15).
987
+ m = (m >> fieldBase) +
988
+ uint64(val.n[6])*uint64(val2.n[9]) +
989
+ uint64(val.n[7])*uint64(val2.n[8]) +
990
+ uint64(val.n[8])*uint64(val2.n[7]) +
991
+ uint64(val.n[9])*uint64(val2.n[6])
992
+ t15 := m & fieldBaseMask
993
+
994
+ // Terms for 2^(fieldBase*16).
995
+ m = (m >> fieldBase) +
996
+ uint64(val.n[7])*uint64(val2.n[9]) +
997
+ uint64(val.n[8])*uint64(val2.n[8]) +
998
+ uint64(val.n[9])*uint64(val2.n[7])
999
+ t16 := m & fieldBaseMask
1000
+
1001
+ // Terms for 2^(fieldBase*17).
1002
+ m = (m >> fieldBase) +
1003
+ uint64(val.n[8])*uint64(val2.n[9]) +
1004
+ uint64(val.n[9])*uint64(val2.n[8])
1005
+ t17 := m & fieldBaseMask
1006
+
1007
+ // Terms for 2^(fieldBase*18).
1008
+ m = (m >> fieldBase) + uint64(val.n[9])*uint64(val2.n[9])
1009
+ t18 := m & fieldBaseMask
1010
+
1011
+ // What's left is for 2^(fieldBase*19).
1012
+ t19 := m >> fieldBase
1013
+
1014
+ // At this point, all of the terms are grouped into their respective
1015
+ // base.
1016
+ //
1017
+ // Per [HAC] section 14.3.4: Reduction method of moduli of special form,
1018
+ // when the modulus is of the special form m = b^t - c, highly efficient
1019
+ // reduction can be achieved per the provided algorithm.
1020
+ //
1021
+ // The secp256k1 prime is equivalent to 2^256 - 4294968273, so it fits
1022
+ // this criteria.
1023
+ //
1024
+ // 4294968273 in field representation (base 2^26) is:
1025
+ // n[0] = 977
1026
+ // n[1] = 64
1027
+ // That is to say (2^26 * 64) + 977 = 4294968273
1028
+ //
1029
+ // Since each word is in base 26, the upper terms (t10 and up) start
1030
+ // at 260 bits (versus the final desired range of 256 bits), so the
1031
+ // field representation of 'c' from above needs to be adjusted for the
1032
+ // extra 4 bits by multiplying it by 2^4 = 16. 4294968273 * 16 =
1033
+ // 68719492368. Thus, the adjusted field representation of 'c' is:
1034
+ // n[0] = 977 * 16 = 15632
1035
+ // n[1] = 64 * 16 = 1024
1036
+ // That is to say (2^26 * 1024) + 15632 = 68719492368
1037
+ //
1038
+ // To reduce the final term, t19, the entire 'c' value is needed instead
1039
+ // of only n[0] because there are no more terms left to handle n[1].
1040
+ // This means there might be some magnitude left in the upper bits that
1041
+ // is handled below.
1042
+ m = t0 + t10*15632
1043
+ t0 = m & fieldBaseMask
1044
+ m = (m >> fieldBase) + t1 + t10*1024 + t11*15632
1045
+ t1 = m & fieldBaseMask
1046
+ m = (m >> fieldBase) + t2 + t11*1024 + t12*15632
1047
+ t2 = m & fieldBaseMask
1048
+ m = (m >> fieldBase) + t3 + t12*1024 + t13*15632
1049
+ t3 = m & fieldBaseMask
1050
+ m = (m >> fieldBase) + t4 + t13*1024 + t14*15632
1051
+ t4 = m & fieldBaseMask
1052
+ m = (m >> fieldBase) + t5 + t14*1024 + t15*15632
1053
+ t5 = m & fieldBaseMask
1054
+ m = (m >> fieldBase) + t6 + t15*1024 + t16*15632
1055
+ t6 = m & fieldBaseMask
1056
+ m = (m >> fieldBase) + t7 + t16*1024 + t17*15632
1057
+ t7 = m & fieldBaseMask
1058
+ m = (m >> fieldBase) + t8 + t17*1024 + t18*15632
1059
+ t8 = m & fieldBaseMask
1060
+ m = (m >> fieldBase) + t9 + t18*1024 + t19*68719492368
1061
+ t9 = m & fieldMSBMask
1062
+ m >>= fieldMSBBits
1063
+
1064
+ // At this point, if the magnitude is greater than 0, the overall value
1065
+ // is greater than the max possible 256-bit value. In particular, it is
1066
+ // "how many times larger" than the max value it is.
1067
+ //
1068
+ // The algorithm presented in [HAC] section 14.3.4 repeats until the
1069
+ // quotient is zero. However, due to the above, we already know at
1070
+ // least how many times we would need to repeat as it's the value
1071
+ // currently in m. Thus we can simply multiply the magnitude by the
1072
+ // field representation of the prime and do a single iteration. Notice
1073
+ // that nothing will be changed when the magnitude is zero, so we could
1074
+ // skip this in that case, however always running regardless allows it
1075
+ // to run in constant time. The final result will be in the range
1076
+ // 0 <= result <= prime + (2^64 - c), so it is guaranteed to have a
1077
+ // magnitude of 1, but it is denormalized.
1078
+ d := t0 + m*977
1079
+ f.n[0] = uint32(d & fieldBaseMask)
1080
+ d = (d >> fieldBase) + t1 + m*64
1081
+ f.n[1] = uint32(d & fieldBaseMask)
1082
+ f.n[2] = uint32((d >> fieldBase) + t2)
1083
+ f.n[3] = uint32(t3)
1084
+ f.n[4] = uint32(t4)
1085
+ f.n[5] = uint32(t5)
1086
+ f.n[6] = uint32(t6)
1087
+ f.n[7] = uint32(t7)
1088
+ f.n[8] = uint32(t8)
1089
+ f.n[9] = uint32(t9)
1090
+
1091
+ return f
1092
+ }
1093
+
1094
+ // SquareRootVal either calculates the square root of the passed value when it
1095
+ // exists or the square root of the negation of the value when it does not exist
1096
+ // and stores the result in f in constant time. The return flag is true when
1097
+ // the calculated square root is for the passed value itself and false when it
1098
+ // is for its negation.
1099
+ //
1100
+ // Note that this function can overflow if multiplying any of the individual
1101
+ // words exceeds a max uint32. In practice, this means the magnitude of the
1102
+ // field must be a max of 8 to prevent overflow. The magnitude of the result
1103
+ // will be 1.
1104
+ //
1105
+ // Preconditions:
1106
+ // - The input field value MUST have a max magnitude of 8
1107
+ // Output Normalized: No
1108
+ // Output Max Magnitude: 1
1109
+ func (f *FieldVal) SquareRootVal(val *FieldVal) bool {
1110
+ // This uses the Tonelli-Shanks method for calculating the square root of
1111
+ // the value when it exists. The key principles of the method follow.
1112
+ //
1113
+ // Fermat's little theorem states that for a nonzero number 'a' and prime
1114
+ // 'p', a^(p-1) ≡ 1 (mod p).
1115
+ //
1116
+ // Further, Euler's criterion states that an integer 'a' has a square root
1117
+ // (aka is a quadratic residue) modulo a prime if a^((p-1)/2) ≡ 1 (mod p)
1118
+ // and, conversely, when it does NOT have a square root (aka 'a' is a
1119
+ // non-residue) a^((p-1)/2) ≡ -1 (mod p).
1120
+ //
1121
+ // This can be seen by considering that Fermat's little theorem can be
1122
+ // written as (a^((p-1)/2) - 1)(a^((p-1)/2) + 1) ≡ 0 (mod p). Therefore,
1123
+ // one of the two factors must be 0. Then, when a ≡ x^2 (aka 'a' is a
1124
+ // quadratic residue), (x^2)^((p-1)/2) ≡ x^(p-1) ≡ 1 (mod p) which implies
1125
+ // the first factor must be zero. Finally, per Lagrange's theorem, the
1126
+ // non-residues are the only remaining possible solutions and thus must make
1127
+ // the second factor zero to satisfy Fermat's little theorem implying that
1128
+ // a^((p-1)/2) ≡ -1 (mod p) for that case.
1129
+ //
1130
+ // The Tonelli-Shanks method uses these facts along with factoring out
1131
+ // powers of two to solve a congruence that results in either the solution
1132
+ // when the square root exists or the square root of the negation of the
1133
+ // value when it does not. In the case of primes that are ≡ 3 (mod 4), the
1134
+ // possible solutions are r = ±a^((p+1)/4) (mod p). Therefore, either r^2 ≡
1135
+ // a (mod p) is true in which case ±r are the two solutions, or r^2 ≡ -a
1136
+ // (mod p) in which case 'a' is a non-residue and there are no solutions.
1137
+ //
1138
+ // The secp256k1 prime is ≡ 3 (mod 4), so this result applies.
1139
+ //
1140
+ // In other words, calculate a^((p+1)/4) and then square it and check it
1141
+ // against the original value to determine if it is actually the square
1142
+ // root.
1143
+ //
1144
+ // In order to efficiently compute a^((p+1)/4), (p+1)/4 needs to be split
1145
+ // into a sequence of squares and multiplications that minimizes the number
1146
+ // of multiplications needed (since they are more costly than squarings).
1147
+ //
1148
+ // The secp256k1 prime + 1 / 4 is 2^254 - 2^30 - 244. In binary, that is:
1149
+ //
1150
+ // 00111111 11111111 11111111 11111111
1151
+ // 11111111 11111111 11111111 11111111
1152
+ // 11111111 11111111 11111111 11111111
1153
+ // 11111111 11111111 11111111 11111111
1154
+ // 11111111 11111111 11111111 11111111
1155
+ // 11111111 11111111 11111111 11111111
1156
+ // 11111111 11111111 11111111 11111111
1157
+ // 10111111 11111111 11111111 00001100
1158
+ //
1159
+ // Notice that can be broken up into three windows of consecutive 1s (in
1160
+ // order of least to most significant) as:
1161
+ //
1162
+ // 6-bit window with two bits set (bits 4, 5, 6, 7 unset)
1163
+ // 23-bit window with 22 bits set (bit 30 unset)
1164
+ // 223-bit window with all 223 bits set
1165
+ //
1166
+ // Thus, the groups of 1 bits in each window forms the set:
1167
+ // S = {2, 22, 223}.
1168
+ //
1169
+ // The strategy is to calculate a^(2^n - 1) for each grouping via an
1170
+ // addition chain with a sliding window.
1171
+ //
1172
+ // The addition chain used is (credits to Peter Dettman):
1173
+ // (0,0),(1,0),(2,2),(3,2),(4,1),(5,5),(6,6),(7,7),(8,8),(9,7),(10,2)
1174
+ // => 2^1 2^[2] 2^3 2^6 2^9 2^11 2^[22] 2^44 2^88 2^176 2^220 2^[223]
1175
+ //
1176
+ // This has a cost of 254 field squarings and 13 field multiplications.
1177
+ var a, a2, a3, a6, a9, a11, a22, a44, a88, a176, a220, a223 FieldVal
1178
+ a.Set(val)
1179
+ a2.SquareVal(&a).Mul(&a) // a2 = a^(2^2 - 1)
1180
+ a3.SquareVal(&a2).Mul(&a) // a3 = a^(2^3 - 1)
1181
+ a6.SquareVal(&a3).Square().Square() // a6 = a^(2^6 - 2^3)
1182
+ a6.Mul(&a3) // a6 = a^(2^6 - 1)
1183
+ a9.SquareVal(&a6).Square().Square() // a9 = a^(2^9 - 2^3)
1184
+ a9.Mul(&a3) // a9 = a^(2^9 - 1)
1185
+ a11.SquareVal(&a9).Square() // a11 = a^(2^11 - 2^2)
1186
+ a11.Mul(&a2) // a11 = a^(2^11 - 1)
1187
+ a22.SquareVal(&a11).Square().Square().Square().Square() // a22 = a^(2^16 - 2^5)
1188
+ a22.Square().Square().Square().Square().Square() // a22 = a^(2^21 - 2^10)
1189
+ a22.Square() // a22 = a^(2^22 - 2^11)
1190
+ a22.Mul(&a11) // a22 = a^(2^22 - 1)
1191
+ a44.SquareVal(&a22).Square().Square().Square().Square() // a44 = a^(2^27 - 2^5)
1192
+ a44.Square().Square().Square().Square().Square() // a44 = a^(2^32 - 2^10)
1193
+ a44.Square().Square().Square().Square().Square() // a44 = a^(2^37 - 2^15)
1194
+ a44.Square().Square().Square().Square().Square() // a44 = a^(2^42 - 2^20)
1195
+ a44.Square().Square() // a44 = a^(2^44 - 2^22)
1196
+ a44.Mul(&a22) // a44 = a^(2^44 - 1)
1197
+ a88.SquareVal(&a44).Square().Square().Square().Square() // a88 = a^(2^49 - 2^5)
1198
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^54 - 2^10)
1199
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^59 - 2^15)
1200
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^64 - 2^20)
1201
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^69 - 2^25)
1202
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^74 - 2^30)
1203
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^79 - 2^35)
1204
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^84 - 2^40)
1205
+ a88.Square().Square().Square().Square() // a88 = a^(2^88 - 2^44)
1206
+ a88.Mul(&a44) // a88 = a^(2^88 - 1)
1207
+ a176.SquareVal(&a88).Square().Square().Square().Square() // a176 = a^(2^93 - 2^5)
1208
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^98 - 2^10)
1209
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^103 - 2^15)
1210
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^108 - 2^20)
1211
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^113 - 2^25)
1212
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^118 - 2^30)
1213
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^123 - 2^35)
1214
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^128 - 2^40)
1215
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^133 - 2^45)
1216
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^138 - 2^50)
1217
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^143 - 2^55)
1218
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^148 - 2^60)
1219
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^153 - 2^65)
1220
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^158 - 2^70)
1221
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^163 - 2^75)
1222
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^168 - 2^80)
1223
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^173 - 2^85)
1224
+ a176.Square().Square().Square() // a176 = a^(2^176 - 2^88)
1225
+ a176.Mul(&a88) // a176 = a^(2^176 - 1)
1226
+ a220.SquareVal(&a176).Square().Square().Square().Square() // a220 = a^(2^181 - 2^5)
1227
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^186 - 2^10)
1228
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^191 - 2^15)
1229
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^196 - 2^20)
1230
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^201 - 2^25)
1231
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^206 - 2^30)
1232
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^211 - 2^35)
1233
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^216 - 2^40)
1234
+ a220.Square().Square().Square().Square() // a220 = a^(2^220 - 2^44)
1235
+ a220.Mul(&a44) // a220 = a^(2^220 - 1)
1236
+ a223.SquareVal(&a220).Square().Square() // a223 = a^(2^223 - 2^3)
1237
+ a223.Mul(&a3) // a223 = a^(2^223 - 1)
1238
+
1239
+ f.SquareVal(&a223).Square().Square().Square().Square() // f = a^(2^228 - 2^5)
1240
+ f.Square().Square().Square().Square().Square() // f = a^(2^233 - 2^10)
1241
+ f.Square().Square().Square().Square().Square() // f = a^(2^238 - 2^15)
1242
+ f.Square().Square().Square().Square().Square() // f = a^(2^243 - 2^20)
1243
+ f.Square().Square().Square() // f = a^(2^246 - 2^23)
1244
+ f.Mul(&a22) // f = a^(2^246 - 2^22 - 1)
1245
+ f.Square().Square().Square().Square().Square() // f = a^(2^251 - 2^27 - 2^5)
1246
+ f.Square() // f = a^(2^252 - 2^28 - 2^6)
1247
+ f.Mul(&a2) // f = a^(2^252 - 2^28 - 2^6 - 2^1 - 1)
1248
+ f.Square().Square() // f = a^(2^254 - 2^30 - 2^8 - 2^3 - 2^2)
1249
+ // // = a^(2^254 - 2^30 - 244)
1250
+ // // = a^((p+1)/4)
1251
+
1252
+ // Ensure the calculated result is actually the square root by squaring it
1253
+ // and checking against the original value.
1254
+ var sqr FieldVal
1255
+ return sqr.SquareVal(f).Normalize().Equals(val.Normalize())
1256
+ }
1257
+
1258
+ // Square squares the field value in constant time. The existing field value is
1259
+ // modified. Note that this function can overflow if multiplying any of the
1260
+ // individual words exceeds a max uint32. In practice, this means the magnitude
1261
+ // of the field must be a max of 8 to prevent overflow.
1262
+ //
1263
+ // The field value is returned to support chaining. This enables syntax like:
1264
+ // f.Square().Mul(f2) so that f = f^2 * f2.
1265
+ //
1266
+ // Preconditions:
1267
+ // - The field value MUST have a max magnitude of 8
1268
+ // Output Normalized: No
1269
+ // Output Max Magnitude: 1
1270
+ func (f *FieldVal) Square() *FieldVal {
1271
+ return f.SquareVal(f)
1272
+ }
1273
+
1274
+ // SquareVal squares the passed value and stores the result in f in constant
1275
+ // time. Note that this function can overflow if multiplying any of the
1276
+ // individual words exceeds a max uint32. In practice, this means the magnitude
1277
+ // of the field being squared must be a max of 8 to prevent overflow.
1278
+ //
1279
+ // The field value is returned to support chaining. This enables syntax like:
1280
+ // f3.SquareVal(f).Mul(f) so that f3 = f^2 * f = f^3.
1281
+ //
1282
+ // Preconditions:
1283
+ // - The input field value MUST have a max magnitude of 8
1284
+ // Output Normalized: No
1285
+ // Output Max Magnitude: 1
1286
+ func (f *FieldVal) SquareVal(val *FieldVal) *FieldVal {
1287
+ // This could be done with a couple of for loops and an array to store
1288
+ // the intermediate terms, but this unrolled version is significantly
1289
+ // faster.
1290
+
1291
+ // Terms for 2^(fieldBase*0).
1292
+ m := uint64(val.n[0]) * uint64(val.n[0])
1293
+ t0 := m & fieldBaseMask
1294
+
1295
+ // Terms for 2^(fieldBase*1).
1296
+ m = (m >> fieldBase) + 2*uint64(val.n[0])*uint64(val.n[1])
1297
+ t1 := m & fieldBaseMask
1298
+
1299
+ // Terms for 2^(fieldBase*2).
1300
+ m = (m >> fieldBase) +
1301
+ 2*uint64(val.n[0])*uint64(val.n[2]) +
1302
+ uint64(val.n[1])*uint64(val.n[1])
1303
+ t2 := m & fieldBaseMask
1304
+
1305
+ // Terms for 2^(fieldBase*3).
1306
+ m = (m >> fieldBase) +
1307
+ 2*uint64(val.n[0])*uint64(val.n[3]) +
1308
+ 2*uint64(val.n[1])*uint64(val.n[2])
1309
+ t3 := m & fieldBaseMask
1310
+
1311
+ // Terms for 2^(fieldBase*4).
1312
+ m = (m >> fieldBase) +
1313
+ 2*uint64(val.n[0])*uint64(val.n[4]) +
1314
+ 2*uint64(val.n[1])*uint64(val.n[3]) +
1315
+ uint64(val.n[2])*uint64(val.n[2])
1316
+ t4 := m & fieldBaseMask
1317
+
1318
+ // Terms for 2^(fieldBase*5).
1319
+ m = (m >> fieldBase) +
1320
+ 2*uint64(val.n[0])*uint64(val.n[5]) +
1321
+ 2*uint64(val.n[1])*uint64(val.n[4]) +
1322
+ 2*uint64(val.n[2])*uint64(val.n[3])
1323
+ t5 := m & fieldBaseMask
1324
+
1325
+ // Terms for 2^(fieldBase*6).
1326
+ m = (m >> fieldBase) +
1327
+ 2*uint64(val.n[0])*uint64(val.n[6]) +
1328
+ 2*uint64(val.n[1])*uint64(val.n[5]) +
1329
+ 2*uint64(val.n[2])*uint64(val.n[4]) +
1330
+ uint64(val.n[3])*uint64(val.n[3])
1331
+ t6 := m & fieldBaseMask
1332
+
1333
+ // Terms for 2^(fieldBase*7).
1334
+ m = (m >> fieldBase) +
1335
+ 2*uint64(val.n[0])*uint64(val.n[7]) +
1336
+ 2*uint64(val.n[1])*uint64(val.n[6]) +
1337
+ 2*uint64(val.n[2])*uint64(val.n[5]) +
1338
+ 2*uint64(val.n[3])*uint64(val.n[4])
1339
+ t7 := m & fieldBaseMask
1340
+
1341
+ // Terms for 2^(fieldBase*8).
1342
+ m = (m >> fieldBase) +
1343
+ 2*uint64(val.n[0])*uint64(val.n[8]) +
1344
+ 2*uint64(val.n[1])*uint64(val.n[7]) +
1345
+ 2*uint64(val.n[2])*uint64(val.n[6]) +
1346
+ 2*uint64(val.n[3])*uint64(val.n[5]) +
1347
+ uint64(val.n[4])*uint64(val.n[4])
1348
+ t8 := m & fieldBaseMask
1349
+
1350
+ // Terms for 2^(fieldBase*9).
1351
+ m = (m >> fieldBase) +
1352
+ 2*uint64(val.n[0])*uint64(val.n[9]) +
1353
+ 2*uint64(val.n[1])*uint64(val.n[8]) +
1354
+ 2*uint64(val.n[2])*uint64(val.n[7]) +
1355
+ 2*uint64(val.n[3])*uint64(val.n[6]) +
1356
+ 2*uint64(val.n[4])*uint64(val.n[5])
1357
+ t9 := m & fieldBaseMask
1358
+
1359
+ // Terms for 2^(fieldBase*10).
1360
+ m = (m >> fieldBase) +
1361
+ 2*uint64(val.n[1])*uint64(val.n[9]) +
1362
+ 2*uint64(val.n[2])*uint64(val.n[8]) +
1363
+ 2*uint64(val.n[3])*uint64(val.n[7]) +
1364
+ 2*uint64(val.n[4])*uint64(val.n[6]) +
1365
+ uint64(val.n[5])*uint64(val.n[5])
1366
+ t10 := m & fieldBaseMask
1367
+
1368
+ // Terms for 2^(fieldBase*11).
1369
+ m = (m >> fieldBase) +
1370
+ 2*uint64(val.n[2])*uint64(val.n[9]) +
1371
+ 2*uint64(val.n[3])*uint64(val.n[8]) +
1372
+ 2*uint64(val.n[4])*uint64(val.n[7]) +
1373
+ 2*uint64(val.n[5])*uint64(val.n[6])
1374
+ t11 := m & fieldBaseMask
1375
+
1376
+ // Terms for 2^(fieldBase*12).
1377
+ m = (m >> fieldBase) +
1378
+ 2*uint64(val.n[3])*uint64(val.n[9]) +
1379
+ 2*uint64(val.n[4])*uint64(val.n[8]) +
1380
+ 2*uint64(val.n[5])*uint64(val.n[7]) +
1381
+ uint64(val.n[6])*uint64(val.n[6])
1382
+ t12 := m & fieldBaseMask
1383
+
1384
+ // Terms for 2^(fieldBase*13).
1385
+ m = (m >> fieldBase) +
1386
+ 2*uint64(val.n[4])*uint64(val.n[9]) +
1387
+ 2*uint64(val.n[5])*uint64(val.n[8]) +
1388
+ 2*uint64(val.n[6])*uint64(val.n[7])
1389
+ t13 := m & fieldBaseMask
1390
+
1391
+ // Terms for 2^(fieldBase*14).
1392
+ m = (m >> fieldBase) +
1393
+ 2*uint64(val.n[5])*uint64(val.n[9]) +
1394
+ 2*uint64(val.n[6])*uint64(val.n[8]) +
1395
+ uint64(val.n[7])*uint64(val.n[7])
1396
+ t14 := m & fieldBaseMask
1397
+
1398
+ // Terms for 2^(fieldBase*15).
1399
+ m = (m >> fieldBase) +
1400
+ 2*uint64(val.n[6])*uint64(val.n[9]) +
1401
+ 2*uint64(val.n[7])*uint64(val.n[8])
1402
+ t15 := m & fieldBaseMask
1403
+
1404
+ // Terms for 2^(fieldBase*16).
1405
+ m = (m >> fieldBase) +
1406
+ 2*uint64(val.n[7])*uint64(val.n[9]) +
1407
+ uint64(val.n[8])*uint64(val.n[8])
1408
+ t16 := m & fieldBaseMask
1409
+
1410
+ // Terms for 2^(fieldBase*17).
1411
+ m = (m >> fieldBase) + 2*uint64(val.n[8])*uint64(val.n[9])
1412
+ t17 := m & fieldBaseMask
1413
+
1414
+ // Terms for 2^(fieldBase*18).
1415
+ m = (m >> fieldBase) + uint64(val.n[9])*uint64(val.n[9])
1416
+ t18 := m & fieldBaseMask
1417
+
1418
+ // What's left is for 2^(fieldBase*19).
1419
+ t19 := m >> fieldBase
1420
+
1421
+ // At this point, all of the terms are grouped into their respective
1422
+ // base.
1423
+ //
1424
+ // Per [HAC] section 14.3.4: Reduction method of moduli of special form,
1425
+ // when the modulus is of the special form m = b^t - c, highly efficient
1426
+ // reduction can be achieved per the provided algorithm.
1427
+ //
1428
+ // The secp256k1 prime is equivalent to 2^256 - 4294968273, so it fits
1429
+ // this criteria.
1430
+ //
1431
+ // 4294968273 in field representation (base 2^26) is:
1432
+ // n[0] = 977
1433
+ // n[1] = 64
1434
+ // That is to say (2^26 * 64) + 977 = 4294968273
1435
+ //
1436
+ // Since each word is in base 26, the upper terms (t10 and up) start
1437
+ // at 260 bits (versus the final desired range of 256 bits), so the
1438
+ // field representation of 'c' from above needs to be adjusted for the
1439
+ // extra 4 bits by multiplying it by 2^4 = 16. 4294968273 * 16 =
1440
+ // 68719492368. Thus, the adjusted field representation of 'c' is:
1441
+ // n[0] = 977 * 16 = 15632
1442
+ // n[1] = 64 * 16 = 1024
1443
+ // That is to say (2^26 * 1024) + 15632 = 68719492368
1444
+ //
1445
+ // To reduce the final term, t19, the entire 'c' value is needed instead
1446
+ // of only n[0] because there are no more terms left to handle n[1].
1447
+ // This means there might be some magnitude left in the upper bits that
1448
+ // is handled below.
1449
+ m = t0 + t10*15632
1450
+ t0 = m & fieldBaseMask
1451
+ m = (m >> fieldBase) + t1 + t10*1024 + t11*15632
1452
+ t1 = m & fieldBaseMask
1453
+ m = (m >> fieldBase) + t2 + t11*1024 + t12*15632
1454
+ t2 = m & fieldBaseMask
1455
+ m = (m >> fieldBase) + t3 + t12*1024 + t13*15632
1456
+ t3 = m & fieldBaseMask
1457
+ m = (m >> fieldBase) + t4 + t13*1024 + t14*15632
1458
+ t4 = m & fieldBaseMask
1459
+ m = (m >> fieldBase) + t5 + t14*1024 + t15*15632
1460
+ t5 = m & fieldBaseMask
1461
+ m = (m >> fieldBase) + t6 + t15*1024 + t16*15632
1462
+ t6 = m & fieldBaseMask
1463
+ m = (m >> fieldBase) + t7 + t16*1024 + t17*15632
1464
+ t7 = m & fieldBaseMask
1465
+ m = (m >> fieldBase) + t8 + t17*1024 + t18*15632
1466
+ t8 = m & fieldBaseMask
1467
+ m = (m >> fieldBase) + t9 + t18*1024 + t19*68719492368
1468
+ t9 = m & fieldMSBMask
1469
+ m >>= fieldMSBBits
1470
+
1471
+ // At this point, if the magnitude is greater than 0, the overall value
1472
+ // is greater than the max possible 256-bit value. In particular, it is
1473
+ // "how many times larger" than the max value it is.
1474
+ //
1475
+ // The algorithm presented in [HAC] section 14.3.4 repeats until the
1476
+ // quotient is zero. However, due to the above, we already know at
1477
+ // least how many times we would need to repeat as it's the value
1478
+ // currently in m. Thus we can simply multiply the magnitude by the
1479
+ // field representation of the prime and do a single iteration. Notice
1480
+ // that nothing will be changed when the magnitude is zero, so we could
1481
+ // skip this in that case, however always running regardless allows it
1482
+ // to run in constant time. The final result will be in the range
1483
+ // 0 <= result <= prime + (2^64 - c), so it is guaranteed to have a
1484
+ // magnitude of 1, but it is denormalized.
1485
+ n := t0 + m*977
1486
+ f.n[0] = uint32(n & fieldBaseMask)
1487
+ n = (n >> fieldBase) + t1 + m*64
1488
+ f.n[1] = uint32(n & fieldBaseMask)
1489
+ f.n[2] = uint32((n >> fieldBase) + t2)
1490
+ f.n[3] = uint32(t3)
1491
+ f.n[4] = uint32(t4)
1492
+ f.n[5] = uint32(t5)
1493
+ f.n[6] = uint32(t6)
1494
+ f.n[7] = uint32(t7)
1495
+ f.n[8] = uint32(t8)
1496
+ f.n[9] = uint32(t9)
1497
+
1498
+ return f
1499
+ }
1500
+
1501
+ // Inverse finds the modular multiplicative inverse of the field value in
1502
+ // constant time. The existing field value is modified.
1503
+ //
1504
+ // The field value is returned to support chaining. This enables syntax like:
1505
+ // f.Inverse().Mul(f2) so that f = f^-1 * f2.
1506
+ //
1507
+ // Preconditions:
1508
+ // - The field value MUST have a max magnitude of 8
1509
+ // Output Normalized: No
1510
+ // Output Max Magnitude: 1
1511
+ func (f *FieldVal) Inverse() *FieldVal {
1512
+ // Fermat's little theorem states that for a nonzero number 'a' and prime
1513
+ // 'p', a^(p-1) ≡ 1 (mod p). Multiplying both sides of the equation by the
1514
+ // multiplicative inverse a^-1 yields a^(p-2) ≡ a^-1 (mod p). Thus, a^(p-2)
1515
+ // is the multiplicative inverse.
1516
+ //
1517
+ // In order to efficiently compute a^(p-2), p-2 needs to be split into a
1518
+ // sequence of squares and multiplications that minimizes the number of
1519
+ // multiplications needed (since they are more costly than squarings).
1520
+ // Intermediate results are saved and reused as well.
1521
+ //
1522
+ // The secp256k1 prime - 2 is 2^256 - 4294968275. In binary, that is:
1523
+ //
1524
+ // 11111111 11111111 11111111 11111111
1525
+ // 11111111 11111111 11111111 11111111
1526
+ // 11111111 11111111 11111111 11111111
1527
+ // 11111111 11111111 11111111 11111111
1528
+ // 11111111 11111111 11111111 11111111
1529
+ // 11111111 11111111 11111111 11111111
1530
+ // 11111111 11111111 11111111 11111110
1531
+ // 11111111 11111111 11111100 00101101
1532
+ //
1533
+ // Notice that can be broken up into five windows of consecutive 1s (in
1534
+ // order of least to most significant) as:
1535
+ //
1536
+ // 2-bit window with 1 bit set (bit 1 unset)
1537
+ // 3-bit window with 2 bits set (bit 4 unset)
1538
+ // 5-bit window with 1 bit set (bits 6, 7, 8, 9 unset)
1539
+ // 23-bit window with 22 bits set (bit 32 unset)
1540
+ // 223-bit window with all 223 bits set
1541
+ //
1542
+ // Thus, the groups of 1 bits in each window forms the set:
1543
+ // S = {1, 2, 22, 223}.
1544
+ //
1545
+ // The strategy is to calculate a^(2^n - 1) for each grouping via an
1546
+ // addition chain with a sliding window.
1547
+ //
1548
+ // The addition chain used is (credits to Peter Dettman):
1549
+ // (0,0),(1,0),(2,2),(3,2),(4,1),(5,5),(6,6),(7,7),(8,8),(9,7),(10,2)
1550
+ // => 2^[1] 2^[2] 2^3 2^6 2^9 2^11 2^[22] 2^44 2^88 2^176 2^220 2^[223]
1551
+ //
1552
+ // This has a cost of 255 field squarings and 15 field multiplications.
1553
+ var a, a2, a3, a6, a9, a11, a22, a44, a88, a176, a220, a223 FieldVal
1554
+ a.Set(f)
1555
+ a2.SquareVal(&a).Mul(&a) // a2 = a^(2^2 - 1)
1556
+ a3.SquareVal(&a2).Mul(&a) // a3 = a^(2^3 - 1)
1557
+ a6.SquareVal(&a3).Square().Square() // a6 = a^(2^6 - 2^3)
1558
+ a6.Mul(&a3) // a6 = a^(2^6 - 1)
1559
+ a9.SquareVal(&a6).Square().Square() // a9 = a^(2^9 - 2^3)
1560
+ a9.Mul(&a3) // a9 = a^(2^9 - 1)
1561
+ a11.SquareVal(&a9).Square() // a11 = a^(2^11 - 2^2)
1562
+ a11.Mul(&a2) // a11 = a^(2^11 - 1)
1563
+ a22.SquareVal(&a11).Square().Square().Square().Square() // a22 = a^(2^16 - 2^5)
1564
+ a22.Square().Square().Square().Square().Square() // a22 = a^(2^21 - 2^10)
1565
+ a22.Square() // a22 = a^(2^22 - 2^11)
1566
+ a22.Mul(&a11) // a22 = a^(2^22 - 1)
1567
+ a44.SquareVal(&a22).Square().Square().Square().Square() // a44 = a^(2^27 - 2^5)
1568
+ a44.Square().Square().Square().Square().Square() // a44 = a^(2^32 - 2^10)
1569
+ a44.Square().Square().Square().Square().Square() // a44 = a^(2^37 - 2^15)
1570
+ a44.Square().Square().Square().Square().Square() // a44 = a^(2^42 - 2^20)
1571
+ a44.Square().Square() // a44 = a^(2^44 - 2^22)
1572
+ a44.Mul(&a22) // a44 = a^(2^44 - 1)
1573
+ a88.SquareVal(&a44).Square().Square().Square().Square() // a88 = a^(2^49 - 2^5)
1574
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^54 - 2^10)
1575
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^59 - 2^15)
1576
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^64 - 2^20)
1577
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^69 - 2^25)
1578
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^74 - 2^30)
1579
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^79 - 2^35)
1580
+ a88.Square().Square().Square().Square().Square() // a88 = a^(2^84 - 2^40)
1581
+ a88.Square().Square().Square().Square() // a88 = a^(2^88 - 2^44)
1582
+ a88.Mul(&a44) // a88 = a^(2^88 - 1)
1583
+ a176.SquareVal(&a88).Square().Square().Square().Square() // a176 = a^(2^93 - 2^5)
1584
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^98 - 2^10)
1585
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^103 - 2^15)
1586
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^108 - 2^20)
1587
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^113 - 2^25)
1588
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^118 - 2^30)
1589
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^123 - 2^35)
1590
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^128 - 2^40)
1591
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^133 - 2^45)
1592
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^138 - 2^50)
1593
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^143 - 2^55)
1594
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^148 - 2^60)
1595
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^153 - 2^65)
1596
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^158 - 2^70)
1597
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^163 - 2^75)
1598
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^168 - 2^80)
1599
+ a176.Square().Square().Square().Square().Square() // a176 = a^(2^173 - 2^85)
1600
+ a176.Square().Square().Square() // a176 = a^(2^176 - 2^88)
1601
+ a176.Mul(&a88) // a176 = a^(2^176 - 1)
1602
+ a220.SquareVal(&a176).Square().Square().Square().Square() // a220 = a^(2^181 - 2^5)
1603
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^186 - 2^10)
1604
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^191 - 2^15)
1605
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^196 - 2^20)
1606
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^201 - 2^25)
1607
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^206 - 2^30)
1608
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^211 - 2^35)
1609
+ a220.Square().Square().Square().Square().Square() // a220 = a^(2^216 - 2^40)
1610
+ a220.Square().Square().Square().Square() // a220 = a^(2^220 - 2^44)
1611
+ a220.Mul(&a44) // a220 = a^(2^220 - 1)
1612
+ a223.SquareVal(&a220).Square().Square() // a223 = a^(2^223 - 2^3)
1613
+ a223.Mul(&a3) // a223 = a^(2^223 - 1)
1614
+
1615
+ f.SquareVal(&a223).Square().Square().Square().Square() // f = a^(2^228 - 2^5)
1616
+ f.Square().Square().Square().Square().Square() // f = a^(2^233 - 2^10)
1617
+ f.Square().Square().Square().Square().Square() // f = a^(2^238 - 2^15)
1618
+ f.Square().Square().Square().Square().Square() // f = a^(2^243 - 2^20)
1619
+ f.Square().Square().Square() // f = a^(2^246 - 2^23)
1620
+ f.Mul(&a22) // f = a^(2^246 - 4194305)
1621
+ f.Square().Square().Square().Square().Square() // f = a^(2^251 - 134217760)
1622
+ f.Mul(&a) // f = a^(2^251 - 134217759)
1623
+ f.Square().Square().Square() // f = a^(2^254 - 1073742072)
1624
+ f.Mul(&a2) // f = a^(2^254 - 1073742069)
1625
+ f.Square().Square() // f = a^(2^256 - 4294968276)
1626
+ return f.Mul(&a) // f = a^(2^256 - 4294968275) = a^(p-2)
1627
+ }
1628
+
1629
+ // IsGtOrEqPrimeMinusOrder returns whether or not the field value is greater
1630
+ // than or equal to the field prime minus the secp256k1 group order in constant
1631
+ // time.
1632
+ //
1633
+ // Preconditions:
1634
+ // - The field value MUST be normalized
1635
+ func (f *FieldVal) IsGtOrEqPrimeMinusOrder() bool {
1636
+ // The secp256k1 prime is equivalent to 2^256 - 4294968273 and the group
1637
+ // order is 2^256 - 432420386565659656852420866394968145599. Thus,
1638
+ // the prime minus the group order is:
1639
+ // 432420386565659656852420866390673177326
1640
+ //
1641
+ // In hex that is:
1642
+ // 0x00000000 00000000 00000000 00000001 45512319 50b75fc4 402da172 2fc9baee
1643
+ //
1644
+ // Converting that to field representation (base 2^26) is:
1645
+ //
1646
+ // n[0] = 0x03c9baee
1647
+ // n[1] = 0x03685c8b
1648
+ // n[2] = 0x01fc4402
1649
+ // n[3] = 0x006542dd
1650
+ // n[4] = 0x01455123
1651
+ //
1652
+ // This can be verified with the following test code:
1653
+ // pMinusN := new(big.Int).Sub(curveParams.P, curveParams.N)
1654
+ // var fv FieldVal
1655
+ // fv.SetByteSlice(pMinusN.Bytes())
1656
+ // t.Logf("%x", fv.n)
1657
+ //
1658
+ // Outputs: [3c9baee 3685c8b 1fc4402 6542dd 1455123 0 0 0 0 0]
1659
+ const (
1660
+ pMinusNWordZero = 0x03c9baee
1661
+ pMinusNWordOne = 0x03685c8b
1662
+ pMinusNWordTwo = 0x01fc4402
1663
+ pMinusNWordThree = 0x006542dd
1664
+ pMinusNWordFour = 0x01455123
1665
+ pMinusNWordFive = 0x00000000
1666
+ pMinusNWordSix = 0x00000000
1667
+ pMinusNWordSeven = 0x00000000
1668
+ pMinusNWordEight = 0x00000000
1669
+ pMinusNWordNine = 0x00000000
1670
+ )
1671
+
1672
+ // The intuition here is that the value is greater than field prime minus
1673
+ // the group order if one of the higher individual words is greater than the
1674
+ // corresponding word and all higher words in the value are equal.
1675
+ result := constantTimeGreater(f.n[9], pMinusNWordNine)
1676
+ highWordsEqual := constantTimeEq(f.n[9], pMinusNWordNine)
1677
+ result |= highWordsEqual & constantTimeGreater(f.n[8], pMinusNWordEight)
1678
+ highWordsEqual &= constantTimeEq(f.n[8], pMinusNWordEight)
1679
+ result |= highWordsEqual & constantTimeGreater(f.n[7], pMinusNWordSeven)
1680
+ highWordsEqual &= constantTimeEq(f.n[7], pMinusNWordSeven)
1681
+ result |= highWordsEqual & constantTimeGreater(f.n[6], pMinusNWordSix)
1682
+ highWordsEqual &= constantTimeEq(f.n[6], pMinusNWordSix)
1683
+ result |= highWordsEqual & constantTimeGreater(f.n[5], pMinusNWordFive)
1684
+ highWordsEqual &= constantTimeEq(f.n[5], pMinusNWordFive)
1685
+ result |= highWordsEqual & constantTimeGreater(f.n[4], pMinusNWordFour)
1686
+ highWordsEqual &= constantTimeEq(f.n[4], pMinusNWordFour)
1687
+ result |= highWordsEqual & constantTimeGreater(f.n[3], pMinusNWordThree)
1688
+ highWordsEqual &= constantTimeEq(f.n[3], pMinusNWordThree)
1689
+ result |= highWordsEqual & constantTimeGreater(f.n[2], pMinusNWordTwo)
1690
+ highWordsEqual &= constantTimeEq(f.n[2], pMinusNWordTwo)
1691
+ result |= highWordsEqual & constantTimeGreater(f.n[1], pMinusNWordOne)
1692
+ highWordsEqual &= constantTimeEq(f.n[1], pMinusNWordOne)
1693
+ result |= highWordsEqual & constantTimeGreaterOrEq(f.n[0], pMinusNWordZero)
1694
+
1695
+ return result != 0
1696
+ }