v3.12.6.1

This commit is contained in:
Jay D Dee
2020-03-07 14:11:06 -05:00
parent c0aadbcc99
commit 6e8b8ed34f
29 changed files with 294 additions and 168 deletions

View File

@@ -79,7 +79,7 @@ int main(int argc, const char * const *argv)
for (i = 0; i < sizeof(src); i++)
src.u8[i] = i * 3;
if (yespower_tls(src.u8, sizeof(src), &params, &dst)) {
if (!yespower_tls(src.u8, sizeof(src), &params, &dst)) {
puts("FAILED");
return 1;
}

View File

@@ -53,7 +53,7 @@ int scanhash_yespower_r8g( struct work *work, uint32_t max_nonce,
do {
yespower_tls( (unsigned char *)endiandata, params.perslen,
&params, (yespower_binary_t*)hash );
&params, (yespower_binary_t*)hash, thr_id );
if unlikely( valid_hash( hash, ptarget ) && !opt_benchmark )
{

View File

@@ -194,11 +194,13 @@ static int free_region(yespower_region_t *region)
#define restrict
#endif
/*
#ifdef __GNUC__
#define unlikely(exp) __builtin_expect(exp, 0)
#else
#define unlikely(exp) (exp)
#endif
*/
#ifdef __SSE__
#define PREFETCH(x, hint) _mm_prefetch((const char *)(x), (hint));
@@ -1113,7 +1115,7 @@ static void smix(uint8_t *B, size_t r, uint32_t N,
int yespower_b2b(yespower_local_t *local,
const uint8_t *src, size_t srclen,
const yespower_params_t *params,
yespower_binary_t *dst)
yespower_binary_t *dst, int thrid )
{
uint32_t N = params->N;
uint32_t r = params->r;
@@ -1168,17 +1170,25 @@ int yespower_b2b(yespower_local_t *local,
srclen = 0;
}
if ( work_restart[thrid].restart ) return false;
pbkdf2_blake2b_yp(init_hash, sizeof(init_hash), src, srclen, 1, B, 128);
if ( work_restart[thrid].restart ) return false;
memcpy(init_hash, B, sizeof(init_hash));
smix_1_0(B, r, N, V, XY, &ctx);
if ( work_restart[thrid].restart ) return false;
hmac_blake2b_yp_hash((uint8_t *)dst, B + B_size - 64, 64, init_hash, sizeof(init_hash));
/* Success! */
return 0;
return 1;
fail:
memset(dst, 0xff, sizeof(*dst));
return -1;
return 0;
}
/**
@@ -1189,7 +1199,7 @@ fail:
* Return 0 on success; or -1 on error.
*/
int yespower_b2b_tls(const uint8_t *src, size_t srclen,
const yespower_params_t *params, yespower_binary_t *dst)
const yespower_params_t *params, yespower_binary_t *dst, int thrid )
{
static __thread int initialized = 0;
static __thread yespower_local_t local;
@@ -1199,7 +1209,7 @@ int yespower_b2b_tls(const uint8_t *src, size_t srclen,
initialized = 1;
}
return yespower_b2b(&local, src, srclen, params, dst);
return yespower_b2b(&local, src, srclen, params, dst, thrid);
}
/*
int yespower_init_local(yespower_local_t *local)

View File

@@ -34,9 +34,10 @@ static yespower_params_t yespower_params;
// YESPOWER
void yespower_hash( const char *input, char *output, uint32_t len )
int yespower_hash( const char *input, char *output, uint32_t len, int thrid )
{
yespower_tls( input, len, &yespower_params, (yespower_binary_t*)output );
return yespower_tls( input, len, &yespower_params,
(yespower_binary_t*)output, thrid );
}
int scanhash_yespower( struct work *work, uint32_t max_nonce,
@@ -55,7 +56,7 @@ int scanhash_yespower( struct work *work, uint32_t max_nonce,
be32enc( &endiandata[k], pdata[k] );
endiandata[19] = n;
do {
yespower_hash( (char*)endiandata, (char*)vhash, 80 );
if ( yespower_hash( (char*)endiandata, (char*)vhash, 80, thr_id ) )
if unlikely( valid_hash( vhash, ptarget ) && !opt_benchmark )
{
be32enc( pdata+19, n );
@@ -70,9 +71,9 @@ int scanhash_yespower( struct work *work, uint32_t max_nonce,
// YESPOWER-B2B
void yespower_b2b_hash( const char *input, char *output, uint32_t len )
int yespower_b2b_hash( const char *input, char *output, uint32_t len, int thrid )
{
yespower_b2b_tls( input, len, &yespower_params, (yespower_binary_t*)output );
return yespower_b2b_tls( input, len, &yespower_params, (yespower_binary_t*)output, thrid );
}
int scanhash_yespower_b2b( struct work *work, uint32_t max_nonce,
@@ -91,7 +92,7 @@ int scanhash_yespower_b2b( struct work *work, uint32_t max_nonce,
be32enc( &endiandata[k], pdata[k] );
endiandata[19] = n;
do {
yespower_b2b_hash( (char*) endiandata, (char*) vhash, 80 );
if (yespower_b2b_hash( (char*) endiandata, (char*) vhash, 80, thr_id ) )
if unlikely( valid_hash( vhash, ptarget ) && !opt_benchmark )
{
be32enc( pdata+19, n );

View File

@@ -107,11 +107,13 @@
#define restrict
#endif
/*
#ifdef __GNUC__
#define unlikely(exp) __builtin_expect(exp, 0)
#else
#define unlikely(exp) (exp)
#endif
*/
#ifdef __SSE__
#define PREFETCH(x, hint) _mm_prefetch((const char *)(x), (hint));
@@ -1023,7 +1025,7 @@ static void smix(uint8_t *B, size_t r, uint32_t N,
int yespower(yespower_local_t *local,
const uint8_t *src, size_t srclen,
const yespower_params_t *params,
yespower_binary_t *dst)
yespower_binary_t *dst, int thrid )
{
yespower_version_t version = params->version;
uint32_t N = params->N;
@@ -1077,15 +1079,24 @@ int yespower(yespower_local_t *local,
if (version == YESPOWER_0_5) {
PBKDF2_SHA256(sha256, sizeof(sha256), src, srclen, 1,
B, B_size);
memcpy(sha256, B, sizeof(sha256));
if ( work_restart[thrid].restart ) return false;
memcpy(sha256, B, sizeof(sha256));
smix(B, r, N, V, XY, &ctx);
PBKDF2_SHA256(sha256, sizeof(sha256), B, B_size, 1,
if ( work_restart[thrid].restart ) return false;
PBKDF2_SHA256(sha256, sizeof(sha256), B, B_size, 1,
(uint8_t *)dst, sizeof(*dst));
if (pers) {
HMAC_SHA256_Buf(dst, sizeof(*dst), pers, perslen,
sha256);
SHA256_Buf(sha256, sizeof(sha256), (uint8_t *)dst);
if ( work_restart[thrid].restart ) return false;
SHA256_Buf(sha256, sizeof(sha256), (uint8_t *)dst);
}
} else {
ctx.S2 = S + 2 * Swidth_to_Sbytes1(Swidth);
@@ -1106,7 +1117,7 @@ int yespower(yespower_local_t *local,
}
/* Success! */
return 0;
return 1;
}
/**
@@ -1117,7 +1128,7 @@ int yespower(yespower_local_t *local,
* Return 0 on success; or -1 on error.
*/
int yespower_tls(const uint8_t *src, size_t srclen,
const yespower_params_t *params, yespower_binary_t *dst)
const yespower_params_t *params, yespower_binary_t *dst, int thrid )
{
static __thread int initialized = 0;
static __thread yespower_local_t local;
@@ -1128,7 +1139,7 @@ int yespower_tls(const uint8_t *src, size_t srclen,
initialized = 1;
}
return yespower(&local, src, srclen, params, dst);
return yespower( &local, src, srclen, params, dst, thrid );
}
int yespower_init_local(yespower_local_t *local)

View File

@@ -32,6 +32,7 @@
#include <stdint.h>
#include <stdlib.h> /* for size_t */
#include "miner.h"
#ifdef __cplusplus
extern "C" {
@@ -109,11 +110,11 @@ extern int yespower_free_local(yespower_local_t *local);
*/
extern int yespower(yespower_local_t *local,
const uint8_t *src, size_t srclen,
const yespower_params_t *params, yespower_binary_t *dst);
const yespower_params_t *params, yespower_binary_t *dst, int thrid);
extern int yespower_b2b(yespower_local_t *local,
const uint8_t *src, size_t srclen,
const yespower_params_t *params, yespower_binary_t *dst);
const yespower_params_t *params, yespower_binary_t *dst, int thrid );
/**
* yespower_tls(src, srclen, params, dst):
@@ -125,10 +126,10 @@ extern int yespower_b2b(yespower_local_t *local,
* MT-safe as long as dst is local to the thread.
*/
extern int yespower_tls(const uint8_t *src, size_t srclen,
const yespower_params_t *params, yespower_binary_t *dst);
const yespower_params_t *params, yespower_binary_t *dst, int thr_id);
extern int yespower_b2b_tls(const uint8_t *src, size_t srclen,
const yespower_params_t *params, yespower_binary_t *dst);
const yespower_params_t *params, yespower_binary_t *dst, int thr_id);
#ifdef __cplusplus
}