@leocuvee/wrkzcoin-multi-hashing 0.0.20

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 (314) hide show
  1. package/.travis.yml +5 -0
  2. package/LICENSE +674 -0
  3. package/README.md +87 -0
  4. package/appveyor.yml +12 -0
  5. package/argon2/.gitattributes +10 -0
  6. package/argon2/.travis.yml +25 -0
  7. package/argon2/Argon2.sln +160 -0
  8. package/argon2/CHANGELOG.md +32 -0
  9. package/argon2/CMakeLists.txt +87 -0
  10. package/argon2/LICENSE +314 -0
  11. package/argon2/Makefile +196 -0
  12. package/argon2/README.md +297 -0
  13. package/argon2/appveyor.yml +40 -0
  14. package/argon2/argon2-specs.pdf +0 -0
  15. package/argon2/export.sh +7 -0
  16. package/argon2/include/argon2.h +427 -0
  17. package/argon2/latex/CMakeLists.txt +34 -0
  18. package/argon2/latex/IEEEtran.cls +6347 -0
  19. package/argon2/latex/Makefile +18 -0
  20. package/argon2/latex/argon2-specs.tex +920 -0
  21. package/argon2/latex/pics/argon2-par.pdf +0 -0
  22. package/argon2/latex/pics/compression.pdf +0 -0
  23. package/argon2/latex/pics/generic.pdf +0 -0
  24. package/argon2/latex/pics/power-distribution.jpg +0 -0
  25. package/argon2/latex/tradeoff.bib +822 -0
  26. package/argon2/libargon2.pc +16 -0
  27. package/argon2/man/CMakeLists.txt +8 -0
  28. package/argon2/man/argon2.1 +57 -0
  29. package/argon2/meson.build +16 -0
  30. package/argon2/meson_options.txt +1 -0
  31. package/argon2/src/CMakeLists.txt +147 -0
  32. package/argon2/src/argon2.c +452 -0
  33. package/argon2/src/argon2.pc.in +11 -0
  34. package/argon2/src/blake2/blake2-impl.h +156 -0
  35. package/argon2/src/blake2/blake2.h +89 -0
  36. package/argon2/src/blake2/blake2b.c +390 -0
  37. package/argon2/src/blake2/blamka-round-opt.h +471 -0
  38. package/argon2/src/blake2/blamka-round-ref.h +56 -0
  39. package/argon2/src/core.c +634 -0
  40. package/argon2/src/core.h +228 -0
  41. package/argon2/src/encoding.c +467 -0
  42. package/argon2/src/encoding.h +57 -0
  43. package/argon2/src/genkat.h +51 -0
  44. package/argon2/src/meson.build +68 -0
  45. package/argon2/src/opt.c +283 -0
  46. package/argon2/src/optimization/CMakeLists.txt +10 -0
  47. package/argon2/src/ref.c +194 -0
  48. package/argon2/src/thread.c +57 -0
  49. package/argon2/src/thread.h +67 -0
  50. package/argon2/tests/CMakeLists.txt +43 -0
  51. package/argon2/tests/bench.c +111 -0
  52. package/argon2/tests/genkat.c +207 -0
  53. package/argon2/tests/kats/argon2d +12304 -0
  54. package/argon2/tests/kats/argon2d.shasum +1 -0
  55. package/argon2/tests/kats/argon2d_v16 +12304 -0
  56. package/argon2/tests/kats/argon2d_v16.shasum +1 -0
  57. package/argon2/tests/kats/argon2i +12304 -0
  58. package/argon2/tests/kats/argon2i.shasum +1 -0
  59. package/argon2/tests/kats/argon2i_v16 +12304 -0
  60. package/argon2/tests/kats/argon2i_v16.shasum +1 -0
  61. package/argon2/tests/kats/argon2id +12304 -0
  62. package/argon2/tests/kats/argon2id.shasum +1 -0
  63. package/argon2/tests/kats/argon2id_v16 +12304 -0
  64. package/argon2/tests/kats/argon2id_v16.shasum +1 -0
  65. package/argon2/tests/kats/check-sums.ps1 +48 -0
  66. package/argon2/tests/kats/check-sums.sh +16 -0
  67. package/argon2/tests/kats/test.ps1 +132 -0
  68. package/argon2/tests/kats/test.sh +117 -0
  69. package/argon2/tests/meson.build +34 -0
  70. package/argon2/tests/test.c +289 -0
  71. package/argon2/tool/CMakeLists.txt +7 -0
  72. package/argon2/tool/main.c +339 -0
  73. package/argon2/tool/meson.build +8 -0
  74. package/argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj +226 -0
  75. package/argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj.filters +69 -0
  76. package/argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj +226 -0
  77. package/argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj.filters +69 -0
  78. package/argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj +225 -0
  79. package/argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj.filters +66 -0
  80. package/argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj +239 -0
  81. package/argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj.filters +72 -0
  82. package/argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj +227 -0
  83. package/argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj.filters +69 -0
  84. package/argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj +226 -0
  85. package/argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj.filters +69 -0
  86. package/argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj +226 -0
  87. package/argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj.filters +69 -0
  88. package/argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj +225 -0
  89. package/argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj.filters +66 -0
  90. package/argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj +227 -0
  91. package/argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj.filters +72 -0
  92. package/argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj +226 -0
  93. package/argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj.filters +69 -0
  94. package/bcrypt.c +566 -0
  95. package/bcrypt.h +14 -0
  96. package/binding.gyp +93 -0
  97. package/blake.c +17 -0
  98. package/blake.h +16 -0
  99. package/boolberry.cc +11 -0
  100. package/boolberry.h +6 -0
  101. package/build/Makefile +354 -0
  102. package/build/Release/.deps/Release/multihashing.node.d +1 -0
  103. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/argon2.o.d +8 -0
  104. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/blake2/blake2b.o.d +8 -0
  105. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/core.o.d +10 -0
  106. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/encoding.o.d +8 -0
  107. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/ref.o.d +14 -0
  108. package/build/Release/.deps/Release/obj.target/multihashing/argon2/src/thread.o.d +5 -0
  109. package/build/Release/.deps/Release/obj.target/multihashing/bcrypt.o.d +4 -0
  110. package/build/Release/.deps/Release/obj.target/multihashing/blake.o.d +7 -0
  111. package/build/Release/.deps/Release/obj.target/multihashing/boolberry.o.d +12 -0
  112. package/build/Release/.deps/Release/obj.target/multihashing/c11.o.d +20 -0
  113. package/build/Release/.deps/Release/obj.target/multihashing/crypto/aesb.o.d +3 -0
  114. package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_blake256.o.d +5 -0
  115. package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_groestl.o.d +10 -0
  116. package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_jh.o.d +9 -0
  117. package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_keccak.o.d +7 -0
  118. package/build/Release/.deps/Release/obj.target/multihashing/crypto/c_skein.o.d +10 -0
  119. package/build/Release/.deps/Release/obj.target/multihashing/crypto/hash.o.d +7 -0
  120. package/build/Release/.deps/Release/obj.target/multihashing/crypto/oaes_lib.o.d +6 -0
  121. package/build/Release/.deps/Release/obj.target/multihashing/crypto/wild_keccak.o.d +8 -0
  122. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight.o.d +18 -0
  123. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_dark.o.d +18 -0
  124. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_dark_lite.o.d +18 -0
  125. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_fast.o.d +18 -0
  126. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_lite.o.d +18 -0
  127. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_soft_shell.o.d +18 -0
  128. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_turtle.o.d +18 -0
  129. package/build/Release/.deps/Release/obj.target/multihashing/cryptonight_turtle_lite.o.d +18 -0
  130. package/build/Release/.deps/Release/obj.target/multihashing/fresh.o.d +10 -0
  131. package/build/Release/.deps/Release/obj.target/multihashing/fugue.o.d +7 -0
  132. package/build/Release/.deps/Release/obj.target/multihashing/groestl.o.d +8 -0
  133. package/build/Release/.deps/Release/obj.target/multihashing/hefty1.o.d +12 -0
  134. package/build/Release/.deps/Release/obj.target/multihashing/keccak.o.d +8 -0
  135. package/build/Release/.deps/Release/obj.target/multihashing/multihashing.o.d +155 -0
  136. package/build/Release/.deps/Release/obj.target/multihashing/nist5.o.d +12 -0
  137. package/build/Release/.deps/Release/obj.target/multihashing/quark.o.d +14 -0
  138. package/build/Release/.deps/Release/obj.target/multihashing/qubit.o.d +12 -0
  139. package/build/Release/.deps/Release/obj.target/multihashing/scryptjane.o.d +30 -0
  140. package/build/Release/.deps/Release/obj.target/multihashing/scryptn.o.d +6 -0
  141. package/build/Release/.deps/Release/obj.target/multihashing/sha1.o.d +24 -0
  142. package/build/Release/.deps/Release/obj.target/multihashing/sha3/aes_helper.o.d +5 -0
  143. package/build/Release/.deps/Release/obj.target/multihashing/sha3/hamsi.o.d +7 -0
  144. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_blake.o.d +6 -0
  145. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_bmw.o.d +6 -0
  146. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_cubehash.o.d +6 -0
  147. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_echo.o.d +7 -0
  148. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_fugue.o.d +6 -0
  149. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_groestl.o.d +6 -0
  150. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_hefty1.o.d +5 -0
  151. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_jh.o.d +6 -0
  152. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_keccak.o.d +6 -0
  153. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_luffa.o.d +6 -0
  154. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_shabal.o.d +6 -0
  155. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_shavite.o.d +7 -0
  156. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_simd.o.d +6 -0
  157. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_skein.o.d +6 -0
  158. package/build/Release/.deps/Release/obj.target/multihashing/sha3/sph_whirlpool.o.d +8 -0
  159. package/build/Release/.deps/Release/obj.target/multihashing/shavite3.o.d +7 -0
  160. package/build/Release/.deps/Release/obj.target/multihashing/skein.o.d +8 -0
  161. package/build/Release/.deps/Release/obj.target/multihashing/x11.o.d +20 -0
  162. package/build/Release/.deps/Release/obj.target/multihashing/x13.o.d +23 -0
  163. package/build/Release/.deps/Release/obj.target/multihashing/x15.o.d +26 -0
  164. package/build/Release/.deps/Release/obj.target/multihashing.node.d +1 -0
  165. package/build/Release/multihashing.node +0 -0
  166. package/build/binding.Makefile +6 -0
  167. package/build/multihashing.target.mk +255 -0
  168. package/c11.c +85 -0
  169. package/c11.h +17 -0
  170. package/crypto/aesb.c +177 -0
  171. package/crypto/c_blake256.c +326 -0
  172. package/crypto/c_blake256.h +43 -0
  173. package/crypto/c_groestl.c +360 -0
  174. package/crypto/c_groestl.h +56 -0
  175. package/crypto/c_jh.c +367 -0
  176. package/crypto/c_jh.h +20 -0
  177. package/crypto/c_keccak.c +112 -0
  178. package/crypto/c_keccak.h +26 -0
  179. package/crypto/c_skein.c +2036 -0
  180. package/crypto/c_skein.h +45 -0
  181. package/crypto/crypto.h +186 -0
  182. package/crypto/cryptonote_core/account.cpp +50 -0
  183. package/crypto/cryptonote_core/account.h +61 -0
  184. package/crypto/cryptonote_core/cryptonote_basic_impl.cpp +186 -0
  185. package/crypto/cryptonote_core/cryptonote_basic_impl.h +65 -0
  186. package/crypto/cryptonote_core/cryptonote_format_utils.cpp +766 -0
  187. package/crypto/cryptonote_core/cryptonote_format_utils.h +30 -0
  188. package/crypto/cryptonote_protocol/cryptonote_protocol_defs.h +152 -0
  189. package/crypto/groestl_tables.h +38 -0
  190. package/crypto/hash-ops.h +57 -0
  191. package/crypto/hash.c +24 -0
  192. package/crypto/hash.h +22 -0
  193. package/crypto/int-util.h +230 -0
  194. package/crypto/oaes_config.h +50 -0
  195. package/crypto/oaes_lib.c +1468 -0
  196. package/crypto/oaes_lib.h +215 -0
  197. package/crypto/skein_port.h +190 -0
  198. package/crypto/variant2_int_sqrt.h +168 -0
  199. package/crypto/wild_keccak.cpp +119 -0
  200. package/crypto/wild_keccak.h +168 -0
  201. package/cryptonight.c +300 -0
  202. package/cryptonight.h +17 -0
  203. package/cryptonight_dark.c +300 -0
  204. package/cryptonight_dark.h +17 -0
  205. package/cryptonight_dark_lite.c +300 -0
  206. package/cryptonight_dark_lite.h +17 -0
  207. package/cryptonight_fast.c +300 -0
  208. package/cryptonight_fast.h +17 -0
  209. package/cryptonight_lite.c +300 -0
  210. package/cryptonight_lite.h +17 -0
  211. package/cryptonight_soft_shell.c +298 -0
  212. package/cryptonight_soft_shell.h +17 -0
  213. package/cryptonight_turtle.c +300 -0
  214. package/cryptonight_turtle.h +17 -0
  215. package/cryptonight_turtle_lite.c +300 -0
  216. package/cryptonight_turtle_lite.h +17 -0
  217. package/fresh.c +42 -0
  218. package/fresh.h +16 -0
  219. package/fugue.c +12 -0
  220. package/fugue.h +16 -0
  221. package/groestl.c +40 -0
  222. package/groestl.h +17 -0
  223. package/hefty1.c +63 -0
  224. package/hefty1.h +16 -0
  225. package/index.js +1 -0
  226. package/keccak.c +14 -0
  227. package/keccak.h +16 -0
  228. package/leocuvee-wrkzcoin-multi-hashing-0.0.20.tgz +0 -0
  229. package/multihashing.cc +699 -0
  230. package/nist5.c +46 -0
  231. package/nist5.h +16 -0
  232. package/package.json +56 -0
  233. package/quark.c +210 -0
  234. package/quark.h +16 -0
  235. package/qubit.c +45 -0
  236. package/qubit.h +16 -0
  237. package/scryptjane/scrypt-jane-chacha.h +132 -0
  238. package/scryptjane/scrypt-jane-hash.h +48 -0
  239. package/scryptjane/scrypt-jane-hash_keccak.h +168 -0
  240. package/scryptjane/scrypt-jane-hash_sha256.h +135 -0
  241. package/scryptjane/scrypt-jane-mix_chacha-avx.h +340 -0
  242. package/scryptjane/scrypt-jane-mix_chacha-sse2.h +371 -0
  243. package/scryptjane/scrypt-jane-mix_chacha-ssse3.h +348 -0
  244. package/scryptjane/scrypt-jane-mix_chacha.h +69 -0
  245. package/scryptjane/scrypt-jane-mix_salsa-avx.h +381 -0
  246. package/scryptjane/scrypt-jane-mix_salsa-sse2.h +443 -0
  247. package/scryptjane/scrypt-jane-mix_salsa.h +70 -0
  248. package/scryptjane/scrypt-jane-pbkdf2.h +112 -0
  249. package/scryptjane/scrypt-jane-portable-x86.h +364 -0
  250. package/scryptjane/scrypt-jane-portable.h +281 -0
  251. package/scryptjane/scrypt-jane-romix-basic.h +67 -0
  252. package/scryptjane/scrypt-jane-romix-template.h +118 -0
  253. package/scryptjane/scrypt-jane-romix.h +27 -0
  254. package/scryptjane/scrypt-jane-salsa.h +106 -0
  255. package/scryptjane/scrypt-jane-test-vectors.h +261 -0
  256. package/scryptjane.c +223 -0
  257. package/scryptjane.h +36 -0
  258. package/scryptn.c +258 -0
  259. package/scryptn.h +16 -0
  260. package/sha1.c +65 -0
  261. package/sha1.h +16 -0
  262. package/sha256.h +440 -0
  263. package/sha3/aes_helper.c +392 -0
  264. package/sha3/hamsi.c +867 -0
  265. package/sha3/hamsi_helper.c +39648 -0
  266. package/sha3/md_helper.c +347 -0
  267. package/sha3/sph_blake.c +1114 -0
  268. package/sha3/sph_blake.h +327 -0
  269. package/sha3/sph_bmw.c +965 -0
  270. package/sha3/sph_bmw.h +328 -0
  271. package/sha3/sph_cubehash.c +723 -0
  272. package/sha3/sph_cubehash.h +292 -0
  273. package/sha3/sph_echo.c +1031 -0
  274. package/sha3/sph_echo.h +320 -0
  275. package/sha3/sph_fugue.c +1208 -0
  276. package/sha3/sph_fugue.h +81 -0
  277. package/sha3/sph_groestl.c +3119 -0
  278. package/sha3/sph_groestl.h +329 -0
  279. package/sha3/sph_hamsi.h +321 -0
  280. package/sha3/sph_hefty1.c +378 -0
  281. package/sha3/sph_hefty1.h +66 -0
  282. package/sha3/sph_jh.c +1116 -0
  283. package/sha3/sph_jh.h +298 -0
  284. package/sha3/sph_keccak.c +1824 -0
  285. package/sha3/sph_keccak.h +293 -0
  286. package/sha3/sph_luffa.c +1426 -0
  287. package/sha3/sph_luffa.h +296 -0
  288. package/sha3/sph_shabal.c +806 -0
  289. package/sha3/sph_shabal.h +344 -0
  290. package/sha3/sph_shavite.c +1764 -0
  291. package/sha3/sph_shavite.h +314 -0
  292. package/sha3/sph_simd.c +1799 -0
  293. package/sha3/sph_simd.h +309 -0
  294. package/sha3/sph_skein.c +1254 -0
  295. package/sha3/sph_skein.h +298 -0
  296. package/sha3/sph_types.h +1976 -0
  297. package/sha3/sph_whirlpool.c +3480 -0
  298. package/sha3/sph_whirlpool.h +209 -0
  299. package/shavite3.c +24 -0
  300. package/shavite3.h +16 -0
  301. package/skein.c +26 -0
  302. package/skein.h +16 -0
  303. package/stdint.h +259 -0
  304. package/tests/argon2-tests.js +16 -0
  305. package/tests/benchmark.js +36 -0
  306. package/tests/cryptonight-tests.js +189 -0
  307. package/tests/cryptonight_monero.js +53 -0
  308. package/tests/test.js +16 -0
  309. package/x11.c +85 -0
  310. package/x11.h +16 -0
  311. package/x13.c +97 -0
  312. package/x13.h +5 -0
  313. package/x15.c +106 -0
  314. package/x15.h +16 -0
@@ -0,0 +1,69 @@
1
+ #if !defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_CHACHA_INCLUDED)
2
+
3
+ #undef SCRYPT_MIX
4
+ #define SCRYPT_MIX "ChaCha20/8 Ref"
5
+
6
+ #undef SCRYPT_CHACHA_INCLUDED
7
+ #define SCRYPT_CHACHA_INCLUDED
8
+ #define SCRYPT_CHACHA_BASIC
9
+
10
+ static void
11
+ chacha_core_basic(uint32_t state[16]) {
12
+ size_t rounds = 8;
13
+ uint32_t x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,t;
14
+
15
+ x0 = state[0];
16
+ x1 = state[1];
17
+ x2 = state[2];
18
+ x3 = state[3];
19
+ x4 = state[4];
20
+ x5 = state[5];
21
+ x6 = state[6];
22
+ x7 = state[7];
23
+ x8 = state[8];
24
+ x9 = state[9];
25
+ x10 = state[10];
26
+ x11 = state[11];
27
+ x12 = state[12];
28
+ x13 = state[13];
29
+ x14 = state[14];
30
+ x15 = state[15];
31
+
32
+ #define quarter(a,b,c,d) \
33
+ a += b; t = d^a; d = ROTL32(t,16); \
34
+ c += d; t = b^c; b = ROTL32(t,12); \
35
+ a += b; t = d^a; d = ROTL32(t, 8); \
36
+ c += d; t = b^c; b = ROTL32(t, 7);
37
+
38
+ for (; rounds; rounds -= 2) {
39
+ quarter( x0, x4, x8,x12)
40
+ quarter( x1, x5, x9,x13)
41
+ quarter( x2, x6,x10,x14)
42
+ quarter( x3, x7,x11,x15)
43
+ quarter( x0, x5,x10,x15)
44
+ quarter( x1, x6,x11,x12)
45
+ quarter( x2, x7, x8,x13)
46
+ quarter( x3, x4, x9,x14)
47
+ }
48
+
49
+ state[0] += x0;
50
+ state[1] += x1;
51
+ state[2] += x2;
52
+ state[3] += x3;
53
+ state[4] += x4;
54
+ state[5] += x5;
55
+ state[6] += x6;
56
+ state[7] += x7;
57
+ state[8] += x8;
58
+ state[9] += x9;
59
+ state[10] += x10;
60
+ state[11] += x11;
61
+ state[12] += x12;
62
+ state[13] += x13;
63
+ state[14] += x14;
64
+ state[15] += x15;
65
+
66
+ #undef quarter
67
+ }
68
+
69
+ #endif
@@ -0,0 +1,381 @@
1
+ /* x86 */
2
+ #if defined(X86ASM_AVX) && (!defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA_INCLUDED))
3
+
4
+ #define SCRYPT_SALSA_AVX
5
+
6
+ asm_naked_fn_proto(void, scrypt_ChunkMix_avx)(uint32_t *Bout/*[chunkBytes]*/, uint32_t *Bin/*[chunkBytes]*/, uint32_t *Bxor/*[chunkBytes]*/, uint32_t r)
7
+ asm_naked_fn(scrypt_ChunkMix_avx)
8
+ a1(push ebx)
9
+ a1(push edi)
10
+ a1(push esi)
11
+ a1(push ebp)
12
+ a2(mov ebp,esp)
13
+ a2(mov edi,[ebp+20])
14
+ a2(mov esi,[ebp+24])
15
+ a2(mov eax,[ebp+28])
16
+ a2(mov ebx,[ebp+32])
17
+ a2(sub esp,32)
18
+ a2(and esp,~63)
19
+ a2(lea edx,[ebx*2])
20
+ a2(shl edx,6)
21
+ a2(lea ecx,[edx-64])
22
+ a2(and eax, eax)
23
+ a2(movdqa xmm0,[ecx+esi+0])
24
+ a2(movdqa xmm1,[ecx+esi+16])
25
+ a2(movdqa xmm2,[ecx+esi+32])
26
+ a2(movdqa xmm3,[ecx+esi+48])
27
+ a1(jz scrypt_ChunkMix_avx_no_xor1)
28
+ a3(vpxor xmm0,xmm0,[ecx+eax+0])
29
+ a3(vpxor xmm1,xmm1,[ecx+eax+16])
30
+ a3(vpxor xmm2,xmm2,[ecx+eax+32])
31
+ a3(vpxor xmm3,xmm3,[ecx+eax+48])
32
+ a1(scrypt_ChunkMix_avx_no_xor1:)
33
+ a2(xor ecx,ecx)
34
+ a2(xor ebx,ebx)
35
+ a1(scrypt_ChunkMix_avx_loop:)
36
+ a2(and eax, eax)
37
+ a3(vpxor xmm0,xmm0,[esi+ecx+0])
38
+ a3(vpxor xmm1,xmm1,[esi+ecx+16])
39
+ a3(vpxor xmm2,xmm2,[esi+ecx+32])
40
+ a3(vpxor xmm3,xmm3,[esi+ecx+48])
41
+ a1(jz scrypt_ChunkMix_avx_no_xor2)
42
+ a3(vpxor xmm0,xmm0,[eax+ecx+0])
43
+ a3(vpxor xmm1,xmm1,[eax+ecx+16])
44
+ a3(vpxor xmm2,xmm2,[eax+ecx+32])
45
+ a3(vpxor xmm3,xmm3,[eax+ecx+48])
46
+ a1(scrypt_ChunkMix_avx_no_xor2:)
47
+ a2(vmovdqa [esp+0],xmm0)
48
+ a2(vmovdqa [esp+16],xmm1)
49
+ a2(vmovdqa xmm6,xmm2)
50
+ a2(vmovdqa xmm7,xmm3)
51
+ a2(mov eax,8)
52
+ a1(scrypt_salsa_avx_loop: )
53
+ a3(vpaddd xmm4, xmm1, xmm0)
54
+ a3(vpsrld xmm5, xmm4, 25)
55
+ a3(vpslld xmm4, xmm4, 7)
56
+ a3(vpxor xmm3, xmm3, xmm5)
57
+ a3(vpxor xmm3, xmm3, xmm4)
58
+ a3(vpaddd xmm4, xmm0, xmm3)
59
+ a3(vpsrld xmm5, xmm4, 23)
60
+ a3(vpslld xmm4, xmm4, 9)
61
+ a3(vpxor xmm2, xmm2, xmm5)
62
+ a3(vpxor xmm2, xmm2, xmm4)
63
+ a3(vpaddd xmm4, xmm3, xmm2)
64
+ a3(vpsrld xmm5, xmm4, 19)
65
+ a3(vpslld xmm4, xmm4, 13)
66
+ a3(vpxor xmm1, xmm1, xmm5)
67
+ a3(pshufd xmm3, xmm3, 0x93)
68
+ a3(vpxor xmm1, xmm1, xmm4)
69
+ a3(vpaddd xmm4, xmm2, xmm1)
70
+ a3(vpsrld xmm5, xmm4, 14)
71
+ a3(vpslld xmm4, xmm4, 18)
72
+ a3(vpxor xmm0, xmm0, xmm5)
73
+ a3(pshufd xmm2, xmm2, 0x4e)
74
+ a3(vpxor xmm0, xmm0, xmm4)
75
+ a2(sub eax, 2)
76
+ a3(vpaddd xmm4, xmm3, xmm0)
77
+ a3(pshufd xmm1, xmm1, 0x39)
78
+ a3(vpsrld xmm5, xmm4, 25)
79
+ a3(vpslld xmm4, xmm4, 7)
80
+ a3(vpxor xmm1, xmm1, xmm5)
81
+ a3(vpxor xmm1, xmm1, xmm4)
82
+ a3(vpaddd xmm4, xmm0, xmm1)
83
+ a3(vpsrld xmm5, xmm4, 23)
84
+ a3(vpslld xmm4, xmm4, 9)
85
+ a3(vpxor xmm2, xmm2, xmm5)
86
+ a3(vpxor xmm2, xmm2, xmm4)
87
+ a3(vpaddd xmm4, xmm1, xmm2)
88
+ a3(vpsrld xmm5, xmm4, 19)
89
+ a3(vpslld xmm4, xmm4, 13)
90
+ a3(vpxor xmm3, xmm3, xmm5)
91
+ a3(pshufd xmm1, xmm1, 0x93)
92
+ a3(vpxor xmm3, xmm3, xmm4)
93
+ a3(vpaddd xmm4, xmm2, xmm3)
94
+ a3(vpsrld xmm5, xmm4, 14)
95
+ a3(vpslld xmm4, xmm4, 18)
96
+ a3(vpxor xmm0, xmm0, xmm5)
97
+ a3(pshufd xmm2, xmm2, 0x4e)
98
+ a3(vpxor xmm0, xmm0, xmm4)
99
+ a3(pshufd xmm3, xmm3, 0x39)
100
+ a1(ja scrypt_salsa_avx_loop)
101
+ a3(vpaddd xmm0,xmm0,[esp+0])
102
+ a3(vpaddd xmm1,xmm1,[esp+16])
103
+ a3(vpaddd xmm2,xmm2,xmm6)
104
+ a3(vpaddd xmm3,xmm3,xmm7)
105
+ a2(lea eax,[ebx+ecx])
106
+ a2(xor ebx,edx)
107
+ a2(and eax,~0x7f)
108
+ a2(add ecx,64)
109
+ a2(shr eax,1)
110
+ a2(add eax, edi)
111
+ a2(cmp ecx,edx)
112
+ a2(vmovdqa [eax+0],xmm0)
113
+ a2(vmovdqa [eax+16],xmm1)
114
+ a2(vmovdqa [eax+32],xmm2)
115
+ a2(vmovdqa [eax+48],xmm3)
116
+ a2(mov eax,[ebp+28])
117
+ a1(jne scrypt_ChunkMix_avx_loop)
118
+ a2(mov esp,ebp)
119
+ a1(pop ebp)
120
+ a1(pop esi)
121
+ a1(pop edi)
122
+ a1(pop ebx)
123
+ a1(ret 16)
124
+ asm_naked_fn_end(scrypt_ChunkMix_avx)
125
+
126
+ #endif
127
+
128
+
129
+
130
+ /* x64 */
131
+ #if defined(X86_64ASM_AVX) && (!defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA_INCLUDED))
132
+
133
+ #define SCRYPT_SALSA_AVX
134
+
135
+ asm_naked_fn_proto(void, scrypt_ChunkMix_avx)(uint32_t *Bout/*[chunkBytes]*/, uint32_t *Bin/*[chunkBytes]*/, uint32_t *Bxor/*[chunkBytes]*/, uint32_t r)
136
+ asm_naked_fn(scrypt_ChunkMix_avx)
137
+ a2(lea rcx,[rcx*2])
138
+ a2(shl rcx,6)
139
+ a2(lea r9,[rcx-64])
140
+ a2(lea rax,[rsi+r9])
141
+ a2(lea r9,[rdx+r9])
142
+ a2(and rdx, rdx)
143
+ a2(vmovdqa xmm0,[rax+0])
144
+ a2(vmovdqa xmm1,[rax+16])
145
+ a2(vmovdqa xmm2,[rax+32])
146
+ a2(vmovdqa xmm3,[rax+48])
147
+ a1(jz scrypt_ChunkMix_avx_no_xor1)
148
+ a3(vpxor xmm0,xmm0,[r9+0])
149
+ a3(vpxor xmm1,xmm1,[r9+16])
150
+ a3(vpxor xmm2,xmm2,[r9+32])
151
+ a3(vpxor xmm3,xmm3,[r9+48])
152
+ a1(scrypt_ChunkMix_avx_no_xor1:)
153
+ a2(xor r9,r9)
154
+ a2(xor r8,r8)
155
+ a1(scrypt_ChunkMix_avx_loop:)
156
+ a2(and rdx, rdx)
157
+ a3(vpxor xmm0,xmm0,[rsi+r9+0])
158
+ a3(vpxor xmm1,xmm1,[rsi+r9+16])
159
+ a3(vpxor xmm2,xmm2,[rsi+r9+32])
160
+ a3(vpxor xmm3,xmm3,[rsi+r9+48])
161
+ a1(jz scrypt_ChunkMix_avx_no_xor2)
162
+ a3(vpxor xmm0,xmm0,[rdx+r9+0])
163
+ a3(vpxor xmm1,xmm1,[rdx+r9+16])
164
+ a3(vpxor xmm2,xmm2,[rdx+r9+32])
165
+ a3(vpxor xmm3,xmm3,[rdx+r9+48])
166
+ a1(scrypt_ChunkMix_avx_no_xor2:)
167
+ a2(vmovdqa xmm8,xmm0)
168
+ a2(vmovdqa xmm9,xmm1)
169
+ a2(vmovdqa xmm10,xmm2)
170
+ a2(vmovdqa xmm11,xmm3)
171
+ a2(mov rax,8)
172
+ a1(scrypt_salsa_avx_loop: )
173
+ a3(vpaddd xmm4, xmm1, xmm0)
174
+ a3(vpsrld xmm5, xmm4, 25)
175
+ a3(vpslld xmm4, xmm4, 7)
176
+ a3(vpxor xmm3, xmm3, xmm5)
177
+ a3(vpxor xmm3, xmm3, xmm4)
178
+ a3(vpaddd xmm4, xmm0, xmm3)
179
+ a3(vpsrld xmm5, xmm4, 23)
180
+ a3(vpslld xmm4, xmm4, 9)
181
+ a3(vpxor xmm2, xmm2, xmm5)
182
+ a3(vpxor xmm2, xmm2, xmm4)
183
+ a3(vpaddd xmm4, xmm3, xmm2)
184
+ a3(vpsrld xmm5, xmm4, 19)
185
+ a3(vpslld xmm4, xmm4, 13)
186
+ a3(vpxor xmm1, xmm1, xmm5)
187
+ a3(pshufd xmm3, xmm3, 0x93)
188
+ a3(vpxor xmm1, xmm1, xmm4)
189
+ a3(vpaddd xmm4, xmm2, xmm1)
190
+ a3(vpsrld xmm5, xmm4, 14)
191
+ a3(vpslld xmm4, xmm4, 18)
192
+ a3(vpxor xmm0, xmm0, xmm5)
193
+ a3(pshufd xmm2, xmm2, 0x4e)
194
+ a3(vpxor xmm0, xmm0, xmm4)
195
+ a2(sub rax, 2)
196
+ a3(vpaddd xmm4, xmm3, xmm0)
197
+ a3(pshufd xmm1, xmm1, 0x39)
198
+ a3(vpsrld xmm5, xmm4, 25)
199
+ a3(vpslld xmm4, xmm4, 7)
200
+ a3(vpxor xmm1, xmm1, xmm5)
201
+ a3(vpxor xmm1, xmm1, xmm4)
202
+ a3(vpaddd xmm4, xmm0, xmm1)
203
+ a3(vpsrld xmm5, xmm4, 23)
204
+ a3(vpslld xmm4, xmm4, 9)
205
+ a3(vpxor xmm2, xmm2, xmm5)
206
+ a3(vpxor xmm2, xmm2, xmm4)
207
+ a3(vpaddd xmm4, xmm1, xmm2)
208
+ a3(vpsrld xmm5, xmm4, 19)
209
+ a3(vpslld xmm4, xmm4, 13)
210
+ a3(vpxor xmm3, xmm3, xmm5)
211
+ a3(pshufd xmm1, xmm1, 0x93)
212
+ a3(vpxor xmm3, xmm3, xmm4)
213
+ a3(vpaddd xmm4, xmm2, xmm3)
214
+ a3(vpsrld xmm5, xmm4, 14)
215
+ a3(vpslld xmm4, xmm4, 18)
216
+ a3(vpxor xmm0, xmm0, xmm5)
217
+ a3(pshufd xmm2, xmm2, 0x4e)
218
+ a3(vpxor xmm0, xmm0, xmm4)
219
+ a3(pshufd xmm3, xmm3, 0x39)
220
+ a1(ja scrypt_salsa_avx_loop)
221
+ a3(vpaddd xmm0,xmm0,xmm8)
222
+ a3(vpaddd xmm1,xmm1,xmm9)
223
+ a3(vpaddd xmm2,xmm2,xmm10)
224
+ a3(vpaddd xmm3,xmm3,xmm11)
225
+ a2(lea rax,[r8+r9])
226
+ a2(xor r8,rcx)
227
+ a2(and rax,~0x7f)
228
+ a2(add r9,64)
229
+ a2(shr rax,1)
230
+ a2(add rax, rdi)
231
+ a2(cmp r9,rcx)
232
+ a2(vmovdqa [rax+0],xmm0)
233
+ a2(vmovdqa [rax+16],xmm1)
234
+ a2(vmovdqa [rax+32],xmm2)
235
+ a2(vmovdqa [rax+48],xmm3)
236
+ a1(jne scrypt_ChunkMix_avx_loop)
237
+ a1(ret)
238
+ asm_naked_fn_end(scrypt_ChunkMix_avx)
239
+
240
+ #endif
241
+
242
+
243
+ /* intrinsic */
244
+ #if defined(X86_INTRINSIC_AVX) && (!defined(SCRYPT_CHOOSE_COMPILETIME) || !defined(SCRYPT_SALSA_INCLUDED))
245
+
246
+ #define SCRYPT_SALSA_AVX
247
+
248
+ static void NOINLINE
249
+ scrypt_ChunkMix_avx(uint32_t *Bout/*[chunkBytes]*/, uint32_t *Bin/*[chunkBytes]*/, uint32_t *Bxor/*[chunkBytes]*/, uint32_t r) {
250
+ uint32_t i, blocksPerChunk = r * 2, half = 0;
251
+ xmmi *xmmp,x0,x1,x2,x3,x4,x5,t0,t1,t2,t3;
252
+ size_t rounds;
253
+
254
+ /* 1: X = B_{2r - 1} */
255
+ xmmp = (xmmi *)scrypt_block(Bin, blocksPerChunk - 1);
256
+ x0 = xmmp[0];
257
+ x1 = xmmp[1];
258
+ x2 = xmmp[2];
259
+ x3 = xmmp[3];
260
+
261
+ if (Bxor) {
262
+ xmmp = (xmmi *)scrypt_block(Bxor, blocksPerChunk - 1);
263
+ x0 = _mm_xor_si128(x0, xmmp[0]);
264
+ x1 = _mm_xor_si128(x1, xmmp[1]);
265
+ x2 = _mm_xor_si128(x2, xmmp[2]);
266
+ x3 = _mm_xor_si128(x3, xmmp[3]);
267
+ }
268
+
269
+ /* 2: for i = 0 to 2r - 1 do */
270
+ for (i = 0; i < blocksPerChunk; i++, half ^= r) {
271
+ /* 3: X = H(X ^ B_i) */
272
+ xmmp = (xmmi *)scrypt_block(Bin, i);
273
+ x0 = _mm_xor_si128(x0, xmmp[0]);
274
+ x1 = _mm_xor_si128(x1, xmmp[1]);
275
+ x2 = _mm_xor_si128(x2, xmmp[2]);
276
+ x3 = _mm_xor_si128(x3, xmmp[3]);
277
+
278
+ if (Bxor) {
279
+ xmmp = (xmmi *)scrypt_block(Bxor, i);
280
+ x0 = _mm_xor_si128(x0, xmmp[0]);
281
+ x1 = _mm_xor_si128(x1, xmmp[1]);
282
+ x2 = _mm_xor_si128(x2, xmmp[2]);
283
+ x3 = _mm_xor_si128(x3, xmmp[3]);
284
+ }
285
+
286
+ t0 = x0;
287
+ t1 = x1;
288
+ t2 = x2;
289
+ t3 = x3;
290
+
291
+ for (rounds = 8; rounds; rounds -= 2) {
292
+ x4 = x1;
293
+ x4 = _mm_add_epi32(x4, x0);
294
+ x5 = x4;
295
+ x4 = _mm_slli_epi32(x4, 7);
296
+ x5 = _mm_srli_epi32(x5, 25);
297
+ x3 = _mm_xor_si128(x3, x4);
298
+ x4 = x0;
299
+ x3 = _mm_xor_si128(x3, x5);
300
+ x4 = _mm_add_epi32(x4, x3);
301
+ x5 = x4;
302
+ x4 = _mm_slli_epi32(x4, 9);
303
+ x5 = _mm_srli_epi32(x5, 23);
304
+ x2 = _mm_xor_si128(x2, x4);
305
+ x4 = x3;
306
+ x2 = _mm_xor_si128(x2, x5);
307
+ x3 = _mm_shuffle_epi32(x3, 0x93);
308
+ x4 = _mm_add_epi32(x4, x2);
309
+ x5 = x4;
310
+ x4 = _mm_slli_epi32(x4, 13);
311
+ x5 = _mm_srli_epi32(x5, 19);
312
+ x1 = _mm_xor_si128(x1, x4);
313
+ x4 = x2;
314
+ x1 = _mm_xor_si128(x1, x5);
315
+ x2 = _mm_shuffle_epi32(x2, 0x4e);
316
+ x4 = _mm_add_epi32(x4, x1);
317
+ x5 = x4;
318
+ x4 = _mm_slli_epi32(x4, 18);
319
+ x5 = _mm_srli_epi32(x5, 14);
320
+ x0 = _mm_xor_si128(x0, x4);
321
+ x4 = x3;
322
+ x0 = _mm_xor_si128(x0, x5);
323
+ x1 = _mm_shuffle_epi32(x1, 0x39);
324
+ x4 = _mm_add_epi32(x4, x0);
325
+ x5 = x4;
326
+ x4 = _mm_slli_epi32(x4, 7);
327
+ x5 = _mm_srli_epi32(x5, 25);
328
+ x1 = _mm_xor_si128(x1, x4);
329
+ x4 = x0;
330
+ x1 = _mm_xor_si128(x1, x5);
331
+ x4 = _mm_add_epi32(x4, x1);
332
+ x5 = x4;
333
+ x4 = _mm_slli_epi32(x4, 9);
334
+ x5 = _mm_srli_epi32(x5, 23);
335
+ x2 = _mm_xor_si128(x2, x4);
336
+ x4 = x1;
337
+ x2 = _mm_xor_si128(x2, x5);
338
+ x1 = _mm_shuffle_epi32(x1, 0x93);
339
+ x4 = _mm_add_epi32(x4, x2);
340
+ x5 = x4;
341
+ x4 = _mm_slli_epi32(x4, 13);
342
+ x5 = _mm_srli_epi32(x5, 19);
343
+ x3 = _mm_xor_si128(x3, x4);
344
+ x4 = x2;
345
+ x3 = _mm_xor_si128(x3, x5);
346
+ x2 = _mm_shuffle_epi32(x2, 0x4e);
347
+ x4 = _mm_add_epi32(x4, x3);
348
+ x5 = x4;
349
+ x4 = _mm_slli_epi32(x4, 18);
350
+ x5 = _mm_srli_epi32(x5, 14);
351
+ x0 = _mm_xor_si128(x0, x4);
352
+ x3 = _mm_shuffle_epi32(x3, 0x39);
353
+ x0 = _mm_xor_si128(x0, x5);
354
+ }
355
+
356
+ x0 = _mm_add_epi32(x0, t0);
357
+ x1 = _mm_add_epi32(x1, t1);
358
+ x2 = _mm_add_epi32(x2, t2);
359
+ x3 = _mm_add_epi32(x3, t3);
360
+
361
+ /* 4: Y_i = X */
362
+ /* 6: B'[0..r-1] = Y_even */
363
+ /* 6: B'[r..2r-1] = Y_odd */
364
+ xmmp = (xmmi *)scrypt_block(Bout, (i / 2) + half);
365
+ xmmp[0] = x0;
366
+ xmmp[1] = x1;
367
+ xmmp[2] = x2;
368
+ xmmp[3] = x3;
369
+ }
370
+ }
371
+
372
+ #endif
373
+
374
+ #if defined(SCRYPT_SALSA_AVX)
375
+ /* uses salsa_core_tangle_sse2 */
376
+
377
+ #undef SCRYPT_MIX
378
+ #define SCRYPT_MIX "Salsa/8-AVX"
379
+ #undef SCRYPT_SALSA_INCLUDED
380
+ #define SCRYPT_SALSA_INCLUDED
381
+ #endif