react-native-quick-crypto 1.1.0 → 1.1.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 (687) hide show
  1. package/android/build.gradle +5 -1
  2. package/cpp/argon2/HybridArgon2.cpp +10 -3
  3. package/cpp/blake3/HybridBlake3.cpp +5 -3
  4. package/cpp/cipher/CCMCipher.cpp +29 -16
  5. package/cpp/cipher/CCMCipher.hpp +2 -4
  6. package/cpp/cipher/ChaCha20Cipher.cpp +14 -18
  7. package/cpp/cipher/ChaCha20Cipher.hpp +2 -4
  8. package/cpp/cipher/ChaCha20Poly1305Cipher.cpp +34 -23
  9. package/cpp/cipher/ChaCha20Poly1305Cipher.hpp +2 -4
  10. package/cpp/cipher/GCMCipher.cpp +14 -15
  11. package/cpp/cipher/HybridCipher.cpp +39 -36
  12. package/cpp/cipher/HybridCipher.hpp +17 -1
  13. package/cpp/cipher/HybridRsaCipher.cpp +74 -29
  14. package/cpp/cipher/OCBCipher.cpp +4 -3
  15. package/cpp/cipher/XChaCha20Poly1305Cipher.cpp +14 -13
  16. package/cpp/cipher/XSalsa20Cipher.cpp +72 -6
  17. package/cpp/cipher/XSalsa20Cipher.hpp +25 -3
  18. package/cpp/cipher/XSalsa20Poly1305Cipher.cpp +21 -25
  19. package/cpp/dh/HybridDiffieHellman.cpp +29 -0
  20. package/cpp/ec/HybridEcKeyPair.cpp +35 -33
  21. package/cpp/ec/HybridEcKeyPair.hpp +3 -7
  22. package/cpp/ecdh/HybridECDH.cpp +23 -0
  23. package/cpp/ed25519/HybridEdKeyPair.cpp +73 -117
  24. package/cpp/ed25519/HybridEdKeyPair.hpp +5 -9
  25. package/cpp/hash/HybridHash.cpp +5 -7
  26. package/cpp/hkdf/HybridHkdf.cpp +6 -4
  27. package/cpp/hmac/HybridHmac.cpp +4 -6
  28. package/cpp/kmac/HybridKmac.cpp +4 -4
  29. package/cpp/mldsa/HybridMlDsaKeyPair.cpp +37 -49
  30. package/cpp/mlkem/HybridMlKemKeyPair.cpp +39 -43
  31. package/cpp/pbkdf2/HybridPbkdf2.cpp +7 -8
  32. package/cpp/rsa/HybridRsaKeyPair.cpp +5 -8
  33. package/cpp/rsa/HybridRsaKeyPair.hpp +4 -7
  34. package/cpp/scrypt/HybridScrypt.cpp +6 -4
  35. package/cpp/sign/HybridSignHandle.cpp +25 -68
  36. package/cpp/sign/HybridVerifyHandle.cpp +23 -60
  37. package/cpp/utils/HybridUtils.cpp +183 -43
  38. package/cpp/utils/HybridUtils.hpp +9 -2
  39. package/cpp/utils/QuickCryptoUtils.hpp +72 -0
  40. package/lib/commonjs/argon2.js +51 -2
  41. package/lib/commonjs/argon2.js.map +1 -1
  42. package/lib/commonjs/cipher.js +109 -11
  43. package/lib/commonjs/cipher.js.map +1 -1
  44. package/lib/commonjs/dsa.js +8 -2
  45. package/lib/commonjs/dsa.js.map +1 -1
  46. package/lib/commonjs/hash.js +15 -5
  47. package/lib/commonjs/hash.js.map +1 -1
  48. package/lib/commonjs/hkdf.js +33 -6
  49. package/lib/commonjs/hkdf.js.map +1 -1
  50. package/lib/commonjs/hmac.js +15 -5
  51. package/lib/commonjs/hmac.js.map +1 -1
  52. package/lib/commonjs/keys/publicCipher.js +10 -4
  53. package/lib/commonjs/keys/publicCipher.js.map +1 -1
  54. package/lib/commonjs/random.js +11 -2
  55. package/lib/commonjs/random.js.map +1 -1
  56. package/lib/commonjs/rsa.js +12 -5
  57. package/lib/commonjs/rsa.js.map +1 -1
  58. package/lib/commonjs/scrypt.js +47 -6
  59. package/lib/commonjs/scrypt.js.map +1 -1
  60. package/lib/commonjs/subtle.js +76 -5
  61. package/lib/commonjs/subtle.js.map +1 -1
  62. package/lib/commonjs/utils/cipher.js +18 -7
  63. package/lib/commonjs/utils/cipher.js.map +1 -1
  64. package/lib/commonjs/utils/conversion.js +33 -9
  65. package/lib/commonjs/utils/conversion.js.map +1 -1
  66. package/lib/commonjs/utils/timingSafeEqual.js +7 -2
  67. package/lib/commonjs/utils/timingSafeEqual.js.map +1 -1
  68. package/lib/commonjs/x509certificate.js +6 -6
  69. package/lib/commonjs/x509certificate.js.map +1 -1
  70. package/lib/module/argon2.js +51 -2
  71. package/lib/module/argon2.js.map +1 -1
  72. package/lib/module/cipher.js +109 -11
  73. package/lib/module/cipher.js.map +1 -1
  74. package/lib/module/dsa.js +8 -2
  75. package/lib/module/dsa.js.map +1 -1
  76. package/lib/module/hash.js +15 -5
  77. package/lib/module/hash.js.map +1 -1
  78. package/lib/module/hkdf.js +33 -6
  79. package/lib/module/hkdf.js.map +1 -1
  80. package/lib/module/hmac.js +15 -5
  81. package/lib/module/hmac.js.map +1 -1
  82. package/lib/module/keys/publicCipher.js +10 -4
  83. package/lib/module/keys/publicCipher.js.map +1 -1
  84. package/lib/module/random.js +11 -2
  85. package/lib/module/random.js.map +1 -1
  86. package/lib/module/rsa.js +11 -4
  87. package/lib/module/rsa.js.map +1 -1
  88. package/lib/module/scrypt.js +47 -6
  89. package/lib/module/scrypt.js.map +1 -1
  90. package/lib/module/subtle.js +76 -5
  91. package/lib/module/subtle.js.map +1 -1
  92. package/lib/module/utils/cipher.js +18 -7
  93. package/lib/module/utils/cipher.js.map +1 -1
  94. package/lib/module/utils/conversion.js +33 -9
  95. package/lib/module/utils/conversion.js.map +1 -1
  96. package/lib/module/utils/timingSafeEqual.js +8 -3
  97. package/lib/module/utils/timingSafeEqual.js.map +1 -1
  98. package/lib/module/x509certificate.js +6 -6
  99. package/lib/module/x509certificate.js.map +1 -1
  100. package/lib/typescript/argon2.d.ts.map +1 -1
  101. package/lib/typescript/cipher.d.ts +2 -2
  102. package/lib/typescript/cipher.d.ts.map +1 -1
  103. package/lib/typescript/dsa.d.ts.map +1 -1
  104. package/lib/typescript/hash.d.ts +2 -2
  105. package/lib/typescript/hash.d.ts.map +1 -1
  106. package/lib/typescript/hkdf.d.ts.map +1 -1
  107. package/lib/typescript/hmac.d.ts +2 -2
  108. package/lib/typescript/hmac.d.ts.map +1 -1
  109. package/lib/typescript/index.d.ts +1 -1
  110. package/lib/typescript/index.d.ts.map +1 -1
  111. package/lib/typescript/keys/publicCipher.d.ts.map +1 -1
  112. package/lib/typescript/random.d.ts.map +1 -1
  113. package/lib/typescript/rsa.d.ts.map +1 -1
  114. package/lib/typescript/scrypt.d.ts.map +1 -1
  115. package/lib/typescript/specs/utils.nitro.d.ts +0 -2
  116. package/lib/typescript/specs/utils.nitro.d.ts.map +1 -1
  117. package/lib/typescript/subtle.d.ts.map +1 -1
  118. package/lib/typescript/utils/cipher.d.ts +13 -1
  119. package/lib/typescript/utils/cipher.d.ts.map +1 -1
  120. package/lib/typescript/utils/conversion.d.ts +9 -6
  121. package/lib/typescript/utils/conversion.d.ts.map +1 -1
  122. package/lib/typescript/utils/timingSafeEqual.d.ts.map +1 -1
  123. package/lib/typescript/x509certificate.d.ts.map +1 -1
  124. package/nitrogen/generated/shared/c++/HybridUtilsSpec.cpp +0 -2
  125. package/nitrogen/generated/shared/c++/HybridUtilsSpec.hpp +0 -3
  126. package/package.json +37 -5
  127. package/src/argon2.ts +80 -2
  128. package/src/cipher.ts +139 -15
  129. package/src/dsa.ts +11 -2
  130. package/src/hash.ts +17 -7
  131. package/src/hkdf.ts +44 -6
  132. package/src/hmac.ts +17 -7
  133. package/src/keys/publicCipher.ts +10 -4
  134. package/src/random.ts +11 -2
  135. package/src/rsa.ts +18 -4
  136. package/src/scrypt.ts +73 -6
  137. package/src/specs/utils.nitro.ts +0 -2
  138. package/src/subtle.ts +90 -8
  139. package/src/utils/cipher.ts +30 -8
  140. package/src/utils/conversion.ts +58 -20
  141. package/src/utils/timingSafeEqual.ts +8 -3
  142. package/src/x509certificate.ts +5 -6
  143. package/deps/blake3/.cargo/config.toml +0 -2
  144. package/deps/blake3/.git-blame-ignore-revs +0 -2
  145. package/deps/blake3/.github/workflows/build_b3sum.py +0 -38
  146. package/deps/blake3/.github/workflows/ci.yml +0 -491
  147. package/deps/blake3/.github/workflows/tag.yml +0 -43
  148. package/deps/blake3/.github/workflows/upload_github_release_asset.py +0 -73
  149. package/deps/blake3/CONTRIBUTING.md +0 -31
  150. package/deps/blake3/Cargo.toml +0 -135
  151. package/deps/blake3/b3sum/Cargo.lock +0 -513
  152. package/deps/blake3/b3sum/Cargo.toml +0 -26
  153. package/deps/blake3/b3sum/README.md +0 -72
  154. package/deps/blake3/b3sum/src/main.rs +0 -564
  155. package/deps/blake3/b3sum/src/unit_tests.rs +0 -235
  156. package/deps/blake3/b3sum/tests/cli_tests.rs +0 -680
  157. package/deps/blake3/b3sum/what_does_check_do.md +0 -176
  158. package/deps/blake3/benches/bench.rs +0 -623
  159. package/deps/blake3/build.rs +0 -389
  160. package/deps/blake3/c/CMakeLists.txt +0 -383
  161. package/deps/blake3/c/CMakePresets.json +0 -73
  162. package/deps/blake3/c/Makefile.testing +0 -82
  163. package/deps/blake3/c/blake3-config.cmake.in +0 -14
  164. package/deps/blake3/c/blake3_avx2.c +0 -326
  165. package/deps/blake3/c/blake3_avx2_x86-64_unix.S +0 -1815
  166. package/deps/blake3/c/blake3_avx2_x86-64_windows_gnu.S +0 -1817
  167. package/deps/blake3/c/blake3_avx2_x86-64_windows_msvc.asm +0 -1828
  168. package/deps/blake3/c/blake3_avx512.c +0 -1388
  169. package/deps/blake3/c/blake3_avx512_x86-64_unix.S +0 -4824
  170. package/deps/blake3/c/blake3_avx512_x86-64_windows_gnu.S +0 -2615
  171. package/deps/blake3/c/blake3_avx512_x86-64_windows_msvc.asm +0 -2634
  172. package/deps/blake3/c/blake3_c_rust_bindings/Cargo.toml +0 -32
  173. package/deps/blake3/c/blake3_c_rust_bindings/README.md +0 -4
  174. package/deps/blake3/c/blake3_c_rust_bindings/benches/bench.rs +0 -477
  175. package/deps/blake3/c/blake3_c_rust_bindings/build.rs +0 -253
  176. package/deps/blake3/c/blake3_c_rust_bindings/cross_test.sh +0 -31
  177. package/deps/blake3/c/blake3_c_rust_bindings/src/lib.rs +0 -333
  178. package/deps/blake3/c/blake3_c_rust_bindings/src/test.rs +0 -696
  179. package/deps/blake3/c/blake3_sse2.c +0 -566
  180. package/deps/blake3/c/blake3_sse2_x86-64_unix.S +0 -2291
  181. package/deps/blake3/c/blake3_sse2_x86-64_windows_gnu.S +0 -2332
  182. package/deps/blake3/c/blake3_sse2_x86-64_windows_msvc.asm +0 -2350
  183. package/deps/blake3/c/blake3_sse41.c +0 -560
  184. package/deps/blake3/c/blake3_sse41_x86-64_unix.S +0 -2028
  185. package/deps/blake3/c/blake3_sse41_x86-64_windows_gnu.S +0 -2069
  186. package/deps/blake3/c/blake3_sse41_x86-64_windows_msvc.asm +0 -2089
  187. package/deps/blake3/c/blake3_tbb.cpp +0 -37
  188. package/deps/blake3/c/dependencies/CMakeLists.txt +0 -3
  189. package/deps/blake3/c/dependencies/tbb/CMakeLists.txt +0 -28
  190. package/deps/blake3/c/example.c +0 -36
  191. package/deps/blake3/c/example_tbb.c +0 -57
  192. package/deps/blake3/c/libblake3.pc.in +0 -12
  193. package/deps/blake3/c/main.c +0 -166
  194. package/deps/blake3/c/test.py +0 -97
  195. package/deps/blake3/media/B3.svg +0 -70
  196. package/deps/blake3/media/BLAKE3.svg +0 -85
  197. package/deps/blake3/media/speed.svg +0 -1474
  198. package/deps/blake3/reference_impl/Cargo.toml +0 -8
  199. package/deps/blake3/reference_impl/README.md +0 -14
  200. package/deps/blake3/reference_impl/reference_impl.rs +0 -374
  201. package/deps/blake3/src/ffi_avx2.rs +0 -65
  202. package/deps/blake3/src/ffi_avx512.rs +0 -169
  203. package/deps/blake3/src/ffi_neon.rs +0 -82
  204. package/deps/blake3/src/ffi_sse2.rs +0 -126
  205. package/deps/blake3/src/ffi_sse41.rs +0 -126
  206. package/deps/blake3/src/guts.rs +0 -60
  207. package/deps/blake3/src/hazmat.rs +0 -704
  208. package/deps/blake3/src/io.rs +0 -64
  209. package/deps/blake3/src/join.rs +0 -92
  210. package/deps/blake3/src/lib.rs +0 -1835
  211. package/deps/blake3/src/platform.rs +0 -587
  212. package/deps/blake3/src/portable.rs +0 -198
  213. package/deps/blake3/src/rust_avx2.rs +0 -474
  214. package/deps/blake3/src/rust_sse2.rs +0 -775
  215. package/deps/blake3/src/rust_sse41.rs +0 -766
  216. package/deps/blake3/src/test.rs +0 -1049
  217. package/deps/blake3/src/traits.rs +0 -227
  218. package/deps/blake3/src/wasm32_simd.rs +0 -794
  219. package/deps/blake3/test_vectors/Cargo.toml +0 -19
  220. package/deps/blake3/test_vectors/cross_test.sh +0 -25
  221. package/deps/blake3/test_vectors/src/bin/generate.rs +0 -4
  222. package/deps/blake3/test_vectors/src/lib.rs +0 -350
  223. package/deps/blake3/test_vectors/test_vectors.json +0 -217
  224. package/deps/blake3/tools/compiler_version/Cargo.toml +0 -7
  225. package/deps/blake3/tools/compiler_version/build.rs +0 -6
  226. package/deps/blake3/tools/compiler_version/src/main.rs +0 -27
  227. package/deps/blake3/tools/instruction_set_support/Cargo.toml +0 -6
  228. package/deps/blake3/tools/instruction_set_support/src/main.rs +0 -10
  229. package/deps/blake3/tools/release.md +0 -16
  230. package/deps/ncrypto/.bazelignore +0 -4
  231. package/deps/ncrypto/.bazelrc +0 -1
  232. package/deps/ncrypto/.bazelversion +0 -1
  233. package/deps/ncrypto/.clang-format +0 -111
  234. package/deps/ncrypto/.github/workflows/bazel.yml +0 -58
  235. package/deps/ncrypto/.github/workflows/commitlint.yml +0 -16
  236. package/deps/ncrypto/.github/workflows/linter.yml +0 -38
  237. package/deps/ncrypto/.github/workflows/macos.yml +0 -43
  238. package/deps/ncrypto/.github/workflows/release-please.yml +0 -16
  239. package/deps/ncrypto/.github/workflows/ubuntu.yml +0 -128
  240. package/deps/ncrypto/.github/workflows/visual-studio.yml +0 -49
  241. package/deps/ncrypto/.python-version +0 -1
  242. package/deps/ncrypto/.release-please-manifest.json +0 -3
  243. package/deps/ncrypto/BUILD.bazel +0 -44
  244. package/deps/ncrypto/CHANGELOG.md +0 -37
  245. package/deps/ncrypto/CMakeLists.txt +0 -79
  246. package/deps/ncrypto/MODULE.bazel +0 -16
  247. package/deps/ncrypto/MODULE.bazel.lock +0 -461
  248. package/deps/ncrypto/cmake/CPM.cmake +0 -1225
  249. package/deps/ncrypto/cmake/ncrypto-flags.cmake +0 -17
  250. package/deps/ncrypto/ncrypto.pc.in +0 -10
  251. package/deps/ncrypto/patches/0001-Expose-libdecrepit-so-NodeJS-can-use-it-for-ncrypto.patch +0 -28
  252. package/deps/ncrypto/pyproject.toml +0 -38
  253. package/deps/ncrypto/release-please-config.json +0 -11
  254. package/deps/ncrypto/src/CMakeLists.txt +0 -40
  255. package/deps/ncrypto/tests/BUILD.bazel +0 -11
  256. package/deps/ncrypto/tests/CMakeLists.txt +0 -7
  257. package/deps/ncrypto/tests/basic.cpp +0 -856
  258. package/deps/ncrypto/tools/run-clang-format.sh +0 -42
  259. package/deps/simdutf/.clang-format +0 -4
  260. package/deps/simdutf/.github/ISSUE_TEMPLATE/bug_report.md +0 -62
  261. package/deps/simdutf/.github/ISSUE_TEMPLATE/config.yml +0 -1
  262. package/deps/simdutf/.github/ISSUE_TEMPLATE/feature_request.md +0 -35
  263. package/deps/simdutf/.github/ISSUE_TEMPLATE/standard-issue-template.md +0 -29
  264. package/deps/simdutf/.github/pull_request_template.md +0 -51
  265. package/deps/simdutf/.github/workflows/aarch64.yml +0 -39
  266. package/deps/simdutf/.github/workflows/alpine.yml +0 -27
  267. package/deps/simdutf/.github/workflows/amalgamation_demos.yml +0 -34
  268. package/deps/simdutf/.github/workflows/armv7.yml +0 -32
  269. package/deps/simdutf/.github/workflows/atomic_fuzz.yml +0 -25
  270. package/deps/simdutf/.github/workflows/cifuzz.yml +0 -37
  271. package/deps/simdutf/.github/workflows/clangformat.yml +0 -36
  272. package/deps/simdutf/.github/workflows/debian-latestcxxstandards.yml +0 -40
  273. package/deps/simdutf/.github/workflows/debian.yml +0 -33
  274. package/deps/simdutf/.github/workflows/documentation.yml +0 -36
  275. package/deps/simdutf/.github/workflows/emscripten.yml +0 -19
  276. package/deps/simdutf/.github/workflows/loongarch64-gcc-14.2.yml +0 -39
  277. package/deps/simdutf/.github/workflows/macos-latest.yml +0 -29
  278. package/deps/simdutf/.github/workflows/msys2-clang.yml +0 -48
  279. package/deps/simdutf/.github/workflows/msys2.yml +0 -50
  280. package/deps/simdutf/.github/workflows/ppc64le.yml +0 -29
  281. package/deps/simdutf/.github/workflows/rvv-1024-clang-18.yml +0 -35
  282. package/deps/simdutf/.github/workflows/rvv-128-clang-17.yml +0 -35
  283. package/deps/simdutf/.github/workflows/rvv-256-gcc-14.yml +0 -31
  284. package/deps/simdutf/.github/workflows/s390x.yml +0 -29
  285. package/deps/simdutf/.github/workflows/selective-amalgamation.yml +0 -29
  286. package/deps/simdutf/.github/workflows/typos.yml +0 -19
  287. package/deps/simdutf/.github/workflows/ubuntu22-cxx20.yml +0 -30
  288. package/deps/simdutf/.github/workflows/ubuntu22.yml +0 -32
  289. package/deps/simdutf/.github/workflows/ubuntu22_gcc12.yml +0 -27
  290. package/deps/simdutf/.github/workflows/ubuntu22sani.yml +0 -29
  291. package/deps/simdutf/.github/workflows/ubuntu24-cxxstandards.yml +0 -34
  292. package/deps/simdutf/.github/workflows/ubuntu24-unsignedchar.yml +0 -34
  293. package/deps/simdutf/.github/workflows/ubuntu24.yml +0 -32
  294. package/deps/simdutf/.github/workflows/ubuntu24sani.yml +0 -36
  295. package/deps/simdutf/.github/workflows/ubuntu24sani_clang.yml +0 -29
  296. package/deps/simdutf/.github/workflows/vs17-arm-ci.yml +0 -21
  297. package/deps/simdutf/.github/workflows/vs17-ci-cxx20.yml +0 -41
  298. package/deps/simdutf/.github/workflows/vs17-ci.yml +0 -41
  299. package/deps/simdutf/.github/workflows/vs17-clang-ci.yml +0 -41
  300. package/deps/simdutf/.github/workflows/vs17-cxxstandards.yml +0 -36
  301. package/deps/simdutf/AI_USAGE_POLICY.md +0 -56
  302. package/deps/simdutf/AUTHORS +0 -6
  303. package/deps/simdutf/CMakeLists.txt +0 -231
  304. package/deps/simdutf/CONTRIBUTING.md +0 -214
  305. package/deps/simdutf/CONTRIBUTORS +0 -1
  306. package/deps/simdutf/Doxyfile +0 -2584
  307. package/deps/simdutf/Makefile.crosscompile +0 -54
  308. package/deps/simdutf/README-RVV.md +0 -16
  309. package/deps/simdutf/SECURITY.md +0 -8
  310. package/deps/simdutf/benchmarks/CMakeLists.txt +0 -101
  311. package/deps/simdutf/benchmarks/alignment.cpp +0 -150
  312. package/deps/simdutf/benchmarks/base64/CMakeLists.txt +0 -30
  313. package/deps/simdutf/benchmarks/base64/benchmark_base64.cpp +0 -875
  314. package/deps/simdutf/benchmarks/base64/libbase64_spaces.h +0 -49
  315. package/deps/simdutf/benchmarks/base64/node_base64.h +0 -227
  316. package/deps/simdutf/benchmarks/base64/openssl3_base64.h +0 -334
  317. package/deps/simdutf/benchmarks/benchmark.cpp +0 -65
  318. package/deps/simdutf/benchmarks/benchmark_to_well_formed_utf16.cpp +0 -347
  319. package/deps/simdutf/benchmarks/competition/.clang-format-ignore +0 -5
  320. package/deps/simdutf/benchmarks/competition/CppCon2018/utf_utils.cpp +0 -1276
  321. package/deps/simdutf/benchmarks/competition/CppCon2018/utf_utils.h +0 -595
  322. package/deps/simdutf/benchmarks/competition/README.md +0 -7
  323. package/deps/simdutf/benchmarks/competition/hoehrmann/hoehrmann.h +0 -91
  324. package/deps/simdutf/benchmarks/competition/inoue2008/inoue_utf8_to_utf16.h +0 -444
  325. package/deps/simdutf/benchmarks/competition/inoue2008/inoue_utf8_to_utf16_tables.h +0 -13183
  326. package/deps/simdutf/benchmarks/competition/inoue2008/script.py +0 -73
  327. package/deps/simdutf/benchmarks/competition/llvm/ConvertUTF.cpp +0 -738
  328. package/deps/simdutf/benchmarks/competition/llvm/ConvertUTF.h +0 -293
  329. package/deps/simdutf/benchmarks/competition/u8u16/COPYRIGHT +0 -8
  330. package/deps/simdutf/benchmarks/competition/u8u16/Makefile +0 -44
  331. package/deps/simdutf/benchmarks/competition/u8u16/OSL3.0.txt +0 -169
  332. package/deps/simdutf/benchmarks/competition/u8u16/Profiling/BOM_Profiler.h +0 -148
  333. package/deps/simdutf/benchmarks/competition/u8u16/Profiling/i386_timer.h +0 -45
  334. package/deps/simdutf/benchmarks/competition/u8u16/Profiling/ppc_timer.c +0 -34
  335. package/deps/simdutf/benchmarks/competition/u8u16/README +0 -56
  336. package/deps/simdutf/benchmarks/competition/u8u16/config/config_defs.h +0 -43
  337. package/deps/simdutf/benchmarks/competition/u8u16/config/g4_config.h +0 -27
  338. package/deps/simdutf/benchmarks/competition/u8u16/config/mmx_config.h +0 -16
  339. package/deps/simdutf/benchmarks/competition/u8u16/config/p4_config.h +0 -18
  340. package/deps/simdutf/benchmarks/competition/u8u16/config/p4_ideal_config.h +0 -16
  341. package/deps/simdutf/benchmarks/competition/u8u16/config/spu_config.h +0 -28
  342. package/deps/simdutf/benchmarks/competition/u8u16/config/ssse3_config.h +0 -20
  343. package/deps/simdutf/benchmarks/competition/u8u16/iconv_u8u16.c +0 -2
  344. package/deps/simdutf/benchmarks/competition/u8u16/lib/altivec_simd.h +0 -440
  345. package/deps/simdutf/benchmarks/competition/u8u16/lib/libgen/make_basic_ops.py +0 -121
  346. package/deps/simdutf/benchmarks/competition/u8u16/lib/libgen/make_half_operand_versions.py +0 -158
  347. package/deps/simdutf/benchmarks/competition/u8u16/lib/libgen/make_test.py +0 -270
  348. package/deps/simdutf/benchmarks/competition/u8u16/lib/mmx_simd.h +0 -141
  349. package/deps/simdutf/benchmarks/competition/u8u16/lib/mmx_simd_basic.h +0 -216
  350. package/deps/simdutf/benchmarks/competition/u8u16/lib/mmx_simd_built_in.h +0 -119
  351. package/deps/simdutf/benchmarks/competition/u8u16/lib/mmx_simd_modified.h +0 -2430
  352. package/deps/simdutf/benchmarks/competition/u8u16/lib/outline.txt +0 -39
  353. package/deps/simdutf/benchmarks/competition/u8u16/lib/spu_simd.h +0 -421
  354. package/deps/simdutf/benchmarks/competition/u8u16/lib/sse_simd.h +0 -836
  355. package/deps/simdutf/benchmarks/competition/u8u16/lib/stdint.h +0 -222
  356. package/deps/simdutf/benchmarks/competition/u8u16/libu8u16_BE.c +0 -4
  357. package/deps/simdutf/benchmarks/competition/u8u16/libu8u16_LE.c +0 -5
  358. package/deps/simdutf/benchmarks/competition/u8u16/proto/u8u16.py +0 -390
  359. package/deps/simdutf/benchmarks/competition/u8u16/src/Makefile +0 -18
  360. package/deps/simdutf/benchmarks/competition/u8u16/src/bytelex.h +0 -448
  361. package/deps/simdutf/benchmarks/competition/u8u16/src/charsets/ASCII_EBCDIC.h +0 -284
  362. package/deps/simdutf/benchmarks/competition/u8u16/src/libu8u16.c +0 -1975
  363. package/deps/simdutf/benchmarks/competition/u8u16/src/libu8u16.pdf +0 -0
  364. package/deps/simdutf/benchmarks/competition/u8u16/src/libu8u16.w +0 -2263
  365. package/deps/simdutf/benchmarks/competition/u8u16/src/multiliteral.h +0 -239
  366. package/deps/simdutf/benchmarks/competition/u8u16/src/u8u16.c +0 -232
  367. package/deps/simdutf/benchmarks/competition/u8u16/src/x8x16.c +0 -194
  368. package/deps/simdutf/benchmarks/competition/u8u16/src/xml_error.c +0 -193
  369. package/deps/simdutf/benchmarks/competition/u8u16/src/xml_error.h +0 -167
  370. package/deps/simdutf/benchmarks/competition/u8u16/src/xmldecl.c +0 -288
  371. package/deps/simdutf/benchmarks/competition/u8u16/src/xmldecl.h +0 -117
  372. package/deps/simdutf/benchmarks/competition/u8u16/u8u16_g4.c +0 -2
  373. package/deps/simdutf/benchmarks/competition/u8u16/u8u16_mmx.c +0 -2
  374. package/deps/simdutf/benchmarks/competition/u8u16/u8u16_p4.c +0 -3
  375. package/deps/simdutf/benchmarks/competition/u8u16/u8u16_p4_ideal.c +0 -2
  376. package/deps/simdutf/benchmarks/competition/u8u16/u8u16_spu.c +0 -2
  377. package/deps/simdutf/benchmarks/competition/u8u16/u8u16_ssse3.c +0 -3
  378. package/deps/simdutf/benchmarks/competition/u8u16/x8x16_p4.c +0 -2
  379. package/deps/simdutf/benchmarks/competition/utf8lut/LICENSE +0 -23
  380. package/deps/simdutf/benchmarks/competition/utf8lut/data/test_minimal.txt +0 -44
  381. package/deps/simdutf/benchmarks/competition/utf8lut/readme.md +0 -106
  382. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_clang_corr_tests.cmd +0 -11
  383. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_clang_corr_tests.sh +0 -13
  384. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_gcc_corr_tests.sh +0 -13
  385. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_gcc_example.sh +0 -13
  386. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_gcc_file_conv.sh +0 -14
  387. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_gcc_iconv_lib.sh +0 -11
  388. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_gcc_iconv_sample.sh +0 -8
  389. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_mingw_corr_tests.cmd +0 -12
  390. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_mingw_example.cmd +0 -13
  391. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_mingw_file_conv.cmd +0 -14
  392. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_mingw_iconv_lib.cmd +0 -11
  393. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_mingw_iconv_sample.cmd +0 -8
  394. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_msvc_corr_tests.cmd +0 -11
  395. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_msvc_example.cmd +0 -12
  396. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_msvc_file_conv.cmd +0 -13
  397. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_msvc_iconv_lib.cmd +0 -10
  398. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/build_msvc_iconv_sample.cmd +0 -9
  399. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/html_table.py +0 -25
  400. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/measure.py +0 -94
  401. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/resize.py +0 -20
  402. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/wipe_all.cmd +0 -2
  403. package/deps/simdutf/benchmarks/competition/utf8lut/scripts/wipe_interm.cmd +0 -1
  404. package/deps/simdutf/benchmarks/competition/utf8lut/src/base/CustomMemcpy.h +0 -75
  405. package/deps/simdutf/benchmarks/competition/utf8lut/src/base/PerfDefs.h +0 -47
  406. package/deps/simdutf/benchmarks/competition/utf8lut/src/base/Timing.cpp +0 -17
  407. package/deps/simdutf/benchmarks/competition/utf8lut/src/base/Timing.h +0 -76
  408. package/deps/simdutf/benchmarks/competition/utf8lut/src/buffer/AllProcessors.cpp +0 -35
  409. package/deps/simdutf/benchmarks/competition/utf8lut/src/buffer/BaseBufferProcessor.cpp +0 -117
  410. package/deps/simdutf/benchmarks/competition/utf8lut/src/buffer/BaseBufferProcessor.h +0 -210
  411. package/deps/simdutf/benchmarks/competition/utf8lut/src/buffer/BufferDecoder.h +0 -158
  412. package/deps/simdutf/benchmarks/competition/utf8lut/src/buffer/BufferEncoder.h +0 -104
  413. package/deps/simdutf/benchmarks/competition/utf8lut/src/buffer/ProcessorPlugins.h +0 -334
  414. package/deps/simdutf/benchmarks/competition/utf8lut/src/buffer/ProcessorSelector.h +0 -186
  415. package/deps/simdutf/benchmarks/competition/utf8lut/src/core/DecoderLut.cpp +0 -140
  416. package/deps/simdutf/benchmarks/competition/utf8lut/src/core/DecoderLut.h +0 -42
  417. package/deps/simdutf/benchmarks/competition/utf8lut/src/core/DecoderProcess.h +0 -100
  418. package/deps/simdutf/benchmarks/competition/utf8lut/src/core/Dfa.h +0 -57
  419. package/deps/simdutf/benchmarks/competition/utf8lut/src/core/EncoderLut.cpp +0 -85
  420. package/deps/simdutf/benchmarks/competition/utf8lut/src/core/EncoderLut.h +0 -27
  421. package/deps/simdutf/benchmarks/competition/utf8lut/src/core/EncoderProcess.h +0 -126
  422. package/deps/simdutf/benchmarks/competition/utf8lut/src/core/ProcessTrivial.h +0 -108
  423. package/deps/simdutf/benchmarks/competition/utf8lut/src/iconv/iconv.cpp +0 -139
  424. package/deps/simdutf/benchmarks/competition/utf8lut/src/iconv/iconv.h +0 -74
  425. package/deps/simdutf/benchmarks/competition/utf8lut/src/message/MessageConverter.cpp +0 -65
  426. package/deps/simdutf/benchmarks/competition/utf8lut/src/message/MessageConverter.h +0 -91
  427. package/deps/simdutf/benchmarks/competition/utf8lut/src/tests/CorrectnessTests.cpp +0 -772
  428. package/deps/simdutf/benchmarks/competition/utf8lut/src/tests/Example.cpp +0 -12
  429. package/deps/simdutf/benchmarks/competition/utf8lut/src/tests/FileConverter.cpp +0 -486
  430. package/deps/simdutf/benchmarks/competition/utf8lut/src/tests/iconv_sample.c +0 -162
  431. package/deps/simdutf/benchmarks/competition/utf8lut/src/utf8lut.h +0 -15
  432. package/deps/simdutf/benchmarks/competition/utf8sse4/fromutf8-sse.cpp +0 -292
  433. package/deps/simdutf/benchmarks/competition/utfcpp/LICENSE +0 -23
  434. package/deps/simdutf/benchmarks/competition/utfcpp/README.md +0 -1503
  435. package/deps/simdutf/benchmarks/competition/utfcpp/source/utf8/checked.h +0 -335
  436. package/deps/simdutf/benchmarks/competition/utfcpp/source/utf8/core.h +0 -338
  437. package/deps/simdutf/benchmarks/competition/utfcpp/source/utf8/cpp11.h +0 -103
  438. package/deps/simdutf/benchmarks/competition/utfcpp/source/utf8/cpp17.h +0 -103
  439. package/deps/simdutf/benchmarks/competition/utfcpp/source/utf8/unchecked.h +0 -274
  440. package/deps/simdutf/benchmarks/competition/utfcpp/source/utf8.h +0 -34
  441. package/deps/simdutf/benchmarks/dataset/README.md +0 -155
  442. package/deps/simdutf/benchmarks/dataset/emoji.txt +0 -204
  443. package/deps/simdutf/benchmarks/dataset/scripts/utf8type.py +0 -40
  444. package/deps/simdutf/benchmarks/dataset/wikipedia_mars/Makefile +0 -80
  445. package/deps/simdutf/benchmarks/dataset/wikipedia_mars/convert_to_utf6.py +0 -20
  446. package/deps/simdutf/benchmarks/find/CMakeLists.txt +0 -6
  447. package/deps/simdutf/benchmarks/find/findbenchmark.cpp +0 -63
  448. package/deps/simdutf/benchmarks/find/findbenchmarker.h +0 -46
  449. package/deps/simdutf/benchmarks/shortbench.cpp +0 -555
  450. package/deps/simdutf/benchmarks/src/CMakeLists.txt +0 -52
  451. package/deps/simdutf/benchmarks/src/apple_arm_events.h +0 -1104
  452. package/deps/simdutf/benchmarks/src/benchmark.cpp +0 -3899
  453. package/deps/simdutf/benchmarks/src/benchmark.h +0 -317
  454. package/deps/simdutf/benchmarks/src/benchmark_base.cpp +0 -144
  455. package/deps/simdutf/benchmarks/src/benchmark_base.h +0 -98
  456. package/deps/simdutf/benchmarks/src/cmdline.cpp +0 -176
  457. package/deps/simdutf/benchmarks/src/cmdline.h +0 -35
  458. package/deps/simdutf/benchmarks/src/event_counter.h +0 -162
  459. package/deps/simdutf/benchmarks/src/linux-perf-events.h +0 -104
  460. package/deps/simdutf/benchmarks/stream.cpp +0 -209
  461. package/deps/simdutf/benchmarks/threaded.cpp +0 -123
  462. package/deps/simdutf/cmake/CPM.cmake +0 -1363
  463. package/deps/simdutf/cmake/JoinPaths.cmake +0 -23
  464. package/deps/simdutf/cmake/add_cpp_test.cmake +0 -68
  465. package/deps/simdutf/cmake/simdutf-config.cmake.in +0 -2
  466. package/deps/simdutf/cmake/simdutf-flags.cmake +0 -26
  467. package/deps/simdutf/cmake/toolchains-ci/riscv64-linux-gnu.cmake +0 -4
  468. package/deps/simdutf/cmake/toolchains-dev/README.md +0 -32
  469. package/deps/simdutf/cmake/toolchains-dev/aarch64.cmake +0 -14
  470. package/deps/simdutf/cmake/toolchains-dev/loongarch64.cmake +0 -22
  471. package/deps/simdutf/cmake/toolchains-dev/powerpc64.cmake +0 -16
  472. package/deps/simdutf/cmake/toolchains-dev/powerpc64le.cmake +0 -16
  473. package/deps/simdutf/cmake/toolchains-dev/riscv64.cmake +0 -16
  474. package/deps/simdutf/cmake/toolchains-dev/rvv-spike.cmake +0 -38
  475. package/deps/simdutf/doc/avx512.png +0 -0
  476. package/deps/simdutf/doc/logo.png +0 -0
  477. package/deps/simdutf/doc/logo.svg +0 -165
  478. package/deps/simdutf/doc/node2023.png +0 -0
  479. package/deps/simdutf/doc/shortinput.md +0 -78
  480. package/deps/simdutf/doc/utf16utf8.png +0 -0
  481. package/deps/simdutf/doc/utf8utf16.png +0 -0
  482. package/deps/simdutf/doc/widelogo.png +0 -0
  483. package/deps/simdutf/doxygen.py +0 -50
  484. package/deps/simdutf/fuzz/.clang-format +0 -9
  485. package/deps/simdutf/fuzz/CMakeLists.txt +0 -45
  486. package/deps/simdutf/fuzz/README.md +0 -168
  487. package/deps/simdutf/fuzz/atomic_base64.cpp +0 -448
  488. package/deps/simdutf/fuzz/base64.cpp +0 -278
  489. package/deps/simdutf/fuzz/build.sh +0 -83
  490. package/deps/simdutf/fuzz/conversion.cpp +0 -669
  491. package/deps/simdutf/fuzz/helpers/.clang-format-ignore +0 -1
  492. package/deps/simdutf/fuzz/helpers/common.h +0 -135
  493. package/deps/simdutf/fuzz/helpers/nameof.hpp +0 -1258
  494. package/deps/simdutf/fuzz/main.cpp +0 -72
  495. package/deps/simdutf/fuzz/minimize_and_cleanse.sh +0 -87
  496. package/deps/simdutf/fuzz/misc.cpp +0 -216
  497. package/deps/simdutf/fuzz/random_fuzz.sh +0 -154
  498. package/deps/simdutf/fuzz/roundtrip.cpp +0 -588
  499. package/deps/simdutf/fuzz/safe_conversion.cpp +0 -104
  500. package/deps/simdutf/riscv/Dockerfile +0 -16
  501. package/deps/simdutf/riscv/README.md +0 -24
  502. package/deps/simdutf/riscv/remove-docker-station +0 -8
  503. package/deps/simdutf/riscv/run-docker-station +0 -31
  504. package/deps/simdutf/scripts/.flake8 +0 -2
  505. package/deps/simdutf/scripts/Makefile +0 -2
  506. package/deps/simdutf/scripts/README_ADD_FUNCTION.md +0 -49
  507. package/deps/simdutf/scripts/add_function.py +0 -330
  508. package/deps/simdutf/scripts/amalgamation_tests.py +0 -156
  509. package/deps/simdutf/scripts/base64/Makefile +0 -2
  510. package/deps/simdutf/scripts/base64/README.md +0 -2
  511. package/deps/simdutf/scripts/base64/avx512.py +0 -76
  512. package/deps/simdutf/scripts/base64/neon_decode.py +0 -143
  513. package/deps/simdutf/scripts/base64/neon_generate_lut.py +0 -101
  514. package/deps/simdutf/scripts/base64/sse.py +0 -252
  515. package/deps/simdutf/scripts/base64/sseregular.py +0 -160
  516. package/deps/simdutf/scripts/base64/sseurl.py +0 -283
  517. package/deps/simdutf/scripts/base64/table.py +0 -59
  518. package/deps/simdutf/scripts/base64bench_print.py +0 -145
  519. package/deps/simdutf/scripts/benchmark-all.py +0 -119
  520. package/deps/simdutf/scripts/benchmark_print.py +0 -324
  521. package/deps/simdutf/scripts/check_feature_macros.py +0 -156
  522. package/deps/simdutf/scripts/check_typos.sh +0 -13
  523. package/deps/simdutf/scripts/clang_format.sh +0 -35
  524. package/deps/simdutf/scripts/clang_format_docker.sh +0 -38
  525. package/deps/simdutf/scripts/common.py +0 -24
  526. package/deps/simdutf/scripts/compilation_benchmark.py +0 -55
  527. package/deps/simdutf/scripts/compile_many_variations.sh +0 -64
  528. package/deps/simdutf/scripts/create_latex_table.py +0 -62
  529. package/deps/simdutf/scripts/docker/Dockerfile +0 -14
  530. package/deps/simdutf/scripts/docker/Makefile +0 -9
  531. package/deps/simdutf/scripts/docker/README.md +0 -30
  532. package/deps/simdutf/scripts/docker/llvm.gpg +0 -0
  533. package/deps/simdutf/scripts/ppc64_convert_utf16_to_utf8.py +0 -155
  534. package/deps/simdutf/scripts/prepare_doxygen.sh +0 -21
  535. package/deps/simdutf/scripts/release.py +0 -197
  536. package/deps/simdutf/scripts/shortinputplots.py +0 -97
  537. package/deps/simdutf/scripts/sse_convert_utf16_to_utf8.py +0 -422
  538. package/deps/simdutf/scripts/sse_convert_utf32_to_utf16.py +0 -105
  539. package/deps/simdutf/scripts/sse_utf8_utf16_decode.py +0 -186
  540. package/deps/simdutf/scripts/sse_validate_utf16le_proof.py +0 -137
  541. package/deps/simdutf/scripts/sse_validate_utf16le_testcases.py +0 -129
  542. package/deps/simdutf/scripts/table.py +0 -207
  543. package/deps/simdutf/scripts/tests/new.txt +0 -33
  544. package/deps/simdutf/scripts/tests/old.txt +0 -33
  545. package/deps/simdutf/scripts/tests/results.txt +0 -272
  546. package/deps/simdutf/simdutf.pc.in +0 -11
  547. package/deps/simdutf/singleheader/.flake8 +0 -2
  548. package/deps/simdutf/singleheader/CMakeLists.txt +0 -64
  549. package/deps/simdutf/singleheader/README-dev.md +0 -81
  550. package/deps/simdutf/singleheader/README.md +0 -19
  551. package/deps/simdutf/singleheader/amalgamate.py +0 -513
  552. package/deps/simdutf/singleheader/amalgamation_demo.c +0 -59
  553. package/deps/simdutf/singleheader/amalgamation_demo.cpp +0 -54
  554. package/deps/simdutf/singleheader/test-features.py +0 -262
  555. package/deps/simdutf/src/CMakeLists.txt +0 -78
  556. package/deps/simdutf/tests/CMakeLists.txt +0 -483
  557. package/deps/simdutf/tests/atomic_base64_tests.cpp +0 -2845
  558. package/deps/simdutf/tests/base64_tests.cpp +0 -3617
  559. package/deps/simdutf/tests/basic_fuzzer.cpp +0 -805
  560. package/deps/simdutf/tests/bele_tests.cpp +0 -182
  561. package/deps/simdutf/tests/constexpr_base64_tests.cpp +0 -387
  562. package/deps/simdutf/tests/convert_latin1_to_utf16be_tests.cpp +0 -52
  563. package/deps/simdutf/tests/convert_latin1_to_utf16le_tests.cpp +0 -80
  564. package/deps/simdutf/tests/convert_latin1_to_utf32_tests.cpp +0 -66
  565. package/deps/simdutf/tests/convert_latin1_to_utf8_tests.cpp +0 -120
  566. package/deps/simdutf/tests/convert_utf16_to_utf8_safe_tests.cpp +0 -203
  567. package/deps/simdutf/tests/convert_utf16_to_utf8_with_replacement_tests.cpp +0 -276
  568. package/deps/simdutf/tests/convert_utf16be_to_latin1_tests.cpp +0 -109
  569. package/deps/simdutf/tests/convert_utf16be_to_latin1_tests_with_errors.cpp +0 -136
  570. package/deps/simdutf/tests/convert_utf16be_to_utf32_tests.cpp +0 -193
  571. package/deps/simdutf/tests/convert_utf16be_to_utf32_with_errors_tests.cpp +0 -381
  572. package/deps/simdutf/tests/convert_utf16be_to_utf8_tests.cpp +0 -259
  573. package/deps/simdutf/tests/convert_utf16be_to_utf8_with_errors_tests.cpp +0 -266
  574. package/deps/simdutf/tests/convert_utf16le_to_latin1_tests.cpp +0 -148
  575. package/deps/simdutf/tests/convert_utf16le_to_latin1_tests_with_errors.cpp +0 -176
  576. package/deps/simdutf/tests/convert_utf16le_to_utf32_tests.cpp +0 -213
  577. package/deps/simdutf/tests/convert_utf16le_to_utf32_with_errors_tests.cpp +0 -318
  578. package/deps/simdutf/tests/convert_utf16le_to_utf8_tests.cpp +0 -343
  579. package/deps/simdutf/tests/convert_utf16le_to_utf8_with_errors_tests.cpp +0 -271
  580. package/deps/simdutf/tests/convert_utf32_to_latin1_tests.cpp +0 -111
  581. package/deps/simdutf/tests/convert_utf32_to_latin1_with_errors_tests.cpp +0 -96
  582. package/deps/simdutf/tests/convert_utf32_to_utf16be_tests.cpp +0 -148
  583. package/deps/simdutf/tests/convert_utf32_to_utf16be_with_errors_tests.cpp +0 -192
  584. package/deps/simdutf/tests/convert_utf32_to_utf16le_tests.cpp +0 -166
  585. package/deps/simdutf/tests/convert_utf32_to_utf16le_with_errors_tests.cpp +0 -215
  586. package/deps/simdutf/tests/convert_utf32_to_utf8_tests.cpp +0 -181
  587. package/deps/simdutf/tests/convert_utf32_to_utf8_with_errors_tests.cpp +0 -261
  588. package/deps/simdutf/tests/convert_utf8_to_latin1_tests.cpp +0 -516
  589. package/deps/simdutf/tests/convert_utf8_to_latin1_with_errors_tests.cpp +0 -579
  590. package/deps/simdutf/tests/convert_utf8_to_utf16be_tests.cpp +0 -412
  591. package/deps/simdutf/tests/convert_utf8_to_utf16be_with_errors_tests.cpp +0 -480
  592. package/deps/simdutf/tests/convert_utf8_to_utf16le_tests.cpp +0 -671
  593. package/deps/simdutf/tests/convert_utf8_to_utf16le_with_errors_tests.cpp +0 -455
  594. package/deps/simdutf/tests/convert_utf8_to_utf32_tests.cpp +0 -1204
  595. package/deps/simdutf/tests/convert_utf8_to_utf32_with_errors_tests.cpp +0 -337
  596. package/deps/simdutf/tests/convert_valid_utf16be_to_latin1_tests.cpp +0 -37
  597. package/deps/simdutf/tests/convert_valid_utf16be_to_utf32_tests.cpp +0 -97
  598. package/deps/simdutf/tests/convert_valid_utf16be_to_utf8_tests.cpp +0 -126
  599. package/deps/simdutf/tests/convert_valid_utf16le_to_latin1_tests.cpp +0 -71
  600. package/deps/simdutf/tests/convert_valid_utf16le_to_utf32_tests.cpp +0 -122
  601. package/deps/simdutf/tests/convert_valid_utf16le_to_utf8_tests.cpp +0 -244
  602. package/deps/simdutf/tests/convert_valid_utf32_to_latin1_tests.cpp +0 -49
  603. package/deps/simdutf/tests/convert_valid_utf32_to_utf16be_tests.cpp +0 -92
  604. package/deps/simdutf/tests/convert_valid_utf32_to_utf16le_tests.cpp +0 -114
  605. package/deps/simdutf/tests/convert_valid_utf32_to_utf8_tests.cpp +0 -109
  606. package/deps/simdutf/tests/convert_valid_utf8_to_latin1_tests.cpp +0 -84
  607. package/deps/simdutf/tests/convert_valid_utf8_to_utf16be_tests.cpp +0 -124
  608. package/deps/simdutf/tests/convert_valid_utf8_to_utf16le_tests.cpp +0 -221
  609. package/deps/simdutf/tests/convert_valid_utf8_to_utf32_tests.cpp +0 -155
  610. package/deps/simdutf/tests/count_utf16be.cpp +0 -64
  611. package/deps/simdutf/tests/count_utf16le.cpp +0 -61
  612. package/deps/simdutf/tests/count_utf8.cpp +0 -87
  613. package/deps/simdutf/tests/detect_encodings_tests.cpp +0 -312
  614. package/deps/simdutf/tests/embed/valid_utf8.txt +0 -1
  615. package/deps/simdutf/tests/embed_tests.cpp +0 -22
  616. package/deps/simdutf/tests/find_tests.cpp +0 -77
  617. package/deps/simdutf/tests/fixed_string_tests.cpp +0 -153
  618. package/deps/simdutf/tests/helpers/CMakeLists.txt +0 -25
  619. package/deps/simdutf/tests/helpers/compiletime_conversions.h +0 -222
  620. package/deps/simdutf/tests/helpers/fixed_string.h +0 -267
  621. package/deps/simdutf/tests/helpers/random_int.cpp +0 -30
  622. package/deps/simdutf/tests/helpers/random_int.h +0 -39
  623. package/deps/simdutf/tests/helpers/random_utf16.cpp +0 -123
  624. package/deps/simdutf/tests/helpers/random_utf16.h +0 -52
  625. package/deps/simdutf/tests/helpers/random_utf32.cpp +0 -41
  626. package/deps/simdutf/tests/helpers/random_utf32.h +0 -40
  627. package/deps/simdutf/tests/helpers/random_utf8.cpp +0 -93
  628. package/deps/simdutf/tests/helpers/random_utf8.h +0 -36
  629. package/deps/simdutf/tests/helpers/test.cpp +0 -231
  630. package/deps/simdutf/tests/helpers/test.h +0 -193
  631. package/deps/simdutf/tests/helpers/transcode_test_base.cpp +0 -1257
  632. package/deps/simdutf/tests/helpers/transcode_test_base.h +0 -683
  633. package/deps/simdutf/tests/helpers/utf16.h +0 -27
  634. package/deps/simdutf/tests/installation_tests/find/CMakeLists.txt +0 -43
  635. package/deps/simdutf/tests/installation_tests/from_fetch/CMakeLists.txt +0 -47
  636. package/deps/simdutf/tests/internal_tests.cpp +0 -27
  637. package/deps/simdutf/tests/null_safety_tests.cpp +0 -94
  638. package/deps/simdutf/tests/random_fuzzer.cpp +0 -779
  639. package/deps/simdutf/tests/readme_tests.cpp +0 -274
  640. package/deps/simdutf/tests/reference/CMakeLists.txt +0 -23
  641. package/deps/simdutf/tests/reference/decode_utf16.h +0 -81
  642. package/deps/simdutf/tests/reference/decode_utf32.h +0 -47
  643. package/deps/simdutf/tests/reference/encode_latin1.cpp +0 -1
  644. package/deps/simdutf/tests/reference/encode_latin1.h +0 -32
  645. package/deps/simdutf/tests/reference/encode_utf16.cpp +0 -49
  646. package/deps/simdutf/tests/reference/encode_utf16.h +0 -20
  647. package/deps/simdutf/tests/reference/encode_utf32.cpp +0 -1
  648. package/deps/simdutf/tests/reference/encode_utf32.h +0 -36
  649. package/deps/simdutf/tests/reference/encode_utf8.cpp +0 -1
  650. package/deps/simdutf/tests/reference/encode_utf8.h +0 -40
  651. package/deps/simdutf/tests/reference/validate_utf16.cpp +0 -60
  652. package/deps/simdutf/tests/reference/validate_utf16.h +0 -14
  653. package/deps/simdutf/tests/reference/validate_utf16_to_latin1.cpp +0 -35
  654. package/deps/simdutf/tests/reference/validate_utf16_to_latin1.h +0 -13
  655. package/deps/simdutf/tests/reference/validate_utf32.cpp +0 -27
  656. package/deps/simdutf/tests/reference/validate_utf32.h +0 -12
  657. package/deps/simdutf/tests/reference/validate_utf32_to_latin1.cpp +0 -27
  658. package/deps/simdutf/tests/reference/validate_utf32_to_latin1.h +0 -12
  659. package/deps/simdutf/tests/reference/validate_utf8.cpp +0 -82
  660. package/deps/simdutf/tests/reference/validate_utf8.h +0 -11
  661. package/deps/simdutf/tests/reference/validate_utf8_to_latin1.cpp +0 -43
  662. package/deps/simdutf/tests/reference/validate_utf8_to_latin1.h +0 -12
  663. package/deps/simdutf/tests/select_implementation.cpp +0 -43
  664. package/deps/simdutf/tests/simdutf_c_tests.cpp +0 -244
  665. package/deps/simdutf/tests/span_tests.cpp +0 -401
  666. package/deps/simdutf/tests/special_tests.cpp +0 -559
  667. package/deps/simdutf/tests/straight_c_test.c +0 -187
  668. package/deps/simdutf/tests/text_encoding_tests.cpp +0 -77
  669. package/deps/simdutf/tests/to_well_formed_utf16_tests.cpp +0 -377
  670. package/deps/simdutf/tests/utf8_length_from_utf16_tests.cpp +0 -202
  671. package/deps/simdutf/tests/validate_ascii_basic_tests.cpp +0 -165
  672. package/deps/simdutf/tests/validate_ascii_with_errors_tests.cpp +0 -77
  673. package/deps/simdutf/tests/validate_utf16be_basic_tests.cpp +0 -175
  674. package/deps/simdutf/tests/validate_utf16be_with_errors_tests.cpp +0 -188
  675. package/deps/simdutf/tests/validate_utf16le_basic_tests.cpp +0 -268
  676. package/deps/simdutf/tests/validate_utf16le_with_errors_tests.cpp +0 -274
  677. package/deps/simdutf/tests/validate_utf32_basic_tests.cpp +0 -92
  678. package/deps/simdutf/tests/validate_utf32_with_errors_tests.cpp +0 -114
  679. package/deps/simdutf/tests/validate_utf8_basic_tests.cpp +0 -178
  680. package/deps/simdutf/tests/validate_utf8_brute_force_tests.cpp +0 -88
  681. package/deps/simdutf/tests/validate_utf8_puzzler_tests.cpp +0 -33
  682. package/deps/simdutf/tests/validate_utf8_with_errors_tests.cpp +0 -228
  683. package/deps/simdutf/tools/CMakeLists.txt +0 -85
  684. package/deps/simdutf/tools/fastbase64.cpp +0 -250
  685. package/deps/simdutf/tools/sutf.cpp +0 -556
  686. package/deps/simdutf/tools/sutf.h +0 -40
  687. package/lib/tsconfig.tsbuildinfo +0 -1
@@ -1,704 +0,0 @@
1
- //! Low-level tree manipulations and other sharp tools
2
- //!
3
- //! The target audience for this module is projects like [Bao](https://github.com/oconnor663/bao),
4
- //! which work directly with the interior hashes ("chaining values") of BLAKE3 chunks and subtrees.
5
- //! For example, you could use these functions to implement a BitTorrent-like protocol using the
6
- //! BLAKE3 tree structure, or to hash an input that's distributed across different machines. These
7
- //! use cases are advanced, and most applications don't need this module. Also:
8
- //!
9
- //! <div class="warning">
10
- //!
11
- //! **Warning:** This module is *hazardous material*. If you've heard folks say *don't roll your
12
- //! own crypto,* this is the sort of thing they're talking about. These functions have complicated
13
- //! requirements, and any mistakes will give you garbage output and/or break the security
14
- //! properties that BLAKE3 is supposed to have. Read section 2.1 of [the BLAKE3
15
- //! paper](https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf) to understand the
16
- //! tree structure you need to maintain. Test your code against [`blake3::hash`](../fn.hash.html)
17
- //! and make sure you can get the same outputs for [lots of different
18
- //! inputs](https://github.com/BLAKE3-team/BLAKE3/blob/master/test_vectors/test_vectors.json).
19
- //!
20
- //! </div>
21
- //!
22
- //! On the other hand:
23
- //!
24
- //! <div class="warning">
25
- //!
26
- //! **Encouragement:** Playing with these functions is a great way to learn how BLAKE3 works on the
27
- //! inside. Have fun!
28
- //!
29
- //! </div>
30
- //!
31
- //! The main entrypoint for this module is the [`HasherExt`] trait, particularly the
32
- //! [`set_input_offset`](HasherExt::set_input_offset) and
33
- //! [`finalize_non_root`](HasherExt::finalize_non_root) methods. These let you compute the chaining
34
- //! values of individual chunks or subtrees. You then combine these chaining values into larger
35
- //! subtrees using [`merge_subtrees_non_root`] and finally (once at the very top)
36
- //! [`merge_subtrees_root`] or [`merge_subtrees_root_xof`].
37
- //!
38
- //! # Examples
39
- //!
40
- //! Here's an example of computing all the interior hashes in a 3-chunk tree:
41
- //!
42
- //! ```text
43
- //! root
44
- //! / \
45
- //! parent \
46
- //! / \ \
47
- //! chunk0 chunk1 chunk2
48
- //! ```
49
- //!
50
- //! ```
51
- //! # fn main() {
52
- //! use blake3::{Hasher, CHUNK_LEN};
53
- //! use blake3::hazmat::{merge_subtrees_non_root, merge_subtrees_root, Mode};
54
- //! use blake3::hazmat::HasherExt; // an extension trait for Hasher
55
- //!
56
- //! let chunk0 = [b'a'; CHUNK_LEN];
57
- //! let chunk1 = [b'b'; CHUNK_LEN];
58
- //! let chunk2 = [b'c'; 42]; // The final chunk can be short.
59
- //!
60
- //! // Compute the non-root hashes ("chaining values") of all three chunks. Chunks or subtrees
61
- //! // that don't begin at the start of the input use `set_input_offset` to say where they begin.
62
- //! let chunk0_cv = Hasher::new()
63
- //! // .set_input_offset(0) is the default.
64
- //! .update(&chunk0)
65
- //! .finalize_non_root();
66
- //! let chunk1_cv = Hasher::new()
67
- //! .set_input_offset(CHUNK_LEN as u64)
68
- //! .update(&chunk1)
69
- //! .finalize_non_root();
70
- //! let chunk2_cv = Hasher::new()
71
- //! .set_input_offset(2 * CHUNK_LEN as u64)
72
- //! .update(&chunk2)
73
- //! .finalize_non_root();
74
- //!
75
- //! // Join the first two chunks with a non-root parent node and compute its chaining value.
76
- //! let parent_cv = merge_subtrees_non_root(&chunk0_cv, &chunk1_cv, Mode::Hash);
77
- //!
78
- //! // Join that parent node and the third chunk with a root parent node and compute the hash.
79
- //! let root_hash = merge_subtrees_root(&parent_cv, &chunk2_cv, Mode::Hash);
80
- //!
81
- //! // Double check that we got the right answer.
82
- //! let mut combined_input = Vec::new();
83
- //! combined_input.extend_from_slice(&chunk0);
84
- //! combined_input.extend_from_slice(&chunk1);
85
- //! combined_input.extend_from_slice(&chunk2);
86
- //! assert_eq!(root_hash, blake3::hash(&combined_input));
87
- //! # }
88
- //! ```
89
- //!
90
- //! Hashing many chunks together is important for performance, because it allows the implementation
91
- //! to use SIMD parallelism internally. ([AVX-512](https://en.wikipedia.org/wiki/AVX-512) for
92
- //! example needs 16 chunks to really get going.) We can reproduce `parent_cv` by hashing `chunk0`
93
- //! and `chunk1` at the same time:
94
- //!
95
- //! ```
96
- //! # fn main() {
97
- //! # use blake3::{Hasher, CHUNK_LEN};
98
- //! # use blake3::hazmat::{Mode, HasherExt, merge_subtrees_non_root, merge_subtrees_root};
99
- //! # let chunk0 = [b'a'; CHUNK_LEN];
100
- //! # let chunk1 = [b'b'; CHUNK_LEN];
101
- //! # let chunk0_cv = Hasher::new().update(&chunk0).finalize_non_root();
102
- //! # let chunk1_cv = Hasher::new().set_input_offset(CHUNK_LEN as u64).update(&chunk1).finalize_non_root();
103
- //! # let parent_cv = merge_subtrees_non_root(&chunk0_cv, &chunk1_cv, Mode::Hash);
104
- //! # let mut combined_input = Vec::new();
105
- //! # combined_input.extend_from_slice(&chunk0);
106
- //! # combined_input.extend_from_slice(&chunk1);
107
- //! let left_subtree_cv = Hasher::new()
108
- //! // .set_input_offset(0) is the default.
109
- //! .update(&combined_input[..2 * CHUNK_LEN])
110
- //! .finalize_non_root();
111
- //! assert_eq!(left_subtree_cv, parent_cv);
112
- //!
113
- //! // Using multiple updates gives the same answer, though it's not as efficient.
114
- //! let mut subtree_hasher = Hasher::new();
115
- //! // Again, .set_input_offset(0) is the default.
116
- //! subtree_hasher.update(&chunk0);
117
- //! subtree_hasher.update(&chunk1);
118
- //! assert_eq!(left_subtree_cv, subtree_hasher.finalize_non_root());
119
- //! # }
120
- //! ```
121
- //!
122
- //! However, hashing multiple chunks together **must** respect the overall tree structure. Hashing
123
- //! `chunk0` and `chunk1` together is valid, but hashing `chunk1` and `chunk2` together is
124
- //! incorrect and gives a garbage result that will never match a standard BLAKE3 hash. The
125
- //! implementation includes a few best-effort asserts to catch some of these mistakes, but these
126
- //! checks aren't guaranteed. For example, this second call to `update` currently panics:
127
- //!
128
- //! ```should_panic
129
- //! # fn main() {
130
- //! # use blake3::{Hasher, CHUNK_LEN};
131
- //! # use blake3::hazmat::HasherExt;
132
- //! # let chunk0 = [b'a'; CHUNK_LEN];
133
- //! # let chunk1 = [b'b'; CHUNK_LEN];
134
- //! # let chunk2 = [b'c'; 42];
135
- //! let oops = Hasher::new()
136
- //! .set_input_offset(CHUNK_LEN as u64)
137
- //! .update(&chunk1)
138
- //! // PANIC: "the subtree starting at 1024 contains at most 1024 bytes"
139
- //! .update(&chunk2)
140
- //! .finalize_non_root();
141
- //! # }
142
- //! ```
143
- //!
144
- //! For more on valid tree structures, see the docs for and [`left_subtree_len`] and
145
- //! [`max_subtree_len`], and see section 2.1 of [the BLAKE3
146
- //! paper](https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf). Note that the
147
- //! merging functions ([`merge_subtrees_root`] and friends) don't know the shape of the left and
148
- //! right subtrees you're giving them, and they can't help you catch mistakes. The best way to
149
- //! catch mistakes with these is to compare your root output to the [`blake3::hash`](crate::hash)
150
- //! of the same input.
151
-
152
- use crate::platform::Platform;
153
- use crate::{CVWords, Hasher, CHUNK_LEN, IV, KEY_LEN, OUT_LEN};
154
-
155
- /// Extension methods for [`Hasher`]. This is the main entrypoint to the `hazmat` module.
156
- pub trait HasherExt {
157
- /// Similar to [`Hasher::new_derive_key`] but using a pre-hashed [`ContextKey`] from
158
- /// [`hash_derive_key_context`].
159
- ///
160
- /// The [`hash_derive_key_context`] function is _only_ valid source of the [`ContextKey`]
161
- ///
162
- /// # Example
163
- ///
164
- /// ```
165
- /// use blake3::Hasher;
166
- /// use blake3::hazmat::HasherExt;
167
- ///
168
- /// let context_key = blake3::hazmat::hash_derive_key_context("foo");
169
- /// let mut hasher = Hasher::new_from_context_key(&context_key);
170
- /// hasher.update(b"bar");
171
- /// let derived_key = *hasher.finalize().as_bytes();
172
- ///
173
- /// assert_eq!(derived_key, blake3::derive_key("foo", b"bar"));
174
- /// ```
175
- fn new_from_context_key(context_key: &ContextKey) -> Self;
176
-
177
- /// Configure the `Hasher` to process a chunk or subtree starting at `offset` bytes into the
178
- /// whole input.
179
- ///
180
- /// You must call this function before processing any input with [`update`](Hasher::update) or
181
- /// similar. This step isn't required for the first chunk, or for a subtree that includes the
182
- /// first chunk (i.e. when the `offset` is zero), but it's required for all other chunks and
183
- /// subtrees.
184
- ///
185
- /// The starting input offset of a subtree implies a maximum possible length for that subtree.
186
- /// See [`max_subtree_len`] and section 2.1 of [the BLAKE3
187
- /// paper](https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf). Note that only
188
- /// subtrees along the right edge of the whole tree can have a length less than their maximum
189
- /// possible length.
190
- ///
191
- /// See the [module level examples](index.html#examples).
192
- ///
193
- /// # Panics
194
- ///
195
- /// This function panics if the `Hasher` has already accepted any input with
196
- /// [`update`](Hasher::update) or similar.
197
- ///
198
- /// This should always be paired with [`finalize_non_root`](HasherExt::finalize_non_root). It's
199
- /// never correct to use a non-zero input offset with [`finalize`](Hasher::finalize) or
200
- /// [`finalize_xof`](Hasher::finalize_xof). The `offset` must also be a multiple of
201
- /// `CHUNK_LEN`. Violating either of these rules will currently fail an assertion and panic,
202
- /// but this is not guaranteed.
203
- fn set_input_offset(&mut self, offset: u64) -> &mut Self;
204
-
205
- /// Finalize the non-root hash ("chaining value") of the current chunk or subtree.
206
- ///
207
- /// Afterwards you can merge subtree chaining values into parent nodes using
208
- /// [`merge_subtrees_non_root`] and ultimately into the root node with either
209
- /// [`merge_subtrees_root`] (similar to [`Hasher::finalize`]) or [`merge_subtrees_root_xof`]
210
- /// (similar to [`Hasher::finalize_xof`]).
211
- ///
212
- /// See the [module level examples](index.html#examples), particularly the discussion of valid
213
- /// tree structures.
214
- fn finalize_non_root(&self) -> ChainingValue;
215
- }
216
-
217
- impl HasherExt for Hasher {
218
- fn new_from_context_key(context_key: &[u8; KEY_LEN]) -> Hasher {
219
- let context_key_words = crate::platform::words_from_le_bytes_32(context_key);
220
- Hasher::new_internal(&context_key_words, crate::DERIVE_KEY_MATERIAL)
221
- }
222
-
223
- fn set_input_offset(&mut self, offset: u64) -> &mut Hasher {
224
- assert_eq!(self.count(), 0, "hasher has already accepted input");
225
- assert_eq!(
226
- offset % CHUNK_LEN as u64,
227
- 0,
228
- "offset ({offset}) must be a chunk boundary (divisible by {CHUNK_LEN})",
229
- );
230
- let counter = offset / CHUNK_LEN as u64;
231
- self.chunk_state.chunk_counter = counter;
232
- self.initial_chunk_counter = counter;
233
- self
234
- }
235
-
236
- fn finalize_non_root(&self) -> ChainingValue {
237
- assert_ne!(self.count(), 0, "empty subtrees are never valid");
238
- self.final_output().chaining_value()
239
- }
240
- }
241
-
242
- /// The maximum length of a subtree in bytes, given its starting offset in bytes
243
- ///
244
- /// If you try to hash more than this many bytes as one subtree, you'll end up merging parent nodes
245
- /// that shouldn't be merged, and your output will be garbage. [`Hasher::update`] will currently
246
- /// panic in this case, but this is not guaranteed.
247
- ///
248
- /// For input offset zero (the default), there is no maximum length, and this function returns
249
- /// `None`. For all other offsets it returns `Some`. Note that valid offsets must be a multiple of
250
- /// [`CHUNK_LEN`] (1024); it's not possible to start hashing a chunk in the middle.
251
- ///
252
- /// In the example tree below, chunks are numbered by their _0-based index_. The subtree that
253
- /// _starts_ with chunk 3, i.e. `input_offset = 3 * CHUNK_LEN`, includes only that one chunk, so
254
- /// its max length is `Some(CHUNK_LEN)`. The subtree that starts with chunk 6 includes chunk 7 but
255
- /// not chunk 8, so its max length is `Some(2 * CHUNK_LEN)`. The subtree that starts with chunk 12
256
- /// includes chunks 13, 14, and 15, but if the tree were bigger it would not include chunk 16, so
257
- /// its max length is `Some(4 * CHUNK_LEN)`. One way to think about the rule here is that, if you
258
- /// go beyond the max subtree length from a given starting offset, you start dealing with subtrees
259
- /// that include chunks _to the left_ of where you started.
260
- ///
261
- /// ```text
262
- /// root
263
- /// / \
264
- /// . .
265
- /// / \ / \
266
- /// . . . .
267
- /// / \ / \ / \ / \
268
- /// . . . . . . . .
269
- /// / \ / \ / \ / \ / \ / \ / \ / \
270
- /// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
271
- /// ```
272
- ///
273
- /// The general rule turns out to be that for a subtree starting at a 0-based chunk index N greater
274
- /// than zero, the maximum number of chunks in that subtree is the largest power-of-two that
275
- /// divides N, which is given by `1 << N.trailing_zeros()`.
276
- ///
277
- /// This function can be useful for writing tests or debug assertions, but it's actually rare to
278
- /// use this for real control flow. Callers who split their input recursively using
279
- /// [`left_subtree_len`] will automatically satisfy the `max_subtree_len` bound and don't
280
- /// necessarily need to check. It's also common to choose some fixed power-of-two subtree size, say
281
- /// 64 chunks, and divide your input up into slices of that fixed length (with the final slice
282
- /// possibly short). This approach also automatically satisfies the `max_subtree_len` bound and
283
- /// doesn't need to check. Proving that this is true can be an interesting exercise. Note that
284
- /// chunks 0, 4, 8, and 12 all begin subtrees of at least 4 chunks in the example tree above.
285
- ///
286
- /// # Panics
287
- ///
288
- /// This function currently panics if `input_offset` is not a multiple of `CHUNK_LEN`. This is not
289
- /// guaranteed.
290
- #[inline(always)]
291
- pub fn max_subtree_len(input_offset: u64) -> Option<u64> {
292
- if input_offset == 0 {
293
- return None;
294
- }
295
- assert_eq!(input_offset % CHUNK_LEN as u64, 0);
296
- let counter = input_offset / CHUNK_LEN as u64;
297
- let max_chunks = 1 << counter.trailing_zeros();
298
- Some(max_chunks * CHUNK_LEN as u64)
299
- }
300
-
301
- #[test]
302
- fn test_max_subtree_len() {
303
- assert_eq!(max_subtree_len(0), None);
304
- // (chunk index, max chunks)
305
- let cases = [
306
- (1, 1),
307
- (2, 2),
308
- (3, 1),
309
- (4, 4),
310
- (5, 1),
311
- (6, 2),
312
- (7, 1),
313
- (8, 8),
314
- ];
315
- for (chunk_index, max_chunks) in cases {
316
- let input_offset = chunk_index * CHUNK_LEN as u64;
317
- assert_eq!(
318
- max_subtree_len(input_offset),
319
- Some(max_chunks * CHUNK_LEN as u64),
320
- );
321
- }
322
- }
323
-
324
- /// Given the length in bytes of either a complete input or a subtree input, return the number of
325
- /// bytes that belong to its left child subtree. The rest belong to its right child subtree.
326
- ///
327
- /// Concretely, this function returns the largest power-of-two number of bytes that's strictly less
328
- /// than `input_len`. This leads to a tree where all left subtrees are "complete" and at least as
329
- /// large as their sibling right subtrees, as specified in section 2.1 of [the BLAKE3
330
- /// paper](https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf). For example, if an
331
- /// input is exactly two chunks, its left and right subtrees both get one chunk. But if an input is
332
- /// two chunks plus one more byte, then its left subtree gets two chunks, and its right subtree
333
- /// only gets one byte.
334
- ///
335
- /// This function isn't meaningful for one chunk of input, because chunks don't have children. It
336
- /// currently panics in debug mode if `input_len <= CHUNK_LEN`.
337
- ///
338
- /// # Example
339
- ///
340
- /// Hash a input of random length as two subtrees:
341
- ///
342
- /// ```
343
- /// # #[cfg(feature = "std")] {
344
- /// use blake3::hazmat::{left_subtree_len, merge_subtrees_root, HasherExt, Mode};
345
- /// use blake3::{Hasher, CHUNK_LEN};
346
- ///
347
- /// // Generate a random-length input. Note that to be split into two subtrees, the input length
348
- /// // must be greater than CHUNK_LEN.
349
- /// let input_len = rand::random_range(CHUNK_LEN + 1..1_000_000);
350
- /// let mut input = vec![0; input_len];
351
- /// rand::fill(&mut input[..]);
352
- ///
353
- /// // Compute the left and right subtree hashes and then the root hash. left_subtree_len() tells
354
- /// // us exactly where to split the input. Any other split would either panic (if we're lucky) or
355
- /// // lead to an incorrect root hash.
356
- /// let left_len = left_subtree_len(input_len as u64) as usize;
357
- /// let left_subtree_cv = Hasher::new()
358
- /// .update(&input[..left_len])
359
- /// .finalize_non_root();
360
- /// let right_subtree_cv = Hasher::new()
361
- /// .set_input_offset(left_len as u64)
362
- /// .update(&input[left_len..])
363
- /// .finalize_non_root();
364
- /// let root_hash = merge_subtrees_root(&left_subtree_cv, &right_subtree_cv, Mode::Hash);
365
- ///
366
- /// // Double check the answer.
367
- /// assert_eq!(root_hash, blake3::hash(&input));
368
- /// # }
369
- /// ```
370
- #[inline(always)]
371
- pub fn left_subtree_len(input_len: u64) -> u64 {
372
- debug_assert!(input_len > CHUNK_LEN as u64);
373
- // Note that .next_power_of_two() is greater than *or equal*.
374
- ((input_len + 1) / 2).next_power_of_two()
375
- }
376
-
377
- #[test]
378
- fn test_left_subtree_len() {
379
- assert_eq!(left_subtree_len(1025), 1024);
380
- for boundary_case in [2, 4, 8, 16, 32, 64] {
381
- let input_len = boundary_case * CHUNK_LEN as u64;
382
- assert_eq!(left_subtree_len(input_len - 1), input_len / 2);
383
- assert_eq!(left_subtree_len(input_len), input_len / 2);
384
- assert_eq!(left_subtree_len(input_len + 1), input_len);
385
- }
386
- }
387
-
388
- /// The `mode` argument to [`merge_subtrees_root`] and friends
389
- ///
390
- /// See the [module level examples](index.html#examples).
391
- #[derive(Copy, Clone, Debug)]
392
- pub enum Mode<'a> {
393
- /// Corresponding to [`hash`](crate::hash)
394
- Hash,
395
-
396
- /// Corresponding to [`keyed_hash`](crate::hash)
397
- KeyedHash(&'a [u8; KEY_LEN]),
398
-
399
- /// Corresponding to [`derive_key`](crate::hash)
400
- ///
401
- /// The [`ContextKey`] comes from [`hash_derive_key_context`].
402
- DeriveKeyMaterial(&'a ContextKey),
403
- }
404
-
405
- impl<'a> Mode<'a> {
406
- fn key_words(&self) -> CVWords {
407
- match self {
408
- Mode::Hash => *IV,
409
- Mode::KeyedHash(key) => crate::platform::words_from_le_bytes_32(key),
410
- Mode::DeriveKeyMaterial(cx_key) => crate::platform::words_from_le_bytes_32(cx_key),
411
- }
412
- }
413
-
414
- fn flags_byte(&self) -> u8 {
415
- match self {
416
- Mode::Hash => 0,
417
- Mode::KeyedHash(_) => crate::KEYED_HASH,
418
- Mode::DeriveKeyMaterial(_) => crate::DERIVE_KEY_MATERIAL,
419
- }
420
- }
421
- }
422
-
423
- /// "Chaining value" is the academic term for a non-root or non-final hash.
424
- ///
425
- /// Besides just sounding fancy, it turns out there are [security
426
- /// reasons](https://jacko.io/tree_hashing.html) to be careful about the difference between
427
- /// (root/final) hashes and (non-root/non-final) chaining values.
428
- pub type ChainingValue = [u8; OUT_LEN];
429
-
430
- fn merge_subtrees_inner(
431
- left_child: &ChainingValue,
432
- right_child: &ChainingValue,
433
- mode: Mode,
434
- ) -> crate::Output {
435
- crate::parent_node_output(
436
- &left_child,
437
- &right_child,
438
- &mode.key_words(),
439
- mode.flags_byte(),
440
- Platform::detect(),
441
- )
442
- }
443
-
444
- /// Compute a non-root parent node chaining value from two child chaining values.
445
- ///
446
- /// See the [module level examples](index.html#examples), particularly the discussion of valid tree
447
- /// structures. The left and right child chaining values can come from either
448
- /// [`Hasher::finalize_non_root`](HasherExt::finalize_non_root) or other calls to
449
- /// `merge_subtrees_non_root`. "Chaining value" is the academic term for a non-root or non-final
450
- /// hash.
451
- pub fn merge_subtrees_non_root(
452
- left_child: &ChainingValue,
453
- right_child: &ChainingValue,
454
- mode: Mode,
455
- ) -> ChainingValue {
456
- merge_subtrees_inner(left_child, right_child, mode).chaining_value()
457
- }
458
-
459
- /// Compute a root hash from two child chaining values.
460
- ///
461
- /// See the [module level examples](index.html#examples), particularly the discussion of valid tree
462
- /// structures. The left and right child chaining values can come from either
463
- /// [`Hasher::finalize_non_root`](HasherExt::finalize_non_root) or [`merge_subtrees_non_root`].
464
- /// "Chaining value" is the academic term for a non-root or non-final hash.
465
- ///
466
- /// Note that inputs of [`CHUNK_LEN`] or less don't produce any parent nodes and can't be hashed
467
- /// using this function. In that case you must get the root hash from [`Hasher::finalize`] (or just
468
- /// [`blake3::hash`](crate::hash)).
469
- pub fn merge_subtrees_root(
470
- left_child: &ChainingValue,
471
- right_child: &ChainingValue,
472
- mode: Mode,
473
- ) -> crate::Hash {
474
- merge_subtrees_inner(left_child, right_child, mode).root_hash()
475
- }
476
-
477
- /// Build a root [`OutputReader`](crate::OutputReader) from two child chaining values.
478
- ///
479
- /// See also the [module level examples](index.html#examples), particularly the discussion of valid
480
- /// tree structures. The left and right child chaining values can come from either
481
- /// [`Hasher::finalize_non_root`](HasherExt::finalize_non_root) or [`merge_subtrees_non_root`].
482
- /// "Chaining value" is the academic term for a non-root or non-final hash.
483
- ///
484
- /// Note that inputs of [`CHUNK_LEN`] or less don't produce any parent nodes and can't be hashed
485
- /// using this function. In that case you must get the `OutputReader` from
486
- /// [`Hasher::finalize_xof`].
487
- ///
488
- /// # Example
489
- ///
490
- /// ```
491
- /// use blake3::hazmat::{merge_subtrees_root_xof, HasherExt, Mode};
492
- /// use blake3::{Hasher, CHUNK_LEN};
493
- ///
494
- /// // Hash a 2-chunk subtree in steps. Note that only
495
- /// // the final chunk can be shorter than CHUNK_LEN.
496
- /// let chunk0 = &[42; CHUNK_LEN];
497
- /// let chunk1 = b"hello world";
498
- /// let chunk0_cv = Hasher::new()
499
- /// .update(chunk0)
500
- /// .finalize_non_root();
501
- /// let chunk1_cv = Hasher::new()
502
- /// .set_input_offset(CHUNK_LEN as u64)
503
- /// .update(chunk1)
504
- /// .finalize_non_root();
505
- ///
506
- /// // Obtain a blake3::OutputReader at the root and extract 1000 bytes.
507
- /// let mut output_reader = merge_subtrees_root_xof(&chunk0_cv, &chunk1_cv, Mode::Hash);
508
- /// let mut output_bytes = [0; 1_000];
509
- /// output_reader.fill(&mut output_bytes);
510
- ///
511
- /// // Double check the answer.
512
- /// let mut hasher = Hasher::new();
513
- /// hasher.update(chunk0);
514
- /// hasher.update(chunk1);
515
- /// let mut expected = [0; 1_000];
516
- /// hasher.finalize_xof().fill(&mut expected);
517
- /// assert_eq!(output_bytes, expected);
518
- /// ```
519
- pub fn merge_subtrees_root_xof(
520
- left_child: &ChainingValue,
521
- right_child: &ChainingValue,
522
- mode: Mode,
523
- ) -> crate::OutputReader {
524
- crate::OutputReader::new(merge_subtrees_inner(left_child, right_child, mode))
525
- }
526
-
527
- /// An alias to distinguish [`hash_derive_key_context`] outputs from other keys.
528
- pub type ContextKey = [u8; KEY_LEN];
529
-
530
- /// Hash a [`derive_key`](crate::derive_key) context string and return a [`ContextKey`].
531
- ///
532
- /// The _only_ valid uses for the returned [`ContextKey`] are [`Hasher::new_from_context_key`] and
533
- /// [`Mode::DeriveKeyMaterial`] (together with the merge subtree functions).
534
- ///
535
- /// # Example
536
- ///
537
- /// ```
538
- /// use blake3::Hasher;
539
- /// use blake3::hazmat::HasherExt;
540
- ///
541
- /// let context_key = blake3::hazmat::hash_derive_key_context("foo");
542
- /// let mut hasher = Hasher::new_from_context_key(&context_key);
543
- /// hasher.update(b"bar");
544
- /// let derived_key = *hasher.finalize().as_bytes();
545
- ///
546
- /// assert_eq!(derived_key, blake3::derive_key("foo", b"bar"));
547
- /// ```
548
- pub fn hash_derive_key_context(context: &str) -> ContextKey {
549
- crate::hash_all_at_once::<crate::join::SerialJoin>(
550
- context.as_bytes(),
551
- IV,
552
- crate::DERIVE_KEY_CONTEXT,
553
- )
554
- .root_hash()
555
- .0
556
- }
557
-
558
- #[cfg(test)]
559
- mod test {
560
- use super::*;
561
-
562
- #[test]
563
- #[should_panic]
564
- fn test_empty_subtree_should_panic() {
565
- Hasher::new().finalize_non_root();
566
- }
567
-
568
- #[test]
569
- #[should_panic]
570
- fn test_unaligned_offset_should_panic() {
571
- Hasher::new().set_input_offset(1);
572
- }
573
-
574
- #[test]
575
- #[should_panic]
576
- fn test_hasher_already_accepted_input_should_panic() {
577
- Hasher::new().update(b"x").set_input_offset(0);
578
- }
579
-
580
- #[test]
581
- #[should_panic]
582
- fn test_too_much_input_should_panic() {
583
- Hasher::new()
584
- .set_input_offset(CHUNK_LEN as u64)
585
- .update(&[0; CHUNK_LEN + 1]);
586
- }
587
-
588
- #[test]
589
- #[should_panic]
590
- fn test_set_input_offset_cant_finalize() {
591
- Hasher::new().set_input_offset(CHUNK_LEN as u64).finalize();
592
- }
593
-
594
- #[test]
595
- #[should_panic]
596
- fn test_set_input_offset_cant_finalize_xof() {
597
- Hasher::new()
598
- .set_input_offset(CHUNK_LEN as u64)
599
- .finalize_xof();
600
- }
601
-
602
- #[test]
603
- fn test_grouped_hash() {
604
- const MAX_CHUNKS: usize = (crate::test::TEST_CASES_MAX + 1) / CHUNK_LEN;
605
- let mut input_buf = [0; crate::test::TEST_CASES_MAX];
606
- crate::test::paint_test_input(&mut input_buf);
607
- for subtree_chunks in [1, 2, 4, 8, 16, 32] {
608
- #[cfg(feature = "std")]
609
- dbg!(subtree_chunks);
610
- let subtree_len = subtree_chunks * CHUNK_LEN;
611
- for &case in crate::test::TEST_CASES {
612
- if case <= subtree_len {
613
- continue;
614
- }
615
- #[cfg(feature = "std")]
616
- dbg!(case);
617
- let input = &input_buf[..case];
618
- let expected_hash = crate::hash(input);
619
-
620
- // Collect all the group chaining values.
621
- let mut chaining_values = arrayvec::ArrayVec::<ChainingValue, MAX_CHUNKS>::new();
622
- let mut subtree_offset = 0;
623
- while subtree_offset < input.len() {
624
- let take = core::cmp::min(subtree_len, input.len() - subtree_offset);
625
- let subtree_input = &input[subtree_offset..][..take];
626
- let subtree_cv = Hasher::new()
627
- .set_input_offset(subtree_offset as u64)
628
- .update(subtree_input)
629
- .finalize_non_root();
630
- chaining_values.push(subtree_cv);
631
- subtree_offset += take;
632
- }
633
-
634
- // Compress all the chaining_values together, layer by layer.
635
- assert!(chaining_values.len() >= 2);
636
- while chaining_values.len() > 2 {
637
- let n = chaining_values.len();
638
- // Merge each side-by-side pair in place, overwriting the front half of the
639
- // array with the merged results. This moves us "up one level" in the tree.
640
- for i in 0..(n / 2) {
641
- chaining_values[i] = merge_subtrees_non_root(
642
- &chaining_values[2 * i],
643
- &chaining_values[2 * i + 1],
644
- Mode::Hash,
645
- );
646
- }
647
- // If there's an odd CV out, it moves up.
648
- if n % 2 == 1 {
649
- chaining_values[n / 2] = chaining_values[n - 1];
650
- }
651
- chaining_values.truncate(n / 2 + n % 2);
652
- }
653
- assert_eq!(chaining_values.len(), 2);
654
- let root_hash =
655
- merge_subtrees_root(&chaining_values[0], &chaining_values[1], Mode::Hash);
656
- assert_eq!(expected_hash, root_hash);
657
- }
658
- }
659
- }
660
-
661
- #[test]
662
- fn test_keyed_hash_xof() {
663
- let group0 = &[42; 4096];
664
- let group1 = &[43; 4095];
665
- let mut input = [0; 8191];
666
- input[..4096].copy_from_slice(group0);
667
- input[4096..].copy_from_slice(group1);
668
- let key = &[44; 32];
669
-
670
- let mut expected_output = [0; 100];
671
- Hasher::new_keyed(&key)
672
- .update(&input)
673
- .finalize_xof()
674
- .fill(&mut expected_output);
675
-
676
- let mut hazmat_output = [0; 100];
677
- let left = Hasher::new_keyed(key).update(group0).finalize_non_root();
678
- let right = Hasher::new_keyed(key)
679
- .set_input_offset(group0.len() as u64)
680
- .update(group1)
681
- .finalize_non_root();
682
- merge_subtrees_root_xof(&left, &right, Mode::KeyedHash(&key)).fill(&mut hazmat_output);
683
- assert_eq!(expected_output, hazmat_output);
684
- }
685
-
686
- #[test]
687
- fn test_derive_key() {
688
- let context = "foo";
689
- let mut input = [0; 1025];
690
- crate::test::paint_test_input(&mut input);
691
- let expected = crate::derive_key(context, &input);
692
-
693
- let cx_key = hash_derive_key_context(context);
694
- let left = Hasher::new_from_context_key(&cx_key)
695
- .update(&input[..1024])
696
- .finalize_non_root();
697
- let right = Hasher::new_from_context_key(&cx_key)
698
- .set_input_offset(1024)
699
- .update(&input[1024..])
700
- .finalize_non_root();
701
- let derived_key = merge_subtrees_root(&left, &right, Mode::DeriveKeyMaterial(&cx_key)).0;
702
- assert_eq!(expected, derived_key);
703
- }
704
- }