LCOV - code coverage report
Current view: top level - src - hash_x11.h (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 37 37 100.0 %
Date: 2026-06-25 07:23:51 Functions: 1 1 100.0 %

          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     1020110 : 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     1020110 :     uint512 hash[11];
      43             : 
      44     1020110 :     sph_blake512_init(&ctx_blake);
      45     1020110 :     sph_blake512(&ctx_blake, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0])),
      46     1020110 :                  (pend - pbegin) * sizeof(pbegin[0]));
      47     1020110 :     sph_blake512_close(&ctx_blake, static_cast<void*>(&hash[0]));
      48             : 
      49     1020110 :     sph_bmw512_init(&ctx_bmw);
      50     1020110 :     sph_bmw512(&ctx_bmw, static_cast<const void*>(&hash[0]), 64);
      51     1020110 :     sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash[1]));
      52             : 
      53     1020110 :     sph_groestl512_init(&ctx_groestl);
      54     1020110 :     sph_groestl512(&ctx_groestl, static_cast<const void*>(&hash[1]), 64);
      55     1020110 :     sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash[2]));
      56             : 
      57     1020110 :     sph_skein512_init(&ctx_skein);
      58     1020110 :     sph_skein512(&ctx_skein, static_cast<const void*>(&hash[2]), 64);
      59     1020110 :     sph_skein512_close(&ctx_skein, static_cast<void*>(&hash[3]));
      60             : 
      61     1020110 :     sph_jh512_init(&ctx_jh);
      62     1020110 :     sph_jh512(&ctx_jh, static_cast<const void*>(&hash[3]), 64);
      63     1020110 :     sph_jh512_close(&ctx_jh, static_cast<void*>(&hash[4]));
      64             : 
      65     1020110 :     sph_keccak512_init(&ctx_keccak);
      66     1020110 :     sph_keccak512(&ctx_keccak, static_cast<const void*>(&hash[4]), 64);
      67     1020110 :     sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash[5]));
      68             : 
      69     1020110 :     sph_luffa512_init(&ctx_luffa);
      70     1020110 :     sph_luffa512(&ctx_luffa, static_cast<void*>(&hash[5]), 64);
      71     1020110 :     sph_luffa512_close(&ctx_luffa, static_cast<void*>(&hash[6]));
      72             : 
      73     1020110 :     sph_cubehash512_init(&ctx_cubehash);
      74     1020110 :     sph_cubehash512(&ctx_cubehash, static_cast<const void*>(&hash[6]), 64);
      75     1020110 :     sph_cubehash512_close(&ctx_cubehash, static_cast<void*>(&hash[7]));
      76             : 
      77     1020110 :     sph_shavite512_init(&ctx_shavite);
      78     1020110 :     sph_shavite512(&ctx_shavite, static_cast<const void*>(&hash[7]), 64);
      79     1020110 :     sph_shavite512_close(&ctx_shavite, static_cast<void*>(&hash[8]));
      80             : 
      81     1020110 :     sph_simd512_init(&ctx_simd);
      82     1020110 :     sph_simd512(&ctx_simd, static_cast<const void*>(&hash[8]), 64);
      83     1020110 :     sph_simd512_close(&ctx_simd, static_cast<void*>(&hash[9]));
      84             : 
      85     1020110 :     sph_echo512_init(&ctx_echo);
      86     1020110 :     sph_echo512(&ctx_echo, static_cast<const void*>(&hash[9]), 64);
      87     1020110 :     sph_echo512_close(&ctx_echo, static_cast<void*>(&hash[10]));
      88             : 
      89     1020110 :     return hash[10].trim256();
      90             : }
      91             : 
      92             : #endif // BITCOIN_HASH_X11_H

Generated by: LCOV version 1.16