This commit is contained in:
Jay D Dee
2017-02-16 10:51:20 -05:00
parent 9ee5965e3f
commit 4521b324e3
9 changed files with 94 additions and 52 deletions

View File

@@ -56,6 +56,7 @@ typedef struct {
} xevan_ctx_holder;
xevan_ctx_holder xevan_ctx;
static __thread sph_blake512_context xevan_blake_mid;
void init_xevan_ctx()
{
@@ -83,15 +84,26 @@ void init_xevan_ctx()
#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;
memcpy( &ctx, &xevan_ctx, sizeof(xevan_ctx) );
sph_blake512(&ctx.blake, input, 80);
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(&ctx.blake, input, 80);
sph_blake512_close(&ctx.blake, hash);
memset(&hash[16], 0, 64);
@@ -239,6 +251,8 @@ int scanhash_xevan(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *
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);