Hush Full Node software. We were censored from Github, this is where all development happens now.
https://hush.is
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
54 lines
1.3 KiB
// (C) 2018 The Verus Developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
/*
|
|
This provides the PoW hash function for Verus, enabling CPU mining.
|
|
*/
|
|
#ifndef VERUS_HASH_H_
|
|
#define VERUS_HASH_H_
|
|
|
|
#include <cstring>
|
|
#include <vector>
|
|
|
|
extern "C"
|
|
{
|
|
#include "crypto/haraka.h"
|
|
}
|
|
|
|
class CVerusHash
|
|
{
|
|
public:
|
|
static void Hash(void *result, const void *data, size_t len);
|
|
|
|
CVerusHash() {}
|
|
|
|
CVerusHash &Write(const unsigned char *data, size_t len);
|
|
|
|
CVerusHash &Reset()
|
|
{
|
|
curBuf = buf1;
|
|
result = buf2;
|
|
curPos = 0;
|
|
std::fill(buf1, buf1 + sizeof(buf1), 0);
|
|
std::fill(buf2, buf2 + sizeof(buf2), 0);
|
|
}
|
|
|
|
void Finalize(unsigned char hash[32])
|
|
{
|
|
if (curPos)
|
|
{
|
|
std::fill(curBuf + 32 + curPos, curBuf + 64, 0);
|
|
haraka512(hash, curBuf);
|
|
}
|
|
else
|
|
std::memcpy(hash, result, 32);
|
|
}
|
|
|
|
private:
|
|
unsigned char buf1[64], buf2[64];
|
|
unsigned char *curBuf = buf1, *result = buf2;
|
|
size_t curPos = 0;
|
|
};
|
|
|
|
#endif
|
|
|