forked from gridcoin/Gridcoin-master
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhashqubit.h
63 lines (48 loc) · 1.87 KB
/
hashqubit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef HASH_QUBIT
#define HASH_QUBIT
#include "uint256.h"
#include "serialize.h"
#include "sph_luffa.h"
#include "sph_cubehash.h"
#include "sph_shavite.h"
#include "sph_simd.h"
#include "sph_echo.h"
#include <openssl/sha.h>
#include <openssl/ripemd.h>
#include <vector>
template<typename T1>
inline uint256 HashQubit(const T1 pbegin, const T1 pend)
{
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];
#ifndef QT_NO_DEBUG
//std::string strhash;
//strhash = "";
#endif
uint512 hash[5];
sph_luffa512_init(&ctx_luffa);
sph_luffa512 (&ctx_luffa, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0])), (pend - pbegin) * sizeof(pbegin[0]));
sph_luffa512_close(&ctx_luffa, static_cast<void*>(&hash[0]));
sph_cubehash512_init(&ctx_cubehash);
sph_cubehash512 (&ctx_cubehash, static_cast<const void*>(&hash[0]), 64);
sph_cubehash512_close(&ctx_cubehash, static_cast<void*>(&hash[1]));
sph_shavite512_init(&ctx_shavite);
sph_shavite512(&ctx_shavite, static_cast<const void*>(&hash[1]), 64);
sph_shavite512_close(&ctx_shavite, static_cast<void*>(&hash[2]));
sph_simd512_init(&ctx_simd);
sph_simd512 (&ctx_simd, static_cast<const void*>(&hash[2]), 64);
sph_simd512_close(&ctx_simd, static_cast<void*>(&hash[3]));
sph_echo512_init(&ctx_echo);
sph_echo512 (&ctx_echo, static_cast<const void*>(&hash[3]), 64);
sph_echo512_close(&ctx_echo, static_cast<void*>(&hash[4]));
return hash[4].trim256();
}
#endif