Skip to content

Commit

Permalink
Merge branch 'tpruvot:linux' into linux
Browse files Browse the repository at this point in the history
  • Loading branch information
IT-Berater authored Dec 7, 2021
2 parents 42aa3ad + d2927ed commit e3e24f1
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 16 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Version 1.3.7
- Add geek algo
- Add x16rv2 algo
- Add yescriptr8/16/32 variants

Version 1.3.6
- Add lyra2v3 algo
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Algorithms
* ? luffa (Joincoin, Doomcoin)
* ? rainforest
* ? shavite3 (INKcoin)
* ? __yescryptr8__ __yescryptr16__ and __yescryptr32__ variants

#### Planned support for
* *scrypt-jane* (YaCoin, CopperBars, Pennies, Tickets, etc..)
Expand Down
2 changes: 1 addition & 1 deletion algo/rainforest.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ const uint8_t rf256_iv[32] = {
};

// crc32 lookup tables
#if !defined(__ARM_FEATURE_CRC32)
#if !defined(__aarch64__) || !defined(__ARM_FEATURE_CRC32)
const uint32_t rf_crc32_table[256] = {
/* 0x00 */ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
/* 0x04 */ 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
Expand Down
24 changes: 22 additions & 2 deletions algo/yescrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "yescrypt/yescrypt.h"

int scanhash_yescrypt(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
int do_scanhash(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done, void (*hash_func)(const char *, char *, uint32_t))
{
uint32_t _ALIGN(64) vhash[8];
uint32_t _ALIGN(64) endiandata[20];
Expand All @@ -26,7 +26,7 @@ int scanhash_yescrypt(int thr_id, struct work *work, uint32_t max_nonce, uint64_

do {
be32enc(&endiandata[19], n);
yescrypt_hash((char*) endiandata, (char*) vhash, 80);
hash_func((char*) endiandata, (char*) vhash, 80);
if (vhash[7] < Htarg && fulltest(vhash, ptarget)) {
work_set_target_ratio(work, vhash);
*hashes_done = n - first_nonce + 1;
Expand All @@ -42,3 +42,23 @@ int scanhash_yescrypt(int thr_id, struct work *work, uint32_t max_nonce, uint64_

return 0;
}

int scanhash_yescrypt(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
{
return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash));
}

int scanhash_yescryptr8(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
{
return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash_r8));
}

int scanhash_yescryptr16(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
{
return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash_r16));
}

int scanhash_yescryptr32(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
{
return (do_scanhash(thr_id, work, max_nonce, hashes_done, yescrypt_hash_r32));
}
26 changes: 26 additions & 0 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ enum algos {
ALGO_X20R,
ALGO_XEVAN,
ALGO_YESCRYPT,
ALGO_YESCRYPTR8,
ALGO_YESCRYPTR16,
ALGO_YESCRYPTR32,
ALGO_ZR5,
ALGO_COUNT
};
Expand Down Expand Up @@ -210,6 +213,9 @@ static const char *algo_names[] = {
"x20r",
"xevan",
"yescrypt",
"yescryptr8",
"yescryptr16",
"yescryptr32",
"zr5",
"\0"
};
Expand Down Expand Up @@ -376,6 +382,9 @@ Options:\n\
x20r X20R\n\
xevan Xevan (BitSend)\n\
yescrypt Yescrypt\n\
yescryptr8 Yescrypt r8\n\
yescryptr16 Yescrypt r16\n\
yescryptr32 Yescrypt r32\n\
zr5 ZR5\n\
-o, --url=URL URL of mining server\n\
-O, --userpass=U:P username:password pair for mining server\n\
Expand Down Expand Up @@ -1853,6 +1862,9 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
case ALGO_NEOSCRYPT:
case ALGO_PLUCK:
case ALGO_YESCRYPT:
case ALGO_YESCRYPTR8:
case ALGO_YESCRYPTR16:
case ALGO_YESCRYPTR32:
work_set_target(work, sctx->job.diff / (65536.0 * opt_diff_factor));
break;
case ALGO_ALLIUM:
Expand Down Expand Up @@ -2190,8 +2202,13 @@ static void *miner_thread(void *userdata)
case ALGO_DROP:
case ALGO_PLUCK:
case ALGO_YESCRYPT:
case ALGO_YESCRYPTR8:
max64 = 0x1ff;
break;
case ALGO_YESCRYPTR16:
case ALGO_YESCRYPTR32:
max64 = 0xfff;
break;
case ALGO_ALLIUM:
case ALGO_LYRA2:
case ALGO_LYRA2REV2:
Expand Down Expand Up @@ -2453,6 +2470,15 @@ static void *miner_thread(void *userdata)
case ALGO_YESCRYPT:
rc = scanhash_yescrypt(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_YESCRYPTR8:
rc = scanhash_yescryptr8(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_YESCRYPTR16:
rc = scanhash_yescryptr16(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_YESCRYPTR32:
rc = scanhash_yescryptr32(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_ZR5:
rc = scanhash_zr5(thr_id, &work, max_nonce, &hashes_done);
break;
Expand Down
10 changes: 5 additions & 5 deletions crypto/blake2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ int blake2s_final( blake2s_state *S, uint8_t *out, uint8_t outlen )

int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen )
{
blake2s_state S[1];
blake2s_state S;

/* Verify parameters */
if ( NULL == in ) return -1;
Expand All @@ -334,15 +334,15 @@ int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen

if( keylen > 0 )
{
if( blake2s_init_key( S, outlen, key, keylen ) < 0 ) return -1;
if( blake2s_init_key( &S, outlen, key, keylen ) < 0 ) return -1;
}
else
{
if( blake2s_init( S, outlen ) < 0 ) return -1;
if( blake2s_init( &S, outlen ) < 0 ) return -1;
}

blake2s_update( S, ( uint8_t * )in, inlen );
blake2s_final( S, out, outlen );
blake2s_update( &S, ( uint8_t * )in, inlen );
blake2s_final( &S, out, outlen );
return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ int scanhash_x17(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *ha
int scanhash_x20r(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
int scanhash_xevan(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
int scanhash_yescrypt(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
int scanhash_yescryptr8(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
int scanhash_yescryptr16(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
int scanhash_yescryptr32(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
int scanhash_zr5(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);

/* api related */
Expand Down Expand Up @@ -562,6 +565,9 @@ void x17hash(void *output, const void *input);
void x20r_hash(void *output, const void *input);
void zr5hash(void *output, const void *input);
void yescrypthash(void *output, const void *input);
void yescrypt_hash_r8(const char* input, char* output, uint32_t len);
void yescrypt_hash_r16(const char* input, char* output, uint32_t len);
void yescrypt_hash_r32(const char* input, char* output, uint32_t len);
void zr5hash_pok(void *output, uint32_t *pdata);


Expand Down
5 changes: 5 additions & 0 deletions sysinfos.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"/sys/class/hwmon/hwmon0/temp2_input"
#define HWMON_ALT5 \
"/sys/class/hwmon/hwmon0/device/temp1_input"
#define HWMON_ALT6 \
"/sys/class/thermal/thermal_zone0/temp"

static float linux_cputemp(int core)
{
Expand All @@ -47,6 +49,9 @@ static float linux_cputemp(int core)
if (!fd)
fd = fopen(HWMON_ALT5, "r");

if (!fd)
fd = fopen(HWMON_ALT6, "r");

if (!fd)
return tc;

Expand Down
9 changes: 9 additions & 0 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,15 @@ void print_hash_tests(void)
yescrypthash(&hash[0], &buf[0]);
printpfx("yescrypt", hash);

yescrypt_hash_r8(&buf[0], &hash[0], 80);
printpfx("yescryptr8", hash);

yescrypt_hash_r16(&buf[0], &hash[0], 80);
printpfx("yescryptr16", hash);

yescrypt_hash_r32(&buf[0], &hash[0], 80);
printpfx("yescryptr32", hash);

//zr5hash(&hash[0], &buf[0]);
zr5hash(&hash[0], (uint32_t*) &buf[0]);
memset(buf, 0, sizeof(buf));
Expand Down
26 changes: 26 additions & 0 deletions yescrypt/yescrypt-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
static const char * const itoa64 =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

char *yescrypt_client_key = NULL;
int yescrypt_client_key_len = 0;

static uint8_t* encode64_uint32(uint8_t* dst, size_t dstlen, uint32_t src, uint32_t srcbits)
{
uint32_t bit;
Expand Down Expand Up @@ -367,6 +370,29 @@ void yescrypt_hash(const char *input, char *output, uint32_t len)
yescrypt_bsty((uint8_t*)input, len, (uint8_t*)input, len, 2048, 8, 1, (uint8_t*)output, 32);
}

void yescrypt_hash_r8(const char *input, char *output, uint32_t len)
{
yescrypt_client_key = "Client Key";
yescrypt_client_key_len = strlen("Client Key");
yescrypt_bsty((uint8_t*)input, len, (uint8_t *)input, len, 2048, 8, 1, (uint8_t*)output, 32);

}

void yescrypt_hash_r16(const char *input, char *output, uint32_t len)
{
yescrypt_client_key = "Client Key";
yescrypt_client_key_len = strlen("Client Key");
yescrypt_bsty((uint8_t*)input, len, (uint8_t*)input, len, 4096, 16, 1, (uint8_t*)output, 32);

}

void yescrypt_hash_r32(const char *input, char *output, uint32_t len)
{
yescrypt_client_key = "WaviBanana";
yescrypt_client_key_len = strlen("WaviBanana");
yescrypt_bsty((uint8_t*)input, len, (uint8_t*)input, len, 4096, 32, 1, (uint8_t*)output, 32);

}
/* for util.c test */
void yescrypthash(void *output, const void *input)
{
Expand Down
6 changes: 5 additions & 1 deletion yescrypt/yescrypt-opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,11 @@ yescrypt_kdf(const yescrypt_shared_t * shared, yescrypt_local_t * local,
{
HMAC_SHA256_CTX_Y ctx;
HMAC_SHA256_Init_Y(&ctx, buf, buflen);
HMAC_SHA256_Update_Y(&ctx, salt, saltlen);
if (yescrypt_client_key != NULL)
HMAC_SHA256_Update_Y(&ctx, yescrypt_client_key,
yescrypt_client_key_len);
else
HMAC_SHA256_Update_Y(&ctx, salt, saltlen);
HMAC_SHA256_Final_Y((uint8_t *)sha256, &ctx);
}
/* Compute StoredKey */
Expand Down
13 changes: 6 additions & 7 deletions yescrypt/yescrypt-simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1355,13 +1355,12 @@ yescrypt_kdf(const yescrypt_shared_t * shared, yescrypt_local_t * local,
{
HMAC_SHA256_CTX_Y ctx;
HMAC_SHA256_Init_Y(&ctx, buf, buflen);
#if 0
/* Proper yescrypt */
HMAC_SHA256_Update_Y(&ctx, "Client Key", 10);
#else
/* GlobalBoost-Y buggy yescrypt */
HMAC_SHA256_Update_Y(&ctx, salt, saltlen);
#endif
if (yescrypt_client_key != NULL)
HMAC_SHA256_Update_Y(&ctx, yescrypt_client_key,
yescrypt_client_key_len);
else
/* GlobalBoost-Y buggy yescrypt */
HMAC_SHA256_Update_Y(&ctx, salt, saltlen);
HMAC_SHA256_Final_Y(sha256, &ctx);
}
/* Compute StoredKey */
Expand Down
7 changes: 7 additions & 0 deletions yescrypt/yescrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ extern "C" {
#include <stdlib.h> /* for size_t */

void yescrypt_hash(const char* input, char* output, uint32_t len);
void yescrypt_hash_r8(const char* input, char* output, uint32_t len);
void yescrypt_hash_r16(const char* input, char* output, uint32_t len);
void yescrypt_hash_r32(const char* input, char* output, uint32_t len);


/**
* crypto_scrypt(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):
Expand Down Expand Up @@ -365,6 +369,9 @@ extern uint8_t * yescrypt_gensalt(
yescrypt_flags_t __flags,
const uint8_t * __src, size_t __srclen);

extern char *yescrypt_client_key;
extern int yescrypt_client_key_len;

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit e3e24f1

Please sign in to comment.