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

@@ -18,6 +18,7 @@ typedef struct {
} veltor_ctx_holder;
veltor_ctx_holder veltor_ctx;
static __thread sph_skein512_context veltor_skein_mid;
void init_veltor_ctx()
{
@@ -27,6 +28,12 @@ void init_veltor_ctx()
sph_shabal512_init( &veltor_ctx.shabal);
}
void veltor_skein512_midstate( const void* input )
{
memcpy( &veltor_skein_mid, &veltor_ctx.skein, sizeof veltor_skein_mid );
sph_skein512( &veltor_skein_mid, input, 64 );
}
void veltorhash(void *output, const void *input)
{
uint32_t _ALIGN(64) hashA[16], hashB[16];
@@ -34,7 +41,13 @@ void veltorhash(void *output, const void *input)
veltor_ctx_holder ctx;
memcpy( &ctx, &veltor_ctx, sizeof(veltor_ctx) );
sph_skein512(&ctx.skein, input, 80);
const int midlen = 64; // bytes
const int tail = 80 - midlen; // 16
memcpy( &ctx.skein, &veltor_skein_mid, sizeof veltor_skein_mid );
sph_skein512( &ctx.skein, input + midlen, tail );
// sph_skein512(&ctx.skein, input, 80);
sph_skein512_close(&ctx.skein, hashA);
sph_shavite512(&ctx.shavite, hashA, 64);
@@ -68,6 +81,9 @@ int scanhash_veltor(int thr_id, struct work *work, uint32_t max_nonce, uint64_t
for (int i=0; i < 19; i++) {
be32enc(&endiandata[i], pdata[i]);
}
veltor_skein512_midstate( endiandata );
do {
be32enc(&endiandata[19], nonce);
veltorhash(hash, endiandata);