Line data Source code
1 : // Copyright (c) 2014-2025 The Dash Core developers 2 : // Distributed under the MIT software license, see the accompanying 3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 : 5 : #ifndef BITCOIN_HASH_X11_H 6 : #define BITCOIN_HASH_X11_H 7 : 8 : 9 : #include <crypto/x11/sph_blake.h> 10 : #include <crypto/x11/sph_bmw.h> 11 : #include <crypto/x11/sph_cubehash.h> 12 : #include <crypto/x11/sph_echo.h> 13 : #include <crypto/x11/sph_groestl.h> 14 : #include <crypto/x11/sph_jh.h> 15 : #include <crypto/x11/sph_keccak.h> 16 : #include <crypto/x11/sph_luffa.h> 17 : #include <crypto/x11/sph_shavite.h> 18 : #include <crypto/x11/sph_simd.h> 19 : #include <crypto/x11/sph_skein.h> 20 : 21 : #include <uint256.h> 22 : 23 : 24 : /* ----------- Dash Hash ------------------------------------------------ */ 25 : template <typename T1> 26 6239803 : inline uint256 HashX11(const T1 pbegin, const T1 pend) 27 : 28 : { 29 : sph_blake512_context ctx_blake; 30 : sph_bmw512_context ctx_bmw; 31 : sph_groestl512_context ctx_groestl; 32 : sph_jh512_context ctx_jh; 33 : sph_keccak512_context ctx_keccak; 34 : sph_skein512_context ctx_skein; 35 : sph_luffa512_context ctx_luffa; 36 : sph_cubehash512_context ctx_cubehash; 37 : sph_shavite512_context ctx_shavite; 38 : sph_simd512_context ctx_simd; 39 : sph_echo512_context ctx_echo; 40 : static const unsigned char pblank[1]{}; 41 : 42 6239803 : uint512 hash[11]; 43 : 44 6239803 : sph_blake512_init(&ctx_blake); 45 6239803 : sph_blake512(&ctx_blake, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0])), 46 6239803 : (pend - pbegin) * sizeof(pbegin[0])); 47 6239803 : sph_blake512_close(&ctx_blake, static_cast<void*>(&hash[0])); 48 : 49 6239803 : sph_bmw512_init(&ctx_bmw); 50 6239803 : sph_bmw512(&ctx_bmw, static_cast<const void*>(&hash[0]), 64); 51 6239803 : sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash[1])); 52 : 53 6239803 : sph_groestl512_init(&ctx_groestl); 54 6239803 : sph_groestl512(&ctx_groestl, static_cast<const void*>(&hash[1]), 64); 55 6239803 : sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash[2])); 56 : 57 6239803 : sph_skein512_init(&ctx_skein); 58 6239803 : sph_skein512(&ctx_skein, static_cast<const void*>(&hash[2]), 64); 59 6239803 : sph_skein512_close(&ctx_skein, static_cast<void*>(&hash[3])); 60 : 61 6239803 : sph_jh512_init(&ctx_jh); 62 6239803 : sph_jh512(&ctx_jh, static_cast<const void*>(&hash[3]), 64); 63 6239803 : sph_jh512_close(&ctx_jh, static_cast<void*>(&hash[4])); 64 : 65 6239803 : sph_keccak512_init(&ctx_keccak); 66 6239803 : sph_keccak512(&ctx_keccak, static_cast<const void*>(&hash[4]), 64); 67 6239803 : sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash[5])); 68 : 69 6239803 : sph_luffa512_init(&ctx_luffa); 70 6239803 : sph_luffa512(&ctx_luffa, static_cast<void*>(&hash[5]), 64); 71 6239803 : sph_luffa512_close(&ctx_luffa, static_cast<void*>(&hash[6])); 72 : 73 6239803 : sph_cubehash512_init(&ctx_cubehash); 74 6239803 : sph_cubehash512(&ctx_cubehash, static_cast<const void*>(&hash[6]), 64); 75 6239803 : sph_cubehash512_close(&ctx_cubehash, static_cast<void*>(&hash[7])); 76 : 77 6239803 : sph_shavite512_init(&ctx_shavite); 78 6239803 : sph_shavite512(&ctx_shavite, static_cast<const void*>(&hash[7]), 64); 79 6239803 : sph_shavite512_close(&ctx_shavite, static_cast<void*>(&hash[8])); 80 : 81 6239803 : sph_simd512_init(&ctx_simd); 82 6239803 : sph_simd512(&ctx_simd, static_cast<const void*>(&hash[8]), 64); 83 6239803 : sph_simd512_close(&ctx_simd, static_cast<void*>(&hash[9])); 84 : 85 6239803 : sph_echo512_init(&ctx_echo); 86 6239803 : sph_echo512(&ctx_echo, static_cast<const void*>(&hash[9]), 64); 87 6239803 : sph_echo512_close(&ctx_echo, static_cast<void*>(&hash[10])); 88 : 89 6239803 : return hash[10].trim256(); 90 : } 91 : 92 : #endif // BITCOIN_HASH_X11_H