mirror of
https://github.com/JayDDee/cpuminer-opt.git
synced 2025-09-17 23:44:27 +00:00
v3.7.8
This commit is contained in:
438
algo/x17/hmq1725.c
Normal file
438
algo/x17/hmq1725.c
Normal file
@@ -0,0 +1,438 @@
|
||||
#include "algo-gate-api.h"
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "algo/blake/sph_blake.h"
|
||||
#include "algo/bmw/sph_bmw.h"
|
||||
#include "algo/groestl/sph_groestl.h"
|
||||
#include "algo/jh/sph_jh.h"
|
||||
#include "algo/keccak/sph_keccak.h"
|
||||
#include "algo/skein/sph_skein.h"
|
||||
#include "algo/luffa/sph_luffa.h"
|
||||
#include "algo/cubehash/sph_cubehash.h"
|
||||
#include "algo/shavite/sph_shavite.h"
|
||||
#include "algo/simd/sph_simd.h"
|
||||
#include "algo/echo/sph_echo.h"
|
||||
#include "algo/hamsi/sph_hamsi.h"
|
||||
#include "algo/fugue/sph_fugue.h"
|
||||
#include "algo/shabal/sph_shabal.h"
|
||||
#include "algo/whirlpool/sph_whirlpool.h"
|
||||
#include "algo/sha/sph_sha2.h"
|
||||
#include "algo/haval/sph-haval.h"
|
||||
#include <openssl/sha.h>
|
||||
#ifndef NO_AES_NI
|
||||
#include "algo/groestl/aes_ni/hash-groestl.h"
|
||||
#include "algo/echo/aes_ni/hash_api.h"
|
||||
#endif
|
||||
#include "algo/luffa/sse2/luffa_for_sse2.h"
|
||||
#include "algo/cubehash/sse2/cubehash_sse2.h"
|
||||
#include "algo/simd/sse2/nist.h"
|
||||
#include "algo/jh/sse2/jh_sse2_opt64.h"
|
||||
|
||||
typedef struct {
|
||||
sph_blake512_context blake1, blake2;
|
||||
sph_bmw512_context bmw1, bmw2, bmw3;
|
||||
sph_skein512_context skein1, skein2;
|
||||
sph_jh512_context jh1, jh2;
|
||||
sph_keccak512_context keccak1, keccak2;
|
||||
hashState_luffa luffa1, luffa2;
|
||||
cubehashParam cube;
|
||||
sph_shavite512_context shavite1, shavite2;
|
||||
hashState_sd simd1, simd2;
|
||||
sph_hamsi512_context hamsi1;
|
||||
sph_fugue512_context fugue1, fugue2;
|
||||
sph_shabal512_context shabal1;
|
||||
sph_whirlpool_context whirlpool1, whirlpool2, whirlpool3, whirlpool4;
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA512_CTX sha1, sha2;
|
||||
#else
|
||||
sph_sha512_context sha1, sha2;
|
||||
#endif
|
||||
sph_haval256_5_context haval1, haval2;
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512_context groestl1, groestl2;
|
||||
sph_echo512_context echo1, echo2;
|
||||
#else
|
||||
hashState_echo echo1, echo2;
|
||||
hashState_groestl groestl1, groestl2;
|
||||
#endif
|
||||
} hmq1725_ctx_holder;
|
||||
|
||||
static hmq1725_ctx_holder hmq1725_ctx __attribute__ ((aligned (64)));
|
||||
static __thread sph_bmw512_context hmq_bmw_mid __attribute__ ((aligned (64)));
|
||||
|
||||
void init_hmq1725_ctx()
|
||||
{
|
||||
sph_blake512_init(&hmq1725_ctx.blake1);
|
||||
sph_blake512_init(&hmq1725_ctx.blake2);
|
||||
|
||||
sph_bmw512_init(&hmq1725_ctx.bmw1);
|
||||
sph_bmw512_init(&hmq1725_ctx.bmw2);
|
||||
sph_bmw512_init(&hmq1725_ctx.bmw3);
|
||||
|
||||
sph_skein512_init(&hmq1725_ctx.skein1);
|
||||
sph_skein512_init(&hmq1725_ctx.skein2);
|
||||
|
||||
sph_jh512_init(&hmq1725_ctx.jh1);
|
||||
sph_jh512_init(&hmq1725_ctx.jh2);
|
||||
|
||||
sph_keccak512_init(&hmq1725_ctx.keccak1);
|
||||
sph_keccak512_init(&hmq1725_ctx.keccak2);
|
||||
|
||||
init_luffa( &hmq1725_ctx.luffa1, 512 );
|
||||
init_luffa( &hmq1725_ctx.luffa2, 512 );
|
||||
|
||||
cubehashInit( &hmq1725_ctx.cube, 512, 16, 32 );
|
||||
|
||||
sph_shavite512_init(&hmq1725_ctx.shavite1);
|
||||
sph_shavite512_init(&hmq1725_ctx.shavite2);
|
||||
|
||||
init_sd( &hmq1725_ctx.simd1, 512 );
|
||||
init_sd( &hmq1725_ctx.simd2, 512 );
|
||||
|
||||
sph_hamsi512_init(&hmq1725_ctx.hamsi1);
|
||||
|
||||
sph_fugue512_init(&hmq1725_ctx.fugue1);
|
||||
sph_fugue512_init(&hmq1725_ctx.fugue2);
|
||||
|
||||
sph_shabal512_init(&hmq1725_ctx.shabal1);
|
||||
|
||||
sph_whirlpool_init(&hmq1725_ctx.whirlpool1);
|
||||
sph_whirlpool_init(&hmq1725_ctx.whirlpool2);
|
||||
sph_whirlpool_init(&hmq1725_ctx.whirlpool3);
|
||||
sph_whirlpool_init(&hmq1725_ctx.whirlpool4);
|
||||
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA512_Init( &hmq1725_ctx.sha1 );
|
||||
SHA512_Init( &hmq1725_ctx.sha2 );
|
||||
#else
|
||||
sph_sha512_init(&hmq1725_ctx.sha1);
|
||||
sph_sha512_init(&hmq1725_ctx.sha2);
|
||||
#endif
|
||||
sph_haval256_5_init(&hmq1725_ctx.haval1);
|
||||
sph_haval256_5_init(&hmq1725_ctx.haval2);
|
||||
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512_init( &hmq1725_ctx.groestl1 );
|
||||
sph_groestl512_init( &hmq1725_ctx.groestl2 );
|
||||
sph_echo512_init( &hmq1725_ctx.echo1 );
|
||||
sph_echo512_init( &hmq1725_ctx.echo2 );
|
||||
#else
|
||||
init_echo( &hmq1725_ctx.echo1, 512 );
|
||||
init_echo( &hmq1725_ctx.echo2, 512 );
|
||||
init_groestl( &hmq1725_ctx.groestl1, 64 );
|
||||
init_groestl( &hmq1725_ctx.groestl2, 64 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void hmq_bmw512_midstate( const void* input )
|
||||
{
|
||||
memcpy( &hmq_bmw_mid, &hmq1725_ctx.bmw1, sizeof hmq_bmw_mid );
|
||||
sph_bmw512( &hmq_bmw_mid, input, 64 );
|
||||
}
|
||||
|
||||
__thread hmq1725_ctx_holder h_ctx __attribute__ ((aligned (64)));
|
||||
|
||||
extern void hmq1725hash(void *state, const void *input)
|
||||
{
|
||||
const uint32_t mask = 24;
|
||||
uint32_t hashA[32] __attribute__((aligned(64)));
|
||||
uint32_t hashB[32] __attribute__((aligned(64)));
|
||||
const int midlen = 64; // bytes
|
||||
const int tail = 80 - midlen; // 16
|
||||
|
||||
memcpy(&h_ctx, &hmq1725_ctx, sizeof(hmq1725_ctx));
|
||||
|
||||
memcpy( &h_ctx.bmw1, &hmq_bmw_mid, sizeof hmq_bmw_mid );
|
||||
sph_bmw512( &h_ctx.bmw1, input + midlen, tail );
|
||||
sph_bmw512_close(&h_ctx.bmw1, hashA); //1
|
||||
|
||||
sph_whirlpool (&h_ctx.whirlpool1, hashA, 64); //0
|
||||
sph_whirlpool_close(&h_ctx.whirlpool1, hashB); //1
|
||||
|
||||
if ( hashB[0] & mask ) //1
|
||||
{
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512 (&h_ctx.groestl1, hashB, 64); //1
|
||||
sph_groestl512_close(&h_ctx.groestl1, hashA); //2
|
||||
#else
|
||||
update_and_final_groestl( &h_ctx.groestl1, (char*)hashA,
|
||||
(const char*)hashB, 512 );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
sph_skein512 (&h_ctx.skein1, hashB, 64); //1
|
||||
sph_skein512_close(&h_ctx.skein1, hashA); //2
|
||||
}
|
||||
|
||||
sph_jh512 (&h_ctx.jh1, hashA, 64); //3
|
||||
sph_jh512_close(&h_ctx.jh1, hashB); //4
|
||||
|
||||
sph_keccak512 (&h_ctx.keccak1, hashB, 64); //2
|
||||
sph_keccak512_close(&h_ctx.keccak1, hashA); //3
|
||||
|
||||
if ( hashA[0] & mask ) //4
|
||||
{
|
||||
sph_blake512 (&h_ctx.blake1, hashA, 64); //
|
||||
sph_blake512_close(&h_ctx.blake1, hashB); //5
|
||||
}
|
||||
else
|
||||
{
|
||||
sph_bmw512 (&h_ctx.bmw2, hashA, 64); //4
|
||||
sph_bmw512_close(&h_ctx.bmw2, hashB); //5
|
||||
}
|
||||
|
||||
update_and_final_luffa( &h_ctx.luffa1, (BitSequence*)hashA,
|
||||
(const BitSequence*)hashB, 64 );
|
||||
|
||||
cubehashUpdateDigest( &h_ctx.cube, (BitSequence *)hashB,
|
||||
(const BitSequence *)hashA, 64 );
|
||||
|
||||
if ( hashB[0] & mask ) //7
|
||||
{
|
||||
sph_keccak512 (&h_ctx.keccak2, hashB, 64); //
|
||||
sph_keccak512_close(&h_ctx.keccak2, hashA); //8
|
||||
}
|
||||
else
|
||||
{
|
||||
sph_jh512 (&h_ctx.jh2, hashB, 64); //7
|
||||
sph_jh512_close(&h_ctx.jh2, hashA); //8
|
||||
}
|
||||
|
||||
sph_shavite512 (&h_ctx.shavite1, hashA, 64); //3
|
||||
sph_shavite512_close(&h_ctx.shavite1, hashB); //4
|
||||
|
||||
update_final_sd( &h_ctx.simd1, (BitSequence *)hashA,
|
||||
(const BitSequence *)hashB, 512 );
|
||||
|
||||
if ( hashA[0] & mask ) //4
|
||||
{
|
||||
sph_whirlpool (&h_ctx.whirlpool2, hashA, 64); //
|
||||
sph_whirlpool_close(&h_ctx.whirlpool2, hashB); //5
|
||||
}
|
||||
else
|
||||
{
|
||||
sph_haval256_5 (&h_ctx.haval1, hashA, 64); //4
|
||||
sph_haval256_5_close(&h_ctx.haval1, hashB); //5
|
||||
memset(&hashB[8], 0, 32);
|
||||
}
|
||||
|
||||
#ifdef NO_AES_NI
|
||||
sph_echo512 (&h_ctx.echo1, hashB, 64); //5
|
||||
sph_echo512_close(&h_ctx.echo1, hashA); //6
|
||||
#else
|
||||
update_final_echo ( &h_ctx.echo1, (BitSequence *)hashA,
|
||||
(const BitSequence *)hashB, 512 );
|
||||
#endif
|
||||
|
||||
sph_blake512 (&h_ctx.blake2, hashA, 64); //6
|
||||
sph_blake512_close(&h_ctx.blake2, hashB); //7
|
||||
|
||||
if ( hashB[0] & mask ) //7
|
||||
{
|
||||
sph_shavite512 (&h_ctx.shavite2, hashB, 64); //
|
||||
sph_shavite512_close(&h_ctx.shavite2, hashA); //8
|
||||
}
|
||||
else
|
||||
{
|
||||
update_and_final_luffa( &h_ctx.luffa2, (BitSequence *)hashA,
|
||||
(const BitSequence *)hashB, 64 );
|
||||
}
|
||||
|
||||
sph_hamsi512 (&h_ctx.hamsi1, hashA, 64); //3
|
||||
sph_hamsi512_close(&h_ctx.hamsi1, hashB); //4
|
||||
|
||||
sph_fugue512 (&h_ctx.fugue1, hashB, 64); //2 ////
|
||||
sph_fugue512_close(&h_ctx.fugue1, hashA); //3
|
||||
|
||||
if ( hashA[0] & mask ) //4
|
||||
{
|
||||
#ifdef NO_AES_NI
|
||||
sph_echo512 (&h_ctx.echo2, hashA, 64); //
|
||||
sph_echo512_close(&h_ctx.echo2, hashB); //5
|
||||
#else
|
||||
update_final_echo ( &h_ctx.echo2, (BitSequence *)hashB,
|
||||
(const BitSequence *)hashA, 512 );
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
update_final_sd( &h_ctx.simd2, (BitSequence *)hashB,
|
||||
(const BitSequence *)hashA, 512 );
|
||||
}
|
||||
|
||||
sph_shabal512 (&h_ctx.shabal1, hashB, 64); //5
|
||||
sph_shabal512_close(&h_ctx.shabal1, hashA); //6
|
||||
|
||||
sph_whirlpool (&h_ctx.whirlpool3, hashA, 64); //6
|
||||
sph_whirlpool_close(&h_ctx.whirlpool3, hashB); //7
|
||||
|
||||
if ( hashB[0] & mask ) //7
|
||||
{
|
||||
sph_fugue512 (&h_ctx.fugue2, hashB, 64); //
|
||||
sph_fugue512_close(&h_ctx.fugue2, hashA); //8
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA512_Update( &h_ctx.sha1, hashB, 64 );
|
||||
SHA512_Final( (unsigned char*) hashA, &h_ctx.sha1 );
|
||||
#else
|
||||
sph_sha512 (&h_ctx.sha1, hashB, 64); //7
|
||||
sph_sha512_close(&h_ctx.sha1, hashA); //8
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512 (&h_ctx.groestl2, hashA, 64); //3
|
||||
sph_groestl512_close(&h_ctx.groestl2, hashB); //4
|
||||
#else
|
||||
update_and_final_groestl( &h_ctx.groestl2, (char*)hashB,
|
||||
(const char*)hashA, 512 );
|
||||
#endif
|
||||
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA512_Update( &h_ctx.sha2, hashB, 64 );
|
||||
SHA512_Final( (unsigned char*) hashA, &h_ctx.sha2 );
|
||||
#else
|
||||
sph_sha512 (&h_ctx.sha2, hashB, 64); //2
|
||||
sph_sha512_close(&h_ctx.sha2, hashA); //3
|
||||
#endif
|
||||
|
||||
if ( hashA[0] & mask ) //4
|
||||
{
|
||||
sph_haval256_5 (&h_ctx.haval2, hashA, 64); //
|
||||
sph_haval256_5_close(&h_ctx.haval2, hashB); //5
|
||||
memset(&hashB[8], 0, 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
sph_whirlpool (&h_ctx.whirlpool4, hashA, 64); //4
|
||||
sph_whirlpool_close(&h_ctx.whirlpool4, hashB); //5
|
||||
}
|
||||
|
||||
sph_bmw512 (&h_ctx.bmw3, hashB, 64); //5
|
||||
sph_bmw512_close(&h_ctx.bmw3, hashA); //6
|
||||
|
||||
memcpy(state, hashA, 32);
|
||||
}
|
||||
|
||||
int scanhash_hmq1725( int thr_id, struct work *work, int32_t max_nonce,
|
||||
uint64_t *hashes_done )
|
||||
{
|
||||
uint32_t endiandata[32] __attribute__((aligned(64)));
|
||||
uint32_t hash64[8] __attribute__((aligned(64)));
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
uint32_t n = pdata[19] - 1;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
//const uint32_t Htarg = ptarget[7];
|
||||
|
||||
//we need bigendian data...
|
||||
for (int k = 0; k < 32; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
hmq_bmw512_midstate( endiandata );
|
||||
|
||||
// if (opt_debug)
|
||||
// {
|
||||
// applog(LOG_DEBUG, "Thr: %02d, firstN: %08x, maxN: %08x, ToDo: %d", thr_id, first_nonce, max_nonce, max_nonce-first_nonce);
|
||||
// }
|
||||
|
||||
/* I'm to lazy to put the loop in an inline function... so dirty copy'n'paste.... */
|
||||
/* i know that i could set a variable, but i don't know how the compiler will optimize it, not that then the cpu needs to load the value *everytime* in a register */
|
||||
if (ptarget[7]==0) {
|
||||
do {
|
||||
pdata[19] = ++n;
|
||||
be32enc(&endiandata[19], n);
|
||||
hmq1725hash(hash64, endiandata);
|
||||
if (((hash64[7]&0xFFFFFFFF)==0) &&
|
||||
fulltest(hash64, ptarget)) {
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
return true;
|
||||
}
|
||||
} while (n < max_nonce && !work_restart[thr_id].restart);
|
||||
}
|
||||
else if (ptarget[7]<=0xF)
|
||||
{
|
||||
do {
|
||||
pdata[19] = ++n;
|
||||
be32enc(&endiandata[19], n);
|
||||
hmq1725hash(hash64, endiandata);
|
||||
if (((hash64[7]&0xFFFFFFF0)==0) &&
|
||||
fulltest(hash64, ptarget)) {
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
return true;
|
||||
}
|
||||
} while (n < max_nonce && !work_restart[thr_id].restart);
|
||||
}
|
||||
else if (ptarget[7]<=0xFF)
|
||||
{
|
||||
do {
|
||||
pdata[19] = ++n;
|
||||
be32enc(&endiandata[19], n);
|
||||
hmq1725hash(hash64, endiandata);
|
||||
if (((hash64[7]&0xFFFFFF00)==0) &&
|
||||
fulltest(hash64, ptarget)) {
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
return true;
|
||||
}
|
||||
} while (n < max_nonce && !work_restart[thr_id].restart);
|
||||
}
|
||||
else if (ptarget[7]<=0xFFF)
|
||||
{
|
||||
do {
|
||||
pdata[19] = ++n;
|
||||
be32enc(&endiandata[19], n);
|
||||
hmq1725hash(hash64, endiandata);
|
||||
if (((hash64[7]&0xFFFFF000)==0) &&
|
||||
fulltest(hash64, ptarget)) {
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
return true;
|
||||
}
|
||||
} while (n < max_nonce && !work_restart[thr_id].restart);
|
||||
|
||||
}
|
||||
else if (ptarget[7]<=0xFFFF)
|
||||
{
|
||||
do {
|
||||
pdata[19] = ++n;
|
||||
be32enc(&endiandata[19], n);
|
||||
hmq1725hash(hash64, endiandata);
|
||||
if (((hash64[7]&0xFFFF0000)==0) &&
|
||||
fulltest(hash64, ptarget)) {
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
return true;
|
||||
}
|
||||
} while (n < max_nonce && !work_restart[thr_id].restart);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
do {
|
||||
pdata[19] = ++n;
|
||||
be32enc(&endiandata[19], n);
|
||||
hmq1725hash(hash64, endiandata);
|
||||
if (fulltest(hash64, ptarget)) {
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
return true;
|
||||
}
|
||||
} while (n < max_nonce && !work_restart[thr_id].restart);
|
||||
}
|
||||
|
||||
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
pdata[19] = n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool register_hmq1725_algo( algo_gate_t* gate )
|
||||
{
|
||||
init_hmq1725_ctx();
|
||||
gate->optimizations = SSE2_OPT | AES_OPT | AVX_OPT | AVX2_OPT | SHA_OPT;
|
||||
gate->set_target = (void*)&scrypt_set_target;
|
||||
gate->scanhash = (void*)&scanhash_hmq1725;
|
||||
gate->hash = (void*)&hmq1725hash;
|
||||
return true;
|
||||
};
|
||||
|
||||
364
algo/x17/x17-4way.c
Normal file
364
algo/x17/x17-4way.c
Normal file
@@ -0,0 +1,364 @@
|
||||
#include "x17-gate.h"
|
||||
|
||||
#if defined(__AVX2__) && defined(__AES__)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "algo/blake/blake-hash-4way.h"
|
||||
#include "algo/bmw/sph_bmw.h"
|
||||
#include "algo/groestl/aes_ni/hash-groestl.h"
|
||||
#include "algo/skein/skein-hash-4way.h"
|
||||
#include "algo/jh/jh-hash-4way.h"
|
||||
#include "algo/keccak/keccak-hash-4way.h"
|
||||
#include "algo/luffa/sse2/luffa_for_sse2.h"
|
||||
#include "algo/cubehash/sse2/cubehash_sse2.h"
|
||||
#include "algo/shavite/sph_shavite.h"
|
||||
#include "algo/simd/sse2/nist.h"
|
||||
#include "algo/echo/aes_ni/hash_api.h"
|
||||
#include "algo/echo/sph_echo.h"
|
||||
#include "algo/hamsi/sph_hamsi.h"
|
||||
#include "algo/fugue/sph_fugue.h"
|
||||
#include "algo/shabal/sph_shabal.h"
|
||||
#include "algo/whirlpool/sph_whirlpool.h"
|
||||
#include "algo/haval/sph-haval.h"
|
||||
#include <openssl/sha.h>
|
||||
|
||||
typedef struct {
|
||||
blake512_4way_context blake;
|
||||
sph_bmw512_context bmw;
|
||||
hashState_groestl groestl;
|
||||
skein512_4way_context skein;
|
||||
jh512_4way_context jh;
|
||||
keccak512_4way_context keccak;
|
||||
hashState_luffa luffa;
|
||||
cubehashParam cube;
|
||||
sph_shavite512_context shavite;
|
||||
hashState_sd simd;
|
||||
hashState_echo echo;
|
||||
sph_hamsi512_context hamsi;
|
||||
sph_fugue512_context fugue;
|
||||
sph_shabal512_context shabal;
|
||||
sph_whirlpool_context whirlpool;
|
||||
SHA512_CTX sha512;
|
||||
sph_haval256_5_context haval;
|
||||
} x17_4way_ctx_holder;
|
||||
|
||||
x17_4way_ctx_holder x17_4way_ctx __attribute__ ((aligned (64)));
|
||||
|
||||
void init_x17_4way_ctx()
|
||||
{
|
||||
blake512_4way_init( &x17_4way_ctx.blake );
|
||||
sph_bmw512_init( &x17_4way_ctx.bmw );
|
||||
init_groestl( &x17_4way_ctx.groestl, 64 );
|
||||
skein512_4way_init( &x17_4way_ctx.skein );
|
||||
jh512_4way_init( &x17_4way_ctx.jh );
|
||||
keccak512_4way_init( &x17_4way_ctx.keccak );
|
||||
init_luffa( &x17_4way_ctx.luffa, 512 );
|
||||
cubehashInit( &x17_4way_ctx.cube, 512, 16, 32 );
|
||||
sph_shavite512_init( &x17_4way_ctx.shavite );
|
||||
init_sd( &x17_4way_ctx.simd, 512 );
|
||||
init_echo( &x17_4way_ctx.echo, 512 );
|
||||
sph_hamsi512_init( &x17_4way_ctx.hamsi );
|
||||
sph_fugue512_init( &x17_4way_ctx.fugue );
|
||||
sph_shabal512_init( &x17_4way_ctx.shabal );
|
||||
sph_whirlpool_init( &x17_4way_ctx.whirlpool );
|
||||
SHA512_Init( &x17_4way_ctx.sha512 );
|
||||
sph_haval256_5_init( &x17_4way_ctx.haval );
|
||||
};
|
||||
|
||||
void x17_4way_hash( void *state, const void *input )
|
||||
{
|
||||
uint64_t hash0[8] __attribute__ ((aligned (64)));
|
||||
uint64_t hash1[8] __attribute__ ((aligned (64)));
|
||||
uint64_t hash2[8] __attribute__ ((aligned (64)));
|
||||
uint64_t hash3[8] __attribute__ ((aligned (64)));
|
||||
uint64_t vhash[8*4] __attribute__ ((aligned (64)));
|
||||
x17_4way_ctx_holder ctx;
|
||||
memcpy( &ctx, &x17_4way_ctx, sizeof(x17_4way_ctx) );
|
||||
|
||||
// 1 Blake
|
||||
blake512_4way( &ctx.blake, input, 80 );
|
||||
blake512_4way_close( &ctx.blake, vhash );
|
||||
|
||||
// Serial
|
||||
mm256_deinterleave_4x64( hash0, hash1, hash2, hash3, vhash, 512 );
|
||||
|
||||
// 2 Bmw
|
||||
sph_bmw512( &ctx.bmw, hash0, 64 );
|
||||
sph_bmw512_close( &ctx.bmw, hash0 );
|
||||
memcpy( &ctx.bmw, &x17_4way_ctx.bmw, sizeof(sph_bmw512_context) );
|
||||
sph_bmw512( &ctx.bmw, hash1, 64 );
|
||||
sph_bmw512_close( &ctx.bmw, hash1 );
|
||||
memcpy( &ctx.bmw, &x17_4way_ctx.bmw, sizeof(sph_bmw512_context) );
|
||||
sph_bmw512( &ctx.bmw, hash2, 64 );
|
||||
sph_bmw512_close( &ctx.bmw, hash2 );
|
||||
memcpy( &ctx.bmw, &x17_4way_ctx.bmw, sizeof(sph_bmw512_context) );
|
||||
sph_bmw512( &ctx.bmw, hash3, 64 );
|
||||
sph_bmw512_close( &ctx.bmw, hash3 );
|
||||
|
||||
// 3 Groestl
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash0, (char*)hash0, 512 );
|
||||
memcpy( &ctx.groestl, &x17_4way_ctx.groestl, sizeof(hashState_groestl) );
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash1, (char*)hash1, 512 );
|
||||
memcpy( &ctx.groestl, &x17_4way_ctx.groestl, sizeof(hashState_groestl) );
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash2, (char*)hash2, 512 );
|
||||
memcpy( &ctx.groestl, &x17_4way_ctx.groestl, sizeof(hashState_groestl) );
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash3, (char*)hash3, 512 );
|
||||
|
||||
// Parallel 4way
|
||||
mm256_interleave_4x64( vhash, hash0, hash1, hash2, hash3, 512 );
|
||||
|
||||
// 4 Skein
|
||||
skein512_4way( &ctx.skein, vhash, 64 );
|
||||
skein512_4way_close( &ctx.skein, vhash );
|
||||
|
||||
// 5 JH
|
||||
jh512_4way( &ctx.jh, vhash, 64 );
|
||||
jh512_4way_close( &ctx.jh, vhash );
|
||||
|
||||
// 6 Keccak
|
||||
keccak512_4way( &ctx.keccak, vhash, 64 );
|
||||
keccak512_4way_close( &ctx.keccak, vhash );
|
||||
|
||||
// Serial to the end
|
||||
mm256_deinterleave_4x64( hash0, hash1, hash2, hash3, vhash, 512 );
|
||||
|
||||
// 7 Luffa
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash0,
|
||||
(const BitSequence*)hash0, 64 );
|
||||
memcpy( &ctx.luffa, &x17_4way_ctx.luffa, sizeof(hashState_luffa) );
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash1,
|
||||
(const BitSequence*)hash1, 64 );
|
||||
memcpy( &ctx.luffa, &x17_4way_ctx.luffa, sizeof(hashState_luffa) );
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash2,
|
||||
(const BitSequence*)hash2, 64 );
|
||||
memcpy( &ctx.luffa, &x17_4way_ctx.luffa, sizeof(hashState_luffa) );
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash3,
|
||||
(const BitSequence*)hash3, 64 );
|
||||
|
||||
// 8 Cubehash
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash0, (const byte*) hash0, 64 );
|
||||
memcpy( &ctx.cube, &x17_4way_ctx.cube, sizeof(cubehashParam) );
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash1, (const byte*) hash1, 64 );
|
||||
memcpy( &ctx.cube, &x17_4way_ctx.cube, sizeof(cubehashParam) );
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash2, (const byte*) hash2, 64 );
|
||||
memcpy( &ctx.cube, &x17_4way_ctx.cube, sizeof(cubehashParam) );
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash3, (const byte*) hash3, 64 );
|
||||
|
||||
// 9 Shavite
|
||||
sph_shavite512( &ctx.shavite, hash0, 64 );
|
||||
sph_shavite512_close( &ctx.shavite, hash0 );
|
||||
memcpy( &ctx.shavite, &x17_4way_ctx.shavite,
|
||||
sizeof(sph_shavite512_context) );
|
||||
sph_shavite512( &ctx.shavite, hash1, 64 );
|
||||
sph_shavite512_close( &ctx.shavite, hash1 );
|
||||
memcpy( &ctx.shavite, &x17_4way_ctx.shavite,
|
||||
sizeof(sph_shavite512_context) );
|
||||
sph_shavite512( &ctx.shavite, hash2, 64 );
|
||||
sph_shavite512_close( &ctx.shavite, hash2 );
|
||||
memcpy( &ctx.shavite, &x17_4way_ctx.shavite,
|
||||
sizeof(sph_shavite512_context) );
|
||||
sph_shavite512( &ctx.shavite, hash3, 64 );
|
||||
sph_shavite512_close( &ctx.shavite, hash3 );
|
||||
|
||||
// 10 Simd
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash0,
|
||||
(const BitSequence *)hash0, 512 );
|
||||
memcpy( &ctx.simd, &x17_4way_ctx.simd, sizeof(hashState_sd) );
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash1,
|
||||
(const BitSequence *)hash1, 512 );
|
||||
memcpy( &ctx.simd, &x17_4way_ctx.simd, sizeof(hashState_sd) );
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash2,
|
||||
(const BitSequence *)hash2, 512 );
|
||||
memcpy( &ctx.simd, &x17_4way_ctx.simd, sizeof(hashState_sd) );
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash3,
|
||||
(const BitSequence *)hash3, 512 );
|
||||
|
||||
// 11 Echo
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash0,
|
||||
(const BitSequence *) hash0, 512 );
|
||||
memcpy( &ctx.echo, &x17_4way_ctx.echo, sizeof(hashState_echo) );
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash1,
|
||||
(const BitSequence *) hash1, 512 );
|
||||
memcpy( &ctx.echo, &x17_4way_ctx.echo, sizeof(hashState_echo) );
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash2,
|
||||
(const BitSequence *) hash2, 512 );
|
||||
memcpy( &ctx.echo, &x17_4way_ctx.echo, sizeof(hashState_echo) );
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash3,
|
||||
(const BitSequence *) hash3, 512 );
|
||||
|
||||
// 12 Hamsi
|
||||
sph_hamsi512( &ctx.hamsi, hash0, 64 );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash0 );
|
||||
memcpy( &ctx.hamsi, &x17_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
|
||||
sph_hamsi512( &ctx.hamsi, hash1, 64 );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash1 );
|
||||
memcpy( &ctx.hamsi, &x17_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
|
||||
sph_hamsi512( &ctx.hamsi, hash2, 64 );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash2 );
|
||||
memcpy( &ctx.hamsi, &x17_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
|
||||
sph_hamsi512( &ctx.hamsi, hash3, 64 );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash3 );
|
||||
|
||||
// 13 Fugue
|
||||
sph_fugue512( &ctx.fugue, hash0, 64 );
|
||||
sph_fugue512_close( &ctx.fugue, hash0 );
|
||||
memcpy( &ctx.fugue, &x17_4way_ctx.fugue, sizeof(sph_fugue512_context) );
|
||||
sph_fugue512( &ctx.fugue, hash1, 64 );
|
||||
sph_fugue512_close( &ctx.fugue, hash1 );
|
||||
memcpy( &ctx.fugue, &x17_4way_ctx.fugue, sizeof(sph_fugue512_context) );
|
||||
sph_fugue512( &ctx.fugue, hash2, 64 );
|
||||
sph_fugue512_close( &ctx.fugue, hash2 );
|
||||
memcpy( &ctx.fugue, &x17_4way_ctx.fugue, sizeof(sph_fugue512_context) );
|
||||
sph_fugue512( &ctx.fugue, hash3, 64 );
|
||||
sph_fugue512_close( &ctx.fugue, hash3 );
|
||||
|
||||
// 14 Shabal
|
||||
sph_shabal512( &ctx.shabal, hash0, 64 );
|
||||
sph_shabal512_close( &ctx.shabal, hash0 );
|
||||
memcpy( &ctx.shabal, &x17_4way_ctx.shabal, sizeof(sph_shabal512_context) );
|
||||
sph_shabal512( &ctx.shabal, hash1, 64 );
|
||||
sph_shabal512_close( &ctx.shabal, hash1 );
|
||||
memcpy( &ctx.shabal, &x17_4way_ctx.shabal, sizeof(sph_shabal512_context) );
|
||||
sph_shabal512( &ctx.shabal, hash2, 64 );
|
||||
sph_shabal512_close( &ctx.shabal, hash2 );
|
||||
memcpy( &ctx.shabal, &x17_4way_ctx.shabal, sizeof(sph_shabal512_context) );
|
||||
sph_shabal512( &ctx.shabal, hash3, 64 );
|
||||
sph_shabal512_close( &ctx.shabal, hash3 );
|
||||
|
||||
// 15 Whirlpool
|
||||
sph_whirlpool( &ctx.whirlpool, hash0, 64 );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash0 );
|
||||
memcpy( &ctx.whirlpool, &x17_4way_ctx.whirlpool,
|
||||
sizeof(sph_whirlpool_context) );
|
||||
sph_whirlpool( &ctx.whirlpool, hash1, 64 );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash1 );
|
||||
memcpy( &ctx.whirlpool, &x17_4way_ctx.whirlpool,
|
||||
sizeof(sph_whirlpool_context) );
|
||||
sph_whirlpool( &ctx.whirlpool, hash2, 64 );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash2 );
|
||||
memcpy( &ctx.whirlpool, &x17_4way_ctx.whirlpool,
|
||||
sizeof(sph_whirlpool_context) );
|
||||
sph_whirlpool( &ctx.whirlpool, hash3, 64 );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash3 );
|
||||
|
||||
// 16 SHA512
|
||||
SHA512_Update( &ctx.sha512, hash0, 64 );
|
||||
SHA512_Final( (unsigned char*)hash0, &ctx.sha512 );
|
||||
memcpy( &ctx.sha512, &x17_4way_ctx.sha512, sizeof(SHA512_CTX) );
|
||||
SHA512_Update( &ctx.sha512, hash1, 64 );
|
||||
SHA512_Final( (unsigned char*)hash1, &ctx.sha512 );
|
||||
memcpy( &ctx.sha512, &x17_4way_ctx.sha512, sizeof(SHA512_CTX) );
|
||||
SHA512_Update( &ctx.sha512, hash2, 64 );
|
||||
SHA512_Final( (unsigned char*)hash2, &ctx.sha512 );
|
||||
memcpy( &ctx.sha512, &x17_4way_ctx.sha512, sizeof(SHA512_CTX) );
|
||||
SHA512_Update( &ctx.sha512, hash3, 64 );
|
||||
SHA512_Final( (unsigned char*)hash3, &ctx.sha512 );
|
||||
|
||||
// 17 Haval
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash0, 64 );
|
||||
sph_haval256_5_close( &ctx.haval, hash0 );
|
||||
memcpy( &ctx.haval, &x17_4way_ctx.haval,
|
||||
sizeof(sph_haval256_5_context) );
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash1, 64 );
|
||||
sph_haval256_5_close( &ctx.haval, hash1 );
|
||||
memcpy( &ctx.haval, &x17_4way_ctx.haval,
|
||||
sizeof(sph_haval256_5_context) );
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash2, 64 );
|
||||
sph_haval256_5_close( &ctx.haval, hash2 );
|
||||
memcpy( &ctx.haval, &x17_4way_ctx.haval,
|
||||
sizeof(sph_haval256_5_context) );
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash3, 64 );
|
||||
sph_haval256_5_close( &ctx.haval, hash3 );
|
||||
|
||||
memcpy( state, hash0, 32 );
|
||||
memcpy( state+32, hash1, 32 );
|
||||
memcpy( state+64, hash2, 32 );
|
||||
memcpy( state+96, hash3, 32 );
|
||||
}
|
||||
|
||||
int scanhash_x17_4way( int thr_id, struct work *work, uint32_t max_nonce,
|
||||
uint64_t *hashes_done )
|
||||
{
|
||||
uint32_t hash[4*8] __attribute__ ((aligned (64)));
|
||||
uint32_t vdata[24*4] __attribute__ ((aligned (64)));
|
||||
uint32_t endiandata[20] __attribute__((aligned(64)));
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
uint32_t n = pdata[19];
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
uint32_t *nonces = work->nonces;
|
||||
bool *found = work->nfound;
|
||||
int num_found = 0;
|
||||
uint32_t *noncep0 = vdata + 73; // 9*8 + 1
|
||||
uint32_t *noncep1 = vdata + 75;
|
||||
uint32_t *noncep2 = vdata + 77;
|
||||
uint32_t *noncep3 = vdata + 79;
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint64_t htmax[] = { 0, 0xF, 0xFF,
|
||||
0xFFF, 0xFFFF, 0x10000000 };
|
||||
uint32_t masks[] = { 0xFFFFFFFF, 0xFFFFFFF0, 0xFFFFFF00,
|
||||
0xFFFFF000, 0xFFFF0000, 0 };
|
||||
|
||||
// big endian encode 0..18 uint32_t, 64 bits at a time
|
||||
swab32_array( endiandata, pdata, 20 );
|
||||
|
||||
uint64_t *edata = (uint64_t*)endiandata;
|
||||
mm256_interleave_4x64( (uint64_t*)vdata, edata, edata, edata, edata, 640 );
|
||||
|
||||
for ( int m=0; m < 6; m++ )
|
||||
if ( Htarg <= htmax[m] )
|
||||
{
|
||||
uint32_t mask = masks[m];
|
||||
do
|
||||
{
|
||||
found[0] = found[1] = found[2] = found[3] = false;
|
||||
be32enc( noncep0, n );
|
||||
be32enc( noncep1, n+1 );
|
||||
be32enc( noncep2, n+2 );
|
||||
be32enc( noncep3, n+3 );
|
||||
|
||||
x17_4way_hash( hash, vdata );
|
||||
pdata[19] = n;
|
||||
|
||||
if ( ( hash[7] & mask ) == 0 && fulltest( hash, ptarget ) )
|
||||
{
|
||||
found[0] = true;
|
||||
num_found++;
|
||||
nonces[0] = n;
|
||||
work_set_target_ratio( work, hash );
|
||||
}
|
||||
if ( ( (hash+8)[7] & mask ) == 0 && fulltest( hash+8, ptarget ) )
|
||||
{
|
||||
found[1] = true;
|
||||
num_found++;
|
||||
nonces[1] = n+1;
|
||||
work_set_target_ratio( work, hash+8 );
|
||||
}
|
||||
if ( ( (hash+16)[7] & mask ) == 0 && fulltest( hash+16, ptarget ) )
|
||||
{
|
||||
found[2] = true;
|
||||
num_found++;
|
||||
nonces[2] = n+2;
|
||||
work_set_target_ratio( work, hash+16 );
|
||||
}
|
||||
if ( ( (hash+24)[7] & mask ) == 0 && fulltest( hash+24, ptarget ) )
|
||||
{
|
||||
found[3] = true;
|
||||
num_found++;
|
||||
nonces[3] = n+3;
|
||||
work_set_target_ratio( work, hash+24 );
|
||||
}
|
||||
n += 4;
|
||||
} while ( ( num_found == 0 ) && ( n < max_nonce )
|
||||
&& !work_restart[thr_id].restart );
|
||||
break;
|
||||
}
|
||||
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
return num_found;
|
||||
}
|
||||
|
||||
#endif
|
||||
17
algo/x17/x17-gate.c
Normal file
17
algo/x17/x17-gate.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "x17-gate.h"
|
||||
|
||||
bool register_x17_algo( algo_gate_t* gate )
|
||||
{
|
||||
#if defined (X17_4WAY)
|
||||
init_x17_4way_ctx();
|
||||
gate->scanhash = (void*)&scanhash_x17_4way;
|
||||
gate->hash = (void*)&x17_4way_hash;
|
||||
#else
|
||||
init_x17_ctx();
|
||||
gate->scanhash = (void*)&scanhash_x17;
|
||||
gate->hash = (void*)&x17_hash;
|
||||
#endif
|
||||
gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | FOUR_WAY_OPT;
|
||||
return true;
|
||||
};
|
||||
|
||||
32
algo/x17/x17-gate.h
Normal file
32
algo/x17/x17-gate.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef X17_GATE_H__
|
||||
#define X17_GATE_H__ 1
|
||||
|
||||
#include "algo-gate-api.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(HASH_4WAY) && defined(__AES__)
|
||||
#define X17_4WAY
|
||||
#endif
|
||||
|
||||
bool register_x17_algo( algo_gate_t* gate );
|
||||
|
||||
#if defined(X17_4WAY)
|
||||
|
||||
void x17_4way_hash( void *state, const void *input );
|
||||
|
||||
int scanhash_x17_4way( int thr_id, struct work *work, uint32_t max_nonce,
|
||||
uint64_t *hashes_done );
|
||||
|
||||
void init_x17_4way_ctx();
|
||||
|
||||
#endif
|
||||
|
||||
void x17_hash( void *state, const void *input );
|
||||
|
||||
int scanhash_x17( int thr_id, struct work *work, uint32_t max_nonce,
|
||||
uint64_t *hashes_done );
|
||||
|
||||
void init_x17_ctx();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "algo-gate-api.h"
|
||||
#include "x17-gate.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -86,7 +86,7 @@ void init_x17_ctx()
|
||||
sph_haval256_5_init(&x17_ctx.haval);
|
||||
};
|
||||
|
||||
static void x17hash(void *output, const void *input)
|
||||
void x17_hash(void *output, const void *input)
|
||||
{
|
||||
unsigned char hash[128] __attribute__ ((aligned (64)));
|
||||
#define hashB hash+64
|
||||
@@ -248,7 +248,7 @@ int scanhash_x17(int thr_id, struct work *work,
|
||||
do {
|
||||
pdata[19] = ++n;
|
||||
be32enc(&endiandata[19], n);
|
||||
x17hash(hash64, endiandata);
|
||||
x17_hash(hash64, endiandata);
|
||||
#ifndef DEBUG_ALGO
|
||||
if (!(hash64[7] & mask))
|
||||
{
|
||||
@@ -281,7 +281,7 @@ int scanhash_x17(int thr_id, struct work *work,
|
||||
pdata[19] = n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
bool register_x17_algo( algo_gate_t* gate )
|
||||
{
|
||||
gate->optimizations = SSE2_OPT | AES_OPT | AVX_OPT | AVX2_OPT;
|
||||
@@ -290,4 +290,4 @@ bool register_x17_algo( algo_gate_t* gate )
|
||||
gate->hash = (void*)&x17hash;
|
||||
return true;
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
556
algo/x17/xevan-4way.c
Normal file
556
algo/x17/xevan-4way.c
Normal file
@@ -0,0 +1,556 @@
|
||||
#include "xevan-gate.h"
|
||||
|
||||
#if defined(__AVX2__) && defined(__AES__)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "algo/blake/blake-hash-4way.h"
|
||||
#include "algo/bmw/sph_bmw.h"
|
||||
#include "algo/groestl/aes_ni/hash-groestl.h"
|
||||
#include "algo/jh/jh-hash-4way.h"
|
||||
#include "algo/keccak/keccak-hash-4way.h"
|
||||
#include "algo/skein/skein-hash-4way.h"
|
||||
#include "algo/shavite/sph_shavite.h"
|
||||
#include "algo/luffa/sse2/luffa_for_sse2.h"
|
||||
#include "algo/cubehash/sse2/cubehash_sse2.h"
|
||||
#include "algo/simd/sse2/nist.h"
|
||||
#include "algo/echo/aes_ni/hash_api.h"
|
||||
#include "algo/hamsi/sph_hamsi.h"
|
||||
#include "algo/fugue/sph_fugue.h"
|
||||
#include "algo/shabal/sph_shabal.h"
|
||||
#include "algo/whirlpool/sph_whirlpool.h"
|
||||
#include "algo/sha/sph_sha2.h"
|
||||
#include "algo/haval/sph-haval.h"
|
||||
#include <openssl/sha.h>
|
||||
|
||||
typedef struct {
|
||||
blake512_4way_context blake;
|
||||
sph_bmw512_context bmw;
|
||||
hashState_groestl groestl;
|
||||
skein512_4way_context skein;
|
||||
jh512_4way_context jh;
|
||||
keccak512_4way_context keccak;
|
||||
hashState_luffa luffa;
|
||||
cubehashParam cube;
|
||||
sph_shavite512_context shavite;
|
||||
hashState_sd simd;
|
||||
hashState_echo echo;
|
||||
sph_hamsi512_context hamsi;
|
||||
sph_fugue512_context fugue;
|
||||
sph_shabal512_context shabal;
|
||||
sph_whirlpool_context whirlpool;
|
||||
SHA512_CTX sha512;
|
||||
sph_haval256_5_context haval;
|
||||
} xevan_4way_ctx_holder;
|
||||
|
||||
xevan_4way_ctx_holder xevan_4way_ctx __attribute__ ((aligned (64)));
|
||||
static __thread blake512_4way_context xevan_blake_4way_mid
|
||||
__attribute__ ((aligned (64)));
|
||||
|
||||
void init_xevan_4way_ctx()
|
||||
{
|
||||
blake512_4way_init(&xevan_4way_ctx.blake);
|
||||
sph_bmw512_init(&xevan_4way_ctx.bmw);
|
||||
init_groestl( &xevan_4way_ctx.groestl, 64 );
|
||||
skein512_4way_init(&xevan_4way_ctx.skein);
|
||||
jh512_4way_init(&xevan_4way_ctx.jh);
|
||||
keccak512_4way_init(&xevan_4way_ctx.keccak);
|
||||
init_luffa( &xevan_4way_ctx.luffa, 512 );
|
||||
cubehashInit( &xevan_4way_ctx.cube, 512, 16, 32 );
|
||||
sph_shavite512_init( &xevan_4way_ctx.shavite );
|
||||
init_sd( &xevan_4way_ctx.simd, 512 );
|
||||
init_echo( &xevan_4way_ctx.echo, 512 );
|
||||
sph_hamsi512_init( &xevan_4way_ctx.hamsi );
|
||||
sph_fugue512_init( &xevan_4way_ctx.fugue );
|
||||
sph_shabal512_init( &xevan_4way_ctx.shabal );
|
||||
sph_whirlpool_init( &xevan_4way_ctx.whirlpool );
|
||||
SHA512_Init( &xevan_4way_ctx.sha512 );
|
||||
sph_haval256_5_init( &xevan_4way_ctx.haval );
|
||||
};
|
||||
|
||||
void xevan_4way_blake512_midstate( const void* input )
|
||||
{
|
||||
memcpy( &xevan_blake_4way_mid, &xevan_4way_ctx.blake,
|
||||
sizeof(xevan_blake_4way_mid) );
|
||||
blake512_4way( &xevan_blake_4way_mid, input, 64 );
|
||||
}
|
||||
|
||||
void xevan_4way_hash( void *output, const void *input )
|
||||
{
|
||||
uint64_t hash0[16] __attribute__ ((aligned (64)));
|
||||
uint64_t hash1[16] __attribute__ ((aligned (64)));
|
||||
uint64_t hash2[16] __attribute__ ((aligned (64)));
|
||||
uint64_t hash3[16] __attribute__ ((aligned (64)));
|
||||
uint64_t vhash[16<<2] __attribute__ ((aligned (64)));
|
||||
const int dataLen = 128;
|
||||
const int midlen = 64; // bytes
|
||||
const int tail = 80 - midlen; // 16
|
||||
xevan_4way_ctx_holder ctx __attribute__ ((aligned (64)));
|
||||
memcpy( &ctx, &xevan_4way_ctx, sizeof(xevan_4way_ctx) );
|
||||
|
||||
memcpy( &ctx.blake, &xevan_blake_4way_mid,
|
||||
sizeof(xevan_blake_4way_mid) );
|
||||
blake512_4way( &ctx.blake, input + (midlen<<2), tail );
|
||||
blake512_4way_close(&ctx.blake, vhash);
|
||||
|
||||
memset( &vhash[8<<2], 0, 64<<2 );
|
||||
mm256_deinterleave_4x64( hash0, hash1, hash2, hash3, vhash, dataLen<<3 );
|
||||
|
||||
sph_bmw512( &ctx.bmw, hash0, dataLen );
|
||||
sph_bmw512_close( &ctx.bmw, hash0 );
|
||||
memcpy( &ctx.bmw, &xevan_4way_ctx.bmw, sizeof(sph_bmw512_context) );
|
||||
sph_bmw512( &ctx.bmw, hash1, dataLen );
|
||||
sph_bmw512_close( &ctx.bmw, hash1 );
|
||||
memcpy( &ctx.bmw, &xevan_4way_ctx.bmw, sizeof(sph_bmw512_context) );
|
||||
sph_bmw512( &ctx.bmw, hash2, dataLen );
|
||||
sph_bmw512_close( &ctx.bmw, hash2 );
|
||||
memcpy( &ctx.bmw, &xevan_4way_ctx.bmw, sizeof(sph_bmw512_context) );
|
||||
sph_bmw512( &ctx.bmw, hash3, dataLen );
|
||||
sph_bmw512_close( &ctx.bmw, hash3 );
|
||||
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash0, (char*)hash0,
|
||||
dataLen<<3 );
|
||||
memcpy( &ctx.groestl, &xevan_4way_ctx.groestl, sizeof(hashState_groestl) );
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash1, (char*)hash1,
|
||||
dataLen<<3 );
|
||||
memcpy( &ctx.groestl, &xevan_4way_ctx.groestl, sizeof(hashState_groestl) );
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash2, (char*)hash2,
|
||||
dataLen<<3 );
|
||||
memcpy( &ctx.groestl, &xevan_4way_ctx.groestl, sizeof(hashState_groestl) );
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash3, (char*)hash3,
|
||||
dataLen<<3 );
|
||||
|
||||
mm256_interleave_4x64( vhash, hash0, hash1, hash2, hash3, dataLen<<3 );
|
||||
|
||||
skein512_4way( &ctx.skein, vhash, dataLen );
|
||||
skein512_4way_close( &ctx.skein, vhash );
|
||||
|
||||
jh512_4way( &ctx.jh, vhash, dataLen );
|
||||
jh512_4way_close( &ctx.jh, vhash );
|
||||
|
||||
keccak512_4way( &ctx.keccak, vhash, dataLen );
|
||||
keccak512_4way_close( &ctx.keccak, vhash );
|
||||
|
||||
mm256_deinterleave_4x64( hash0, hash1, hash2, hash3, vhash, dataLen<<3 );
|
||||
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash0,
|
||||
(const BitSequence*)hash0, dataLen );
|
||||
memcpy( &ctx.luffa, &xevan_4way_ctx.luffa, sizeof(hashState_luffa) );
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash1,
|
||||
(const BitSequence*)hash1, dataLen );
|
||||
memcpy( &ctx.luffa, &xevan_4way_ctx.luffa, sizeof(hashState_luffa) );
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash2,
|
||||
(const BitSequence*)hash2, dataLen );
|
||||
memcpy( &ctx.luffa, &xevan_4way_ctx.luffa, sizeof(hashState_luffa) );
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash3,
|
||||
(const BitSequence*)hash3, dataLen );
|
||||
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash0, (const byte*) hash0,
|
||||
dataLen );
|
||||
memcpy( &ctx.cube, &xevan_4way_ctx.cube, sizeof(cubehashParam) );
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash1, (const byte*) hash1,
|
||||
dataLen );
|
||||
memcpy( &ctx.cube, &xevan_4way_ctx.cube, sizeof(cubehashParam) );
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash2, (const byte*) hash2,
|
||||
dataLen );
|
||||
memcpy( &ctx.cube, &xevan_4way_ctx.cube, sizeof(cubehashParam) );
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash3, (const byte*) hash3,
|
||||
dataLen );
|
||||
|
||||
sph_shavite512( &ctx.shavite, hash0, dataLen );
|
||||
sph_shavite512_close( &ctx.shavite, hash0 );
|
||||
memcpy( &ctx.shavite, &xevan_4way_ctx.shavite,
|
||||
sizeof(sph_shavite512_context) );
|
||||
sph_shavite512( &ctx.shavite, hash1, dataLen );
|
||||
sph_shavite512_close( &ctx.shavite, hash1 );
|
||||
memcpy( &ctx.shavite, &xevan_4way_ctx.shavite,
|
||||
sizeof(sph_shavite512_context) );
|
||||
sph_shavite512( &ctx.shavite, hash2, dataLen );
|
||||
sph_shavite512_close( &ctx.shavite, hash2 );
|
||||
memcpy( &ctx.shavite, &xevan_4way_ctx.shavite,
|
||||
sizeof(sph_shavite512_context) );
|
||||
sph_shavite512( &ctx.shavite, hash3, dataLen );
|
||||
sph_shavite512_close( &ctx.shavite, hash3 );
|
||||
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash0,
|
||||
(const BitSequence *)hash0, dataLen<<3 );
|
||||
memcpy( &ctx.simd, &xevan_4way_ctx.simd, sizeof(hashState_sd) );
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash1,
|
||||
(const BitSequence *)hash1, dataLen<<3 );
|
||||
memcpy( &ctx.simd, &xevan_4way_ctx.simd, sizeof(hashState_sd) );
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash2,
|
||||
(const BitSequence *)hash2, dataLen<<3 );
|
||||
memcpy( &ctx.simd, &xevan_4way_ctx.simd, sizeof(hashState_sd) );
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash3,
|
||||
(const BitSequence *)hash3, dataLen<<3 );
|
||||
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash0,
|
||||
(const BitSequence *) hash0, dataLen<<3 );
|
||||
memcpy( &ctx.echo, &xevan_4way_ctx.echo, sizeof(hashState_echo) );
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash1,
|
||||
(const BitSequence *) hash1, dataLen<<3 );
|
||||
memcpy( &ctx.echo, &xevan_4way_ctx.echo, sizeof(hashState_echo) );
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash2,
|
||||
(const BitSequence *) hash2, dataLen<<3 );
|
||||
memcpy( &ctx.echo, &xevan_4way_ctx.echo, sizeof(hashState_echo) );
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash3,
|
||||
(const BitSequence *) hash3, dataLen<<3 );
|
||||
|
||||
sph_hamsi512( &ctx.hamsi, hash0, dataLen );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash0 );
|
||||
memcpy( &ctx.hamsi, &xevan_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
|
||||
sph_hamsi512( &ctx.hamsi, hash1, dataLen );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash1 );
|
||||
memcpy( &ctx.hamsi, &xevan_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
|
||||
sph_hamsi512( &ctx.hamsi, hash2, dataLen );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash2 );
|
||||
memcpy( &ctx.hamsi, &xevan_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
|
||||
sph_hamsi512( &ctx.hamsi, hash3, dataLen );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash3 );
|
||||
|
||||
sph_fugue512( &ctx.fugue, hash0, dataLen );
|
||||
sph_fugue512_close( &ctx.fugue, hash0 );
|
||||
memcpy( &ctx.fugue, &xevan_4way_ctx.fugue, sizeof(sph_fugue512_context) );
|
||||
sph_fugue512( &ctx.fugue, hash1, dataLen );
|
||||
sph_fugue512_close( &ctx.fugue, hash1 );
|
||||
memcpy( &ctx.fugue, &xevan_4way_ctx.fugue, sizeof(sph_fugue512_context) );
|
||||
sph_fugue512( &ctx.fugue, hash2, dataLen );
|
||||
sph_fugue512_close( &ctx.fugue, hash2 );
|
||||
memcpy( &ctx.fugue, &xevan_4way_ctx.fugue, sizeof(sph_fugue512_context) );
|
||||
sph_fugue512( &ctx.fugue, hash3, dataLen );
|
||||
sph_fugue512_close( &ctx.fugue, hash3 );
|
||||
|
||||
sph_shabal512( &ctx.shabal, hash0, dataLen );
|
||||
sph_shabal512_close( &ctx.shabal, hash0 );
|
||||
memcpy( &ctx.shabal, &xevan_4way_ctx.shabal,
|
||||
sizeof(sph_shabal512_context) );
|
||||
sph_shabal512( &ctx.shabal, hash1, dataLen );
|
||||
sph_shabal512_close( &ctx.shabal, hash1 );
|
||||
memcpy( &ctx.shabal, &xevan_4way_ctx.shabal,
|
||||
sizeof(sph_shabal512_context) );
|
||||
sph_shabal512( &ctx.shabal, hash2, dataLen );
|
||||
sph_shabal512_close( &ctx.shabal, hash2 );
|
||||
memcpy( &ctx.shabal, &xevan_4way_ctx.shabal,
|
||||
sizeof(sph_shabal512_context) );
|
||||
sph_shabal512( &ctx.shabal, hash3, dataLen );
|
||||
sph_shabal512_close( &ctx.shabal, hash3 );
|
||||
|
||||
sph_whirlpool( &ctx.whirlpool, hash0, dataLen );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash0 );
|
||||
memcpy( &ctx.whirlpool, &xevan_4way_ctx.whirlpool,
|
||||
sizeof(sph_whirlpool_context) );
|
||||
sph_whirlpool( &ctx.whirlpool, hash1, dataLen );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash1 );
|
||||
memcpy( &ctx.whirlpool, &xevan_4way_ctx.whirlpool,
|
||||
sizeof(sph_whirlpool_context) );
|
||||
sph_whirlpool( &ctx.whirlpool, hash2, dataLen );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash2 );
|
||||
memcpy( &ctx.whirlpool, &xevan_4way_ctx.whirlpool,
|
||||
sizeof(sph_whirlpool_context) );
|
||||
sph_whirlpool( &ctx.whirlpool, hash3, dataLen );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash3 );
|
||||
|
||||
SHA512_Update( &ctx.sha512, hash0, dataLen );
|
||||
SHA512_Final( (unsigned char*)hash0, &ctx.sha512 );
|
||||
memcpy( &ctx.sha512, &xevan_4way_ctx.sha512, sizeof(SHA512_CTX) );
|
||||
SHA512_Update( &ctx.sha512, hash1, dataLen );
|
||||
SHA512_Final( (unsigned char*)hash1, &ctx.sha512 );
|
||||
memcpy( &ctx.sha512, &xevan_4way_ctx.sha512, sizeof(SHA512_CTX) );
|
||||
SHA512_Update( &ctx.sha512, hash2, dataLen );
|
||||
SHA512_Final( (unsigned char*)hash2, &ctx.sha512 );
|
||||
memcpy( &ctx.sha512, &xevan_4way_ctx.sha512, sizeof(SHA512_CTX) );
|
||||
SHA512_Update( &ctx.sha512, hash3, dataLen );
|
||||
SHA512_Final( (unsigned char*)hash3, &ctx.sha512 );
|
||||
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash0, dataLen );
|
||||
sph_haval256_5_close( &ctx.haval, hash0 );
|
||||
memcpy( &ctx.haval, &xevan_4way_ctx.haval,
|
||||
sizeof(sph_haval256_5_context) );
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash1, dataLen );
|
||||
sph_haval256_5_close( &ctx.haval, hash1 );
|
||||
memcpy( &ctx.haval, &xevan_4way_ctx.haval,
|
||||
sizeof(sph_haval256_5_context) );
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash2, dataLen );
|
||||
sph_haval256_5_close( &ctx.haval, hash2 );
|
||||
memcpy( &ctx.haval, &xevan_4way_ctx.haval,
|
||||
sizeof(sph_haval256_5_context) );
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash3, dataLen );
|
||||
sph_haval256_5_close( &ctx.haval, hash3 );
|
||||
|
||||
mm256_interleave_4x64( vhash, hash0, hash1, hash2, hash3, dataLen<<3 );
|
||||
memset( &vhash[ 4<<2 ], 0, (dataLen-32) << 2 );
|
||||
memcpy( &ctx, &xevan_4way_ctx, sizeof(xevan_4way_ctx) );
|
||||
|
||||
blake512_4way( &ctx.blake, vhash, dataLen );
|
||||
blake512_4way_close(&ctx.blake, vhash);
|
||||
|
||||
mm256_deinterleave_4x64( hash0, hash1, hash2, hash3, vhash, dataLen<<3 );
|
||||
|
||||
sph_bmw512( &ctx.bmw, hash0, dataLen );
|
||||
sph_bmw512_close( &ctx.bmw, hash0 );
|
||||
memcpy( &ctx.bmw, &xevan_4way_ctx.bmw, sizeof(sph_bmw512_context) );
|
||||
sph_bmw512( &ctx.bmw, hash1, dataLen );
|
||||
sph_bmw512_close( &ctx.bmw, hash1 );
|
||||
memcpy( &ctx.bmw, &xevan_4way_ctx.bmw, sizeof(sph_bmw512_context) );
|
||||
sph_bmw512( &ctx.bmw, hash2, dataLen );
|
||||
sph_bmw512_close( &ctx.bmw, hash2 );
|
||||
memcpy( &ctx.bmw, &xevan_4way_ctx.bmw, sizeof(sph_bmw512_context) );
|
||||
sph_bmw512( &ctx.bmw, hash3, dataLen );
|
||||
sph_bmw512_close( &ctx.bmw, hash3 );
|
||||
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash0, (char*)hash0,
|
||||
dataLen<<3 );
|
||||
memcpy( &ctx.groestl, &xevan_4way_ctx.groestl, sizeof(hashState_groestl) );
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash1, (char*)hash1,
|
||||
dataLen<<3 );
|
||||
memcpy( &ctx.groestl, &xevan_4way_ctx.groestl, sizeof(hashState_groestl) );
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash2, (char*)hash2,
|
||||
dataLen<<3 );
|
||||
memcpy( &ctx.groestl, &xevan_4way_ctx.groestl, sizeof(hashState_groestl) );
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash3, (char*)hash3,
|
||||
dataLen<<3 );
|
||||
|
||||
mm256_interleave_4x64( vhash, hash0, hash1, hash2, hash3, dataLen<<3 );
|
||||
|
||||
skein512_4way( &ctx.skein, vhash, dataLen );
|
||||
skein512_4way_close( &ctx.skein, vhash );
|
||||
|
||||
jh512_4way( &ctx.jh, vhash, dataLen );
|
||||
jh512_4way_close( &ctx.jh, vhash );
|
||||
|
||||
keccak512_4way( &ctx.keccak, vhash, dataLen );
|
||||
keccak512_4way_close( &ctx.keccak, vhash );
|
||||
|
||||
mm256_deinterleave_4x64( hash0, hash1, hash2, hash3, vhash, dataLen<<3 );
|
||||
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash0,
|
||||
(const BitSequence*)hash0, dataLen );
|
||||
memcpy( &ctx.luffa, &xevan_4way_ctx.luffa, sizeof(hashState_luffa) );
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash1,
|
||||
(const BitSequence*)hash1, dataLen );
|
||||
memcpy( &ctx.luffa, &xevan_4way_ctx.luffa, sizeof(hashState_luffa) );
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash2,
|
||||
(const BitSequence*)hash2, dataLen );
|
||||
memcpy( &ctx.luffa, &xevan_4way_ctx.luffa, sizeof(hashState_luffa) );
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash3,
|
||||
(const BitSequence*)hash3, dataLen );
|
||||
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash0, (const byte*) hash0,
|
||||
dataLen );
|
||||
memcpy( &ctx.cube, &xevan_4way_ctx.cube, sizeof(cubehashParam) );
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash1, (const byte*) hash1,
|
||||
dataLen );
|
||||
memcpy( &ctx.cube, &xevan_4way_ctx.cube, sizeof(cubehashParam) );
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash2, (const byte*) hash2,
|
||||
dataLen );
|
||||
memcpy( &ctx.cube, &xevan_4way_ctx.cube, sizeof(cubehashParam) );
|
||||
cubehashUpdateDigest( &ctx.cube, (byte*)hash3, (const byte*) hash3,
|
||||
dataLen );
|
||||
|
||||
sph_shavite512( &ctx.shavite, hash0, dataLen );
|
||||
sph_shavite512_close( &ctx.shavite, hash0 );
|
||||
memcpy( &ctx.shavite, &xevan_4way_ctx.shavite,
|
||||
sizeof(sph_shavite512_context) );
|
||||
sph_shavite512( &ctx.shavite, hash1, dataLen );
|
||||
sph_shavite512_close( &ctx.shavite, hash1 );
|
||||
memcpy( &ctx.shavite, &xevan_4way_ctx.shavite,
|
||||
sizeof(sph_shavite512_context) );
|
||||
sph_shavite512( &ctx.shavite, hash2, dataLen );
|
||||
sph_shavite512_close( &ctx.shavite, hash2 );
|
||||
memcpy( &ctx.shavite, &xevan_4way_ctx.shavite,
|
||||
sizeof(sph_shavite512_context) );
|
||||
sph_shavite512( &ctx.shavite, hash3, dataLen );
|
||||
sph_shavite512_close( &ctx.shavite, hash3 );
|
||||
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash0,
|
||||
(const BitSequence *)hash0, dataLen<<3 );
|
||||
memcpy( &ctx.simd, &xevan_4way_ctx.simd, sizeof(hashState_sd) );
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash1,
|
||||
(const BitSequence *)hash1, dataLen<<3 );
|
||||
memcpy( &ctx.simd, &xevan_4way_ctx.simd, sizeof(hashState_sd) );
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash2,
|
||||
(const BitSequence *)hash2, dataLen<<3 );
|
||||
memcpy( &ctx.simd, &xevan_4way_ctx.simd, sizeof(hashState_sd) );
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash3,
|
||||
(const BitSequence *)hash3, dataLen<<3 );
|
||||
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash0,
|
||||
(const BitSequence *) hash0, dataLen<<3 );
|
||||
memcpy( &ctx.echo, &xevan_4way_ctx.echo, sizeof(hashState_echo) );
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash1,
|
||||
(const BitSequence *) hash1, dataLen<<3 );
|
||||
memcpy( &ctx.echo, &xevan_4way_ctx.echo, sizeof(hashState_echo) );
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash2,
|
||||
(const BitSequence *) hash2, dataLen<<3 );
|
||||
memcpy( &ctx.echo, &xevan_4way_ctx.echo, sizeof(hashState_echo) );
|
||||
update_final_echo( &ctx.echo, (BitSequence *)hash3,
|
||||
(const BitSequence *) hash3, dataLen<<3 );
|
||||
|
||||
sph_hamsi512( &ctx.hamsi, hash0, dataLen );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash0 );
|
||||
memcpy( &ctx.hamsi, &xevan_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
|
||||
sph_hamsi512( &ctx.hamsi, hash1, dataLen );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash1 );
|
||||
memcpy( &ctx.hamsi, &xevan_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
|
||||
sph_hamsi512( &ctx.hamsi, hash2, dataLen );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash2 );
|
||||
memcpy( &ctx.hamsi, &xevan_4way_ctx.hamsi, sizeof(sph_hamsi512_context) );
|
||||
sph_hamsi512( &ctx.hamsi, hash3, dataLen );
|
||||
sph_hamsi512_close( &ctx.hamsi, hash3 );
|
||||
|
||||
sph_fugue512( &ctx.fugue, hash0, dataLen );
|
||||
sph_fugue512_close( &ctx.fugue, hash0 );
|
||||
memcpy( &ctx.fugue, &xevan_4way_ctx.fugue, sizeof(sph_fugue512_context) );
|
||||
sph_fugue512( &ctx.fugue, hash1, dataLen );
|
||||
sph_fugue512_close( &ctx.fugue, hash1 );
|
||||
memcpy( &ctx.fugue, &xevan_4way_ctx.fugue, sizeof(sph_fugue512_context) );
|
||||
sph_fugue512( &ctx.fugue, hash2, dataLen );
|
||||
sph_fugue512_close( &ctx.fugue, hash2 );
|
||||
memcpy( &ctx.fugue, &xevan_4way_ctx.fugue, sizeof(sph_fugue512_context) );
|
||||
sph_fugue512( &ctx.fugue, hash3, dataLen );
|
||||
sph_fugue512_close( &ctx.fugue, hash3 );
|
||||
|
||||
sph_shabal512( &ctx.shabal, hash0, dataLen );
|
||||
sph_shabal512_close( &ctx.shabal, hash0 );
|
||||
memcpy( &ctx.shabal, &xevan_4way_ctx.shabal,
|
||||
sizeof(sph_shabal512_context) );
|
||||
sph_shabal512( &ctx.shabal, hash1, dataLen );
|
||||
sph_shabal512_close( &ctx.shabal, hash1 );
|
||||
memcpy( &ctx.shabal, &xevan_4way_ctx.shabal,
|
||||
sizeof(sph_shabal512_context) );
|
||||
sph_shabal512( &ctx.shabal, hash2, dataLen );
|
||||
sph_shabal512_close( &ctx.shabal, hash2 );
|
||||
memcpy( &ctx.shabal, &xevan_4way_ctx.shabal,
|
||||
sizeof(sph_shabal512_context) );
|
||||
sph_shabal512( &ctx.shabal, hash3, dataLen );
|
||||
sph_shabal512_close( &ctx.shabal, hash3 );
|
||||
|
||||
sph_whirlpool( &ctx.whirlpool, hash0, dataLen );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash0 );
|
||||
memcpy( &ctx.whirlpool, &xevan_4way_ctx.whirlpool,
|
||||
sizeof(sph_whirlpool_context) );
|
||||
sph_whirlpool( &ctx.whirlpool, hash1, dataLen );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash1 );
|
||||
memcpy( &ctx.whirlpool, &xevan_4way_ctx.whirlpool,
|
||||
sizeof(sph_whirlpool_context) );
|
||||
sph_whirlpool( &ctx.whirlpool, hash2, dataLen );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash2 );
|
||||
memcpy( &ctx.whirlpool, &xevan_4way_ctx.whirlpool,
|
||||
sizeof(sph_whirlpool_context) );
|
||||
sph_whirlpool( &ctx.whirlpool, hash3, dataLen );
|
||||
sph_whirlpool_close( &ctx.whirlpool, hash3 );
|
||||
|
||||
SHA512_Update( &ctx.sha512, hash0, dataLen );
|
||||
SHA512_Final( (unsigned char*)hash0, &ctx.sha512 );
|
||||
memcpy( &ctx.sha512, &xevan_4way_ctx.sha512, sizeof(SHA512_CTX) );
|
||||
SHA512_Update( &ctx.sha512, hash1, dataLen );
|
||||
SHA512_Final( (unsigned char*)hash1, &ctx.sha512 );
|
||||
memcpy( &ctx.sha512, &xevan_4way_ctx.sha512, sizeof(SHA512_CTX) );
|
||||
SHA512_Update( &ctx.sha512, hash2, dataLen );
|
||||
SHA512_Final( (unsigned char*)hash2, &ctx.sha512 );
|
||||
memcpy( &ctx.sha512, &xevan_4way_ctx.sha512, sizeof(SHA512_CTX) );
|
||||
SHA512_Update( &ctx.sha512, hash3, dataLen );
|
||||
SHA512_Final( (unsigned char*)hash3, &ctx.sha512 );
|
||||
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash0, dataLen );
|
||||
sph_haval256_5_close( &ctx.haval, hash0 );
|
||||
memcpy( &ctx.haval, &xevan_4way_ctx.haval,
|
||||
sizeof(sph_haval256_5_context) );
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash1, dataLen );
|
||||
sph_haval256_5_close( &ctx.haval, hash1 );
|
||||
memcpy( &ctx.haval, &xevan_4way_ctx.haval,
|
||||
sizeof(sph_haval256_5_context) );
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash2, dataLen );
|
||||
sph_haval256_5_close( &ctx.haval, hash2 );
|
||||
memcpy( &ctx.haval, &xevan_4way_ctx.haval,
|
||||
sizeof(sph_haval256_5_context) );
|
||||
sph_haval256_5( &ctx.haval, (const void*)hash3, dataLen );
|
||||
sph_haval256_5_close( &ctx.haval, hash3 );
|
||||
|
||||
memcpy( output, hash0, 32 );
|
||||
memcpy( output+32, hash1, 32 );
|
||||
memcpy( output+64, hash2, 32 );
|
||||
memcpy( output+96, hash3, 32 );
|
||||
}
|
||||
|
||||
int scanhash_xevan_4way( int thr_id, struct work *work, uint32_t max_nonce,
|
||||
uint64_t *hashes_done )
|
||||
{
|
||||
uint32_t hash[4*8] __attribute__ ((aligned (64)));
|
||||
uint32_t vdata[24*4] __attribute__ ((aligned (64)));
|
||||
// uint32_t _ALIGN(64) hash[8];
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
uint32_t n = first_nonce;
|
||||
uint32_t *nonces = work->nonces;
|
||||
bool *found = work->nfound;
|
||||
int num_found = 0;
|
||||
uint32_t *noncep0 = vdata + 73; // 9*8 + 1
|
||||
uint32_t *noncep1 = vdata + 75;
|
||||
uint32_t *noncep2 = vdata + 77;
|
||||
uint32_t *noncep3 = vdata + 79;
|
||||
|
||||
if ( opt_benchmark )
|
||||
ptarget[7] = 0x0cff;
|
||||
|
||||
for ( int k=0; k < 19; k++ )
|
||||
be32enc( &endiandata[k], pdata[k] );
|
||||
|
||||
uint64_t *edata = (uint64_t*)endiandata;
|
||||
mm256_interleave_4x64( (uint64_t*)vdata, edata, edata, edata, edata, 640 );
|
||||
|
||||
xevan_4way_blake512_midstate( vdata );
|
||||
|
||||
do {
|
||||
found[0] = found[1] = found[2] = found[3] = false;
|
||||
be32enc( noncep0, n );
|
||||
be32enc( noncep1, n+1 );
|
||||
be32enc( noncep2, n+2 );
|
||||
be32enc( noncep3, n+3 );
|
||||
|
||||
xevan_4way_hash( hash, vdata );
|
||||
|
||||
pdata[19] = n;
|
||||
|
||||
if ( ( hash[7] <= Htarg ) && fulltest( hash, ptarget ) )
|
||||
{
|
||||
found[0] = true;
|
||||
num_found++;
|
||||
nonces[0] = n;
|
||||
work_set_target_ratio( work, hash );
|
||||
}
|
||||
if ( ( (hash+8)[7] <= Htarg ) && fulltest( hash+8, ptarget ) )
|
||||
{
|
||||
found[1] = true;
|
||||
num_found++;
|
||||
nonces[1] = n+1;
|
||||
work_set_target_ratio( work, hash+8 );
|
||||
}
|
||||
if ( ( (hash+16)[7] <= Htarg ) && fulltest( hash+16, ptarget ) )
|
||||
{
|
||||
found[2] = true;
|
||||
num_found++;
|
||||
nonces[2] = n+2;
|
||||
work_set_target_ratio( work, hash+16 );
|
||||
}
|
||||
if ( ( (hash+24)[7] <= Htarg ) && fulltest( hash+24, ptarget ) )
|
||||
{
|
||||
found[3] = true;
|
||||
num_found++;
|
||||
nonces[3] = n+3;
|
||||
work_set_target_ratio( work, hash+24 );
|
||||
}
|
||||
n += 4;
|
||||
} while ( ( num_found == 0 ) && ( n < max_nonce )
|
||||
&& !work_restart[thr_id].restart );
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
return num_found;
|
||||
}
|
||||
|
||||
#endif
|
||||
24
algo/x17/xevan-gate.c
Normal file
24
algo/x17/xevan-gate.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "xevan-gate.h"
|
||||
|
||||
void xevan_set_target( struct work* work, double job_diff )
|
||||
{
|
||||
work_set_target( work, job_diff / (256.0 * opt_diff_factor) );
|
||||
}
|
||||
|
||||
bool register_xevan_algo( algo_gate_t* gate )
|
||||
{
|
||||
#if defined (XEVAN_4WAY)
|
||||
init_xevan_4way_ctx();
|
||||
gate->scanhash = (void*)&scanhash_xevan_4way;
|
||||
gate->hash = (void*)&xevan_4way_hash;
|
||||
#else
|
||||
init_xevan_ctx();
|
||||
gate->scanhash = (void*)&scanhash_xevan;
|
||||
gate->hash = (void*)&xevan_hash;
|
||||
#endif
|
||||
gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | FOUR_WAY_OPT;
|
||||
gate->set_target = (void*)&xevan_set_target;
|
||||
gate->get_max64 = (void*)&get_max64_0xffffLL;
|
||||
return true;
|
||||
};
|
||||
|
||||
32
algo/x17/xevan-gate.h
Normal file
32
algo/x17/xevan-gate.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef XEVAN_GATE_H__
|
||||
#define XEVAN_GATE_H__ 1
|
||||
|
||||
#include "algo-gate-api.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(HASH_4WAY) && defined(__AES__)
|
||||
#define XEVAN_4WAY
|
||||
#endif
|
||||
|
||||
bool register_xevan_algo( algo_gate_t* gate );
|
||||
|
||||
#if defined(XEVAN_4WAY)
|
||||
|
||||
void xevan_4way_hash( void *state, const void *input );
|
||||
|
||||
int scanhash_xevan_4way( int thr_id, struct work *work, uint32_t max_nonce,
|
||||
uint64_t *hashes_done );
|
||||
|
||||
void init_xevan_4way_ctx();
|
||||
|
||||
#endif
|
||||
|
||||
void xevan_hash( void *state, const void *input );
|
||||
|
||||
int scanhash_xevan( int thr_id, struct work *work, uint32_t max_nonce,
|
||||
uint64_t *hashes_done );
|
||||
|
||||
void init_xevan_ctx();
|
||||
|
||||
#endif
|
||||
|
||||
288
algo/x17/xevan.c
Normal file
288
algo/x17/xevan.c
Normal file
@@ -0,0 +1,288 @@
|
||||
#include "xevan-gate.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "algo/blake/sph_blake.h"
|
||||
#include "algo/bmw/sph_bmw.h"
|
||||
#include "algo/jh/sph_jh.h"
|
||||
#include "algo/keccak/sph_keccak.h"
|
||||
#include "algo/skein/sph_skein.h"
|
||||
#include "algo/shavite/sph_shavite.h"
|
||||
#include "algo/luffa/sse2/luffa_for_sse2.h"
|
||||
#include "algo/hamsi/sph_hamsi.h"
|
||||
#include "algo/fugue/sph_fugue.h"
|
||||
#include "algo/shabal/sph_shabal.h"
|
||||
#include "algo/whirlpool/sph_whirlpool.h"
|
||||
#include "algo/sha/sph_sha2.h"
|
||||
#include "algo/haval/sph-haval.h"
|
||||
#include "algo/simd/sse2/nist.h"
|
||||
#include "algo/cubehash/sse2/cubehash_sse2.h"
|
||||
#include <openssl/sha.h>
|
||||
#ifdef NO_AES_NI
|
||||
#include "algo/groestl/sph_groestl.h"
|
||||
#include "algo/echo/sph_echo.h"
|
||||
#else
|
||||
#include "algo/groestl/aes_ni/hash-groestl.h"
|
||||
#include "algo/echo/aes_ni/hash_api.h"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
sph_blake512_context blake;
|
||||
sph_bmw512_context bmw;
|
||||
sph_skein512_context skein;
|
||||
sph_jh512_context jh;
|
||||
sph_keccak512_context keccak;
|
||||
hashState_luffa luffa;
|
||||
cubehashParam cubehash;
|
||||
sph_shavite512_context shavite;
|
||||
hashState_sd simd;
|
||||
sph_hamsi512_context hamsi;
|
||||
sph_fugue512_context fugue;
|
||||
sph_shabal512_context shabal;
|
||||
sph_whirlpool_context whirlpool;
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA512_CTX sha512;
|
||||
#else
|
||||
sph_sha512_context sha512;
|
||||
#endif
|
||||
sph_haval256_5_context haval;
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512_context groestl;
|
||||
sph_echo512_context echo;
|
||||
#else
|
||||
hashState_echo echo;
|
||||
hashState_groestl groestl;
|
||||
#endif
|
||||
} xevan_ctx_holder;
|
||||
|
||||
xevan_ctx_holder xevan_ctx __attribute__ ((aligned (64)));
|
||||
static __thread sph_blake512_context xevan_blake_mid
|
||||
__attribute__ ((aligned (64)));
|
||||
|
||||
void init_xevan_ctx()
|
||||
{
|
||||
sph_blake512_init(&xevan_ctx.blake);
|
||||
sph_bmw512_init(&xevan_ctx.bmw);
|
||||
sph_skein512_init(&xevan_ctx.skein);
|
||||
sph_jh512_init(&xevan_ctx.jh);
|
||||
sph_keccak512_init(&xevan_ctx.keccak);
|
||||
init_luffa( &xevan_ctx.luffa, 512 );
|
||||
cubehashInit( &xevan_ctx.cubehash, 512, 16, 32 );
|
||||
sph_shavite512_init( &xevan_ctx.shavite );
|
||||
init_sd( &xevan_ctx.simd, 512 );
|
||||
sph_hamsi512_init( &xevan_ctx.hamsi );
|
||||
sph_fugue512_init( &xevan_ctx.fugue );
|
||||
sph_shabal512_init( &xevan_ctx.shabal );
|
||||
sph_whirlpool_init( &xevan_ctx.whirlpool );
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA512_Init( &xevan_ctx.sha512 );
|
||||
#else
|
||||
sph_sha512_init(&xevan_ctx.sha512);
|
||||
#endif
|
||||
sph_haval256_5_init(&xevan_ctx.haval);
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512_init( &xevan_ctx.groestl );
|
||||
sph_echo512_init( &xevan_ctx.echo );
|
||||
#else
|
||||
init_groestl( &xevan_ctx.groestl, 64 );
|
||||
init_echo( &xevan_ctx.echo, 512 );
|
||||
#endif
|
||||
};
|
||||
|
||||
void xevan_blake512_midstate( const void* input )
|
||||
{
|
||||
memcpy( &xevan_blake_mid, &xevan_ctx.blake, sizeof xevan_blake_mid );
|
||||
sph_blake512( &xevan_blake_mid, input, 64 );
|
||||
}
|
||||
|
||||
void xevan_hash(void *output, const void *input)
|
||||
{
|
||||
uint32_t _ALIGN(64) hash[32]; // 128 bytes required
|
||||
const int dataLen = 128;
|
||||
xevan_ctx_holder ctx __attribute__ ((aligned (64)));
|
||||
memcpy( &ctx, &xevan_ctx, sizeof(xevan_ctx) );
|
||||
|
||||
const int midlen = 64; // bytes
|
||||
const int tail = 80 - midlen; // 16
|
||||
|
||||
memcpy( &ctx.blake, &xevan_blake_mid, sizeof xevan_blake_mid );
|
||||
sph_blake512( &ctx.blake, input + midlen, tail );
|
||||
sph_blake512_close(&ctx.blake, hash);
|
||||
|
||||
memset(&hash[16], 0, 64);
|
||||
|
||||
sph_bmw512(&ctx.bmw, hash, dataLen);
|
||||
sph_bmw512_close(&ctx.bmw, hash);
|
||||
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512(&ctx.groestl, hash, dataLen);
|
||||
sph_groestl512_close(&ctx.groestl, hash);
|
||||
#else
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash,
|
||||
(const char*)hash, dataLen*8 );
|
||||
#endif
|
||||
|
||||
sph_skein512(&ctx.skein, hash, dataLen);
|
||||
sph_skein512_close(&ctx.skein, hash);
|
||||
|
||||
sph_jh512(&ctx.jh, hash, dataLen);
|
||||
sph_jh512_close(&ctx.jh, hash);
|
||||
|
||||
sph_keccak512(&ctx.keccak, hash, dataLen);
|
||||
sph_keccak512_close(&ctx.keccak, hash);
|
||||
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash,
|
||||
(const BitSequence*)hash, dataLen );
|
||||
|
||||
cubehashUpdateDigest( &ctx.cubehash, (byte*)hash,
|
||||
(const byte*) hash, dataLen );
|
||||
|
||||
sph_shavite512(&ctx.shavite, hash, dataLen);
|
||||
sph_shavite512_close(&ctx.shavite, hash);
|
||||
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash,
|
||||
(const BitSequence *)hash, dataLen*8 );
|
||||
|
||||
#ifdef NO_AES_NI
|
||||
sph_echo512(&ctx.echo, hash, dataLen);
|
||||
sph_echo512_close(&ctx.echo, hash);
|
||||
#else
|
||||
update_final_echo( &ctx.echo, (BitSequence *) hash,
|
||||
(const BitSequence *) hash, dataLen*8 );
|
||||
#endif
|
||||
|
||||
sph_hamsi512(&ctx.hamsi, hash, dataLen);
|
||||
sph_hamsi512_close(&ctx.hamsi, hash);
|
||||
|
||||
sph_fugue512(&ctx.fugue, hash, dataLen);
|
||||
sph_fugue512_close(&ctx.fugue, hash);
|
||||
|
||||
sph_shabal512(&ctx.shabal, hash, dataLen);
|
||||
sph_shabal512_close(&ctx.shabal, hash);
|
||||
|
||||
sph_whirlpool(&ctx.whirlpool, hash, dataLen);
|
||||
sph_whirlpool_close(&ctx.whirlpool, hash);
|
||||
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA512_Update( &ctx.sha512, hash, dataLen );
|
||||
SHA512_Final( (unsigned char*) hash, &ctx.sha512 );
|
||||
#else
|
||||
sph_sha512(&ctx.sha512,(const void*) hash, dataLen);
|
||||
sph_sha512_close(&ctx.sha512,(void*) hash);
|
||||
#endif
|
||||
sph_haval256_5(&ctx.haval,(const void*) hash, dataLen);
|
||||
sph_haval256_5_close(&ctx.haval, hash);
|
||||
|
||||
memset(&hash[8], 0, dataLen - 32);
|
||||
|
||||
memcpy( &ctx, &xevan_ctx, sizeof(xevan_ctx) );
|
||||
|
||||
sph_blake512(&ctx.blake, hash, dataLen);
|
||||
sph_blake512_close(&ctx.blake, hash);
|
||||
|
||||
sph_bmw512(&ctx.bmw, hash, dataLen);
|
||||
sph_bmw512_close(&ctx.bmw, hash);
|
||||
|
||||
#ifdef NO_AES_NI
|
||||
sph_groestl512(&ctx.groestl, hash, dataLen);
|
||||
sph_groestl512_close(&ctx.groestl, hash);
|
||||
#else
|
||||
update_and_final_groestl( &ctx.groestl, (char*)hash,
|
||||
(const BitSequence*)hash, dataLen*8 );
|
||||
#endif
|
||||
|
||||
sph_skein512(&ctx.skein, hash, dataLen);
|
||||
sph_skein512_close(&ctx.skein, hash);
|
||||
|
||||
sph_jh512(&ctx.jh, hash, dataLen);
|
||||
sph_jh512_close(&ctx.jh, hash);
|
||||
|
||||
sph_keccak512(&ctx.keccak, hash, dataLen);
|
||||
sph_keccak512_close(&ctx.keccak, hash);
|
||||
update_and_final_luffa( &ctx.luffa, (BitSequence*)hash,
|
||||
(const BitSequence*)hash, dataLen );
|
||||
|
||||
cubehashUpdateDigest( &ctx.cubehash, (byte*)hash,
|
||||
(const byte*) hash, dataLen );
|
||||
|
||||
sph_shavite512(&ctx.shavite, hash, dataLen);
|
||||
sph_shavite512_close(&ctx.shavite, hash);
|
||||
|
||||
update_final_sd( &ctx.simd, (BitSequence *)hash,
|
||||
(const BitSequence *)hash, dataLen*8 );
|
||||
|
||||
#ifdef NO_AES_NI
|
||||
sph_echo512(&ctx.echo, hash, dataLen);
|
||||
sph_echo512_close(&ctx.echo, hash);
|
||||
#else
|
||||
update_final_echo( &ctx.echo, (BitSequence *) hash,
|
||||
(const BitSequence *) hash, dataLen*8 );
|
||||
#endif
|
||||
|
||||
sph_hamsi512(&ctx.hamsi, hash, dataLen);
|
||||
sph_hamsi512_close(&ctx.hamsi, hash);
|
||||
|
||||
sph_fugue512(&ctx.fugue, hash, dataLen);
|
||||
sph_fugue512_close(&ctx.fugue, hash);
|
||||
|
||||
sph_shabal512(&ctx.shabal, hash, dataLen);
|
||||
sph_shabal512_close(&ctx.shabal, hash);
|
||||
|
||||
sph_whirlpool(&ctx.whirlpool, hash, dataLen);
|
||||
sph_whirlpool_close(&ctx.whirlpool, hash);
|
||||
|
||||
#ifndef USE_SPH_SHA
|
||||
SHA512_Update( &ctx.sha512, hash, dataLen );
|
||||
SHA512_Final( (unsigned char*) hash, &ctx.sha512 );
|
||||
#else
|
||||
sph_sha512(&ctx.sha512,(const void*) hash, dataLen);
|
||||
sph_sha512_close(&ctx.sha512,(void*) hash);
|
||||
#endif
|
||||
sph_haval256_5(&ctx.haval,(const void*) hash, dataLen);
|
||||
sph_haval256_5_close(&ctx.haval, hash);
|
||||
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
int scanhash_xevan(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) hash[8];
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
uint32_t nonce = first_nonce;
|
||||
volatile uint8_t *restart = &(work_restart[thr_id].restart);
|
||||
|
||||
if (opt_benchmark)
|
||||
ptarget[7] = 0x0cff;
|
||||
|
||||
for (int k=0; k < 19; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
xevan_blake512_midstate( endiandata );
|
||||
|
||||
do {
|
||||
be32enc(&endiandata[19], nonce);
|
||||
xevan_hash(hash, endiandata);
|
||||
|
||||
if (hash[7] <= Htarg && fulltest(hash, ptarget)) {
|
||||
work_set_target_ratio(work, hash);
|
||||
pdata[19] = nonce;
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
return 1;
|
||||
}
|
||||
nonce++;
|
||||
|
||||
} while (nonce < max_nonce && !(*restart));
|
||||
|
||||
pdata[19] = nonce;
|
||||
*hashes_done = pdata[19] - first_nonce + 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user