├── README.md ├── binding.gyp ├── c29.h ├── c29 ├── blake2-impl.h ├── blake2.h ├── blake2b-ref.c ├── int-util.h └── portable_endian.h ├── c29b.cc ├── c29i.cc ├── c29s.cc ├── c29v.cc ├── check_cpu.sh ├── index.js ├── multihashing.cc ├── package.json ├── tests ├── compare_both.js ├── cryptonight-1.txt ├── cryptonight-2.txt ├── cryptonight-ccx.txt ├── cryptonight-double.txt ├── cryptonight-gpu.txt ├── cryptonight-half.txt ├── cryptonight-msr.txt ├── cryptonight-r.txt ├── cryptonight-rto.txt ├── cryptonight-rwz.txt ├── cryptonight-wow.txt ├── cryptonight-xao.txt ├── cryptonight-xtl.txt ├── cryptonight-zls.txt ├── cryptonight.txt ├── cryptonight_heavy-tube.txt ├── cryptonight_heavy-xhv.txt ├── cryptonight_heavy.txt ├── cryptonight_light-1.txt ├── cryptonight_light.txt ├── cryptonight_pico.txt ├── k12.txt ├── run.sh ├── rx0.txt ├── rx_arq.txt ├── rx_graft.txt ├── rx_keva.txt ├── rx_xeq.txt ├── test.js ├── test_ar2_chukwa.js ├── test_ar2_chukwa2.js ├── test_ar2_wrkz.js ├── test_astrobwt.js ├── test_astrobwt2.js ├── test_async-wow.js ├── test_async.js ├── test_async_heavy.js ├── test_async_light.js ├── test_async_pico.js ├── test_autolykos2.js ├── test_etchash.js ├── test_ethash.js ├── test_k12.js ├── test_kawpow.js ├── test_kcn.js ├── test_perf.js ├── test_perf_ar2_chukwa.js ├── test_perf_ar2_chukwa2.js ├── test_perf_ar2_wrkz.js ├── test_perf_astrobwt.js ├── test_perf_astrobwt2.js ├── test_perf_double.js ├── test_perf_ethash.js ├── test_perf_gpu.js ├── test_perf_heavy.js ├── test_perf_k12.js ├── test_perf_kawpow.js ├── test_perf_kcn.js ├── test_perf_light.js ├── test_perf_loki.js ├── test_perf_pico.js ├── test_perf_rtm.js ├── test_perf_rwz.js ├── test_perf_rx_defyx.js ├── test_perf_rx_graft.js ├── test_perf_rx_keva.js ├── test_perf_rx_loki.js ├── test_perf_rx_switch.js ├── test_perf_rx_wow.js ├── test_perf_xla.js ├── test_perf_zls.js ├── test_rtm.js ├── test_rx0.js ├── test_rx_arq.js ├── test_rx_defyx.js ├── test_rx_graft.js ├── test_rx_keva.js ├── test_rx_loki.js ├── test_rx_switch.js ├── test_rx_wow.js ├── test_rx_xeq.js ├── test_rx_xla.js ├── test_sync-1.js ├── test_sync-2.js ├── test_sync-ccx.js ├── test_sync-double.js ├── test_sync-gpu.js ├── test_sync-half.js ├── test_sync-msr.js ├── test_sync-r.js ├── test_sync-rto.js ├── test_sync-rwz.js ├── test_sync-wow.js ├── test_sync-xao.js ├── test_sync-xtl.js ├── test_sync-zls.js ├── test_sync.js ├── test_sync_heavy-tube.js ├── test_sync_heavy-xhv.js ├── test_sync_heavy.js ├── test_sync_light-1.js ├── test_sync_light.js └── test_sync_pico.js ├── xmrig-override ├── backend │ └── cpu │ │ ├── Cpu.cpp │ │ ├── Cpu.h │ │ ├── interfaces │ │ └── ICpuInfo.h │ │ └── platform │ │ ├── BasicCpuInfo.cpp │ │ ├── BasicCpuInfo.h │ │ └── BasicCpuInfo_arm.cpp ├── base │ ├── crypto │ │ └── Algorithm.h │ └── io │ │ └── log │ │ ├── Log.h │ │ └── Tags.h └── crypto │ ├── common │ └── Assembly.h │ ├── ghostrider │ ├── ghostrider.cpp │ └── ghostrider.h │ └── kawpow │ ├── KPHash.cpp │ └── KPHash.h └── xmrig ├── 3rdparty ├── argon2.h ├── argon2 │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── arch │ │ ├── generic │ │ │ └── lib │ │ │ │ └── argon2-arch.c │ │ └── x86_64 │ │ │ ├── lib │ │ │ ├── argon2-arch.c │ │ │ ├── argon2-avx2.c │ │ │ ├── argon2-avx2.h │ │ │ ├── argon2-avx512f.c │ │ │ ├── argon2-avx512f.h │ │ │ ├── argon2-sse2.c │ │ │ ├── argon2-sse2.h │ │ │ ├── argon2-ssse3.c │ │ │ ├── argon2-ssse3.h │ │ │ ├── argon2-template-128.h │ │ │ ├── argon2-xop.c │ │ │ └── argon2-xop.h │ │ │ └── src │ │ │ ├── test-feature-avx2.c │ │ │ ├── test-feature-avx512f.c │ │ │ ├── test-feature-sse2.c │ │ │ ├── test-feature-ssse3.c │ │ │ └── test-feature-xop.c │ ├── include │ │ └── argon2.h │ └── lib │ │ ├── argon2-template-64.h │ │ ├── argon2.c │ │ ├── blake2 │ │ ├── blake2-impl.h │ │ ├── blake2.c │ │ └── blake2.h │ │ ├── core.c │ │ ├── core.h │ │ ├── encoding.c │ │ ├── encoding.h │ │ ├── genkat.c │ │ ├── genkat.h │ │ ├── impl-select.c │ │ └── impl-select.h └── libethash │ ├── CMakeLists.txt │ ├── data_sizes.h │ ├── endian.h │ ├── ethash.h │ ├── ethash_internal.c │ ├── ethash_internal.h │ ├── fnv.h │ └── keccakf800.c ├── backend └── common │ └── interfaces │ └── IMemoryPool.h ├── base ├── crypto │ ├── keccak.cpp │ ├── keccak.h │ ├── sha3.cpp │ └── sha3.h └── tools │ ├── Chrono.h │ ├── Object.h │ ├── Profiler.h │ ├── bswap_64.h │ └── cryptonote │ └── umul128.h └── crypto ├── argon2 └── Hash.h ├── astrobwt ├── AstroBWT.cpp ├── AstroBWT.h ├── Salsa20.cpp ├── Salsa20.hpp ├── salsa20_ref │ ├── ecrypt-config.h │ ├── ecrypt-machine.h │ ├── ecrypt-portable.h │ ├── ecrypt-sync.h │ └── salsa20.c ├── sha3_256_avx2.S ├── sha3_256_avx2.asm ├── sha3_256_avx2.inc ├── sha3_256_keccakf1600_avx2.inc ├── sort_indices2.cpp └── sort_indices2.h ├── cn ├── CnAlgo.h ├── CnCtx.cpp ├── CnCtx.h ├── CnHash.cpp ├── CnHash.h ├── CryptoNight.h ├── CryptoNight_arm.h ├── CryptoNight_monero.h ├── CryptoNight_test.h ├── CryptoNight_x86.h ├── CryptoNight_x86_vaes.cpp ├── CryptoNight_x86_vaes.h ├── asm │ ├── CryptonightR_soft_aes_template.inc │ ├── CryptonightR_soft_aes_template_win.inc │ ├── CryptonightR_template.S │ ├── CryptonightR_template.asm │ ├── CryptonightR_template.h │ ├── CryptonightR_template.inc │ ├── CryptonightR_template_win.inc │ ├── cn1 │ │ ├── cnv1_double_main_loop.inc │ │ ├── cnv1_quad_main_loop.inc │ │ └── cnv1_single_main_loop.inc │ ├── cn2 │ │ ├── cnv2_double_main_loop_sandybridge.inc │ │ ├── cnv2_main_loop_bulldozer.inc │ │ ├── cnv2_main_loop_ivybridge.inc │ │ ├── cnv2_main_loop_ryzen.inc │ │ ├── cnv2_rwz_double_main_loop.inc │ │ ├── cnv2_rwz_main_loop.inc │ │ └── cnv2_upx_double_mainloop_zen3.inc │ ├── cn_main_loop.S │ ├── cn_main_loop.asm │ └── win64 │ │ ├── CryptonightR_soft_aes_template_win.inc │ │ ├── CryptonightR_template.asm │ │ ├── CryptonightR_template_win.inc │ │ ├── cn2 │ │ ├── cnv2_double_main_loop_sandybridge.inc │ │ ├── cnv2_main_loop_bulldozer.inc │ │ ├── cnv2_main_loop_ivybridge.inc │ │ ├── cnv2_main_loop_ryzen.inc │ │ ├── cnv2_rwz_double_main_loop.inc │ │ ├── cnv2_rwz_main_loop.inc │ │ └── cnv2_upx_double_mainloop_zen3.inc │ │ ├── cn_main_loop.S │ │ └── cn_main_loop.asm ├── c_blake256.c ├── c_blake256.h ├── c_groestl.c ├── c_groestl.h ├── c_jh.c ├── c_jh.h ├── c_skein.c ├── c_skein.h ├── gpu │ ├── cn_gpu_arm.cpp │ ├── cn_gpu_avx.cpp │ └── cn_gpu_ssse3.cpp ├── groestl_tables.h ├── hash.h ├── r │ ├── CryptonightR_gen.cpp │ └── variant4_random_math.h ├── skein_port.h ├── soft_aes.h └── sse2neon.h ├── common ├── Assembly.cpp ├── HugePagesInfo.h ├── MemoryPool.cpp ├── MemoryPool.h ├── Nonce.cpp ├── Nonce.h ├── VirtualMemory.cpp ├── VirtualMemory.h ├── VirtualMemory_unix.cpp ├── VirtualMemory_win.cpp └── portable │ └── mm_malloc.h ├── flex ├── flex.cpp └── flex.h ├── ghostrider ├── CMakeLists.txt ├── README.md ├── aes_helper.c ├── md_helper.c ├── sph_blake.c ├── sph_blake.h ├── sph_bmw.c ├── sph_bmw.h ├── sph_cubehash.c ├── sph_cubehash.h ├── sph_echo.c ├── sph_echo.h ├── sph_fugue.c ├── sph_fugue.h ├── sph_groestl.c ├── sph_groestl.h ├── sph_hamsi.c ├── sph_hamsi.h ├── sph_hamsi_helper.c ├── sph_jh.c ├── sph_jh.h ├── sph_keccak.c ├── sph_keccak.h ├── sph_luffa.c ├── sph_luffa.h ├── sph_sha2.c ├── sph_sha2.h ├── sph_shabal.c ├── sph_shabal.h ├── sph_shavite.c ├── sph_shavite.h ├── sph_simd.c ├── sph_simd.h ├── sph_skein.c ├── sph_skein.h ├── sph_types.h ├── sph_whirlpool.c └── sph_whirlpool.h ├── kawpow ├── KPCache.cpp ├── KPCache.h ├── KPHash.cpp └── KPHash.h └── randomx ├── aes_hash.cpp ├── aes_hash.hpp ├── allocator.cpp ├── allocator.hpp ├── asm ├── program_epilogue_linux.inc ├── program_epilogue_store.inc ├── program_epilogue_win64.inc ├── program_loop_load.inc ├── program_loop_load_xop.inc ├── program_loop_store.inc ├── program_prologue_linux.inc ├── program_prologue_win64.inc ├── program_read_dataset.inc ├── program_read_dataset_ryzen.inc ├── program_read_dataset_sshash_fin.inc ├── program_read_dataset_sshash_init.inc ├── program_sshash_constants.inc ├── program_sshash_load.inc ├── program_sshash_prefetch.inc ├── program_xmm_constants.inc └── randomx_reciprocal.inc ├── blake2 ├── blake2-impl.h ├── blake2.h ├── blake2b.c ├── blamka-round-ref.h └── endian.h ├── blake2_generator.cpp ├── blake2_generator.hpp ├── bytecode_machine.cpp ├── bytecode_machine.hpp ├── common.hpp ├── configuration.h ├── dataset.cpp ├── dataset.hpp ├── instruction.hpp ├── instructions_portable.cpp ├── intrin_portable.h ├── jit_compiler.hpp ├── jit_compiler_a64.cpp ├── jit_compiler_a64.hpp ├── jit_compiler_a64_static.S ├── jit_compiler_a64_static.hpp ├── jit_compiler_fallback.hpp ├── jit_compiler_x86.cpp ├── jit_compiler_x86.hpp ├── jit_compiler_x86_static.S ├── jit_compiler_x86_static.asm ├── jit_compiler_x86_static.hpp ├── panthera ├── KangarooTwelve.c ├── KangarooTwelve.h ├── KeccakP-1600-SnP.h ├── KeccakP-1600-reference.c ├── KeccakSponge-common.h ├── KeccakSponge.inc ├── KeccakSpongeWidth1600.c ├── KeccakSpongeWidth1600.h ├── Phases.h ├── align.h ├── brg_endian.h ├── insecure_memzero.h ├── sha256.c ├── sha256.h ├── sysendian.h ├── yespower-opt.c ├── yespower-platform.c ├── yespower-ref.c └── yespower.h ├── program.hpp ├── randomx.cpp ├── randomx.h ├── reciprocal.c ├── reciprocal.h ├── soft_aes.cpp ├── soft_aes.h ├── superscalar.cpp ├── superscalar.hpp ├── superscalar_program.hpp ├── virtual_machine.cpp ├── virtual_machine.hpp ├── virtual_memory.cpp ├── virtual_memory.hpp ├── vm_compiled.cpp ├── vm_compiled.hpp ├── vm_compiled_light.cpp ├── vm_compiled_light.hpp ├── vm_interpreted.cpp ├── vm_interpreted.hpp ├── vm_interpreted_light.cpp └── vm_interpreted_light.hpp /README.md: -------------------------------------------------------------------------------- 1 | node-cryptonight-hashing 2 | =============== 3 | 4 | Cryptonight hashing functions for node.js. 5 | 6 | 7 | Algorithms 8 | ---------- 9 | * cryptonight (v0, v1, v2, r, half, xtl, msr, rto, xao, gpu, wow, rwz, zls, double, ccx) 10 | * cryptonight-light (v0, v1) 11 | * cryptonight-heavy (v0, xhv, tube) 12 | * cryptonight-pico (IRD) 13 | * argon2 (chukwa, chukwa2, wrkz) 14 | * astrobwt (DERO, DERO-HE) 15 | * RandomX (Wownero, Arqma, Equilibria, Keva, Graft) 16 | * Panther (Scala) 17 | * KangarooTwelve (AEON) 18 | * cuckaroo29s, cuckaroo29v, cuckaroo29b, cuckaroo29i 19 | * KawPow (RVN) 20 | * Ethash (ETH) 21 | * Autolykos2 (ERG) 22 | * Ghostrider (TRM) 23 | 24 | Installing locally and testing 25 | ----- 26 | ``` 27 | JOBS=$(nproc) npm install https://github.com/MoneroOcean/node-cryptonight-hashing 28 | node_modules/cryptonight-hashing/tests/run.sh 29 | ``` 30 | 31 | Credits 32 | ------- 33 | * [XMrig](https://github.com/xmrig) - For advanced cryptonight implementations from [XMrig](https://github.com/xmrig/xmrig) 34 | * [SChernykh](https://github.com/SChernykh) - For PoW development and its integration help 35 | -------------------------------------------------------------------------------- /c29.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define PROOFSIZE 32 6 | #define PROOFSIZEb 40 7 | #define PROOFSIZEi 48 8 | #define EDGEBITS 29 9 | 10 | typedef struct siphash_keys__ 11 | { 12 | uint64_t k0; 13 | uint64_t k1; 14 | uint64_t k2; 15 | uint64_t k3; 16 | } siphash_keys; 17 | 18 | enum verify_code { POW_OK, POW_HEADER_LENGTH, POW_TOO_BIG, POW_TOO_SMALL, POW_NON_MATCHING, POW_BRANCH, POW_DEAD_END, POW_SHORT_CYCLE, POW_UNBALANCED}; 19 | 20 | extern int c29s_verify(uint32_t edges[32], siphash_keys *keys); 21 | extern int c29b_verify(uint32_t edges[40], siphash_keys *keys); 22 | extern int c29i_verify(uint32_t edges[48], siphash_keys *keys); 23 | extern int c29v_verify(uint32_t edges[32], siphash_keys *keys); 24 | -------------------------------------------------------------------------------- /check_cpu.sh: -------------------------------------------------------------------------------- 1 | 2 | set -e 3 | QUERY="$1" 4 | 5 | check_mac() { 6 | case "$1" in 7 | avx) sysctl -n machdep.cpu.features | grep -i avx >/dev/null;; 8 | avx2) sysctl -n machdep.cpu.features | grep -i avx2 >/dev/null;; 9 | amd) sysctl -n machdep.cpu.vendor | grep -i amd >/dev/null;; 10 | amdnew) sysctl -n machdep.cpu.vendor | grep -i amd && test `sysctl -n machdep.cpu.family` -ge 23;; 11 | intel) sysctl -n machdep.cpu.vendor | grep -i intel >/dev/null;; 12 | sse2) sysctl -n machdep.cpu.features | grep -i sse2 >/dev/null;; 13 | ssse3) sysctl -n machdep.cpu.features | grep -i ssse3 >/dev/null;; 14 | avx512f) sysctl -n machdep.cpu.features | grep -i avx512f >/dev/null;; 15 | xop) sysctl -n machdep.cpu.features | grep -i xop >/dev/null;; 16 | *) echo "UNRECOGNISED CHECK $QUERY"; exit 1; ;; 17 | esac 18 | } 19 | 20 | check_linux() { 21 | case "$1" in 22 | avx) grep avx /proc/cpuinfo >/dev/null;; 23 | avx2) grep avx2 /proc/cpuinfo >/dev/null;; 24 | amd) grep -i amd /proc/cpuinfo >/dev/null;; 25 | amdnew) grep -i amd /proc/cpuinfo >/dev/null && test `awk '/cpu family/ && $NF~/^[0-9]*$/ {print $NF}' /proc/cpuinfo | head -n1` -ge 23 >/dev/null;; 26 | intel) grep -i intel /proc/cpuinfo >/dev/null;; 27 | sse2) grep sse2 /proc/cpuinfo >/dev/null;; 28 | ssse3) grep ssse3 /proc/cpuinfo >/dev/null;; 29 | avx512f) grep avx512f /proc/cpuinfo >/dev/null;; 30 | xop) grep xop /proc/cpuinfo >/dev/null;; 31 | *) echo "UNRECOGNISED CHECK $QUERY"; exit 1; ;; 32 | esac 33 | } 34 | 35 | case "$(uname -a)" in 36 | Darwin*) check_mac "$QUERY" ;; 37 | *) check_linux "$QUERY" ;; 38 | esac 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cryptonight-hashing", 3 | "version": "29.0.6", 4 | "author": { 5 | "name": "Multiple", 6 | "email": "Check The Git Repo" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "https://github.com/AdminXeq/node-cryptonight-hashing.git" 11 | }, 12 | "dependencies": { 13 | "bindings": "*", 14 | "nan": "^2.14.2", 15 | "bigint-buffer": "^1.1.5", 16 | "blake2": "^4.0.2", 17 | "uint64be": "^3.0.0" 18 | }, 19 | "keywords": [ 20 | "cryptonight", 21 | "randomx", 22 | "cuckaroo29", 23 | "argon2", 24 | "astrobwt", 25 | "KangarooTwelve", 26 | "monero", 27 | "kawpow" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /tests/compare_both.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0, line_count=0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | line_count += 1; 13 | multiHashing.cryptonight_async(Buffer.from(line_data[1]), function(err, result){ 14 | result = result.toString('hex'); 15 | if (line_data[0] !== result){ 16 | testsFailed += 1; 17 | } else { 18 | testsPassed += 1; 19 | } 20 | let result2 = multiHashing.cryptonight(Buffer.from(line_data[1])).toString('hex'); 21 | if (result !== result2){ 22 | console.log('line_data[1]: the two functions do not agree: ' + result + ' and ' + result2); 23 | } 24 | if (line_count === (testsFailed + testsPassed)){ 25 | if (testsFailed > 0){ 26 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' comparision tests failed'); 27 | process.exit(1); 28 | } else { 29 | console.log(testsPassed + ' comparision tests passed'); 30 | } 31 | } 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /tests/cryptonight-1.txt: -------------------------------------------------------------------------------- 1 | b5a7f63abb94d07d1a6445c36c07c7e8327fe61b1647e391b4c7edae5de57a3d 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2 | 80563c40ed46575a9e44820d93ee095e2851aa22483fd67837118c6cd951ba61 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 3 | 5bb40c5880cef2f739bdb6aaaf16161eaae55530e7b10d7ea996b751a299e949 8519e039172b0d70e5ca7b3383d6b3167315a422747b73f019cf9528f0fde341fd0f2a63030ba6450525cf6de31837669af6f1df8131faf50aaab8d3a7405589 4 | 613e638505ba1fd05f428d5c9f8e08f8165614342dac419adc6a47dce257eb3e 37a636d7dafdf259b7287eddca2f58099e98619d2f99bdb8969d7b14498102cc065201c8be90bd777323f449848b215d2977c92c4c1c2da36ab46b2e389689ed97c18fec08cd3b03235c5e4c62a37ad88c7b67932495a71090e85dd4020a9300 5 | ed082e49dbd5bbe34a3726a0d1dad981146062b39d36d62c71eb1ed8ab49459b 38274c97c45a172cfc97679870422e3a1ab0784960c60514d816271415c306ee3a3ed1a77e31f6a885c3cb 6 | f22d3d6203d2a08b41d9027278d8bcc983acada9b68e52e3c689692a50e921d9 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 7 | -------------------------------------------------------------------------------- /tests/cryptonight-2.txt: -------------------------------------------------------------------------------- 1 | 353fdc068fd47b03c04b9431e005e00b68c2168a3cc7335c8b9b308156591a4f 5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374 2 | 72f134fc50880c330fe65a2cb7896d59b2e708a0221c6a9da3f69b3a702d8682 4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e67 3 | 410919660ec540fc49d8695ff01f974226a2a28dbbac82949c12f541b9a62d2f 656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f7265 4 | 4472fecfeb371e8b7942ce0378c0ba5e6d0c6361b669c587807365c787ae652d 657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c 5 | 577568395203f1f1225f2982b637f7d5e61b47a0f546ba16d46020b471b74076 71756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e697369 6 | f6fd7efe95a5c6c4bb46d9b429e3faf65b1ce439e116742d42b928e61de52385 757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e20447569732061757465 7 | 422f8cfe8060cf6c3d9fd66f68e3c9977adb683aea2788029308bbe9bc50d728 697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c6974 8 | 512e62c8c8c833cfbd9d361442cb00d63c0a3fd8964cfd2fedc17c7c25ec2d4b 657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e 9 | 12a794c1aa13d561c9c6111cee631ca9d0a321718d67d3416add9de1693ba41e 4578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c 10 | 2659ff95fc74b6215c1dc741e85b7a9710101b30620212f80eb59c3c55993f9d 73756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e 11 | 97378282cf10e7ad033f7b8074c40e14d06e7f609dddda787680b58c05f43d21 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 12 | -------------------------------------------------------------------------------- /tests/cryptonight-ccx.txt: -------------------------------------------------------------------------------- 1 | b3a16786d2c985ecadc45f910527c7a196f0e1e97c8709381d7d419335f81672 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight-double.txt: -------------------------------------------------------------------------------- 1 | aefbb3f0cc88046d119f6c54b96d90c9e884ea3b5983a60d50a42d7d3ebe4821 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight-gpu.txt: -------------------------------------------------------------------------------- 1 | e55cb23e51649a59b127b96b515f2bf7bfea199741a0216cf838ded06eff82df 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | 555e0aee7879316d7deff772973cb9118e3895709db2547ac072d5b9131001d8 3 | -------------------------------------------------------------------------------- /tests/cryptonight-half.txt: -------------------------------------------------------------------------------- 1 | 5d4fbc356097ea6440b0888edeb635ddc84a0e397c868456895c3f29be7312a7 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight-msr.txt: -------------------------------------------------------------------------------- 1 | 3c7a61084c5eb865b498ab2f5a1ac52c49c177c2d0133442d65ed514335c82c5 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight-r.txt: -------------------------------------------------------------------------------- 1 | f759588ad57e758467295443a9bd71490abff8e9dad1b95b6bf2f5d0d78387bc 5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374 2 | -------------------------------------------------------------------------------- /tests/cryptonight-rto.txt: -------------------------------------------------------------------------------- 1 | 82661e1c6e6436668406327a9bb11319a5561615dfec1c9ee3884a6c1ceb76a5 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight-rwz.txt: -------------------------------------------------------------------------------- 1 | 32f736ec1d2f3fc54c49beb8a0476cbfdd14c351b9c6d72c6f9ffcb5875be6b3 5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374 2 | 2f001ca3218aeb29280514ad32bf90ac4cf0e06176e5669a2694db326a25518b 4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e67 3 | 4f935f941de36db8d12022a5d37587318417f0e98de7cb535d17751d6433aea8 656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f7265 4 | e49f8d8561690a6ede1f8bd92e578fa75d4af3323e9b6bfa2c2985fb2c32b8eb 657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c 5 | b2ce1cb3293b72ee75e8992afd531348731fac349e8e4b0705a5c545b986aea6 71756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e697369 6 | ef466f69b3b6ca0fdf895540d386ec4a98cb58a5a6a0ce26a1cb9aa5cf077868 757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e20447569732061757465 7 | 48efbc78144e8c90d9ddfc073640d2e520e654a78d4c127760d9d3465d1db1cc 697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c6974 8 | f6398891bff9254667eb8c8c92a4a4458c688602826fd56850f96fbbe3527022 657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e 9 | d1ce08548c2ec6f64f997e8e6b662b5aeefabfc2e1435ecfec1e7094e732c23f 4578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c 10 | 7d10e1a432d77b0fd3c26f3f9fe880f498128b801a62887d9655105eb712d9e8 73756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e 11 | 5f56c6b0996ba23e0bba0729c99074855a10e3087fdbfe947533547376f075b8 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 12 | -------------------------------------------------------------------------------- /tests/cryptonight-wow.txt: -------------------------------------------------------------------------------- 1 | 9d47bf4c41b7e8e727e681715acb47fa1677cdba9ca7bcb05ad8cc8abd5daa66 5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374 1806260 2 | 0d4a495cb844a3ca8ba4edb8e6bcf829ef1c06d9cdea2b62ca46c2a21b8b0a79 4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e67 1806261 3 | a1d6d848b5c5915fccd2f64cf216c6b1a02cf7c77bc80d8d4e51b419e88ff0dd 656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f7265 1806262 4 | af3a8544a0221a148c2ac90484b19861e3afca33fe17021efb8ad6496b567915 657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c 1806263 5 | 313399e0963ae8a99dab8af66d343e097dae0c0feb08dbc43ccdafef5515f413 71756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e697369 1806264 6 | 6021c6ef90bff9ae94a7506d623d3a7a86c1756d655f50dd558f716d64622a34 757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e20447569732061757465 1806265 7 | 2b13000535f3db5f9b9b84a65c4351f386cd2cdedebb8c3ad2eab086e6a3fee5 697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c6974 1806266 8 | fc0e1dad8e895749dc90eb690bc1ba059a1cd772afaaf65a106bf9e5e6b80503 657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e 1806267 9 | b60b0afe144deff7d903ed2d5545e77ebe66a3c51fee7016eeb8fee9eb630c0f 4578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c 1806268 10 | 64774b27e7d5fec862fc4c0c13ac6bf09123b6f05bb0e4b75c97f379a2b3a679 73756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e 1806269 11 | -------------------------------------------------------------------------------- /tests/cryptonight-xao.txt: -------------------------------------------------------------------------------- 1 | 9a29d0c4afdc639b6553b1c83735114c5d77162142975cb850c0a51f6407bd33 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight-xtl.txt: -------------------------------------------------------------------------------- 1 | 8fe5f05f022a617de53f79364b25cbc3c08e0e1fe3be48570703fee1ec0eb0b1 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight-zls.txt: -------------------------------------------------------------------------------- 1 | 648bdfaaf0544a7edca608c06deaed66d8984512c7515b3d7bbc4e824be8c353 5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374 2 | afca646c21339a24d9783155462f39495415ec21b16c16ff5e3bcfa8a94c2425 4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e67 3 | 8d24fb2f77edc270f60c6c4e26d1378f4a0d56e1a3e2a357c0c7b2a65b834cb1 656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f7265 4 | 76345c5dda34b73f4f9216f39aa6ef083fa62fa00a0e377c6be83c62c4ec4724 657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c 5 | 56bcec4e5a8cdbf4adcfdd231f6c6ba60eb58720306345c580194ac9e9ae4c7e 71756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e697369 6 | efc640e3b3fa54cba6715374601c10b81fded5eb9eb9938b501c2e8378086e52 757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e20447569732061757465 7 | d052059191295630ea711092491d639fd8ee5de4e6513f292709b1441cf4fc88 697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c6974 8 | 98ba7989255b072b13bb0652d0ea9f7d8116f7f50a4f7c3bce94ca5c151c69f4 657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e 9 | 76aa7df97a1107542e85d49317f5099b61aa43915133c6ed9605f93ab0135332 4578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c 10 | 767b3b8d7b632c6b23fddd09c649dab4eb7325fc084d483169ea8190bd011acf 73756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e 11 | 516e33c6e446abbccdad18c04cd9a25e64102853b20a42dfdeaa8b599ecf40e2 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 12 | -------------------------------------------------------------------------------- /tests/cryptonight.txt: -------------------------------------------------------------------------------- 1 | a084f01d1437a09c6985401b60d43554ae105802c5f5d8a9b3253649c0be6605 This is a test 2 | 0bbe54bd26caa92a1d436eec71cbef02560062fa689fe14d7efcf42566b411cf Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus pellentesque metus. 3 | 2f8e3df40bd11f9ac90c743ca8e32bb391da4fb98612aa3b6cdc639ee00b31f5 de omnibus dubitandum 4 | 722fa8ccd594d40e4a41f3822734304c8d5eff7e1b528408e2229da38ba553c4 abundans cautela non nocet 5 | bbec2cacf69866a8e740380fe7b818fc78f8571221742d729d9d02d7f8989b87 caveat emptor 6 | b1257de4efc5ce28c6b40ceb1c6c8f812a64634eb3e81c5220bee9b2b76a6f05 ex nihilo nihil fit 7 | -------------------------------------------------------------------------------- /tests/cryptonight_heavy-tube.txt: -------------------------------------------------------------------------------- 1 | fe53352076eae689fa3b4fda614634cfc312ee0c387df2b8b74da2a159741235 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight_heavy-xhv.txt: -------------------------------------------------------------------------------- 1 | c7d452092b48a5afae11af409a87e588f02935a3680de36bce43f6c8dfd3e309 5468697320697320612074657374205468697320697320612074657374205468697320697320612074657374 2 | 6b67ee997252ed2fe74de2bb906b8132663cc91e3bb2f15e5875823f6b21f097 4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e67 3 | 8e9c20c03c06981e5673d9f306001c50c9cf2ca151140d69a0f94c8c6c49ba13 656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f7265 4 | fb3e639493d1e3e48c2d3abc1f0a1086ed916090d25abafa1ffbd0edeff09c44 657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c 5 | 6b0dd4b7cd38f5540c845711c78f391d2e7f3ed623e6e171f39c1717d6999a12 71756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e697369 6 | ba5389c6cbb0d8cc1342a35e96e386c97aab251c6b05438d9dce0c65fcc27302 757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e20447569732061757465 7 | f8b4b717733e2d5cf28bd3228c3166e6f09e190f233e9cac9a1a4875d0fda3a1 697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c6974 8 | f0cbc47a31857a4ec32833c60563629c0b2ccd06f61bd4f422b8f657aea375ed 657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e 9 | 26af5579cce4a1b7547150fe6e038f8f0c777b37878a143166db19b02647756f 4578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c 10 | f37048e1189c100b74b238f64a1d64fb5cb0a5fbdb4037cecf06b5528713da33 73756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e 11 | 5ac3f785c490c58550ec95d2726563577e7c1c212d0cde591273201e44fdd5b6 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 -------------------------------------------------------------------------------- /tests/cryptonight_heavy.txt: -------------------------------------------------------------------------------- 1 | 9983f21bdf2010a8d707bb2f14d78664bbe1187f55014b39e5f3d69328e48fc2 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight_light-1.txt: -------------------------------------------------------------------------------- 1 | 6d8cdc444e9bbbfd68fc43fcd4855b228c8a1bd91d9d00285bec02b7ca2d6741 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight_light.txt: -------------------------------------------------------------------------------- 1 | 3695b4b53bb00358b0ad38dc160feb9e004eece09b83a72ef6ba9864d3510c88 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/cryptonight_pico.txt: -------------------------------------------------------------------------------- 1 | 08f421d7833117300eda66e98f4a2569093df300500173944efc401e9a4a17af 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 2 | -------------------------------------------------------------------------------- /tests/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | cd $DIR 6 | node test_kcn.js 7 | node test_rtm.js 8 | node test.js 9 | node test_autolykos2.js 10 | node test_ethash.js 11 | node test_etchash.js 12 | node test_kawpow.js 13 | node test_astrobwt.js 14 | node test_astrobwt2.js 15 | node test_k12.js 16 | node test_sync-1.js 17 | node test_sync-2.js 18 | node test_sync-r.js 19 | node test_sync-half.js 20 | node test_sync-msr.js 21 | node test_sync-xao.js 22 | node test_sync-rto.js 23 | node test_sync-gpu.js 24 | node test_sync-rwz.js 25 | node test_sync-zls.js 26 | node test_sync-ccx.js 27 | node test_sync-double.js 28 | node test_sync.js 29 | node test_sync_light.js 30 | node test_sync_light-1.js 31 | node test_sync_heavy.js 32 | node test_sync_heavy-xhv.js 33 | node test_sync_heavy-tube.js 34 | node test_sync_pico.js 35 | node test_rx0.js 36 | node test_rx_xeq.js 37 | node test_rx_arq.js 38 | #node test_rx_defyx.js 39 | node test_rx_xla.js 40 | #node test_rx_wow.js 41 | #node test_rx_loki.js 42 | #node test_rx_keva.js 43 | #node test_rx_graft.js 44 | node test_rx_switch.js 45 | node test_ar2_chukwa.js 46 | node test_ar2_chukwa2.js 47 | node test_ar2_wrkz.js 48 | 49 | node test_perf_kcn.js 50 | node test_perf_rtm.js 51 | node test_perf.js 52 | node test_perf_xla.js 53 | node test_perf_kawpow.js 54 | node test_perf_ethash.js 55 | node test_perf_astrobwt.js 56 | node test_perf_astrobwt2.js 57 | node test_perf_k12.js 58 | node test_perf_light.js 59 | node test_perf_heavy.js 60 | node test_perf_gpu.js 61 | #node test_perf_rx_defyx.js 62 | node test_perf_rx_wow.js 63 | #node test_perf_rx_loki.js 64 | #node test_perf_rx_keva.js 65 | #node test_perf_rx_graft.js 66 | node test_perf_rx_switch.js 67 | node test_perf_pico.js 68 | node test_perf_double.js 69 | node test_perf_ar2_chukwa2.js 70 | node test_perf_ar2_wrkz.js 71 | -------------------------------------------------------------------------------- /tests/rx0.txt: -------------------------------------------------------------------------------- 1 | 38f638606c730dd6f271d037556b83988c71acc6980e22e25271b22389ecfce6 12345678901234567890123456789012 This is a test 2 | 86cb0f6306d536f373650bd196a5205a0293fba2ead85003d7aee4006afee147 12345678901234567890123456789012 Lorem ipsum dolor sit amet 3 | 375aa54e18029b6f04372dd51b7349f130810b1270e67a22f26c15dab6f93a65 12345678901234567890123456789012 sed do eiusmod tempor incididunt ut labore et dolore magna aliqua -------------------------------------------------------------------------------- /tests/rx_arq.txt: -------------------------------------------------------------------------------- 1 | 8b9937420651309742f833333371a8ab4d04e5f06d4b3d0a2dbec1b381e9a0e5 12345678901234567890123456789012 This is a test 2 | 4ac3679fa183247704de12ff913a7f787e5b854f999981eee62063051dc7e5f3 12345678901234567890123456789012 Lorem ipsum dolor sit amet 3 | 45a7e12fa47f26de4fd425703688c6902b82d312dec1c341b051c297784df0b3 12345678901234567890123456789012 sed do eiusmod tempor incididunt ut labore et dolore magna aliqua -------------------------------------------------------------------------------- /tests/rx_graft.txt: -------------------------------------------------------------------------------- 1 | 08135aaeb098d86f269d0a037aba423093e4c48e9e31f16c13d2ed3dc4489ba7 12345678901234567890123456789012 This is a test 2 | 200047b130fd8fc97b59ddf4f720e6c7a3784c221a9c4453ad7f00dae310b576 12345678901234567890123456789012 Lorem ipsum dolor sit amet 3 | a01b6795ed4063683f15b0f488d55e1aff164c66b0c1686f34a18b48445dbeaa 12345678901234567890123456789012 sed do eiusmod tempor incididunt ut labore et dolore magna aliqua 4 | -------------------------------------------------------------------------------- /tests/rx_keva.txt: -------------------------------------------------------------------------------- 1 | 745ac75a1d5d044ebd5cbc97269c1f75b1bfeb6ce2df4ed700be898356a879df 12345678901234567890123456789012 This is a test 2 | a17feef611cbb7ad1802f2af62961b4219f76952a1b08b7892cf1fc87b4870a3 12345678901234567890123456789012 Lorem ipsum dolor sit amet 3 | dc4eba2a3b047ea8d45545fddd9d1f23332a4e85a8d42f0691939ba61d85d469 12345678901234567890123456789012 sed do eiusmod tempor incididunt ut labore et dolore magna aliqua -------------------------------------------------------------------------------- /tests/rx_xeq.txt: -------------------------------------------------------------------------------- 1 | 2d4dc87b3d1d8edf238b4adc546439388f1e9a796066f519f2c0cb2e9fe6fcd2 12345678901234567890123456789012 This is a test 2 | 20d6111232c7b14a28b7385d1f9f5ed058bfa3ec2ef1a96d0bbb5f66609dfbfd 12345678901234567890123456789012 Lorem ipsum dolor sit amet 3 | 6cf7cd127bf94742468b9d3c7ec6aa4f9b3600f8f4891fc7da6db9a2b7d3db23 12345678901234567890123456789012 sed do eiusmod tempor incididunt ut labore et dolore magna aliqua 4 | -------------------------------------------------------------------------------- /tests/test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let hashes = { 7 | 'CryptoNight': { 8 | 'file': 'cryptonight.txt', 9 | 'fileFormat': 'cn', 10 | 'function': multiHashing.cryptonight 11 | }, 12 | }; 13 | 14 | for (let hashType in hashes){ 15 | if (hashes.hasOwnProperty(hashType)){ 16 | let testsFailed = 0, testsPassed = 0; 17 | let lr = lineReader.createInterface({ 18 | input: fs.createReadStream(hashes[hashType].file) 19 | }); 20 | lr.on('line', function (line) { 21 | if (hashes[hashType].fileFormat === 'cn'){ 22 | let line_data = line.split(/ (.+)/); 23 | let result = hashes[hashType].function(Buffer.from(line_data[1])).toString('hex'); 24 | if (line_data[0] !== result){ 25 | console.error(line_data[1] + ": " + result); 26 | testsFailed += 1; 27 | } else { 28 | testsPassed += 1; 29 | } 30 | } 31 | }); 32 | lr.on('close', function(){ 33 | if (testsFailed > 0){ 34 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: ' + hashType); 35 | process.exit(1); 36 | } else { 37 | console.log(testsPassed + ' tests passed on: ' +hashType); 38 | } 39 | }); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/test_ar2_chukwa.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.argon2(Buffer.from('0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601', 'hex'), 0).toString('hex'); 5 | if (result == 'c158a105ae75c7561cfd029083a47a87653d51f914128e21c1971d8b10c49034') 6 | console.log('Argon2-Chukwa test passed'); 7 | else { 8 | console.log('Argon2-Chukwa test failed: ' + result); 9 | process.exit(1); 10 | } -------------------------------------------------------------------------------- /tests/test_ar2_chukwa2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.argon2(Buffer.from('0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601', 'hex'), 2).toString('hex'); 5 | if (result == '77cf6958b3536e1f9f0d1ea165f22811ca7bc487ea9f52030b5050c17fcdd8f5') 6 | console.log('Argon2-Chukwa2 test passed'); 7 | else { 8 | console.log('Argon2-Chukwa2 test failed: ' + result); 9 | process.exit(1); 10 | } -------------------------------------------------------------------------------- /tests/test_ar2_wrkz.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.argon2(Buffer.from('0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601', 'hex'), 1).toString('hex'); 5 | if (result == '35e083d4b9c64c2a68820a431f61311998a8cd1864dba4077e25b7f121d54bd1') 6 | console.log('Argon2-WRKZ test passed'); 7 | else { 8 | console.log('Argon2-WRKZ test failed: ' + result); 9 | process.exit(1); 10 | } 11 | -------------------------------------------------------------------------------- /tests/test_astrobwt.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.astrobwt(Buffer.from('0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601', 'hex'), 0).toString('hex'); 5 | if (result == '7e8844f2d6b7a43498fe6d226527689023da8a52f9fc4ec69e5aaaa63edce1c1') 6 | console.log('AstroBWT (DERO) test passed'); 7 | else { 8 | console.log('AstroBWT (DERO) test failed: ' + result); 9 | process.exit(1); 10 | } 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/test_astrobwt2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.astrobwt(Buffer.from('0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601', 'hex'), 1).toString('hex'); 5 | if (result == '489ed2661427986503fb8725e1d398da27ee253db4378798bf5a5c94ee0ce22a') 6 | console.log('AstroBWT (DERO-HE) test passed'); 7 | else { 8 | console.log('AstroBWT (DERO-HE) test failed: ' + result); 9 | process.exit(1); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/test_async-wow.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0, line_count = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-wow.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(" "); 12 | line_count += 1; 13 | multiHashing.cryptonight_async(Buffer.from(line_data[1], 'hex'), 12, parseInt(line_data[2]), function(err, result){ 14 | result = result.toString('hex'); 15 | if (line_data[0] !== result){ 16 | console.error(line_data[1] + ": " + result); 17 | testsFailed += 1; 18 | } else { 19 | testsPassed += 1; 20 | } 21 | if (line_count === (testsFailed + testsPassed)){ 22 | if (testsFailed > 0){ 23 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-wow_async'); 24 | process.exit(1); 25 | } else { 26 | console.log(testsPassed + ' tests passed on: cryptonight-wow_async'); 27 | } 28 | } 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/test_async.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0, line_count = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-1.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | line_count += 1; 13 | multiHashing.cryptonight_async(Buffer.from(line_data[1], 'hex'), 1, function(err, result){ 14 | result = result.toString('hex'); 15 | if (line_data[0] !== result){ 16 | console.error(line_data[1] + ": " + result); 17 | testsFailed += 1; 18 | } else { 19 | testsPassed += 1; 20 | } 21 | if (line_count === (testsFailed + testsPassed)){ 22 | if (testsFailed > 0){ 23 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_async'); 24 | process.exit(1); 25 | } else { 26 | console.log(testsPassed + ' tests passed on: cryptonight_async'); 27 | } 28 | } 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/test_async_heavy.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0, line_count = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight_heavy.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | line_count += 1; 13 | multiHashing.cryptonight_heavy_async(Buffer.from(line_data[1], 'hex'), function(err, result){ 14 | result = result.toString('hex'); 15 | if (line_data[0] !== result){ 16 | console.error(line_data[1] + ": " + result); 17 | testsFailed += 1; 18 | } else { 19 | testsPassed += 1; 20 | } 21 | if (line_count === (testsFailed + testsPassed)){ 22 | if (testsFailed > 0){ 23 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_heavy_async'); 24 | process.exit(1); 25 | } else { 26 | console.log(testsPassed + ' tests passed on: cryptonight_heavy_async'); 27 | } 28 | } 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/test_async_light.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0, line_count = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight_light-1.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | line_count += 1; 13 | multiHashing.cryptonight_light_async(Buffer.from(line_data[1], 'hex'), 1, function(err, result){ 14 | result = result.toString('hex'); 15 | if (line_data[0] !== result){ 16 | console.error(line_data[1] + ": " + result); 17 | testsFailed += 1; 18 | } else { 19 | testsPassed += 1; 20 | } 21 | if (line_count === (testsFailed + testsPassed)){ 22 | if (testsFailed > 0){ 23 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_light_async'); 24 | process.exit(1); 25 | } else { 26 | console.log(testsPassed + ' tests passed on: cryptonight_light_async'); 27 | } 28 | } 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/test_async_pico.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0, line_count = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight_pico.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | line_count += 1; 13 | multiHashing.cryptonight_pico_async(Buffer.from(line_data[1], 'hex'), function(err, result){ 14 | result = result.toString('hex'); 15 | if (line_data[0] !== result){ 16 | console.error(line_data[1] + ": " + result); 17 | testsFailed += 1; 18 | } else { 19 | testsPassed += 1; 20 | } 21 | if (line_count === (testsFailed + testsPassed)){ 22 | if (testsFailed > 0){ 23 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_pico_async'); 24 | process.exit(1); 25 | } else { 26 | console.log(testsPassed + ' tests passed on: cryptonight_pico_async'); 27 | } 28 | } 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/test_autolykos2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const multiHashing = require('cryptonight-hashing'); 3 | 4 | const extraNonce1 = Buffer.from("9618", 'hex'); 5 | const extraNonce2 = Buffer.from("33e73592d373", 'hex'); 6 | const nonce = "961833e73592d373"; 7 | const height = 535357; 8 | const msg = Buffer.from("9dbb7796a8c29559d5906331975dae9e16f8513ee4864692dcee05fd12c09e6d", 'hex'); 9 | 10 | function serializeCoinbase(msg, extraNonce1, extraNonce2){ 11 | return Buffer.concat([ 12 | msg, 13 | extraNonce1, 14 | extraNonce2 15 | ]); 16 | }; 17 | 18 | const result = multiHashing.autolykos2_hashes(serializeCoinbase(msg, extraNonce1, extraNonce2), height); 19 | 20 | if (result !== null && result[0].toString('hex') === '10cf53f111fa6236ab59d87a70888fca6bd4d8a9dec816df013b94b91f8e09d8') 21 | console.log('autolykos2 test passed'); 22 | else { 23 | console.log('autolykos2 test failed: ' + (result ? result[0].toString('hex') : result[0])); 24 | process.exit(1); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /tests/test_etchash.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const result = multiHashing.etchash( 5 | Buffer.from('053690289a0a9dac132c268d6ffe64ad8e025b74eefa61b51934c57d2a49d9e4', 'hex'), 6 | Buffer.from('fe09000002a784b0', 'hex'), 7 | 15658542 8 | ); 9 | 10 | if (result !== null && result[0].toString('hex') === '0000000d4899e38dbd9ac5bdc3726e34669986f53af0c60f50c5aa54e7fa4ed0') 11 | console.log('Etchash test result passed'); 12 | else { 13 | console.log('Etchash test result failed: ' + (result[0] ? result[0].toString('hex') : result[0])); 14 | process.exit(1); 15 | } 16 | 17 | if (result !== null && result[1].toString('hex') === '9b4f5f7321d7b132ea2cc8d4eef5f61d906658cbf7bc49edd77c9a192c290697') 18 | console.log('Etchash test mix hash passed'); 19 | else { 20 | console.log('Etchash test mix hash failed: ' + (result[1] ? result[1].toString('hex') : result[1])); 21 | process.exit(1); 22 | } -------------------------------------------------------------------------------- /tests/test_ethash.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const result = multiHashing.ethash( 5 | Buffer.from('f5afa3074287b2b33e975468ae613e023e478112530bc19d4187693c13943445', 'hex'), 6 | Buffer.from('ff4136b6b6a244ec', 'hex'), 7 | 1257006 8 | ); 9 | 10 | if (result !== null && result[0].toString('hex') === '0000000000095d18875acd4a2c2a5ff476c9acf283b4975d7af8d6c33d119c74') 11 | console.log('Ethash test result passed'); 12 | else { 13 | console.log('Ethash test result failed: ' + (result[0] ? result[0].toString('hex') : result[0])); 14 | process.exit(1); 15 | } 16 | 17 | if (result !== null && result[1].toString('hex') === '47da5e47804594550791c24331163c1f1fde5bc622170e83515843b2b13dbe14') 18 | console.log('Ethash test mix hash passed'); 19 | else { 20 | console.log('Ethash test mix hash failed: ' + (result[1] ? result[1].toString('hex') : result[1])); 21 | process.exit(1); 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/test_k12.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('k12.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.k12(Buffer.from(line_data[1], 'hex')).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: k12'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: k12'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_kawpow.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const result = multiHashing.kawpow( 5 | Buffer.from('63543d3913fe56e6720c5e61e8d208d05582875822628f483279a3e8d9c9a8b3', 'hex'), 6 | Buffer.from('88a23b0033eb959b', 'hex'), 7 | Buffer.from('89732e5ff8711c32558a308fc4b8ee77416038a70995670e3eb84cbdead2e337', 'hex') 8 | ); 9 | 10 | if (result !== null && result.toString('hex') === '0000000718ba5143286c46f44eee668fdf59b8eba810df21e4e2f4ec9538fc20') 11 | console.log('KawPow test passed'); 12 | else { 13 | console.log('KawPow test failed: ' + (result ? result.toString('hex') : result)); 14 | process.exit(1); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /tests/test_kcn.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.cryptonight(Buffer.from('0100000000000000000000000000000000000000000000000000000000000000000000001ccca66a44f8bd5545c3164a3a76da50395328c9075633775bc4c8798fd6772b700d215cf0ff0f1e00000000', 'hex'), 19).toString('hex'); 5 | if (result == '2e4f857aa81008c4d1fe9acd7489e84d3bc55b7054e6c02b2c0e1b76cca0da7b') 6 | console.log('RandomX-Flex test passed'); 7 | else { 8 | console.log('RandomX-Flex test failed: ' + result); 9 | process.exit(1); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/test_perf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.cryptonight(input, 8); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_ar2_chukwa.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.argon2(input, 0); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_ar2_chukwa2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.argon2(input, 2); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_ar2_wrkz.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.argon2(input, 1); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_astrobwt.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | 6 | let start = Date.now(); 7 | for (let i = ITER; i; -- i) { 8 | multiHashing.astrobwt(Buffer.from("test" + i), 0); 9 | } 10 | let end = Date.now(); 11 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 12 | -------------------------------------------------------------------------------- /tests/test_perf_astrobwt2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 20000; 5 | 6 | let start = Date.now(); 7 | for (let i = ITER; i; -- i) { 8 | multiHashing.astrobwt(Buffer.from("test" + i), 1); 9 | } 10 | let end = Date.now(); 11 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 12 | -------------------------------------------------------------------------------- /tests/test_perf_double.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 100; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.cryptonight(input, 16); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_ethash.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input1 = Buffer.from('f5afa3074287b2b33e975468ae613e023e478112530bc19d4187693c13943445', 'hex'); 6 | let input2 = Buffer.from('ff4136b6b6a244ec', 'hex'); 7 | 8 | let start = Date.now(); 9 | for (let i = ITER; i; -- i) { 10 | multiHashing.ethash(input1, input2, 1257006+i); 11 | } 12 | let end = Date.now(); 13 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); -------------------------------------------------------------------------------- /tests/test_perf_gpu.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 100; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.cryptonight(input, 11); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_heavy.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 100; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.cryptonight_heavy(input); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_k12.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 2000000; 5 | 6 | let start = Date.now(); 7 | for (let i = ITER; i; -- i) { 8 | multiHashing.k12(Buffer.from("test" + i)); 9 | } 10 | let end = Date.now(); 11 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 12 | -------------------------------------------------------------------------------- /tests/test_perf_kawpow.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 10000000; 5 | let input1 = Buffer.from('63543d3913fe56e6720c5e61e8d208d05582875822628f483279a3e8d9c9a8b3', 'hex'); 6 | let input2 = Buffer.from('9b95eb33003ba288', 'hex'); 7 | let input3 = Buffer.from('89732e5ff8711c32558a308fc4b8ee77416038a70995670e3eb84cbdead2e337', 'hex'); 8 | 9 | let start = Date.now(); 10 | for (let i = ITER; i; -- i) { 11 | multiHashing.kawpow(input1, input2, input3); 12 | } 13 | let end = Date.now(); 14 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); -------------------------------------------------------------------------------- /tests/test_perf_kcn.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input = Buffer.from('000000208c246d0b90c3b389c4086e8b672ee040d64db5b9648527133e217fbfa48da64c0f3c0a0b0e8350800568b40fbb323ac3ccdf2965de51b9aaeb939b4f11ff81c49b74a16156ff251c00000000', 'hex'); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.cryptonight(input, 19); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_light.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 100; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.cryptonight_light(input); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_loki.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.randomx(input, Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'), 18); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_pico.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 1000; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.cryptonight_pico(input); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_rtm.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input = Buffer.from('000000208c246d0b90c3b389c4086e8b672ee040d64db5b9648527133e217fbfa48da64c0f3c0a0b0e8350800568b40fbb323ac3ccdf2965de51b9aaeb939b4f11ff81c49b74a16156ff251c00000000', 'hex'); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.cryptonight(input, 18); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_rwz.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.cryptonight(input, 14); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_rx_defyx.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | const seed = Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'); 6 | 7 | multiHashing.randomx(Buffer.from("test"), seed, 1); 8 | 9 | let start = Date.now(); 10 | for (let i = ITER; i; -- i) { 11 | multiHashing.randomx(Buffer.from("test" + i), seed, 1); 12 | } 13 | let end = Date.now(); 14 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 15 | -------------------------------------------------------------------------------- /tests/test_perf_rx_graft.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | const seed = Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'); 6 | 7 | multiHashing.randomx(Buffer.from("test"), seed, 20); 8 | 9 | let start = Date.now(); 10 | for (let i = ITER; i; -- i) { 11 | multiHashing.randomx(Buffer.from("test" + i), seed, 20); 12 | } 13 | let end = Date.now(); 14 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 15 | -------------------------------------------------------------------------------- /tests/test_perf_rx_keva.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | const seed = Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'); 6 | 7 | multiHashing.randomx(Buffer.from("test"), seed, 19); 8 | 9 | let start = Date.now(); 10 | for (let i = ITER; i; -- i) { 11 | multiHashing.randomx(Buffer.from("test" + i), seed, 19); 12 | } 13 | let end = Date.now(); 14 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 15 | -------------------------------------------------------------------------------- /tests/test_perf_rx_loki.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | const seed = Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'); 6 | 7 | multiHashing.randomx(Buffer.from("test"), seed, 18); 8 | 9 | let start = Date.now(); 10 | for (let i = ITER; i; -- i) { 11 | multiHashing.randomx(Buffer.from("test" + i), seed, 18); 12 | } 13 | let end = Date.now(); 14 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 15 | -------------------------------------------------------------------------------- /tests/test_perf_rx_switch.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 100; 5 | const seed1 = Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'); 6 | const seed2 = Buffer.from('0000000000000000000000000000000000000000000000000000000000000001', 'hex'); 7 | const seed3 = Buffer.from('0000000000000000000000000000000000000000000000000000000000000002', 'hex'); 8 | 9 | multiHashing.randomx(Buffer.from("test"), seed1, 2); 10 | multiHashing.randomx(Buffer.from("test"), seed2, 3); 11 | multiHashing.randomx(Buffer.from("test"), seed3, 0); 12 | 13 | let start = Date.now(); 14 | for (let i = ITER; i; -- i) { 15 | multiHashing.randomx(Buffer.from("test" + i), seed1, 2); 16 | multiHashing.randomx(Buffer.from("test" + i), seed2, 3); 17 | multiHashing.randomx(Buffer.from("test" + i), seed3, 0); 18 | } 19 | let end = Date.now(); 20 | console.log("Perf: " + 1000 * ITER * 3 / (end - start) + " H/s"); 21 | -------------------------------------------------------------------------------- /tests/test_perf_rx_wow.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | const seed = Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'); 6 | 7 | multiHashing.randomx(Buffer.from("test"), seed, 17); 8 | 9 | let start = Date.now(); 10 | for (let i = ITER; i; -- i) { 11 | multiHashing.randomx(Buffer.from("test" + i), seed, 17); 12 | } 13 | let end = Date.now(); 14 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 15 | -------------------------------------------------------------------------------- /tests/test_perf_xla.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.randomx(input, Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'), 3); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_perf_zls.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | const ITER = 200; 5 | let input = Buffer.from("test"); 6 | 7 | let start = Date.now(); 8 | for (let i = ITER; i; -- i) { 9 | multiHashing.cryptonight(input, 15); 10 | } 11 | let end = Date.now(); 12 | console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); 13 | -------------------------------------------------------------------------------- /tests/test_rtm.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.cryptonight(Buffer.from('000000208c246d0b90c3b389c4086e8b672ee040d64db5b9648527133e217fbfa48da64c0f3c0a0b0e8350800568b40fbb323ac3ccdf2965de51b9aaeb939b4f11ff81c49b74a16156ff251c00000000', 'hex'), 18).toString('hex'); 5 | if (result == '84402e62b6bedafcd65f6ba13b59ff19ad7f273900c59fa49bfbb5f67e10030f') 6 | console.log('RandomX-Ghostrider test passed'); 7 | else { 8 | console.log('RandomX-Ghostrider test failed: ' + result); 9 | process.exit(1); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/test_rx0.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('rx0.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | const line_data0 = line.split(" "); 12 | const line_data = line_data0.slice(0, 2).concat(line_data0.slice(2).join(" ")); 13 | let result = multiHashing.randomx(Buffer.from(line_data[2]), Buffer.from(line_data[1]), 0).toString('hex'); 14 | if (line_data[0] !== result) { 15 | console.error(line_data[1] + " '" + line_data[2] + "': " + result); 16 | testsFailed += 1; 17 | } else { 18 | testsPassed += 1; 19 | } 20 | }); 21 | lr.on('close', function(){ 22 | if (testsFailed > 0){ 23 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: rx/0'); 24 | process.exit(1); 25 | } else { 26 | console.log(testsPassed + ' tests passed on: rx/0'); 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /tests/test_rx_arq.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('rx_arq.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | const line_data0 = line.split(" "); 12 | const line_data = line_data0.slice(0, 2).concat(line_data0.slice(2).join(" ")); 13 | let result = multiHashing.randomx(Buffer.from(line_data[2]), Buffer.from(line_data[1]), 2).toString('hex'); 14 | if (line_data[0] !== result) { 15 | console.error(line_data[1] + " '" + line_data[2] + "': " + result); 16 | testsFailed += 1; 17 | } else { 18 | testsPassed += 1; 19 | } 20 | }); 21 | lr.on('close', function(){ 22 | if (testsFailed > 0){ 23 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: rx/arq'); 24 | process.exit(1); 25 | } else { 26 | console.log(testsPassed + ' tests passed on: rx/arq'); 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /tests/test_rx_defyx.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.randomx(Buffer.from('This is a test'), Buffer.from('1000000000000000000000000000000000000000000000000000000000000000', 'hex'), 1).toString('hex'); 5 | if (result == 'b7a974208efe1759adbb7d160f5b76e850f226265a00cf07b78d8c8c4d55b8bd') 6 | console.log('DefyX test passed'); 7 | else { 8 | console.log('DefyX test failed: ' + result); 9 | process.exit(1); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/test_rx_graft.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('rx_graft.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | const line_data0 = line.split(" "); 12 | const line_data = line_data0.slice(0, 2).concat(line_data0.slice(2).join(" ")); 13 | let result = multiHashing.randomx(Buffer.from(line_data[2]), Buffer.from(line_data[1]), 20).toString('hex'); 14 | if (line_data[0] !== result) { 15 | console.error(line_data[1] + " '" + line_data[2] + "': " + result); 16 | testsFailed += 1; 17 | } else { 18 | testsPassed += 1; 19 | } 20 | }); 21 | lr.on('close', function(){ 22 | if (testsFailed > 0){ 23 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: rx/graft'); 24 | process.exit(1); 25 | } else { 26 | console.log(testsPassed + ' tests passed on: rx/graft'); 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /tests/test_rx_keva.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('rx_keva.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | const line_data0 = line.split(" "); 12 | const line_data = line_data0.slice(0, 2).concat(line_data0.slice(2).join(" ")); 13 | let result = multiHashing.randomx(Buffer.from(line_data[2]), Buffer.from(line_data[1]), 19).toString('hex'); 14 | if (line_data[0] !== result) { 15 | console.error(line_data[1] + " '" + line_data[2] + "': " + result); 16 | testsFailed += 1; 17 | } else { 18 | testsPassed += 1; 19 | } 20 | }); 21 | lr.on('close', function(){ 22 | if (testsFailed > 0){ 23 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: rx/keva'); 24 | process.exit(1); 25 | } else { 26 | console.log(testsPassed + ' tests passed on: rx/keva'); 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /tests/test_rx_loki.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.randomx(Buffer.from('This is a test'), Buffer.from('000000000000000100000000000000000000000f000000042000000000000000', 'hex'), 18).toString('hex'); 5 | if (result == '3c1f6d871c8571ae74cce3c6ff7d11ed7f5848c19a26d9c5972869cfabc449a8') 6 | console.log('RandomX-Loki test passed'); 7 | else { 8 | console.log('RandomX-Loki test failed: ' + result); 9 | process.exit(1); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/test_rx_switch.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | for (let i = 2; i; -- i) { 5 | { let result = multiHashing.randomx(Buffer.from('This is a test'), Buffer.from('12345678901234567890123456789012'), 22).toString('hex'); 6 | if (result == '2d4dc87b3d1d8edf238b4adc546439388f1e9a796066f519f2c0cb2e9fe6fcd2') 7 | console.log('RandomWOW test passed'); 8 | else { 9 | console.log('RandomWOW test failed: ' + result); 10 | process.exit(1); 11 | } 12 | } 13 | 14 | { let result = multiHashing.randomx(Buffer.from('0c0cedabc4f8059535516f43f0f480ca4ab081ef4119fc8b1eb980e78f16cfad8fb3227f5f113e278400003e2d90c6f83a2f0f95f829455e739f8c16d5eeedad382804b2cfefea4b150e4c01', 'hex'), 15 | Buffer.from('1b7d5a95878b2d38be374cf3476bd07f5ea83adf2e8ca3f34aca49009af7f498', 'hex'), 3).toString('hex'); 16 | if (result == '8ef59b356386cccba1e481c79fe1bf4423b8837d539610842a4ab576695e0800') 17 | console.log('RandomX-Panther test passed'); 18 | else { 19 | console.log('RandomX-Panther test failed: ' + result); 20 | process.exit(1); 21 | } 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /tests/test_rx_wow.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.randomx(Buffer.from('This is a test'), Buffer.from('0000000000000000000000000000000000000000000000000000000000000001', 'hex'), 17).toString('hex'); 5 | if (result == '7f7d2ec8dd966f1bacdb19f450255a46eef353d917758f775559df6f6431ce33') 6 | console.log('RandomWOW test passed'); 7 | else { 8 | console.log('RandomWOW test failed: ' + result); 9 | process.exit(1); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/test_rx_xeq.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('rx_xeq.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | const line_data0 = line.split(" "); 12 | const line_data = line_data0.slice(0, 2).concat(line_data0.slice(2).join(" ")); 13 | let result = multiHashing.randomx(Buffer.from(line_data[2]), Buffer.from(line_data[1]), 22).toString('hex'); 14 | if (line_data[0] !== result) { 15 | console.error(line_data[1] + " '" + line_data[2] + "': " + result); 16 | testsFailed += 1; 17 | } else { 18 | testsPassed += 1; 19 | } 20 | }); 21 | lr.on('close', function(){ 22 | if (testsFailed > 0){ 23 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: rx/xeq'); 24 | process.exit(1); 25 | } else { 26 | console.log(testsPassed + ' tests passed on: rx/xeq'); 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /tests/test_rx_xla.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | 4 | let result = multiHashing.randomx(Buffer.from('0c0cedabc4f8059535516f43f0f480ca4ab081ef4119fc8b1eb980e78f16cfad8fb3227f5f113e278400003e2d90c6f83a2f0f95f829455e739f8c16d5eeedad382804b2cfefea4b150e4c01', 'hex'), 5 | Buffer.from('1b7d5a95878b2d38be374cf3476bd07f5ea83adf2e8ca3f34aca49009af7f498', 'hex'), 3).toString('hex'); 6 | if (result == '8ef59b356386cccba1e481c79fe1bf4423b8837d539610842a4ab576695e0800') 7 | console.log('RandomX-Panther test passed'); 8 | else { 9 | console.log('RandomX-Panther test failed: ' + result); 10 | process.exit(1); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /tests/test_sync-1.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-1.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 1).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-1'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-1'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-2.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 8).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-2'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-2'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-ccx.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-ccx.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 17).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-ccx'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-ccx'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-double.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-double.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 16).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-double'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-double'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-gpu.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-gpu.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.*)$/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 11).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-gpu'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-gpu'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-half.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-half.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 9).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-half'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-half'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-msr.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-msr.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 4).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-msr'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-msr'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-r.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-r.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 13, 1806260).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-r'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-r'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-rto.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-rto.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 7).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-rto'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-rto'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-rwz.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-rwz.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 14).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-rwz'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-rwz'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-wow.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-wow.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(" "); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 12, parseInt(line_data[2])).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-r'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-wow'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-xao.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-xao.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 6).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-xao'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-xao'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-xtl.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-xtl.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 3).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-xtl'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-xtl'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync-zls.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight-zls.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1], 'hex'), 15).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight-zls'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight-zls'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight(Buffer.from(line_data[1])).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync_heavy-tube.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight_heavy-tube.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight_heavy(Buffer.from(line_data[1], 'hex'), 2).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_heavy-tube'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight_heavy-tube'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync_heavy-xhv.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight_heavy-xhv.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight_heavy(Buffer.from(line_data[1], 'hex'), 1).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_heavy-xhv'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight_heavy-xhv'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync_heavy.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight_heavy.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight_heavy(Buffer.from(line_data[1], 'hex')).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_heavy'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight_heavy'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync_light-1.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight_light-1.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight_light(Buffer.from(line_data[1], 'hex'), 1).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_light-1'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight_light-1'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync_light.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight_light.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight_light(Buffer.from(line_data[1], 'hex'), 0).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_light'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight_light'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /tests/test_sync_pico.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let multiHashing = require('../build/Release/cryptonight-hashing'); 3 | let fs = require('fs'); 4 | let lineReader = require('readline'); 5 | 6 | let testsFailed = 0, testsPassed = 0; 7 | let lr = lineReader.createInterface({ 8 | input: fs.createReadStream('cryptonight_pico.txt') 9 | }); 10 | lr.on('line', function (line) { 11 | let line_data = line.split(/ (.+)/); 12 | let result = multiHashing.cryptonight_pico(Buffer.from(line_data[1], 'hex')).toString('hex'); 13 | if (line_data[0] !== result){ 14 | console.error(line_data[1] + ": " + result); 15 | testsFailed += 1; 16 | } else { 17 | testsPassed += 1; 18 | } 19 | }); 20 | lr.on('close', function(){ 21 | if (testsFailed > 0){ 22 | console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_pico'); 23 | process.exit(1); 24 | } else { 25 | console.log(testsPassed + ' tests passed on: cryptonight_pico'); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /xmrig-override/backend/cpu/Cpu.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2020 SChernykh 9 | * Copyright 2016-2020 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | 26 | #include 27 | 28 | 29 | #include "backend/cpu/Cpu.h" 30 | 31 | 32 | #if defined(XMRIG_FEATURE_HWLOC) 33 | # include "backend/cpu/platform/HwlocCpuInfo.h" 34 | #elif defined(XMRIG_FEATURE_LIBCPUID) 35 | # include "backend/cpu/platform/AdvancedCpuInfo.h" 36 | #else 37 | # include "backend/cpu/platform/BasicCpuInfo.h" 38 | #endif 39 | 40 | 41 | static xmrig::ICpuInfo *cpuInfo = nullptr; 42 | 43 | 44 | xmrig::ICpuInfo *xmrig::Cpu::info() 45 | { 46 | if (cpuInfo == nullptr) { 47 | # if defined(XMRIG_FEATURE_HWLOC) 48 | cpuInfo = new HwlocCpuInfo(); 49 | # elif defined(XMRIG_FEATURE_LIBCPUID) 50 | cpuInfo = new AdvancedCpuInfo(); 51 | # else 52 | cpuInfo = new BasicCpuInfo(); 53 | # endif 54 | } 55 | 56 | return cpuInfo; 57 | } 58 | 59 | 60 | void xmrig::Cpu::release() 61 | { 62 | delete cpuInfo; 63 | cpuInfo = nullptr; 64 | } 65 | -------------------------------------------------------------------------------- /xmrig-override/backend/cpu/Cpu.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2020 SChernykh 9 | * Copyright 2016-2020 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #ifndef XMRIG_CPU_H 26 | #define XMRIG_CPU_H 27 | 28 | 29 | #include "backend/cpu/interfaces/ICpuInfo.h" 30 | 31 | 32 | namespace xmrig { 33 | 34 | 35 | class Cpu 36 | { 37 | public: 38 | static ICpuInfo *info(); 39 | static void release(); 40 | 41 | inline static Assembly::Id assembly(Assembly::Id hint) { return hint == Assembly::AUTO ? Cpu::info()->assembly() : hint; } 42 | }; 43 | 44 | 45 | } /* namespace xmrig */ 46 | 47 | 48 | #endif /* XMRIG_CPU_H */ 49 | -------------------------------------------------------------------------------- /xmrig-override/base/io/log/Log.h: -------------------------------------------------------------------------------- 1 | #define LOG_INFO(x, ...) 2 | -------------------------------------------------------------------------------- /xmrig-override/base/io/log/Tags.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoneroOcean/node-cryptonight-hashing/662bc36c461cbdf2418b657cd568f08830d4948c/xmrig-override/base/io/log/Tags.h -------------------------------------------------------------------------------- /xmrig-override/crypto/ghostrider/ghostrider.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2018-2021 SChernykh 3 | * Copyright 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_GR_HASH_H 20 | #define XMRIG_GR_HASH_H 21 | 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | 28 | struct cryptonight_ctx; 29 | 30 | 31 | namespace xmrig 32 | { 33 | 34 | 35 | namespace ghostrider 36 | { 37 | 38 | 39 | struct HelperThread; 40 | 41 | void benchmark(); 42 | HelperThread* create_helper_thread(int64_t cpu_index, const std::vector& affinities); 43 | void destroy_helper_thread(HelperThread* t); 44 | void hash(const uint8_t* data, size_t size, uint8_t* output, cryptonight_ctx** ctx, HelperThread* helper, bool verbose = true); 45 | 46 | 47 | } // namespace ghostrider 48 | 49 | 50 | } // namespace xmrig 51 | 52 | #endif // XMRIG_GR_HASH_H -------------------------------------------------------------------------------- /xmrig-override/crypto/kawpow/KPHash.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2019 XMR-Stak , 8 | * Copyright 2018 Lee Clagett 9 | * Copyright 2018-2019 tevador 10 | * Copyright 2018-2020 SChernykh 11 | * Copyright 2016-2019 XMRig , 12 | * 13 | * This program is free software: you can redistribute it and/or modify 14 | * it under the terms of the GNU General Public License as published by 15 | * the Free Software Foundation, either version 3 of the License, or 16 | * (at your option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | * GNU General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU General Public License 24 | * along with this program. If not, see . 25 | */ 26 | 27 | #ifndef XMRIG_KP_HASH_H 28 | #define XMRIG_KP_HASH_H 29 | 30 | 31 | #include 32 | 33 | 34 | namespace xmrig 35 | { 36 | 37 | class KPHash 38 | { 39 | public: 40 | static void verify(const uint32_t (&header_hash)[8], uint64_t nonce, const uint32_t (&mix_hash)[8], uint32_t (&output)[8]); 41 | }; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | 47 | #endif /* XMRIG_KP_HASH_H */ 48 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2019 SChernykh 9 | * Copyright 2016-2019 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | 26 | #ifndef XMRIG_3RDPARTY_ARGON2_H 27 | #define XMRIG_3RDPARTY_ARGON2_H 28 | 29 | 30 | #include "3rdparty/argon2/include/argon2.h" 31 | 32 | 33 | #endif /* XMRIG_3RDPARTY_ARGON2_H */ 34 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Ondrej Mosnáček 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/README.md: -------------------------------------------------------------------------------- 1 | # Argon2 [![Build Status](https://travis-ci.org/WOnder93/argon2.svg?branch=master)](https://travis-ci.org/WOnder93/argon2) 2 | A multi-arch library implementing the Argon2 password hashing algorithm. 3 | 4 | This project is based on the [original source code](https://github.com/P-H-C/phc-winner-argon2) by the Argon2 authors. The goal of this project is to provide efficient Argon2 implementations for various HW architectures (x86, SSE, ARM, PowerPC, ...). 5 | 6 | For the x86_64 architecture, the library implements a simple CPU dispatch which automatically selects the best implementation based on CPU flags and quick benchmarks. 7 | 8 | # Building 9 | ## Using GNU autotools 10 | 11 | To prepare the build environment, run: 12 | ```bash 13 | autoreconf -i 14 | ./configure 15 | ``` 16 | 17 | After that, just run `make` to build the library. 18 | 19 | ### Running tests 20 | After configuring the build environment, run `make check` to run the tests. 21 | 22 | ### Architecture options 23 | You can specify the target architecture by passing the `--host=...` flag to `./configure`. 24 | 25 | Supported architectures: 26 | * `x86_64` – 64-bit x86 architecture 27 | * `generic` – use generic C impementation 28 | 29 | ## Using CMake 30 | 31 | To prepare the build environment, run: 32 | ```bash 33 | cmake -DCMAKE_BUILD_TYPE=Release . 34 | ``` 35 | 36 | Then you can run `make` to build the library. 37 | 38 | ## Using QMake/Qt Creator 39 | A [QMake](http://doc.qt.io/qt-4.8/qmake-manual.html) project is also available in the `qmake` directory. You can open it in the [Qt Creator IDE](http://wiki.qt.io/Category:Tools::QtCreator) or build it from terminal: 40 | ```bash 41 | cd qmake 42 | # see table below for the list of possible ARCH and CONFIG values 43 | qmake ARCH=... CONFIG+=... 44 | make 45 | ``` 46 | 47 | ### Architecture options 48 | For QMake builds you can configure support for different architectures. Use the `ARCH` variable to choose the architecture and the `CONFIG` variable to set additional options. 49 | 50 | Supported architectures: 51 | * `x86_64` – 64-bit x86 architecture 52 | * QMake config flags: 53 | * `USE_SSE2` – use SSE2 instructions 54 | * `USE_SSSE3` – use SSSE3 instructions 55 | * `USE_XOP` – use XOP instructions 56 | * `USE_AVX2` – use AVX2 instructions 57 | * `USE_AVX512F` – use AVX-512F instructions 58 | * `generic` – use generic C impementation 59 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/generic/lib/argon2-arch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "impl-select.h" 6 | 7 | #define rotr64(x, n) (((x) >> (n)) | ((x) << (64 - (n)))) 8 | 9 | #include "argon2-template-64.h" 10 | 11 | void fill_segment_default(const argon2_instance_t *instance, 12 | argon2_position_t position) 13 | { 14 | fill_segment_64(instance, position); 15 | } 16 | 17 | void argon2_get_impl_list(argon2_impl_list *list) 18 | { 19 | list->count = 0; 20 | } 21 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/lib/argon2-arch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "impl-select.h" 6 | 7 | #include "argon2-sse2.h" 8 | #include "argon2-ssse3.h" 9 | #include "argon2-xop.h" 10 | #include "argon2-avx2.h" 11 | #include "argon2-avx512f.h" 12 | 13 | /* NOTE: there is no portable intrinsic for 64-bit rotate, but any 14 | * sane compiler should be able to compile this into a ROR instruction: */ 15 | #define rotr64(x, n) ((x) >> (n)) | ((x) << (64 - (n))) 16 | 17 | #include "argon2-template-64.h" 18 | 19 | void fill_segment_default(const argon2_instance_t *instance, 20 | argon2_position_t position) 21 | { 22 | fill_segment_64(instance, position); 23 | } 24 | 25 | void argon2_get_impl_list(argon2_impl_list *list) 26 | { 27 | static const argon2_impl IMPLS[] = { 28 | { "x86_64", NULL, fill_segment_default }, 29 | { "SSE2", xmrig_ar2_check_sse2, xmrig_ar2_fill_segment_sse2 }, 30 | { "SSSE3", xmrig_ar2_check_ssse3, xmrig_ar2_fill_segment_ssse3 }, 31 | { "XOP", xmrig_ar2_check_xop, xmrig_ar2_fill_segment_xop }, 32 | { "AVX2", xmrig_ar2_check_avx2, xmrig_ar2_fill_segment_avx2 }, 33 | { "AVX-512F", xmrig_ar2_check_avx512f, xmrig_ar2_fill_segment_avx512f }, 34 | }; 35 | 36 | list->count = sizeof(IMPLS) / sizeof(IMPLS[0]); 37 | list->entries = IMPLS; 38 | } 39 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/lib/argon2-avx2.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_AVX2_H 2 | #define ARGON2_AVX2_H 3 | 4 | #include "core.h" 5 | 6 | void xmrig_ar2_fill_segment_avx2(const argon2_instance_t *instance, argon2_position_t position); 7 | int xmrig_ar2_check_avx2(void); 8 | 9 | #endif // ARGON2_AVX2_H 10 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/lib/argon2-avx512f.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_AVX512F_H 2 | #define ARGON2_AVX512F_H 3 | 4 | #include "core.h" 5 | 6 | void xmrig_ar2_fill_segment_avx512f(const argon2_instance_t *instance, argon2_position_t position); 7 | int xmrig_ar2_check_avx512f(void); 8 | 9 | #endif // ARGON2_AVX512F_H 10 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/lib/argon2-sse2.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_SSE2_H 2 | #define ARGON2_SSE2_H 3 | 4 | #include "core.h" 5 | 6 | void xmrig_ar2_fill_segment_sse2(const argon2_instance_t *instance, argon2_position_t position); 7 | int xmrig_ar2_check_sse2(void); 8 | 9 | #endif // ARGON2_SSE2_H 10 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/lib/argon2-ssse3.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_SSSE3_H 2 | #define ARGON2_SSSE3_H 3 | 4 | #include "core.h" 5 | 6 | void xmrig_ar2_fill_segment_ssse3(const argon2_instance_t *instance, argon2_position_t position); 7 | int xmrig_ar2_check_ssse3(void); 8 | 9 | #endif // ARGON2_SSSE3_H 10 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/lib/argon2-xop.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_XOP_H 2 | #define ARGON2_XOP_H 3 | 4 | #include "core.h" 5 | 6 | void xmrig_ar2_fill_segment_xop(const argon2_instance_t *instance, argon2_position_t position); 7 | int xmrig_ar2_check_xop(void); 8 | 9 | #endif // ARGON2_XOP_H 10 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/src/test-feature-avx2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void function_avx2(__m256i *dst, const __m256i *a, const __m256i *b) 4 | { 5 | *dst = _mm256_xor_si256(*a, *b); 6 | } 7 | 8 | int main(void) { return 0; } 9 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/src/test-feature-avx512f.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void function_avx512f(__m512i *dst, const __m512i *a) 4 | { 5 | *dst = _mm512_ror_epi64(*a, 57); 6 | } 7 | 8 | int main(void) { return 0; } 9 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/src/test-feature-sse2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void function_sse2(__m128i *dst, const __m128i *a, const __m128i *b) 4 | { 5 | *dst = _mm_xor_si128(*a, *b); 6 | } 7 | 8 | int main(void) { return 0; } 9 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/src/test-feature-ssse3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void function_ssse3(__m128i *dst, const __m128i *a, const __m128i *b) 4 | { 5 | *dst = _mm_shuffle_epi8(*a, *b); 6 | } 7 | 8 | int main(void) { return 0; } 9 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/arch/x86_64/src/test-feature-xop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void function_xop(__m128i *dst, const __m128i *a, int b) 4 | { 5 | *dst = _mm_roti_epi64(*a, b); 6 | } 7 | 8 | int main(void) { return 0; } 9 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/lib/blake2/blake2.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_BLAKE2_H 2 | #define ARGON2_BLAKE2_H 3 | 4 | #include 5 | #include 6 | 7 | enum blake2b_constant { 8 | BLAKE2B_BLOCKBYTES = 128, 9 | BLAKE2B_OUTBYTES = 64, 10 | BLAKE2B_KEYBYTES = 64, 11 | BLAKE2B_SALTBYTES = 16, 12 | BLAKE2B_PERSONALBYTES = 16 13 | }; 14 | 15 | typedef struct __blake2b_state { 16 | uint64_t h[8]; 17 | uint64_t t[2]; 18 | uint8_t buf[BLAKE2B_BLOCKBYTES]; 19 | size_t buflen; 20 | } blake2b_state; 21 | 22 | /* Streaming API */ 23 | void xmrig_ar2_blake2b_init(blake2b_state *S, size_t outlen); 24 | void xmrig_ar2_blake2b_update(blake2b_state *S, const void *in, size_t inlen); 25 | void xmrig_ar2_blake2b_final(blake2b_state *S, void *out, size_t outlen); 26 | 27 | void xmrig_ar2_blake2b_long(void *out, size_t outlen, const void *in, size_t inlen); 28 | 29 | #endif // ARGON2_BLAKE2_H 30 | 31 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/lib/encoding.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODING_H 2 | #define ENCODING_H 3 | #include "3rdparty/argon2.h" 4 | 5 | #define ARGON2_MAX_DECODED_LANES UINT32_C(255) 6 | #define ARGON2_MIN_DECODED_SALT_LEN UINT32_C(8) 7 | #define ARGON2_MIN_DECODED_OUT_LEN UINT32_C(12) 8 | 9 | /* 10 | * encode an Argon2 hash string into the provided buffer. 'dst_len' 11 | * contains the size, in characters, of the 'dst' buffer; if 'dst_len' 12 | * is less than the number of required characters (including the 13 | * terminating 0), then this function returns ARGON2_ENCODING_ERROR. 14 | * 15 | * on success, ARGON2_OK is returned. 16 | */ 17 | int encode_string(char *dst, size_t dst_len, argon2_context *ctx, 18 | argon2_type type); 19 | 20 | /* 21 | * Decodes an Argon2 hash string into the provided structure 'ctx'. 22 | * The only fields that must be set prior to this call are ctx.saltlen and 23 | * ctx.outlen (which must be the maximal salt and out length values that are 24 | * allowed), ctx.salt and ctx.out (which must be buffers of the specified 25 | * length), and ctx.pwd and ctx.pwdlen which must hold a valid password. 26 | * 27 | * Invalid input string causes an error. On success, the ctx is valid and all 28 | * fields have been initialized. 29 | * 30 | * Returned value is ARGON2_OK on success, other ARGON2_ codes on error. 31 | */ 32 | int decode_string(argon2_context *ctx, const char *str, argon2_type type); 33 | 34 | /* Returns the length of the encoded byte stream with length len */ 35 | size_t b64len(uint32_t len); 36 | 37 | /* Returns the length of the encoded number num */ 38 | size_t numlen(uint32_t num); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/lib/genkat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Argon2 source code package 3 | * 4 | * Written by Daniel Dinu and Dmitry Khovratovich, 2015 5 | * 6 | * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. 7 | * 8 | * You should have received a copy of the CC0 Public Domain Dedication along 9 | * with 10 | * this software. If not, see 11 | * . 12 | */ 13 | 14 | #ifndef ARGON2_KAT_H 15 | #define ARGON2_KAT_H 16 | 17 | #include "core.h" 18 | 19 | /* 20 | * Initial KAT function that prints the inputs to the file 21 | * @param blockhash Array that contains pre-hashing digest 22 | * @param context Holds inputs 23 | * @param type Argon2 type 24 | * @pre blockhash must point to INPUT_INITIAL_HASH_LENGTH bytes 25 | * @pre context member pointers must point to allocated memory of size according 26 | * to the length values 27 | */ 28 | void initial_kat(const uint8_t *blockhash, const argon2_context *context, 29 | argon2_type type); 30 | 31 | /* 32 | * Function that prints the output tag 33 | * @param out output array pointer 34 | * @param outlen digest length 35 | * @pre out must point to @a outlen bytes 36 | **/ 37 | void print_tag(const void *out, uint32_t outlen); 38 | 39 | /* 40 | * Function that prints the internal state at given moment 41 | * @param instance pointer to the current instance 42 | * @param pass current pass number 43 | * @pre instance must have necessary memory allocated 44 | **/ 45 | void internal_kat(const argon2_instance_t *instance, uint32_t pass); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /xmrig/3rdparty/argon2/lib/impl-select.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGON2_IMPL_SELECT_H 2 | #define ARGON2_IMPL_SELECT_H 3 | 4 | #include "core.h" 5 | 6 | typedef struct Argon2_impl { 7 | const char *name; 8 | int (*check)(void); 9 | void (*fill_segment)(const argon2_instance_t *instance, 10 | argon2_position_t position); 11 | } argon2_impl; 12 | 13 | typedef struct Argon2_impl_list { 14 | const argon2_impl *entries; 15 | size_t count; 16 | } argon2_impl_list; 17 | 18 | void argon2_get_impl_list(argon2_impl_list *list); 19 | void fill_segment_default(const argon2_instance_t *instance, 20 | argon2_position_t position); 21 | 22 | #endif // ARGON2_IMPL_SELECT_H 23 | 24 | -------------------------------------------------------------------------------- /xmrig/3rdparty/libethash/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8.12) 2 | project (ethash C) 3 | 4 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os") 5 | 6 | set(HEADERS 7 | data_sizes.h 8 | endian.h 9 | ethash.h 10 | ethash_internal.h 11 | fnv.h 12 | ) 13 | 14 | set(SOURCES 15 | ethash_internal.c 16 | keccakf800.c 17 | ) 18 | 19 | include_directories(../..) 20 | 21 | add_library(ethash STATIC 22 | ${HEADERS} 23 | ${SOURCES} 24 | ) 25 | -------------------------------------------------------------------------------- /xmrig/3rdparty/libethash/fnv.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of cpp-ethereum. 3 | 4 | cpp-ethereum is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | cpp-ethereum is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with cpp-ethereum. If not, see . 16 | */ 17 | /** @file fnv.h 18 | * @author Matthew Wampler-Doty 19 | * @date 2015 20 | */ 21 | 22 | #pragma once 23 | #include 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #define FNV_PRIME 0x01000193 30 | 31 | /* The FNV-1 spec multiplies the prime with the input one byte (octet) in turn. 32 | We instead multiply it with the full 32-bit input. 33 | This gives a different result compared to a canonical FNV-1 implementation. 34 | */ 35 | static inline uint32_t fnv_hash(uint32_t const x, uint32_t const y) 36 | { 37 | return x * FNV_PRIME ^ y; 38 | } 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /xmrig/backend/common/interfaces/IMemoryPool.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2020 SChernykh 3 | * Copyright (c) 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_IMEMORYPOOL_H 20 | #define XMRIG_IMEMORYPOOL_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | 25 | 26 | #include 27 | #include 28 | 29 | 30 | namespace xmrig { 31 | 32 | 33 | class IMemoryPool 34 | { 35 | public: 36 | XMRIG_DISABLE_COPY_MOVE(IMemoryPool) 37 | 38 | IMemoryPool() = default; 39 | virtual ~IMemoryPool() = default; 40 | 41 | virtual bool isHugePages(uint32_t node) const = 0; 42 | virtual uint8_t *get(size_t size, uint32_t node) = 0; 43 | virtual void release(uint32_t node) = 0; 44 | }; 45 | 46 | 47 | } /* namespace xmrig */ 48 | 49 | 50 | 51 | #endif /* XMRIG_IMEMORYPOOL_H */ 52 | -------------------------------------------------------------------------------- /xmrig/base/crypto/keccak.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2011 Markku-Juhani O. Saarinen 4 | * Copyright 2012-2014 pooler 5 | * Copyright 2014 Lucas Jones 6 | * Copyright 2014-2016 Wolf9466 7 | * Copyright 2016 Jay D Dee 8 | * Copyright 2017-2018 XMR-Stak , 9 | * Copyright 2018-2020 SChernykh 10 | * Copyright 2016-2020 XMRig , 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation, either version 3 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program. If not, see . 24 | */ 25 | 26 | 27 | #ifndef XMRIG_KECCAK_H 28 | #define XMRIG_KECCAK_H 29 | 30 | #include 31 | #include 32 | 33 | 34 | namespace xmrig { 35 | 36 | // compute a keccak hash (md) of given byte length from "in" 37 | void keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen); 38 | 39 | 40 | inline void keccak(const uint8_t *in, size_t inlen, uint8_t *md) 41 | { 42 | keccak(in, static_cast(inlen), md, 200); 43 | } 44 | 45 | 46 | inline void keccak(const char *in, size_t inlen, uint8_t *md) 47 | { 48 | keccak(reinterpret_cast(in), static_cast(inlen), md, 200); 49 | } 50 | 51 | // update the state 52 | void keccakf(uint64_t st[25], int norounds); 53 | 54 | } /* namespace xmrig */ 55 | 56 | #endif /* XMRIG_KECCAK_H */ 57 | -------------------------------------------------------------------------------- /xmrig/base/tools/Chrono.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_CHRONO_H 20 | #define XMRIG_CHRONO_H 21 | 22 | 23 | #include 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class Chrono 30 | { 31 | public: 32 | static inline uint64_t highResolutionMSecs() 33 | { 34 | using namespace std::chrono; 35 | 36 | return static_cast(time_point_cast(high_resolution_clock::now()).time_since_epoch().count()); 37 | } 38 | 39 | 40 | static inline uint64_t steadyMSecs() 41 | { 42 | using namespace std::chrono; 43 | if (high_resolution_clock::is_steady) { 44 | return static_cast(time_point_cast(high_resolution_clock::now()).time_since_epoch().count()); 45 | } 46 | 47 | return static_cast(time_point_cast(steady_clock::now()).time_since_epoch().count()); 48 | } 49 | 50 | 51 | static inline uint64_t currentMSecsSinceEpoch() 52 | { 53 | using namespace std::chrono; 54 | 55 | return static_cast(time_point_cast(system_clock::now()).time_since_epoch().count()); 56 | } 57 | }; 58 | 59 | 60 | } /* namespace xmrig */ 61 | 62 | #endif /* XMRIG_CHRONO_H */ 63 | -------------------------------------------------------------------------------- /xmrig/base/tools/Object.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_OBJECT_H 20 | #define XMRIG_OBJECT_H 21 | 22 | 23 | #include 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | #define XMRIG_DISABLE_COPY_MOVE(X) \ 30 | X(const X &other) = delete; \ 31 | X(X &&other) = delete; \ 32 | X &operator=(const X &other) = delete; \ 33 | X &operator=(X &&other) = delete; 34 | 35 | 36 | #define XMRIG_DISABLE_COPY_MOVE_DEFAULT(X) \ 37 | X() = delete; \ 38 | X(const X &other) = delete; \ 39 | X(X &&other) = delete; \ 40 | X &operator=(const X &other) = delete; \ 41 | X &operator=(X &&other) = delete; 42 | 43 | 44 | } /* namespace xmrig */ 45 | 46 | #endif /* XMRIG_OBJECT_H */ 47 | -------------------------------------------------------------------------------- /xmrig/base/tools/bswap_64.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_BSWAP_64_H 20 | #define XMRIG_BSWAP_64_H 21 | 22 | #ifdef _MSC_VER 23 | 24 | #include 25 | #define bswap_64(x) _byteswap_uint64(x) 26 | #define bswap_32(x) _byteswap_ulong(x) 27 | 28 | #elif defined __GNUC__ 29 | 30 | #define bswap_64(x) __builtin_bswap64(x) 31 | #define bswap_32(x) __builtin_bswap32(x) 32 | 33 | #else 34 | 35 | #include 36 | 37 | #endif 38 | 39 | #endif /* XMRIG_BSWAP_64_H */ 40 | -------------------------------------------------------------------------------- /xmrig/crypto/argon2/Hash.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018-2020 SChernykh 9 | * Copyright 2016-2020 XMRig , 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #ifndef XMRIG_ARGON2_HASH_H 26 | #define XMRIG_ARGON2_HASH_H 27 | 28 | 29 | #include "3rdparty/argon2.h" 30 | #include "base/crypto/Algorithm.h" 31 | #include "crypto/cn/CryptoNight.h" 32 | 33 | 34 | namespace xmrig { namespace argon2 { 35 | 36 | 37 | template 38 | inline void single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t) 39 | { 40 | if (ALGO == Algorithm::AR2_CHUKWA) { 41 | argon2id_hash_raw_ex(3, 512, 1, input, size, input, 16, output, 32, ctx[0]->memory); 42 | } 43 | else if (ALGO == Algorithm::AR2_CHUKWA_V2) { 44 | argon2id_hash_raw_ex(4, 1024, 1, input, size, input, 16, output, 32, ctx[0]->memory); 45 | } 46 | else if (ALGO == Algorithm::AR2_WRKZ) { 47 | argon2id_hash_raw_ex(4, 256, 1, input, size, input, 16, output, 32, ctx[0]->memory); 48 | } 49 | } 50 | 51 | 52 | }} // namespace xmrig::argon2 53 | 54 | 55 | #endif /* XMRIG_ARGON2_HASH_H */ 56 | -------------------------------------------------------------------------------- /xmrig/crypto/astrobwt/AstroBWT.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018 Lee Clagett 3 | * Copyright (c) 2018-2019 tevador 4 | * Copyright (c) 2000 Transmeta Corporation 5 | * Copyright (c) 2004-2008 H. Peter Anvin 6 | * Copyright (c) 2018-2021 SChernykh 7 | * Copyright (c) 2016-2021 XMRig , 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | #include "base/crypto/Algorithm.h" 24 | 25 | 26 | struct cryptonight_ctx; 27 | 28 | 29 | namespace xmrig { 30 | 31 | 32 | namespace astrobwt { 33 | 34 | bool astrobwt_dero(const void* input_data, uint32_t input_size, void* scratchpad, uint8_t* output_hash, int stage2_max_size, bool avx2); 35 | bool astrobwt_dero_v2(const void* input_data, uint32_t input_size, void* scratchpad, uint8_t* output_hash); 36 | void init(); 37 | 38 | template 39 | void single_hash(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx** ctx, uint64_t); 40 | 41 | template<> 42 | void single_hash(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx** ctx, uint64_t); 43 | 44 | template<> 45 | void single_hash(const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx** ctx, uint64_t); 46 | 47 | }} // namespace xmrig::astrobwt 48 | -------------------------------------------------------------------------------- /xmrig/crypto/astrobwt/Salsa20.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on public domain code available at: http://cr.yp.to/snuffle.html 3 | * 4 | * This therefore is public domain. 5 | */ 6 | 7 | #ifndef ZT_SALSA20_HPP 8 | #define ZT_SALSA20_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #if defined(XMRIG_ARM) 15 | # include "crypto/cn/sse2neon.h" 16 | #else 17 | # include 18 | #endif 19 | 20 | namespace ZeroTier { 21 | 22 | /** 23 | * Salsa20 stream cipher 24 | */ 25 | class Salsa20 26 | { 27 | public: 28 | /** 29 | * @param key 256-bit (32 byte) key 30 | * @param iv 64-bit initialization vector 31 | */ 32 | Salsa20(const void *key,const void *iv) 33 | { 34 | init(key,iv); 35 | } 36 | 37 | /** 38 | * Initialize cipher 39 | * 40 | * @param key Key bits 41 | * @param iv 64-bit initialization vector 42 | */ 43 | void init(const void *key,const void *iv); 44 | 45 | void XORKeyStream(void *out,unsigned int bytes); 46 | 47 | private: 48 | union { 49 | __m128i v[4]; 50 | uint32_t i[16]; 51 | } _state; 52 | }; 53 | 54 | } // namespace ZeroTier 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /xmrig/crypto/astrobwt/salsa20_ref/ecrypt-machine.h: -------------------------------------------------------------------------------- 1 | /* ecrypt-machine.h */ 2 | 3 | /* 4 | * This file is included by 'ecrypt-portable.h'. It allows to override 5 | * the default macros for specific platforms. Please carefully check 6 | * the machine code generated by your compiler (with optimisations 7 | * turned on) before deciding to edit this file. 8 | */ 9 | 10 | /* ------------------------------------------------------------------------- */ 11 | 12 | #if (defined(ECRYPT_DEFAULT_ROT) && !defined(ECRYPT_MACHINE_ROT)) 13 | 14 | #define ECRYPT_MACHINE_ROT 15 | 16 | #if (defined(WIN32) && defined(_MSC_VER)) 17 | 18 | #undef ROTL32 19 | #undef ROTR32 20 | #undef ROTL64 21 | #undef ROTR64 22 | 23 | #include 24 | 25 | #define ROTL32(v, n) _lrotl(v, n) 26 | #define ROTR32(v, n) _lrotr(v, n) 27 | #define ROTL64(v, n) _rotl64(v, n) 28 | #define ROTR64(v, n) _rotr64(v, n) 29 | 30 | #endif 31 | 32 | #endif 33 | 34 | /* ------------------------------------------------------------------------- */ 35 | 36 | #if (defined(ECRYPT_DEFAULT_SWAP) && !defined(ECRYPT_MACHINE_SWAP)) 37 | 38 | #define ECRYPT_MACHINE_SWAP 39 | 40 | /* 41 | * If you want to overwrite the default swap macros, put it here. And so on. 42 | */ 43 | 44 | #endif 45 | 46 | /* ------------------------------------------------------------------------- */ 47 | -------------------------------------------------------------------------------- /xmrig/crypto/astrobwt/sha3_256_avx2.S: -------------------------------------------------------------------------------- 1 | ;# XMRig 2 | ;# Copyright 2010 Jeff Garzik 3 | ;# Copyright 2012-2014 pooler 4 | ;# Copyright 2014 Lucas Jones 5 | ;# Copyright 2014-2016 Wolf9466 6 | ;# Copyright 2016 Jay D Dee 7 | ;# Copyright 2017-2019 XMR-Stak , 8 | ;# Copyright 2018 Lee Clagett 9 | ;# Copyright 2018-2019 tevador 10 | ;# Copyright 2000 Transmeta Corporation 11 | ;# Copyright 2004-2008 H. Peter Anvin 12 | ;# Copyright 2018-2020 SChernykh 13 | ;# Copyright 2016-2020 XMRig , 14 | ;# 15 | ;# This program is free software: you can redistribute it and/or modify 16 | ;# it under the terms of the GNU General Public License as published by 17 | ;# the Free Software Foundation, either version 3 of the License, or 18 | ;# (at your option) any later version. 19 | ;# 20 | ;# This program is distributed in the hope that it will be useful, 21 | ;# but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | ;# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | ;# GNU General Public License for more details. 24 | ;# 25 | ;# You should have received a copy of the GNU General Public License 26 | ;# along with this program. If not, see . 27 | ;# 28 | 29 | .intel_syntax noprefix 30 | #if defined(__APPLE__) 31 | .text 32 | #define DECL(x) _##x 33 | #else 34 | .section .text 35 | #define DECL(x) x 36 | #endif 37 | 38 | #define ALIGN .balign 39 | #define dq .quad 40 | 41 | .global DECL(SHA3_256_AVX2_ASM) 42 | 43 | ALIGN 64 44 | DECL(SHA3_256_AVX2_ASM): 45 | 46 | #include "sha3_256_avx2.inc" 47 | 48 | KeccakF1600_AVX2_ASM: 49 | lea r8,[rip+rot_left+96] 50 | lea r9,[rip+rot_right+96] 51 | lea r10,[rip+rndc] 52 | 53 | #include "sha3_256_keccakf1600_avx2.inc" 54 | 55 | #if defined(__linux__) && defined(__ELF__) 56 | .section .note.GNU-stack,"",%progbits 57 | #endif 58 | -------------------------------------------------------------------------------- /xmrig/crypto/astrobwt/sha3_256_avx2.asm: -------------------------------------------------------------------------------- 1 | ;# XMRig 2 | ;# Copyright 2010 Jeff Garzik 3 | ;# Copyright 2012-2014 pooler 4 | ;# Copyright 2014 Lucas Jones 5 | ;# Copyright 2014-2016 Wolf9466 6 | ;# Copyright 2016 Jay D Dee 7 | ;# Copyright 2017-2019 XMR-Stak , 8 | ;# Copyright 2018 Lee Clagett 9 | ;# Copyright 2018-2019 tevador 10 | ;# Copyright 2000 Transmeta Corporation 11 | ;# Copyright 2004-2008 H. Peter Anvin 12 | ;# Copyright 2018-2020 SChernykh 13 | ;# Copyright 2016-2020 XMRig , 14 | ;# 15 | ;# This program is free software: you can redistribute it and/or modify 16 | ;# it under the terms of the GNU General Public License as published by 17 | ;# the Free Software Foundation, either version 3 of the License, or 18 | ;# (at your option) any later version. 19 | ;# 20 | ;# This program is distributed in the hope that it will be useful, 21 | ;# but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | ;# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | ;# GNU General Public License for more details. 24 | ;# 25 | ;# You should have received a copy of the GNU General Public License 26 | ;# along with this program. If not, see . 27 | ;# 28 | 29 | _SHA3_256_AVX2_ASM SEGMENT PAGE READ EXECUTE 30 | PUBLIC SHA3_256_AVX2_ASM 31 | 32 | ALIGN 64 33 | SHA3_256_AVX2_ASM: 34 | 35 | include sha3_256_avx2.inc 36 | 37 | KeccakF1600_AVX2_ASM: 38 | lea r8,[rot_left+96] 39 | lea r9,[rot_right+96] 40 | lea r10,[rndc] 41 | 42 | include sha3_256_keccakf1600_avx2.inc 43 | 44 | _SHA3_256_AVX2_ASM ENDS 45 | END 46 | -------------------------------------------------------------------------------- /xmrig/crypto/astrobwt/sort_indices2.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018 Lee Clagett 3 | * Copyright (c) 2018-2019 tevador 4 | * Copyright (c) 2000 Transmeta Corporation 5 | * Copyright (c) 2004-2008 H. Peter Anvin 6 | * Copyright (c) 2018-2021 SChernykh 7 | * Copyright (c) 2016-2021 XMRig , 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | #include 24 | 25 | 26 | void sort_indices_astrobwt_v2(uint32_t N, const uint8_t* v, uint32_t* indices, uint32_t* tmp_indices); 27 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/CnCtx.cpp: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018 Lee Clagett 3 | * Copyright (c) 2018-2020 SChernykh 4 | * Copyright (c) 2016-2020 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #include 21 | 22 | 23 | #include "crypto/cn/CnCtx.h" 24 | #include "base/crypto/Algorithm.h" 25 | #include "crypto/cn/CryptoNight.h" 26 | #include "crypto/common/portable/mm_malloc.h" 27 | #include "crypto/common/VirtualMemory.h" 28 | 29 | 30 | void xmrig::CnCtx::create(cryptonight_ctx **ctx, uint8_t *memory, size_t size, size_t count) 31 | { 32 | for (size_t i = 0; i < count; ++i) { 33 | auto *c = static_cast(_mm_malloc(sizeof(cryptonight_ctx), 4096)); 34 | c->memory = memory + (i * size); 35 | 36 | c->generated_code = reinterpret_cast(VirtualMemory::allocateExecutableMemory(0x4000, false)); 37 | c->generated_code_data.algo = Algorithm::INVALID; 38 | c->generated_code_data.height = std::numeric_limits::max(); 39 | 40 | ctx[i] = c; 41 | } 42 | } 43 | 44 | 45 | void xmrig::CnCtx::release(cryptonight_ctx **ctx, size_t count) 46 | { 47 | if (ctx[0] == nullptr) { 48 | return; 49 | } 50 | 51 | for (size_t i = 0; i < count; ++i) { 52 | _mm_free(ctx[i]); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/CnCtx.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018 Lee Clagett 3 | * Copyright (c) 2018-2020 SChernykh 4 | * Copyright (c) 2016-2020 XMRig , 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | 20 | #ifndef XMRIG_CN_CTX_H 21 | #define XMRIG_CN_CTX_H 22 | 23 | 24 | #include 25 | #include 26 | 27 | 28 | struct cryptonight_ctx; 29 | 30 | 31 | namespace xmrig 32 | { 33 | 34 | 35 | class CnCtx 36 | { 37 | public: 38 | static void create(cryptonight_ctx **ctx, uint8_t *memory, size_t size, size_t count); 39 | static void release(cryptonight_ctx **ctx, size_t count); 40 | }; 41 | 42 | 43 | } /* namespace xmrig */ 44 | 45 | 46 | #endif /* XMRIG_CN_CTX_H */ 47 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/CryptoNight_x86_vaes.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2019 XMR-Stak , 8 | * Copyright 2018 Lee Clagett 9 | * Copyright 2018-2020 SChernykh 10 | * Copyright 2016-2020 XMRig , 11 | * 12 | * This program is free software: you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation, either version 3 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program. If not, see . 24 | */ 25 | 26 | #ifndef XMRIG_CRYPTONIGHT_X86_VAES_H 27 | #define XMRIG_CRYPTONIGHT_X86_VAES_H 28 | 29 | 30 | #include "crypto/cn/CnAlgo.h" 31 | 32 | 33 | struct cryptonight_ctx; 34 | 35 | 36 | namespace xmrig { 37 | 38 | 39 | void cn_explode_scratchpad_vaes(cryptonight_ctx* ctx, size_t memory, bool half_mem); 40 | void cn_explode_scratchpad_vaes_double(cryptonight_ctx* ctx1, cryptonight_ctx* ctx2, size_t memory, bool half_mem); 41 | void cn_implode_scratchpad_vaes(cryptonight_ctx* ctx, size_t memory, bool half_mem); 42 | void cn_implode_scratchpad_vaes_double(cryptonight_ctx* ctx1, cryptonight_ctx* ctx2, size_t memory, bool half_mem); 43 | 44 | 45 | } // xmrig 46 | 47 | 48 | #endif /* XMRIG_CRYPTONIGHT_X86_VAES_H */ 49 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/asm/cn1/cnv1_single_main_loop.inc: -------------------------------------------------------------------------------- 1 | mov QWORD PTR [rsp+8], rbx 2 | mov QWORD PTR [rsp+16], rbp 3 | mov QWORD PTR [rsp+24], rsi 4 | mov QWORD PTR [rsp+32], rdi 5 | push r13 6 | push r14 7 | push r15 8 | mov rdx, QWORD PTR [rcx] 9 | mov esi, 524288 10 | mov r11, QWORD PTR [rdx+32] 11 | xor r11, QWORD PTR [rdx] 12 | mov rdi, QWORD PTR [rdx+224] 13 | mov rbx, QWORD PTR [rdx+40] 14 | xor rbx, QWORD PTR [rdx+8] 15 | mov rcx, QWORD PTR [rdx+56] 16 | xor rcx, QWORD PTR [rdx+24] 17 | mov rax, QWORD PTR [rdx+48] 18 | xor rax, QWORD PTR [rdx+16] 19 | mov rbp, QWORD PTR [rdx+240] 20 | mov r14, QWORD PTR [rdx+232] 21 | movq xmm2, rax 22 | pinsrq xmm2, rcx, 1 23 | 24 | ALIGN(64) 25 | main_loop_cnv1_single: 26 | mov r8, r11 27 | and r8d, 2097136 28 | movdqu xmm1, XMMWORD PTR [rdi+r8] 29 | movq xmm0, r11 30 | pinsrq xmm0, rbx, 1 31 | aesenc xmm1, xmm0 32 | movq r15, xmm1 33 | mov r9, r15 34 | and r9d, 2097136 35 | movdqa xmm0, xmm1 36 | pxor xmm0, xmm2 37 | movdqa xmm2, xmm1 38 | movq QWORD PTR [rdi+r8], xmm0 39 | pextrq rdx, xmm0, 1 40 | mov eax, edx 41 | shr rax, 24 42 | mov ecx, DWORD PTR [r14+rax*4] 43 | xor rcx, rdx 44 | mov QWORD PTR [rdi+r8+8], rcx 45 | mov r10, QWORD PTR [rdi+r9] 46 | mov r8, QWORD PTR [rdi+r9+8] 47 | mov rax, r10 48 | mul r15 49 | add rbx, rax 50 | add r11, rdx 51 | mov QWORD PTR [rdi+r9], r11 52 | mov rax, rbx 53 | xor rbx, r8 54 | xor r11, r10 55 | xor rax, rbp 56 | mov QWORD PTR [rdi+r9+8], rax 57 | sub rsi, 1 58 | jne main_loop_cnv1_single 59 | 60 | pop r15 61 | pop r14 62 | pop r13 63 | mov rbx, QWORD PTR [rsp+8] 64 | mov rbp, QWORD PTR [rsp+16] 65 | mov rsi, QWORD PTR [rsp+24] 66 | mov rdi, QWORD PTR [rsp+32] 67 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/asm/cn_main_loop.asm: -------------------------------------------------------------------------------- 1 | _TEXT_CNV2_MAINLOOP SEGMENT PAGE READ EXECUTE 2 | PUBLIC cnv1_single_mainloop_asm 3 | PUBLIC cnv1_double_mainloop_asm 4 | PUBLIC cnv1_quad_mainloop_asm 5 | PUBLIC cnv2_mainloop_ivybridge_asm 6 | PUBLIC cnv2_mainloop_ryzen_asm 7 | PUBLIC cnv2_mainloop_bulldozer_asm 8 | PUBLIC cnv2_double_mainloop_sandybridge_asm 9 | PUBLIC cnv2_rwz_mainloop_asm 10 | PUBLIC cnv2_rwz_double_mainloop_asm 11 | 12 | ALIGN(64) 13 | cnv1_single_mainloop_asm PROC 14 | INCLUDE cn1/cnv1_single_main_loop.inc 15 | ret 0 16 | mov eax, 3735929054 17 | cnv1_single_mainloop_asm ENDP 18 | 19 | ALIGN(64) 20 | cnv1_double_mainloop_asm PROC 21 | INCLUDE cn1/cnv1_double_main_loop.inc 22 | ret 0 23 | mov eax, 3735929054 24 | cnv1_double_mainloop_asm ENDP 25 | 26 | ALIGN(64) 27 | cnv1_quad_mainloop_asm PROC 28 | INCLUDE cn1/cnv1_quad_main_loop.inc 29 | ret 0 30 | mov eax, 3735929054 31 | cnv1_quad_mainloop_asm ENDP 32 | 33 | ALIGN(64) 34 | cnv2_mainloop_ivybridge_asm PROC 35 | INCLUDE cn2/cnv2_main_loop_ivybridge.inc 36 | ret 0 37 | mov eax, 3735929054 38 | cnv2_mainloop_ivybridge_asm ENDP 39 | 40 | ALIGN(64) 41 | cnv2_mainloop_ryzen_asm PROC 42 | INCLUDE cn2/cnv2_main_loop_ryzen.inc 43 | ret 0 44 | mov eax, 3735929054 45 | cnv2_mainloop_ryzen_asm ENDP 46 | 47 | ALIGN(64) 48 | cnv2_mainloop_bulldozer_asm PROC 49 | INCLUDE cn2/cnv2_main_loop_bulldozer.inc 50 | ret 0 51 | mov eax, 3735929054 52 | cnv2_mainloop_bulldozer_asm ENDP 53 | 54 | ALIGN(64) 55 | cnv2_double_mainloop_sandybridge_asm PROC 56 | INCLUDE cn2/cnv2_double_main_loop_sandybridge.inc 57 | ret 0 58 | mov eax, 3735929054 59 | cnv2_double_mainloop_sandybridge_asm ENDP 60 | 61 | ALIGN(64) 62 | cnv2_rwz_mainloop_asm PROC 63 | INCLUDE cn2/cnv2_rwz_main_loop.inc 64 | ret 0 65 | mov eax, 3735929054 66 | cnv2_rwz_mainloop_asm ENDP 67 | 68 | ALIGN(64) 69 | cnv2_rwz_double_mainloop_asm PROC 70 | INCLUDE cn2/cnv2_rwz_double_main_loop.inc 71 | ret 0 72 | mov eax, 3735929054 73 | cnv2_rwz_double_mainloop_asm ENDP 74 | 75 | ALIGN(64) 76 | cnv2_upx_double_mainloop_zen3_asm PROC 77 | INCLUDE cn2/cnv2_upx_double_mainloop_zen3.inc 78 | ret 0 79 | mov eax, 3735929054 80 | cnv2_upx_double_mainloop_zen3_asm ENDP 81 | 82 | _TEXT_CNV2_MAINLOOP ENDS 83 | END 84 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/asm/win64/cn_main_loop.S: -------------------------------------------------------------------------------- 1 | #define ALIGN(x) .align 64 2 | .intel_syntax noprefix 3 | .section .text 4 | .global cnv1_single_mainloop_asm 5 | .global cnv1_double_mainloop_asm 6 | .global cnv1_quad_mainloop_asm 7 | .global cnv2_mainloop_ivybridge_asm 8 | .global cnv2_mainloop_ryzen_asm 9 | .global cnv2_mainloop_bulldozer_asm 10 | .global cnv2_double_mainloop_sandybridge_asm 11 | .global cnv2_rwz_mainloop_asm 12 | .global cnv2_rwz_double_mainloop_asm 13 | .global cnv2_upx_double_mainloop_zen3_asm 14 | 15 | ALIGN(64) 16 | cnv1_single_mainloop_asm: 17 | #include "../cn1/cnv1_single_main_loop.inc" 18 | ret 0 19 | mov eax, 3735929054 20 | 21 | ALIGN(64) 22 | cnv1_double_mainloop_asm: 23 | #include "../cn1/cnv1_double_main_loop.inc" 24 | ret 0 25 | mov eax, 3735929054 26 | 27 | ALIGN(64) 28 | cnv1_quad_mainloop_asm: 29 | #include "../cn1/cnv1_quad_main_loop.inc" 30 | ret 0 31 | mov eax, 3735929054 32 | 33 | ALIGN(64) 34 | cnv2_mainloop_ivybridge_asm: 35 | #include "../cn2/cnv2_main_loop_ivybridge.inc" 36 | ret 0 37 | mov eax, 3735929054 38 | 39 | ALIGN(64) 40 | cnv2_mainloop_ryzen_asm: 41 | #include "../cn2/cnv2_main_loop_ryzen.inc" 42 | ret 0 43 | mov eax, 3735929054 44 | 45 | ALIGN(64) 46 | cnv2_mainloop_bulldozer_asm: 47 | #include "../cn2/cnv2_main_loop_bulldozer.inc" 48 | ret 0 49 | mov eax, 3735929054 50 | 51 | ALIGN(64) 52 | cnv2_double_mainloop_sandybridge_asm: 53 | #include "../cn2/cnv2_double_main_loop_sandybridge.inc" 54 | ret 0 55 | mov eax, 3735929054 56 | 57 | ALIGN(64) 58 | cnv2_rwz_mainloop_asm: 59 | #include "cn2/cnv2_rwz_main_loop.inc" 60 | ret 0 61 | mov eax, 3735929054 62 | 63 | ALIGN(64) 64 | cnv2_rwz_double_mainloop_asm: 65 | #include "cn2/cnv2_rwz_double_main_loop.inc" 66 | ret 0 67 | mov eax, 3735929054 68 | 69 | ALIGN(64) 70 | cnv2_upx_double_mainloop_zen3_asm: 71 | #include "cn2/cnv2_upx_double_mainloop_zen3.inc" 72 | ret 0 73 | mov eax, 3735929054 74 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/asm/win64/cn_main_loop.asm: -------------------------------------------------------------------------------- 1 | _TEXT_CNV2_MAINLOOP SEGMENT PAGE READ EXECUTE 2 | PUBLIC cnv1_single_mainloop_asm 3 | PUBLIC cnv1_double_mainloop_asm 4 | PUBLIC cnv1_quad_mainloop_asm 5 | PUBLIC cnv2_mainloop_ivybridge_asm 6 | PUBLIC cnv2_mainloop_ryzen_asm 7 | PUBLIC cnv2_mainloop_bulldozer_asm 8 | PUBLIC cnv2_double_mainloop_sandybridge_asm 9 | PUBLIC cnv2_rwz_mainloop_asm 10 | PUBLIC cnv2_rwz_double_mainloop_asm 11 | 12 | ALIGN(64) 13 | cnv1_single_mainloop_asm PROC 14 | INCLUDE cn1/cnv1_single_main_loop.inc 15 | ret 0 16 | mov eax, 3735929054 17 | cnv1_single_mainloop_asm ENDP 18 | 19 | ALIGN(64) 20 | cnv1_double_mainloop_asm PROC 21 | INCLUDE cn1/cnv1_double_main_loop.inc 22 | ret 0 23 | mov eax, 3735929054 24 | cnv1_double_mainloop_asm ENDP 25 | 26 | ALIGN(64) 27 | cnv1_quad_mainloop_asm PROC 28 | INCLUDE cn1/cnv1_quad_main_loop.inc 29 | ret 0 30 | mov eax, 3735929054 31 | cnv1_quad_mainloop_asm ENDP 32 | 33 | ALIGN(64) 34 | cnv2_mainloop_ivybridge_asm PROC 35 | INCLUDE cn2/cnv2_main_loop_ivybridge.inc 36 | ret 0 37 | mov eax, 3735929054 38 | cnv2_mainloop_ivybridge_asm ENDP 39 | 40 | ALIGN(64) 41 | cnv2_mainloop_ryzen_asm PROC 42 | INCLUDE cn2/cnv2_main_loop_ryzen.inc 43 | ret 0 44 | mov eax, 3735929054 45 | cnv2_mainloop_ryzen_asm ENDP 46 | 47 | ALIGN(64) 48 | cnv2_mainloop_bulldozer_asm PROC 49 | INCLUDE cn2/cnv2_main_loop_bulldozer.inc 50 | ret 0 51 | mov eax, 3735929054 52 | cnv2_mainloop_bulldozer_asm ENDP 53 | 54 | ALIGN(64) 55 | cnv2_double_mainloop_sandybridge_asm PROC 56 | INCLUDE cn2/cnv2_double_main_loop_sandybridge.inc 57 | ret 0 58 | mov eax, 3735929054 59 | cnv2_double_mainloop_sandybridge_asm ENDP 60 | 61 | ALIGN(64) 62 | cnv2_rwz_mainloop_asm PROC 63 | INCLUDE cn2/cnv2_rwz_main_loop.inc 64 | ret 0 65 | mov eax, 3735929054 66 | cnv2_rwz_mainloop_asm ENDP 67 | 68 | ALIGN(64) 69 | cnv2_rwz_double_mainloop_asm PROC 70 | INCLUDE cn2/cnv2_rwz_double_main_loop.inc 71 | ret 0 72 | mov eax, 3735929054 73 | cnv2_rwz_double_mainloop_asm ENDP 74 | 75 | ALIGN(64) 76 | cnv2_upx_double_mainloop_zen3_asm PROC 77 | INCLUDE cn2/cnv2_upx_double_mainloop_zen3.inc 78 | ret 0 79 | mov eax, 3735929054 80 | cnv2_upx_double_mainloop_zen3_asm ENDP 81 | 82 | _TEXT_CNV2_MAINLOOP ENDS 83 | END 84 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/c_blake256.h: -------------------------------------------------------------------------------- 1 | #ifndef _BLAKE256_H_ 2 | #define _BLAKE256_H_ 3 | 4 | #include 5 | 6 | typedef struct { 7 | uint32_t h[8], s[4], t[2]; 8 | int buflen, nullt; 9 | uint8_t buf[64]; 10 | } state; 11 | 12 | typedef struct { 13 | state inner; 14 | state outer; 15 | } hmac_state; 16 | 17 | void blake256_init(state *); 18 | void blake224_init(state *); 19 | 20 | void blake256_update(state *, const uint8_t *, uint64_t); 21 | void blake224_update(state *, const uint8_t *, uint64_t); 22 | 23 | void blake256_final(state *, uint8_t *); 24 | void blake224_final(state *, uint8_t *); 25 | 26 | void blake256_hash(uint8_t *, const uint8_t *, uint64_t); 27 | void blake224_hash(uint8_t *, const uint8_t *, uint64_t); 28 | 29 | /* HMAC functions: */ 30 | 31 | void hmac_blake256_init(hmac_state *, const uint8_t *, uint64_t); 32 | void hmac_blake224_init(hmac_state *, const uint8_t *, uint64_t); 33 | 34 | void hmac_blake256_update(hmac_state *, const uint8_t *, uint64_t); 35 | void hmac_blake224_update(hmac_state *, const uint8_t *, uint64_t); 36 | 37 | void hmac_blake256_final(hmac_state *, uint8_t *); 38 | void hmac_blake224_final(hmac_state *, uint8_t *); 39 | 40 | void hmac_blake256_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); 41 | void hmac_blake224_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); 42 | 43 | #endif /* _BLAKE256_H_ */ 44 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/c_groestl.h: -------------------------------------------------------------------------------- 1 | #ifndef __hash_h 2 | #define __hash_h 3 | /* 4 | #include "crypto_uint8.h" 5 | #include "crypto_uint32.h" 6 | #include "crypto_uint64.h" 7 | #include "crypto_hash.h" 8 | 9 | typedef crypto_uint8 uint8_t; 10 | typedef crypto_uint32 uint32_t; 11 | typedef crypto_uint64 uint64_t; 12 | */ 13 | #include 14 | 15 | #include "hash.h" 16 | 17 | /* some sizes (number of bytes) */ 18 | #define ROWS 8 19 | #define LENGTHFIELDLEN ROWS 20 | #define COLS512 8 21 | 22 | #define SIZE512 (ROWS*COLS512) 23 | 24 | #define ROUNDS512 10 25 | #define HASH_BIT_LEN 256 26 | 27 | #define ROTL32(v, n) ((((v)<<(n))|((v)>>(32-(n))))&li_32(ffffffff)) 28 | 29 | 30 | #define li_32(h) 0x##h##u 31 | #define EXT_BYTE(var,n) ((uint8_t)((uint32_t)(var) >> (8*n))) 32 | #define u32BIG(a) \ 33 | ((ROTL32(a,8) & li_32(00FF00FF)) | \ 34 | (ROTL32(a,24) & li_32(FF00FF00))) 35 | 36 | 37 | /* NIST API begin */ 38 | typedef struct { 39 | uint32_t chaining[SIZE512/sizeof(uint32_t)]; /* actual state */ 40 | uint32_t block_counter1, 41 | block_counter2; /* message block counter(s) */ 42 | BitSequence buffer[SIZE512]; /* data buffer */ 43 | int buf_ptr; /* data buffer pointer */ 44 | int bits_in_last_byte; /* no. of message bits in last byte of 45 | data buffer */ 46 | } groestlHashState; 47 | 48 | /*void Init(hashState*); 49 | void Update(hashState*, const BitSequence*, DataLength); 50 | void Final(hashState*, BitSequence*); */ 51 | void groestl(const BitSequence*, DataLength, BitSequence*); 52 | /* NIST API end */ 53 | 54 | /* 55 | int crypto_hash(unsigned char *out, 56 | const unsigned char *in, 57 | unsigned long long len); 58 | */ 59 | 60 | #endif /* __hash_h */ 61 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/c_jh.h: -------------------------------------------------------------------------------- 1 | /*This program gives the 64-bit optimized bitslice implementation of JH using ANSI C 2 | 3 | -------------------------------- 4 | Performance 5 | 6 | Microprocessor: Intel CORE 2 processor (Core 2 Duo Mobile T6600 2.2GHz) 7 | Operating System: 64-bit Ubuntu 10.04 (Linux kernel 2.6.32-22-generic) 8 | Speed for long message: 9 | 1) 45.8 cycles/byte compiler: Intel C++ Compiler 11.1 compilation option: icc -O2 10 | 2) 56.8 cycles/byte compiler: gcc 4.4.3 compilation option: gcc -O3 11 | 12 | -------------------------------- 13 | Last Modified: January 16, 2011 14 | */ 15 | #pragma once 16 | 17 | #include "hash.h" 18 | 19 | HashReturn jh_hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval); 20 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/c_skein.h: -------------------------------------------------------------------------------- 1 | #ifndef _SKEIN_H_ 2 | #define _SKEIN_H_ 1 3 | /************************************************************************** 4 | ** 5 | ** Interface declarations and internal definitions for Skein hashing. 6 | ** 7 | ** Source code author: Doug Whiting, 2008. 8 | ** 9 | ** This algorithm and source code is released to the public domain. 10 | ** 11 | *************************************************************************** 12 | ** 13 | ** The following compile-time switches may be defined to control some 14 | ** tradeoffs between speed, code size, error checking, and security. 15 | ** 16 | ** The "default" note explains what happens when the switch is not defined. 17 | ** 18 | ** SKEIN_DEBUG -- make callouts from inside Skein code 19 | ** to examine/display intermediate values. 20 | ** [default: no callouts (no overhead)] 21 | ** 22 | ** SKEIN_ERR_CHECK -- how error checking is handled inside Skein 23 | ** code. If not defined, most error checking 24 | ** is disabled (for performance). Otherwise, 25 | ** the switch value is interpreted as: 26 | ** 0: use assert() to flag errors 27 | ** 1: return SKEIN_FAIL to flag errors 28 | ** 29 | ***************************************************************************/ 30 | #include "skein_port.h" /* get platform-specific definitions */ 31 | 32 | typedef enum 33 | { 34 | SKEIN_SUCCESS = 0, /* return codes from Skein calls */ 35 | SKEIN_FAIL = 1, 36 | SKEIN_BAD_HASHLEN = 2 37 | } 38 | SkeinHashReturn; 39 | 40 | typedef size_t SkeinDataLength; /* bit count type */ 41 | typedef u08b_t SkeinBitSequence; /* bit stream type */ 42 | 43 | /* "all-in-one" call */ 44 | SkeinHashReturn skein_hash(int hashbitlen, const SkeinBitSequence *data, 45 | SkeinDataLength databitlen, SkeinBitSequence *hashval); 46 | 47 | void xmr_skein(const SkeinBitSequence *data, SkeinBitSequence *hashval); 48 | 49 | #endif /* ifndef _SKEIN_H_ */ 50 | -------------------------------------------------------------------------------- /xmrig/crypto/cn/hash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef unsigned char BitSequence; 4 | typedef unsigned long long DataLength; 5 | typedef enum {SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2} HashReturn; 6 | -------------------------------------------------------------------------------- /xmrig/crypto/common/HugePagesInfo.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_HUGEPAGESINFO_H 20 | #define XMRIG_HUGEPAGESINFO_H 21 | 22 | 23 | #include 24 | #include 25 | 26 | 27 | namespace xmrig { 28 | 29 | 30 | class VirtualMemory; 31 | 32 | 33 | class HugePagesInfo 34 | { 35 | public: 36 | HugePagesInfo() = default; 37 | HugePagesInfo(const VirtualMemory *memory); 38 | 39 | size_t allocated = 0; 40 | size_t total = 0; 41 | size_t size = 0; 42 | 43 | inline bool isFullyAllocated() const { return allocated == total; } 44 | inline double percent() const { return total == 0 ? 0.0 : static_cast(allocated) / total * 100.0; } 45 | inline void reset() { allocated = 0; total = 0; size = 0; } 46 | 47 | inline HugePagesInfo &operator+=(const HugePagesInfo &other) 48 | { 49 | allocated += other.allocated; 50 | total += other.total; 51 | size += other.size; 52 | 53 | return *this; 54 | } 55 | }; 56 | 57 | 58 | } /* namespace xmrig */ 59 | 60 | 61 | #endif /* XMRIG_HUGEPAGESINFO_H */ 62 | -------------------------------------------------------------------------------- /xmrig/crypto/common/MemoryPool.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2018 XMR-Stak , 8 | * Copyright 2018 Lee Clagett 9 | * Copyright 2018-2019 SChernykh 10 | * Copyright 2018-2019 tevador 11 | * Copyright 2016-2019 XMRig , 12 | * 13 | * This program is free software: you can redistribute it and/or modify 14 | * it under the terms of the GNU General Public License as published by 15 | * the Free Software Foundation, either version 3 of the License, or 16 | * (at your option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | * GNU General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU General Public License 24 | * along with this program. If not, see . 25 | */ 26 | 27 | #ifndef XMRIG_MEMORYPOOL_H 28 | #define XMRIG_MEMORYPOOL_H 29 | 30 | 31 | #include "backend/common/interfaces/IMemoryPool.h" 32 | #include "base/tools/Object.h" 33 | 34 | 35 | namespace xmrig { 36 | 37 | 38 | class VirtualMemory; 39 | 40 | 41 | class MemoryPool : public IMemoryPool 42 | { 43 | public: 44 | XMRIG_DISABLE_COPY_MOVE_DEFAULT(MemoryPool) 45 | 46 | MemoryPool(size_t size, bool hugePages, uint32_t node = 0); 47 | ~MemoryPool() override; 48 | 49 | protected: 50 | bool isHugePages(uint32_t node) const override; 51 | uint8_t *get(size_t size, uint32_t node) override; 52 | void release(uint32_t node) override; 53 | 54 | private: 55 | size_t m_refs = 0; 56 | size_t m_offset = 0; 57 | size_t m_alignOffset = 0; 58 | VirtualMemory *m_memory = nullptr; 59 | }; 60 | 61 | 62 | } /* namespace xmrig */ 63 | 64 | 65 | 66 | #endif /* XMRIG_MEMORYPOOL_H */ 67 | -------------------------------------------------------------------------------- /xmrig/crypto/common/Nonce.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright (c) 2018-2021 SChernykh 3 | * Copyright (c) 2016-2021 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_NONCE_H 20 | #define XMRIG_NONCE_H 21 | 22 | 23 | #include 24 | 25 | 26 | namespace xmrig { 27 | 28 | 29 | class Nonce 30 | { 31 | public: 32 | enum Backend : uint32_t { 33 | CPU, 34 | OPENCL, 35 | CUDA, 36 | MAX 37 | }; 38 | 39 | 40 | static inline bool isOutdated(Backend backend, uint64_t sequence) { return m_sequence[backend].load(std::memory_order_relaxed) != sequence; } 41 | static inline bool isPaused() { return m_paused.load(std::memory_order_relaxed); } 42 | static inline uint64_t sequence(Backend backend) { return m_sequence[backend].load(std::memory_order_relaxed); } 43 | static inline void pause(bool paused) { m_paused = paused; } 44 | static inline void reset(uint8_t index) { m_nonces[index] = 0; } 45 | static inline void stop(Backend backend) { m_sequence[backend] = 0; } 46 | static inline void touch(Backend backend) { m_sequence[backend]++; } 47 | 48 | static bool next(uint8_t index, uint32_t *nonce, uint32_t reserveCount, uint64_t mask); 49 | static void stop(); 50 | static void touch(); 51 | 52 | private: 53 | static std::atomic m_paused; 54 | static std::atomic m_sequence[MAX]; 55 | static std::atomic m_nonces[2]; 56 | }; 57 | 58 | 59 | } // namespace xmrig 60 | 61 | 62 | #endif /* XMRIG_NONCE_H */ 63 | -------------------------------------------------------------------------------- /xmrig/crypto/flex/flex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct cryptonight_ctx; 4 | void flex_hash(const char* input, char* output, cryptonight_ctx** ctx); 5 | -------------------------------------------------------------------------------- /xmrig/crypto/ghostrider/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | project(GhostRider) 3 | 4 | set(HEADERS 5 | sph_types.h 6 | sph_blake.h 7 | sph_bmw.h 8 | sph_cubehash.h 9 | sph_echo.h 10 | sph_fugue.h 11 | sph_groestl.h 12 | sph_hamsi.h 13 | sph_jh.h 14 | sph_keccak.h 15 | sph_luffa.h 16 | sph_sha2.h 17 | sph_shabal.h 18 | sph_shavite.h 19 | sph_simd.h 20 | sph_skein.h 21 | sph_whirlpool.h 22 | ghostrider.h 23 | ) 24 | 25 | set(SOURCES 26 | sph_blake.c 27 | sph_bmw.c 28 | sph_cubehash.c 29 | sph_echo.c 30 | sph_fugue.c 31 | sph_groestl.c 32 | sph_hamsi.c 33 | sph_jh.c 34 | sph_keccak.c 35 | sph_luffa.c 36 | sph_shabal.c 37 | sph_shavite.c 38 | sph_simd.c 39 | sph_sha2.c 40 | sph_skein.c 41 | sph_whirlpool.c 42 | ghostrider.cpp 43 | ) 44 | 45 | if (CMAKE_C_COMPILER_ID MATCHES GNU) 46 | # gcc 11.2.0 crashes with -ftree-vrp 47 | set_source_files_properties(sph_jh.c PROPERTIES COMPILE_FLAGS "-Ofast -fno-tree-vrp") 48 | 49 | # gcc 11.2.0 creates incorrect code with -O3 50 | set_source_files_properties(sph_sha2.c PROPERTIES COMPILE_FLAGS "-O2") 51 | 52 | set_source_files_properties(sph_luffa.c PROPERTIES COMPILE_FLAGS "-Ofast -Wno-unused-const-variable") 53 | endif() 54 | 55 | include_directories(.) 56 | include_directories(../..) 57 | include_directories(${UV_INCLUDE_DIR}) 58 | 59 | add_library(ghostrider STATIC ${HEADERS} ${SOURCES}) 60 | -------------------------------------------------------------------------------- /xmrig/crypto/ghostrider/sph_fugue.h: -------------------------------------------------------------------------------- 1 | #ifndef SPH_FUGUE_H__ 2 | #define SPH_FUGUE_H__ 3 | 4 | #include 5 | #include "sph_types.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C"{ 9 | #endif 10 | 11 | #define SPH_SIZE_fugue224 224 12 | 13 | #define SPH_SIZE_fugue256 256 14 | 15 | #define SPH_SIZE_fugue384 384 16 | 17 | #define SPH_SIZE_fugue512 512 18 | 19 | typedef struct { 20 | #ifndef DOXYGEN_IGNORE 21 | sph_u32 partial; 22 | unsigned partial_len; 23 | unsigned round_shift; 24 | sph_u32 S[36]; 25 | #if SPH_64 26 | sph_u64 bit_count; 27 | #else 28 | sph_u32 bit_count_high, bit_count_low; 29 | #endif 30 | #endif 31 | } sph_fugue_context; 32 | 33 | typedef sph_fugue_context sph_fugue224_context; 34 | 35 | typedef sph_fugue_context sph_fugue256_context; 36 | 37 | typedef sph_fugue_context sph_fugue384_context; 38 | 39 | typedef sph_fugue_context sph_fugue512_context; 40 | 41 | void sph_fugue224_init(void *cc); 42 | 43 | void sph_fugue224(void *cc, const void *data, size_t len); 44 | 45 | void sph_fugue224_close(void *cc, void *dst); 46 | 47 | void sph_fugue224_addbits_and_close( 48 | void *cc, unsigned ub, unsigned n, void *dst); 49 | 50 | void sph_fugue256_init(void *cc); 51 | 52 | void sph_fugue256(void *cc, const void *data, size_t len); 53 | 54 | void sph_fugue256_close(void *cc, void *dst); 55 | 56 | void sph_fugue256_addbits_and_close( 57 | void *cc, unsigned ub, unsigned n, void *dst); 58 | 59 | void sph_fugue384_init(void *cc); 60 | 61 | void sph_fugue384(void *cc, const void *data, size_t len); 62 | 63 | void sph_fugue384_close(void *cc, void *dst); 64 | 65 | void sph_fugue384_addbits_and_close( 66 | void *cc, unsigned ub, unsigned n, void *dst); 67 | 68 | void sph_fugue512_init(void *cc); 69 | 70 | void sph_fugue512(void *cc, const void *data, size_t len); 71 | 72 | void sph_fugue512_close(void *cc, void *dst); 73 | 74 | void sph_fugue512_addbits_and_close( 75 | void *cc, unsigned ub, unsigned n, void *dst); 76 | 77 | #define sph_fugue512_full( cc, dst, data, len ) \ 78 | do{ \ 79 | sph_fugue512_init( cc ); \ 80 | sph_fugue512( cc, data, len ); \ 81 | sph_fugue512_close( cc, dst ); \ 82 | }while(0) 83 | 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /xmrig/crypto/kawpow/KPCache.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2018-2020 SChernykh 3 | * Copyright 2016-2020 XMRig , 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef XMRIG_KP_CACHE_H 20 | #define XMRIG_KP_CACHE_H 21 | 22 | 23 | #include "base/tools/Object.h" 24 | #include 25 | #include 26 | 27 | 28 | namespace xmrig 29 | { 30 | 31 | 32 | class VirtualMemory; 33 | 34 | 35 | class KPCache 36 | { 37 | public: 38 | static constexpr size_t l1_cache_size = 16 * 1024; 39 | static constexpr size_t l1_cache_num_items = l1_cache_size / sizeof(uint32_t); 40 | static constexpr uint32_t num_dataset_parents = 512; 41 | 42 | XMRIG_DISABLE_COPY_MOVE(KPCache) 43 | 44 | KPCache(); 45 | ~KPCache(); 46 | 47 | bool init(uint32_t epoch); 48 | 49 | void* data() const; 50 | size_t size() const { return m_size; } 51 | uint32_t epoch() const { return m_epoch; } 52 | 53 | const uint32_t* l1_cache() const { return m_DAGCache.data(); } 54 | 55 | static uint64_t cache_size(uint32_t epoch); 56 | static uint64_t dag_size(uint32_t epoch); 57 | 58 | static void calculate_fast_mod_data(uint32_t divisor, uint32_t &reciprocal, uint32_t &increment, uint32_t& shift); 59 | 60 | static std::mutex s_cacheMutex; 61 | static KPCache s_cache; 62 | 63 | private: 64 | VirtualMemory* m_memory = nullptr; 65 | size_t m_size = 0; 66 | uint32_t m_epoch = 0xFFFFFFFFUL; 67 | std::vector m_DAGCache; 68 | }; 69 | 70 | 71 | } /* namespace xmrig */ 72 | 73 | 74 | #endif /* XMRIG_KP_CACHE_H */ 75 | -------------------------------------------------------------------------------- /xmrig/crypto/kawpow/KPHash.h: -------------------------------------------------------------------------------- 1 | /* XMRig 2 | * Copyright 2010 Jeff Garzik 3 | * Copyright 2012-2014 pooler 4 | * Copyright 2014 Lucas Jones 5 | * Copyright 2014-2016 Wolf9466 6 | * Copyright 2016 Jay D Dee 7 | * Copyright 2017-2019 XMR-Stak , 8 | * Copyright 2018 Lee Clagett 9 | * Copyright 2018-2019 tevador 10 | * Copyright 2018-2020 SChernykh 11 | * Copyright 2016-2019 XMRig , 12 | * 13 | * This program is free software: you can redistribute it and/or modify 14 | * it under the terms of the GNU General Public License as published by 15 | * the Free Software Foundation, either version 3 of the License, or 16 | * (at your option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | * GNU General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU General Public License 24 | * along with this program. If not, see . 25 | */ 26 | 27 | #ifndef XMRIG_KP_HASH_H 28 | #define XMRIG_KP_HASH_H 29 | 30 | 31 | #include 32 | 33 | 34 | namespace xmrig 35 | { 36 | 37 | 38 | class KPCache; 39 | 40 | 41 | class KPHash 42 | { 43 | public: 44 | static constexpr uint32_t EPOCH_LENGTH = 7500; 45 | static constexpr uint32_t PERIOD_LENGTH = 3; 46 | static constexpr int CNT_CACHE = 11; 47 | static constexpr int CNT_MATH = 18; 48 | static constexpr uint32_t REGS = 32; 49 | static constexpr uint32_t LANES = 16; 50 | 51 | static void calculate(const KPCache& light_cache, uint32_t block_height, const uint8_t (&header_hash)[32], uint64_t nonce, uint32_t (&output)[8], uint32_t (&mix_hash)[8]); 52 | }; 53 | 54 | 55 | } /* namespace xmrig */ 56 | 57 | 58 | #endif /* XMRIG_KP_HASH_H */ 59 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/aes_hash.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | typedef void (hashAndFillAes1Rx4_impl)(void *scratchpad, size_t scratchpadSize, void *hash, void* fill_state); 34 | 35 | extern hashAndFillAes1Rx4_impl* softAESImpl; 36 | 37 | inline hashAndFillAes1Rx4_impl* GetSoftAESImpl() 38 | { 39 | return softAESImpl; 40 | } 41 | 42 | void SelectSoftAESImpl(size_t threadsCount); 43 | 44 | template 45 | void hashAes1Rx4(const void *input, size_t inputSize, void *hash); 46 | 47 | template 48 | void fillAes1Rx4(void *state, size_t outputSize, void *buffer); 49 | 50 | template 51 | void fillAes4Rx4(void *state, size_t outputSize, void *buffer); 52 | 53 | template 54 | void hashAndFillAes1Rx4(void *scratchpad, size_t scratchpadSize, void *hash, void* fill_state); 55 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/allocator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | namespace randomx { 34 | 35 | template 36 | struct AlignedAllocator { 37 | static void* allocMemory(size_t); 38 | static void freeMemory(void*, size_t); 39 | }; 40 | 41 | struct LargePageAllocator { 42 | static void* allocMemory(size_t); 43 | static void freeMemory(void*, size_t); 44 | }; 45 | 46 | struct OneGbPageAllocator { 47 | static void* allocMemory(size_t); 48 | static void freeMemory(void*, size_t); 49 | }; 50 | 51 | } -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_epilogue_linux.inc: -------------------------------------------------------------------------------- 1 | ;# restore callee-saved registers - System V AMD64 ABI 2 | pop r15 3 | pop r14 4 | pop r13 5 | pop r12 6 | pop rbp 7 | pop rbx 8 | 9 | ;# program finished 10 | ret 0 -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_epilogue_store.inc: -------------------------------------------------------------------------------- 1 | ;# save VM register values 2 | add rsp, 40 3 | pop rcx 4 | mov qword ptr [rcx+0], r8 5 | mov qword ptr [rcx+8], r9 6 | mov qword ptr [rcx+16], r10 7 | mov qword ptr [rcx+24], r11 8 | mov qword ptr [rcx+32], r12 9 | mov qword ptr [rcx+40], r13 10 | mov qword ptr [rcx+48], r14 11 | mov qword ptr [rcx+56], r15 12 | movdqa xmmword ptr [rcx+64], xmm0 13 | movdqa xmmword ptr [rcx+80], xmm1 14 | movdqa xmmword ptr [rcx+96], xmm2 15 | movdqa xmmword ptr [rcx+112], xmm3 16 | lea rcx, [rcx+64] 17 | movdqa xmmword ptr [rcx+64], xmm4 18 | movdqa xmmword ptr [rcx+80], xmm5 19 | movdqa xmmword ptr [rcx+96], xmm6 20 | movdqa xmmword ptr [rcx+112], xmm7 -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_epilogue_win64.inc: -------------------------------------------------------------------------------- 1 | ;# restore callee-saved registers - Microsoft x64 calling convention 2 | movdqu xmm15, xmmword ptr [rsp] 3 | movdqu xmm14, xmmword ptr [rsp+16] 4 | movdqu xmm13, xmmword ptr [rsp+32] 5 | movdqu xmm12, xmmword ptr [rsp+48] 6 | movdqu xmm11, xmmword ptr [rsp+64] 7 | add rsp, 80 8 | movdqu xmm10, xmmword ptr [rsp] 9 | movdqu xmm9, xmmword ptr [rsp+16] 10 | movdqu xmm8, xmmword ptr [rsp+32] 11 | movdqu xmm7, xmmword ptr [rsp+48] 12 | movdqu xmm6, xmmword ptr [rsp+64] 13 | add rsp, 80 14 | pop r15 15 | pop r14 16 | pop r13 17 | pop r12 18 | pop rsi 19 | pop rdi 20 | pop rbp 21 | pop rbx 22 | 23 | ;# program finished 24 | ret 25 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_loop_load.inc: -------------------------------------------------------------------------------- 1 | lea rcx, [rsi+rax] 2 | mov [rsp+16], rcx 3 | xor r8, qword ptr [rcx+0] 4 | xor r9, qword ptr [rcx+8] 5 | xor r10, qword ptr [rcx+16] 6 | xor r11, qword ptr [rcx+24] 7 | xor r12, qword ptr [rcx+32] 8 | xor r13, qword ptr [rcx+40] 9 | xor r14, qword ptr [rcx+48] 10 | xor r15, qword ptr [rcx+56] 11 | lea rcx, [rsi+rdx] 12 | mov [rsp+24], rcx 13 | cvtdq2pd xmm0, qword ptr [rcx+0] 14 | cvtdq2pd xmm1, qword ptr [rcx+8] 15 | cvtdq2pd xmm2, qword ptr [rcx+16] 16 | cvtdq2pd xmm3, qword ptr [rcx+24] 17 | cvtdq2pd xmm4, qword ptr [rcx+32] 18 | cvtdq2pd xmm5, qword ptr [rcx+40] 19 | cvtdq2pd xmm6, qword ptr [rcx+48] 20 | cvtdq2pd xmm7, qword ptr [rcx+56] 21 | andpd xmm4, xmm13 22 | andpd xmm5, xmm13 23 | andpd xmm6, xmm13 24 | andpd xmm7, xmm13 25 | orpd xmm4, xmm14 26 | orpd xmm5, xmm14 27 | orpd xmm6, xmm14 28 | orpd xmm7, xmm14 29 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_loop_load_xop.inc: -------------------------------------------------------------------------------- 1 | lea rcx, [rsi+rax] 2 | mov [rsp+16], rcx 3 | xor r8, qword ptr [rcx+0] 4 | xor r9, qword ptr [rcx+8] 5 | xor r10, qword ptr [rcx+16] 6 | xor r11, qword ptr [rcx+24] 7 | xor r12, qword ptr [rcx+32] 8 | xor r13, qword ptr [rcx+40] 9 | xor r14, qword ptr [rcx+48] 10 | xor r15, qword ptr [rcx+56] 11 | lea rcx, [rsi+rdx] 12 | mov [rsp+24], rcx 13 | cvtdq2pd xmm0, qword ptr [rcx+0] 14 | cvtdq2pd xmm1, qword ptr [rcx+8] 15 | cvtdq2pd xmm2, qword ptr [rcx+16] 16 | cvtdq2pd xmm3, qword ptr [rcx+24] 17 | cvtdq2pd xmm4, qword ptr [rcx+32] 18 | cvtdq2pd xmm5, qword ptr [rcx+40] 19 | cvtdq2pd xmm6, qword ptr [rcx+48] 20 | cvtdq2pd xmm7, qword ptr [rcx+56] 21 | vpcmov xmm4, xmm4, xmm14, xmm13 22 | vpcmov xmm5, xmm5, xmm14, xmm13 23 | vpcmov xmm6, xmm6, xmm14, xmm13 24 | vpcmov xmm7, xmm7, xmm14, xmm13 25 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_loop_store.inc: -------------------------------------------------------------------------------- 1 | mov rcx, [rsp+24] 2 | mov qword ptr [rcx+0], r8 3 | mov qword ptr [rcx+8], r9 4 | mov qword ptr [rcx+16], r10 5 | mov qword ptr [rcx+24], r11 6 | mov qword ptr [rcx+32], r12 7 | mov qword ptr [rcx+40], r13 8 | mov qword ptr [rcx+48], r14 9 | mov qword ptr [rcx+56], r15 10 | mov rcx, [rsp+16] 11 | xorpd xmm0, xmm4 12 | xorpd xmm1, xmm5 13 | xorpd xmm2, xmm6 14 | xorpd xmm3, xmm7 15 | movapd xmmword ptr [rcx+0], xmm0 16 | movapd xmmword ptr [rcx+16], xmm1 17 | movapd xmmword ptr [rcx+32], xmm2 18 | movapd xmmword ptr [rcx+48], xmm3 19 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_prologue_linux.inc: -------------------------------------------------------------------------------- 1 | ;# callee-saved registers - System V AMD64 ABI 2 | push rbx 3 | push rbp 4 | push r12 5 | push r13 6 | push r14 7 | push r15 8 | 9 | ;# function arguments 10 | mov rbx, rcx ;# loop counter 11 | push rdi ;# RegisterFile& registerFile 12 | mov rcx, rdi 13 | mov rbp, qword ptr [rsi] ;# "mx", "ma" 14 | mov rdi, qword ptr [rsi+8] ;# uint8_t* dataset 15 | 16 | ;# dataset prefetch for the first iteration of the main loop 17 | mov rax, rbp 18 | shr rax, 32 19 | and eax, RANDOMX_DATASET_BASE_MASK 20 | prefetchnta byte ptr [rdi+rax] 21 | 22 | mov rsi, rdx ;# uint8_t* scratchpad 23 | 24 | mov rax, rbp 25 | 26 | ;# zero integer registers 27 | xor r8, r8 28 | xor r9, r9 29 | xor r10, r10 30 | xor r11, r11 31 | xor r12, r12 32 | xor r13, r13 33 | xor r14, r14 34 | xor r15, r15 35 | 36 | ;# load constant registers 37 | lea rcx, [rcx+120] 38 | movapd xmm8, xmmword ptr [rcx+72] 39 | movapd xmm9, xmmword ptr [rcx+88] 40 | movapd xmm10, xmmword ptr [rcx+104] 41 | movapd xmm11, xmmword ptr [rcx+120] 42 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_prologue_win64.inc: -------------------------------------------------------------------------------- 1 | ;# callee-saved registers - Microsoft x64 calling convention 2 | push rbx 3 | push rbp 4 | push rdi 5 | push rsi 6 | push r12 7 | push r13 8 | push r14 9 | push r15 10 | sub rsp, 80 11 | movdqu xmmword ptr [rsp+64], xmm6 12 | movdqu xmmword ptr [rsp+48], xmm7 13 | movdqu xmmword ptr [rsp+32], xmm8 14 | movdqu xmmword ptr [rsp+16], xmm9 15 | movdqu xmmword ptr [rsp+0], xmm10 16 | sub rsp, 80 17 | movdqu xmmword ptr [rsp+64], xmm11 18 | movdqu xmmword ptr [rsp+48], xmm12 19 | movdqu xmmword ptr [rsp+32], xmm13 20 | movdqu xmmword ptr [rsp+16], xmm14 21 | movdqu xmmword ptr [rsp+0], xmm15 22 | 23 | ;# function arguments 24 | push rcx ;# RegisterFile& registerFile 25 | mov rbp, qword ptr [rdx] ;# "mx", "ma" 26 | mov rdi, qword ptr [rdx+8] ;# uint8_t* dataset 27 | 28 | ;# dataset prefetch for the first iteration of the main loop 29 | mov rax, rbp 30 | shr rax, 32 31 | and eax, RANDOMX_DATASET_BASE_MASK 32 | prefetchnta byte ptr [rdi+rax] 33 | 34 | mov rsi, r8 ;# uint8_t* scratchpad 35 | mov rbx, r9 ;# loop counter 36 | 37 | mov rax, rbp 38 | 39 | ;# zero integer registers 40 | xor r8, r8 41 | xor r9, r9 42 | xor r10, r10 43 | xor r11, r11 44 | xor r12, r12 45 | xor r13, r13 46 | xor r14, r14 47 | xor r15, r15 48 | 49 | ;# load constant registers 50 | lea rcx, [rcx+120] 51 | movapd xmm8, xmmword ptr [rcx+72] 52 | movapd xmm9, xmmword ptr [rcx+88] 53 | movapd xmm10, xmmword ptr [rcx+104] 54 | movapd xmm11, xmmword ptr [rcx+120] 55 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_read_dataset.inc: -------------------------------------------------------------------------------- 1 | xor rbp, rax ;# modify "mx" 2 | mov edx, ebp ;# edx = mx 3 | and edx, RANDOMX_DATASET_BASE_MASK 4 | prefetchnta byte ptr [rdi+rdx] 5 | ror rbp, 32 ;# swap "ma" and "mx" 6 | mov edx, ebp ;# edx = ma 7 | and edx, RANDOMX_DATASET_BASE_MASK 8 | lea rcx, [rdi+rdx] ;# dataset cache line 9 | xor r8, qword ptr [rcx+0] 10 | xor r9, qword ptr [rcx+8] 11 | xor r10, qword ptr [rcx+16] 12 | xor r11, qword ptr [rcx+24] 13 | xor r12, qword ptr [rcx+32] 14 | xor r13, qword ptr [rcx+40] 15 | xor r14, qword ptr [rcx+48] 16 | xor r15, qword ptr [rcx+56] 17 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_read_dataset_ryzen.inc: -------------------------------------------------------------------------------- 1 | mov rcx, rbp ;# ecx = ma 2 | shr rcx, 32 3 | and ecx, RANDOMX_DATASET_BASE_MASK 4 | xor r8, qword ptr [rdi+rcx] 5 | xor rbp, rax ;# modify "mx" 6 | mov edx, ebp ;# edx = mx 7 | and edx, RANDOMX_DATASET_BASE_MASK 8 | prefetchnta byte ptr [rdi+rdx] 9 | ror rbp, 32 ;# swap "ma" and "mx" 10 | xor r9, qword ptr [rdi+rcx+8] 11 | xor r10, qword ptr [rdi+rcx+16] 12 | xor r11, qword ptr [rdi+rcx+24] 13 | xor r12, qword ptr [rdi+rcx+32] 14 | xor r13, qword ptr [rdi+rcx+40] 15 | xor r14, qword ptr [rdi+rcx+48] 16 | xor r15, qword ptr [rdi+rcx+56] 17 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_read_dataset_sshash_fin.inc: -------------------------------------------------------------------------------- 1 | mov rbx, qword ptr [rsp+64] 2 | xor r8, qword ptr [rsp+56] 3 | xor r9, qword ptr [rsp+48] 4 | xor r10, qword ptr [rsp+40] 5 | xor r11, qword ptr [rsp+32] 6 | xor r12, qword ptr [rsp+24] 7 | xor r13, qword ptr [rsp+16] 8 | xor r14, qword ptr [rsp+8] 9 | xor r15, qword ptr [rsp+0] 10 | add rsp, 72 -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_read_dataset_sshash_init.inc: -------------------------------------------------------------------------------- 1 | sub rsp, 72 2 | mov qword ptr [rsp+64], rbx 3 | mov qword ptr [rsp+56], r8 4 | mov qword ptr [rsp+48], r9 5 | mov qword ptr [rsp+40], r10 6 | mov qword ptr [rsp+32], r11 7 | mov qword ptr [rsp+24], r12 8 | mov qword ptr [rsp+16], r13 9 | mov qword ptr [rsp+8], r14 10 | mov qword ptr [rsp+0], r15 11 | xor rbp, rax ;# modify "mx" 12 | ror rbp, 32 ;# swap "ma" and "mx" 13 | mov ebx, ebp ;# ecx = ma 14 | and ebx, RANDOMX_DATASET_BASE_MASK 15 | shr ebx, 6 ;# ebx = Dataset block number 16 | ;# add ebx, datasetOffset / 64 17 | ;# call 32768 -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_sshash_constants.inc: -------------------------------------------------------------------------------- 1 | r0_mul: 2 | ;#/ 6364136223846793005 3 | db 45, 127, 149, 76, 45, 244, 81, 88 4 | r1_add: 5 | ;#/ 9298411001130361340 6 | db 252, 161, 245, 89, 138, 151, 10, 129 7 | r2_add: 8 | ;#/ 12065312585734608966 9 | db 70, 216, 194, 56, 223, 153, 112, 167 10 | r3_add: 11 | ;#/ 9306329213124626780 12 | db 92, 73, 34, 191, 28, 185, 38, 129 13 | r4_add: 14 | ;#/ 5281919268842080866 15 | db 98, 138, 159, 23, 151, 37, 77, 73 16 | r5_add: 17 | ;#/ 10536153434571861004 18 | db 12, 236, 170, 206, 185, 239, 55, 146 19 | r6_add: 20 | ;#/ 3398623926847679864 21 | db 120, 45, 230, 108, 116, 86, 42, 47 22 | r7_add: 23 | ;#/ 9549104520008361294 24 | db 78, 229, 44, 182, 247, 59, 133, 132 -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_sshash_load.inc: -------------------------------------------------------------------------------- 1 | xor r8, qword ptr [rbx+0] 2 | xor r9, qword ptr [rbx+8] 3 | xor r10, qword ptr [rbx+16] 4 | xor r11, qword ptr [rbx+24] 5 | xor r12, qword ptr [rbx+32] 6 | xor r13, qword ptr [rbx+40] 7 | xor r14, qword ptr [rbx+48] 8 | xor r15, qword ptr [rbx+56] -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_sshash_prefetch.inc: -------------------------------------------------------------------------------- 1 | and rbx, RANDOMX_CACHE_MASK 2 | shl rbx, 6 3 | add rbx, rdi 4 | prefetchnta byte ptr [rbx] -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/program_xmm_constants.inc: -------------------------------------------------------------------------------- 1 | mantissaMask: 2 | db 0, 0, 192, 255, 255, 255, 255, 0, 0, 0, 192, 255, 255, 255, 255, 0 3 | exp240: 4 | db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 5 | scaleMask: 6 | db 0, 0, 0, 0, 0, 0, 240, 128, 0, 0, 0, 0, 0, 0, 240, 128 -------------------------------------------------------------------------------- /xmrig/crypto/randomx/asm/randomx_reciprocal.inc: -------------------------------------------------------------------------------- 1 | mov edx, 1 2 | mov r8, rcx 3 | xor eax, eax 4 | bsr rcx, rcx 5 | shl rdx, cl 6 | div r8 7 | ret -------------------------------------------------------------------------------- /xmrig/crypto/randomx/blake2_generator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | namespace randomx { 34 | 35 | class Blake2Generator { 36 | public: 37 | Blake2Generator(const void* seed, size_t seedSize, int nonce = 0); 38 | uint8_t getByte(); 39 | uint32_t getUInt32(); 40 | private: 41 | void checkData(const size_t); 42 | 43 | uint8_t data[64]; 44 | size_t dataIndex; 45 | }; 46 | } -------------------------------------------------------------------------------- /xmrig/crypto/randomx/configuration.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | // Increase it if some configs use more cache accesses 32 | #define RANDOMX_CACHE_MAX_ACCESSES 16 33 | 34 | // Increase it if some configs use larger superscalar latency 35 | #define RANDOMX_SUPERSCALAR_MAX_LATENCY 256 36 | 37 | // Increase it if some configs use larger cache 38 | #define RANDOMX_CACHE_MAX_SIZE 268435456 39 | 40 | // Increase it if some configs use larger dataset 41 | #define RANDOMX_DATASET_MAX_SIZE 2181038080 42 | 43 | // Increase it if some configs use larger programs 44 | #define RANDOMX_PROGRAM_MAX_SIZE 280 45 | 46 | // Increase it if some configs use larger scratchpad 47 | #define RANDOMX_SCRATCHPAD_L3_MAX_SIZE 2097152 48 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/jit_compiler.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #if defined(_M_X64) || defined(__x86_64__) 32 | #include "crypto/randomx/jit_compiler_x86.hpp" 33 | #elif defined(__aarch64__) 34 | #include "crypto/randomx/jit_compiler_a64.hpp" 35 | #else 36 | #include "crypto/randomx/jit_compiler_fallback.hpp" 37 | #endif 38 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/panthera/KeccakP-1600-SnP.h: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen, 3 | Michaël Peeters, Gilles Van Assche and Ronny Van Keer, 4 | hereby denoted as "the implementer". 5 | 6 | For more information, feedback or questions, please refer to our website: 7 | https://keccak.team/ 8 | 9 | To the extent possible under law, the implementer has waived all copyright 10 | and related or neighboring rights to the source code in this file. 11 | http://creativecommons.org/publicdomain/zero/1.0/ 12 | 13 | --- 14 | 15 | Please refer to SnP-documentation.h for more details. 16 | */ 17 | 18 | #ifndef _KeccakP_1600_SnP_h_ 19 | #define _KeccakP_1600_SnP_h_ 20 | 21 | #define KeccakP1600_implementation "64-bit reference implementation" 22 | #define KeccakP1600_stateSizeInBytes 200 23 | #define KeccakP1600_stateAlignment 8 24 | 25 | #ifdef KeccakReference 26 | void KeccakP1600_StaticInitialize( void ); 27 | #else 28 | #define KeccakP1600_StaticInitialize() 29 | #endif 30 | void KeccakP1600_Initialize(void *state); 31 | void KeccakP1600_AddByte(void *state, unsigned char data, unsigned int offset); 32 | void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length); 33 | void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length); 34 | void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount); 35 | void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds); 36 | void KeccakP1600_Permute_12rounds(void *state); 37 | void KeccakP1600_Permute_24rounds(void *state); 38 | void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length); 39 | void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/panthera/KeccakSponge-common.h: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen, 3 | Michaël Peeters, Gilles Van Assche and Ronny Van Keer, 4 | hereby denoted as "the implementer". 5 | 6 | For more information, feedback or questions, please refer to our website: 7 | https://keccak.team/ 8 | 9 | To the extent possible under law, the implementer has waived all copyright 10 | and related or neighboring rights to the source code in this file. 11 | http://creativecommons.org/publicdomain/zero/1.0/ 12 | */ 13 | 14 | #ifndef _KeccakSpongeCommon_h_ 15 | #define _KeccakSpongeCommon_h_ 16 | 17 | #include 18 | #include "align.h" 19 | 20 | #define KCP_DeclareSpongeStructure(prefix, size, alignment) \ 21 | ALIGN(alignment) typedef struct prefix##_SpongeInstanceStruct { \ 22 | unsigned char state[size]; \ 23 | unsigned int rate; \ 24 | unsigned int byteIOIndex; \ 25 | int squeezing; \ 26 | } prefix##_SpongeInstance; 27 | 28 | #define KCP_DeclareSpongeFunctions(prefix) \ 29 | int prefix##_Sponge(unsigned int rate, unsigned int capacity, const unsigned char *input, size_t inputByteLen, unsigned char suffix, unsigned char *output, size_t outputByteLen); \ 30 | int prefix##_SpongeInitialize(prefix##_SpongeInstance *spongeInstance, unsigned int rate, unsigned int capacity); \ 31 | int prefix##_SpongeAbsorb(prefix##_SpongeInstance *spongeInstance, const unsigned char *data, size_t dataByteLen); \ 32 | int prefix##_SpongeAbsorbLastFewBits(prefix##_SpongeInstance *spongeInstance, unsigned char delimitedData); \ 33 | int prefix##_SpongeSqueeze(prefix##_SpongeInstance *spongeInstance, unsigned char *data, size_t dataByteLen); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/panthera/KeccakSpongeWidth1600.c: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen, 3 | Michaël Peeters, Gilles Van Assche and Ronny Van Keer, 4 | hereby denoted as "the implementer". 5 | 6 | For more information, feedback or questions, please refer to our website: 7 | https://keccak.team/ 8 | 9 | To the extent possible under law, the implementer has waived all copyright 10 | and related or neighboring rights to the source code in this file. 11 | http://creativecommons.org/publicdomain/zero/1.0/ 12 | */ 13 | 14 | #include "KeccakSpongeWidth1600.h" 15 | 16 | #ifdef KeccakReference 17 | #include "displayIntermediateValues.h" 18 | #endif 19 | 20 | #ifndef KeccakP1600_excluded 21 | #include "KeccakP-1600-SnP.h" 22 | 23 | #define prefix KeccakWidth1600 24 | #define SnP KeccakP1600 25 | #define SnP_width 1600 26 | #define SnP_Permute KeccakP1600_Permute_24rounds 27 | #if defined(KeccakF1600_FastLoop_supported) 28 | #define SnP_FastLoop_Absorb KeccakF1600_FastLoop_Absorb 29 | #endif 30 | #include "KeccakSponge.inc" 31 | #undef prefix 32 | #undef SnP 33 | #undef SnP_width 34 | #undef SnP_Permute 35 | #undef SnP_FastLoop_Absorb 36 | #endif 37 | 38 | #ifndef KeccakP1600_excluded 39 | #include "KeccakP-1600-SnP.h" 40 | 41 | #define prefix KeccakWidth1600_12rounds 42 | #define SnP KeccakP1600 43 | #define SnP_width 1600 44 | #define SnP_Permute KeccakP1600_Permute_12rounds 45 | #if defined(KeccakP1600_12rounds_FastLoop_supported) 46 | #define SnP_FastLoop_Absorb KeccakP1600_12rounds_FastLoop_Absorb 47 | #endif 48 | #include "KeccakSponge.inc" 49 | #undef prefix 50 | #undef SnP 51 | #undef SnP_width 52 | #undef SnP_Permute 53 | #undef SnP_FastLoop_Absorb 54 | #endif 55 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/panthera/KeccakSpongeWidth1600.h: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen, 3 | Michaël Peeters, Gilles Van Assche and Ronny Van Keer, 4 | hereby denoted as "the implementer". 5 | 6 | For more information, feedback or questions, please refer to our website: 7 | https://keccak.team/ 8 | 9 | To the extent possible under law, the implementer has waived all copyright 10 | and related or neighboring rights to the source code in this file. 11 | http://creativecommons.org/publicdomain/zero/1.0/ 12 | */ 13 | 14 | #ifndef _KeccakSpongeWidth1600_h_ 15 | #define _KeccakSpongeWidth1600_h_ 16 | 17 | #include "KeccakSponge-common.h" 18 | 19 | #ifndef KeccakP1600_excluded 20 | #include "KeccakP-1600-SnP.h" 21 | KCP_DeclareSpongeStructure(KeccakWidth1600, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment) 22 | KCP_DeclareSpongeFunctions(KeccakWidth1600) 23 | #endif 24 | 25 | #ifndef KeccakP1600_excluded 26 | #include "KeccakP-1600-SnP.h" 27 | KCP_DeclareSpongeStructure(KeccakWidth1600_12rounds, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment) 28 | KCP_DeclareSpongeFunctions(KeccakWidth1600_12rounds) 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/panthera/Phases.h: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by Ronny Van Keer, hereby denoted as "the implementer". 3 | 4 | For more information, feedback or questions, please refer to our website: 5 | https://keccak.team/ 6 | 7 | To the extent possible under law, the implementer has waived all copyright 8 | and related or neighboring rights to the source code in this file. 9 | http://creativecommons.org/publicdomain/zero/1.0/ 10 | */ 11 | 12 | #ifndef _Phases_h_ 13 | #define _Phases_h_ 14 | 15 | typedef enum { 16 | NOT_INITIALIZED, 17 | ABSORBING, 18 | FINAL, 19 | SQUEEZING 20 | } KCP_Phases; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/panthera/align.h: -------------------------------------------------------------------------------- 1 | /* 2 | Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen, 3 | Michaël Peeters, Gilles Van Assche and Ronny Van Keer, 4 | hereby denoted as "the implementer". 5 | 6 | For more information, feedback or questions, please refer to our website: 7 | https://keccak.team/ 8 | 9 | To the extent possible under law, the implementer has waived all copyright 10 | and related or neighboring rights to the source code in this file. 11 | http://creativecommons.org/publicdomain/zero/1.0/ 12 | */ 13 | 14 | #ifndef _align_h_ 15 | #define _align_h_ 16 | 17 | /* on Mac OS-X and possibly others, ALIGN(x) is defined in param.h, and -Werror chokes on the redef. */ 18 | #ifdef ALIGN 19 | #undef ALIGN 20 | #endif 21 | 22 | #if defined(__GNUC__) 23 | #define ALIGN(x) __attribute__ ((aligned(x))) 24 | #elif defined(_MSC_VER) 25 | #define ALIGN(x) __declspec(align(x)) 26 | #elif defined(__ARMCC_VERSION) 27 | #define ALIGN(x) __align(x) 28 | #else 29 | #define ALIGN(x) 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/panthera/insecure_memzero.h: -------------------------------------------------------------------------------- 1 | #define insecure_memzero(buf, len) /* empty */ 2 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/reciprocal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | #if defined(_M_X64) || defined(__x86_64__) 34 | #define RANDOMX_HAVE_FAST_RECIPROCAL 1 35 | #else 36 | #define RANDOMX_HAVE_FAST_RECIPROCAL 0 37 | #endif 38 | 39 | #if defined(__cplusplus) 40 | extern "C" { 41 | #endif 42 | 43 | uint64_t randomx_reciprocal(uint64_t); 44 | uint64_t randomx_reciprocal_fast(uint64_t); 45 | 46 | #if defined(__cplusplus) 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/virtual_memory.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | 33 | void* allocExecutableMemory(std::size_t, bool); 34 | void* allocLargePagesMemory(std::size_t); 35 | void freePagedMemory(void*, std::size_t); 36 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/vm_compiled_light.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "crypto/randomx/vm_compiled_light.hpp" 30 | #include "crypto/randomx/common.hpp" 31 | #include 32 | 33 | namespace randomx { 34 | 35 | template 36 | void CompiledLightVm::setCache(randomx_cache* cache) { 37 | cachePtr = cache; 38 | mem.memory = cache->memory; 39 | compiler.generateSuperscalarHash(cache->programs, cache->reciprocalCache); 40 | } 41 | 42 | template 43 | void CompiledLightVm::run(void* seed) { 44 | VmBase::generateProgram(seed); 45 | randomx_vm::initialize(); 46 | compiler.generateProgramLight(program, config, datasetOffset); 47 | CompiledVm::execute(); 48 | } 49 | 50 | template class CompiledLightVm; 51 | template class CompiledLightVm; 52 | } 53 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/vm_interpreted_light.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include "crypto/randomx/vm_interpreted_light.hpp" 30 | #include "crypto/randomx/dataset.hpp" 31 | 32 | namespace randomx { 33 | 34 | template 35 | void InterpretedLightVm::setCache(randomx_cache* cache) { 36 | cachePtr = cache; 37 | mem.memory = cache->memory; 38 | } 39 | 40 | template 41 | void InterpretedLightVm::datasetRead(uint64_t address, int_reg_t(&r)[8]) { 42 | uint32_t itemNumber = address / CacheLineSize; 43 | int_reg_t rl[8]; 44 | 45 | initDatasetItem(cachePtr, (uint8_t*)rl, itemNumber); 46 | 47 | for (unsigned q = 0; q < 8; ++q) 48 | r[q] ^= rl[q]; 49 | } 50 | 51 | template class InterpretedLightVm; 52 | template class InterpretedLightVm; 53 | } 54 | -------------------------------------------------------------------------------- /xmrig/crypto/randomx/vm_interpreted_light.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018-2019, tevador 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the copyright holder nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | #include "crypto/randomx/vm_interpreted.hpp" 33 | 34 | namespace randomx { 35 | 36 | template 37 | class InterpretedLightVm : public InterpretedVm { 38 | public: 39 | using VmBase::mem; 40 | using VmBase::cachePtr; 41 | 42 | void* operator new(size_t, void* ptr) { return ptr; } 43 | void operator delete(void*) {} 44 | 45 | void setDataset(randomx_dataset* dataset) override { } 46 | void setCache(randomx_cache* cache) override; 47 | 48 | protected: 49 | void datasetRead(uint64_t address, int_reg_t(&r)[8]) override; 50 | void datasetPrefetch(uint64_t address) override { } 51 | }; 52 | 53 | using InterpretedLightVmDefault = InterpretedLightVm<1>; 54 | using InterpretedLightVmHardAes = InterpretedLightVm<0>; 55 | } 56 | --------------------------------------------------------------------------------