mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
refactor: segregate x11 hashing
This commit is contained in:
parent
7c0d44c13c
commit
bd8aa04d44
@ -624,7 +624,6 @@ crypto_libbitcoin_crypto_base_a_SOURCES = \
|
|||||||
crypto/pkcs5_pbkdf2_hmac_sha512.cpp \
|
crypto/pkcs5_pbkdf2_hmac_sha512.cpp \
|
||||||
crypto/pkcs5_pbkdf2_hmac_sha512.h \
|
crypto/pkcs5_pbkdf2_hmac_sha512.h \
|
||||||
crypto/ripemd160.cpp \
|
crypto/ripemd160.cpp \
|
||||||
crypto/aes_helper.c \
|
|
||||||
crypto/ripemd160.h \
|
crypto/ripemd160.h \
|
||||||
crypto/sha1.cpp \
|
crypto/sha1.cpp \
|
||||||
crypto/sha1.h \
|
crypto/sha1.h \
|
||||||
@ -655,29 +654,30 @@ crypto_libbitcoin_crypto_avx2_a_SOURCES = crypto/sha256_avx2.cpp
|
|||||||
|
|
||||||
# x11
|
# x11
|
||||||
crypto_libbitcoin_crypto_base_a_SOURCES += \
|
crypto_libbitcoin_crypto_base_a_SOURCES += \
|
||||||
crypto/blake.c \
|
crypto/x11/aes_helper.c \
|
||||||
crypto/bmw.c \
|
crypto/x11/blake.c \
|
||||||
crypto/cubehash.c \
|
crypto/x11/bmw.c \
|
||||||
crypto/echo.c \
|
crypto/x11/cubehash.c \
|
||||||
crypto/groestl.c \
|
crypto/x11/echo.c \
|
||||||
crypto/jh.c \
|
crypto/x11/groestl.c \
|
||||||
crypto/keccak.c \
|
crypto/x11/jh.c \
|
||||||
crypto/luffa.c \
|
crypto/x11/keccak.c \
|
||||||
crypto/shavite.c \
|
crypto/x11/luffa.c \
|
||||||
crypto/simd.c \
|
crypto/x11/shavite.c \
|
||||||
crypto/skein.c \
|
crypto/x11/simd.c \
|
||||||
crypto/sph_blake.h \
|
crypto/x11/skein.c \
|
||||||
crypto/sph_bmw.h \
|
crypto/x11/sph_blake.h \
|
||||||
crypto/sph_cubehash.h \
|
crypto/x11/sph_bmw.h \
|
||||||
crypto/sph_echo.h \
|
crypto/x11/sph_cubehash.h \
|
||||||
crypto/sph_groestl.h \
|
crypto/x11/sph_echo.h \
|
||||||
crypto/sph_jh.h \
|
crypto/x11/sph_groestl.h \
|
||||||
crypto/sph_keccak.h \
|
crypto/x11/sph_jh.h \
|
||||||
crypto/sph_luffa.h \
|
crypto/x11/sph_keccak.h \
|
||||||
crypto/sph_shavite.h \
|
crypto/x11/sph_luffa.h \
|
||||||
crypto/sph_simd.h \
|
crypto/x11/sph_shavite.h \
|
||||||
crypto/sph_skein.h \
|
crypto/x11/sph_simd.h \
|
||||||
crypto/sph_types.h
|
crypto/x11/sph_skein.h \
|
||||||
|
crypto/x11/sph_types.h
|
||||||
|
|
||||||
crypto_libbitcoin_crypto_x86_shani_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
crypto_libbitcoin_crypto_x86_shani_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||||
crypto_libbitcoin_crypto_x86_shani_a_CPPFLAGS = $(AM_CPPFLAGS)
|
crypto_libbitcoin_crypto_x86_shani_a_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
@ -707,6 +707,7 @@ libbitcoin_consensus_a_SOURCES = \
|
|||||||
consensus/validation.h \
|
consensus/validation.h \
|
||||||
hash.cpp \
|
hash.cpp \
|
||||||
hash.h \
|
hash.h \
|
||||||
|
hash_x11.h \
|
||||||
prevector.h \
|
prevector.h \
|
||||||
primitives/block.cpp \
|
primitives/block.cpp \
|
||||||
primitives/block.h \
|
primitives/block.h \
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <crypto/sha512.h>
|
#include <crypto/sha512.h>
|
||||||
#include <crypto/siphash.h>
|
#include <crypto/siphash.h>
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
|
#include <hash_x11.h>
|
||||||
#include <random.h>
|
#include <random.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ extern "C"{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output size (in bits) for BLAKE-224.
|
* Output size (in bits) for BLAKE-224.
|
@ -41,7 +41,7 @@ extern "C"{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output size (in bits) for BMW-224.
|
* Output size (in bits) for BMW-224.
|
@ -42,7 +42,7 @@ extern "C"{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output size (in bits) for CubeHash-224.
|
* Output size (in bits) for CubeHash-224.
|
@ -41,7 +41,7 @@ extern "C"{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output size (in bits) for ECHO-224.
|
* Output size (in bits) for ECHO-224.
|
@ -40,7 +40,7 @@ extern "C"{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output size (in bits) for Groestl-224.
|
* Output size (in bits) for Groestl-224.
|
@ -41,7 +41,7 @@ extern "C"{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output size (in bits) for JH-224.
|
* Output size (in bits) for JH-224.
|
@ -41,7 +41,7 @@ extern "C"{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output size (in bits) for Keccak-224.
|
* Output size (in bits) for Keccak-224.
|
@ -41,7 +41,7 @@ extern "C"{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output size (in bits) for Luffa-224.
|
* Output size (in bits) for Luffa-224.
|
@ -39,7 +39,7 @@
|
|||||||
#define SPH_SHAVITE_H__
|
#define SPH_SHAVITE_H__
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"{
|
extern "C"{
|
@ -41,7 +41,7 @@ extern "C"{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output size (in bits) for SIMD-224.
|
* Output size (in bits) for SIMD-224.
|
@ -46,7 +46,7 @@ extern "C"{
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <crypto/sph_types.h>
|
#include "sph_types.h"
|
||||||
|
|
||||||
#if SPH_64
|
#if SPH_64
|
||||||
|
|
79
src/hash.h
79
src/hash.h
@ -16,18 +16,6 @@
|
|||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
#include <crypto/sph_blake.h>
|
|
||||||
#include <crypto/sph_bmw.h>
|
|
||||||
#include <crypto/sph_groestl.h>
|
|
||||||
#include <crypto/sph_jh.h>
|
|
||||||
#include <crypto/sph_keccak.h>
|
|
||||||
#include <crypto/sph_skein.h>
|
|
||||||
#include <crypto/sph_luffa.h>
|
|
||||||
#include <crypto/sph_cubehash.h>
|
|
||||||
#include <crypto/sph_shavite.h>
|
|
||||||
#include <crypto/sph_simd.h>
|
|
||||||
#include <crypto/sph_echo.h>
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
typedef uint256 ChainCode;
|
typedef uint256 ChainCode;
|
||||||
@ -253,71 +241,4 @@ unsigned int MurmurHash3(unsigned int nHashSeed, Span<const unsigned char> vData
|
|||||||
|
|
||||||
void BIP32Hash(const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64]);
|
void BIP32Hash(const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64]);
|
||||||
|
|
||||||
/* ----------- Dash Hash ------------------------------------------------ */
|
|
||||||
template<typename T1>
|
|
||||||
inline uint256 HashX11(const T1 pbegin, const T1 pend)
|
|
||||||
|
|
||||||
{
|
|
||||||
sph_blake512_context ctx_blake;
|
|
||||||
sph_bmw512_context ctx_bmw;
|
|
||||||
sph_groestl512_context ctx_groestl;
|
|
||||||
sph_jh512_context ctx_jh;
|
|
||||||
sph_keccak512_context ctx_keccak;
|
|
||||||
sph_skein512_context ctx_skein;
|
|
||||||
sph_luffa512_context ctx_luffa;
|
|
||||||
sph_cubehash512_context ctx_cubehash;
|
|
||||||
sph_shavite512_context ctx_shavite;
|
|
||||||
sph_simd512_context ctx_simd;
|
|
||||||
sph_echo512_context ctx_echo;
|
|
||||||
static unsigned char pblank[1];
|
|
||||||
|
|
||||||
uint512 hash[11];
|
|
||||||
|
|
||||||
sph_blake512_init(&ctx_blake);
|
|
||||||
sph_blake512 (&ctx_blake, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0])), (pend - pbegin) * sizeof(pbegin[0]));
|
|
||||||
sph_blake512_close(&ctx_blake, static_cast<void*>(&hash[0]));
|
|
||||||
|
|
||||||
sph_bmw512_init(&ctx_bmw);
|
|
||||||
sph_bmw512 (&ctx_bmw, static_cast<const void*>(&hash[0]), 64);
|
|
||||||
sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash[1]));
|
|
||||||
|
|
||||||
sph_groestl512_init(&ctx_groestl);
|
|
||||||
sph_groestl512 (&ctx_groestl, static_cast<const void*>(&hash[1]), 64);
|
|
||||||
sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash[2]));
|
|
||||||
|
|
||||||
sph_skein512_init(&ctx_skein);
|
|
||||||
sph_skein512 (&ctx_skein, static_cast<const void*>(&hash[2]), 64);
|
|
||||||
sph_skein512_close(&ctx_skein, static_cast<void*>(&hash[3]));
|
|
||||||
|
|
||||||
sph_jh512_init(&ctx_jh);
|
|
||||||
sph_jh512 (&ctx_jh, static_cast<const void*>(&hash[3]), 64);
|
|
||||||
sph_jh512_close(&ctx_jh, static_cast<void*>(&hash[4]));
|
|
||||||
|
|
||||||
sph_keccak512_init(&ctx_keccak);
|
|
||||||
sph_keccak512 (&ctx_keccak, static_cast<const void*>(&hash[4]), 64);
|
|
||||||
sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash[5]));
|
|
||||||
|
|
||||||
sph_luffa512_init(&ctx_luffa);
|
|
||||||
sph_luffa512 (&ctx_luffa, static_cast<void*>(&hash[5]), 64);
|
|
||||||
sph_luffa512_close(&ctx_luffa, static_cast<void*>(&hash[6]));
|
|
||||||
|
|
||||||
sph_cubehash512_init(&ctx_cubehash);
|
|
||||||
sph_cubehash512 (&ctx_cubehash, static_cast<const void*>(&hash[6]), 64);
|
|
||||||
sph_cubehash512_close(&ctx_cubehash, static_cast<void*>(&hash[7]));
|
|
||||||
|
|
||||||
sph_shavite512_init(&ctx_shavite);
|
|
||||||
sph_shavite512(&ctx_shavite, static_cast<const void*>(&hash[7]), 64);
|
|
||||||
sph_shavite512_close(&ctx_shavite, static_cast<void*>(&hash[8]));
|
|
||||||
|
|
||||||
sph_simd512_init(&ctx_simd);
|
|
||||||
sph_simd512 (&ctx_simd, static_cast<const void*>(&hash[8]), 64);
|
|
||||||
sph_simd512_close(&ctx_simd, static_cast<void*>(&hash[9]));
|
|
||||||
|
|
||||||
sph_echo512_init(&ctx_echo);
|
|
||||||
sph_echo512 (&ctx_echo, static_cast<const void*>(&hash[9]), 64);
|
|
||||||
sph_echo512_close(&ctx_echo, static_cast<void*>(&hash[10]));
|
|
||||||
|
|
||||||
return hash[10].trim256();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // BITCOIN_HASH_H
|
#endif // BITCOIN_HASH_H
|
||||||
|
91
src/hash_x11.h
Normal file
91
src/hash_x11.h
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// Copyright (c) 2014-2023 The Dash Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#ifndef BITCOIN_HASH_X11_H
|
||||||
|
#define BITCOIN_HASH_X11_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <crypto/x11/sph_blake.h>
|
||||||
|
#include <crypto/x11/sph_bmw.h>
|
||||||
|
#include <crypto/x11/sph_groestl.h>
|
||||||
|
#include <crypto/x11/sph_jh.h>
|
||||||
|
#include <crypto/x11/sph_keccak.h>
|
||||||
|
#include <crypto/x11/sph_skein.h>
|
||||||
|
#include <crypto/x11/sph_luffa.h>
|
||||||
|
#include <crypto/x11/sph_cubehash.h>
|
||||||
|
#include <crypto/x11/sph_shavite.h>
|
||||||
|
#include <crypto/x11/sph_simd.h>
|
||||||
|
#include <crypto/x11/sph_echo.h>
|
||||||
|
|
||||||
|
#include <uint256.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------- Dash Hash ------------------------------------------------ */
|
||||||
|
template<typename T1>
|
||||||
|
inline uint256 HashX11(const T1 pbegin, const T1 pend)
|
||||||
|
|
||||||
|
{
|
||||||
|
sph_blake512_context ctx_blake;
|
||||||
|
sph_bmw512_context ctx_bmw;
|
||||||
|
sph_groestl512_context ctx_groestl;
|
||||||
|
sph_jh512_context ctx_jh;
|
||||||
|
sph_keccak512_context ctx_keccak;
|
||||||
|
sph_skein512_context ctx_skein;
|
||||||
|
sph_luffa512_context ctx_luffa;
|
||||||
|
sph_cubehash512_context ctx_cubehash;
|
||||||
|
sph_shavite512_context ctx_shavite;
|
||||||
|
sph_simd512_context ctx_simd;
|
||||||
|
sph_echo512_context ctx_echo;
|
||||||
|
static unsigned char pblank[1];
|
||||||
|
|
||||||
|
uint512 hash[11];
|
||||||
|
|
||||||
|
sph_blake512_init(&ctx_blake);
|
||||||
|
sph_blake512 (&ctx_blake, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0])), (pend - pbegin) * sizeof(pbegin[0]));
|
||||||
|
sph_blake512_close(&ctx_blake, static_cast<void*>(&hash[0]));
|
||||||
|
|
||||||
|
sph_bmw512_init(&ctx_bmw);
|
||||||
|
sph_bmw512 (&ctx_bmw, static_cast<const void*>(&hash[0]), 64);
|
||||||
|
sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash[1]));
|
||||||
|
|
||||||
|
sph_groestl512_init(&ctx_groestl);
|
||||||
|
sph_groestl512 (&ctx_groestl, static_cast<const void*>(&hash[1]), 64);
|
||||||
|
sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash[2]));
|
||||||
|
|
||||||
|
sph_skein512_init(&ctx_skein);
|
||||||
|
sph_skein512 (&ctx_skein, static_cast<const void*>(&hash[2]), 64);
|
||||||
|
sph_skein512_close(&ctx_skein, static_cast<void*>(&hash[3]));
|
||||||
|
|
||||||
|
sph_jh512_init(&ctx_jh);
|
||||||
|
sph_jh512 (&ctx_jh, static_cast<const void*>(&hash[3]), 64);
|
||||||
|
sph_jh512_close(&ctx_jh, static_cast<void*>(&hash[4]));
|
||||||
|
|
||||||
|
sph_keccak512_init(&ctx_keccak);
|
||||||
|
sph_keccak512 (&ctx_keccak, static_cast<const void*>(&hash[4]), 64);
|
||||||
|
sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash[5]));
|
||||||
|
|
||||||
|
sph_luffa512_init(&ctx_luffa);
|
||||||
|
sph_luffa512 (&ctx_luffa, static_cast<void*>(&hash[5]), 64);
|
||||||
|
sph_luffa512_close(&ctx_luffa, static_cast<void*>(&hash[6]));
|
||||||
|
|
||||||
|
sph_cubehash512_init(&ctx_cubehash);
|
||||||
|
sph_cubehash512 (&ctx_cubehash, static_cast<const void*>(&hash[6]), 64);
|
||||||
|
sph_cubehash512_close(&ctx_cubehash, static_cast<void*>(&hash[7]));
|
||||||
|
|
||||||
|
sph_shavite512_init(&ctx_shavite);
|
||||||
|
sph_shavite512(&ctx_shavite, static_cast<const void*>(&hash[7]), 64);
|
||||||
|
sph_shavite512_close(&ctx_shavite, static_cast<void*>(&hash[8]));
|
||||||
|
|
||||||
|
sph_simd512_init(&ctx_simd);
|
||||||
|
sph_simd512 (&ctx_simd, static_cast<const void*>(&hash[8]), 64);
|
||||||
|
sph_simd512_close(&ctx_simd, static_cast<void*>(&hash[9]));
|
||||||
|
|
||||||
|
sph_echo512_init(&ctx_echo);
|
||||||
|
sph_echo512 (&ctx_echo, static_cast<const void*>(&hash[9]), 64);
|
||||||
|
sph_echo512_close(&ctx_echo, static_cast<void*>(&hash[10]));
|
||||||
|
|
||||||
|
return hash[10].trim256();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BITCOIN_HASH_X11_H
|
@ -6,6 +6,7 @@
|
|||||||
#include <primitives/block.h>
|
#include <primitives/block.h>
|
||||||
|
|
||||||
#include <hash.h>
|
#include <hash.h>
|
||||||
|
#include <hash_x11.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
#include <tinyformat.h>
|
#include <tinyformat.h>
|
||||||
|
|
||||||
|
@ -45,3 +45,4 @@ src/util/ranges_set.*
|
|||||||
src/util/wpipe.*
|
src/util/wpipe.*
|
||||||
src/wallet/bip39*
|
src/wallet/bip39*
|
||||||
src/wallet/hdchain.*
|
src/wallet/hdchain.*
|
||||||
|
src/hash_x11.h
|
||||||
|
Loading…
Reference in New Issue
Block a user