From 8ccbb81ad9af19871353b1a910ad40fc9c02a1c2 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Mon, 12 Apr 2021 12:20:01 +0200 Subject: [PATCH 1/6] ifdef fix for armv7 (PR #50) --- algo/rainforest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algo/rainforest.c b/algo/rainforest.c index 914ea7758..d938fda4a 100644 --- a/algo/rainforest.c +++ b/algo/rainforest.c @@ -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, From 7411020cefb5809202dd0db346df947a4561db4b Mon Sep 17 00:00:00 2001 From: 0x9fff00 <0x9fff00+git@protonmail.ch> Date: Wed, 26 May 2021 14:14:30 +0200 Subject: [PATCH 2/6] Fix compile error with GCC 11 Based on https://github.com/JayDDee/cpuminer-opt/commit/3c5e8921b764e03ef09c57b2207b9960d45123b0 Co-authored-by: Jay D Dee --- crypto/blake2s.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crypto/blake2s.c b/crypto/blake2s.c index a20b746c1..0914b5aa7 100644 --- a/crypto/blake2s.c +++ b/crypto/blake2s.c @@ -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; @@ -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; } From e1dedc1691dc4af8d5b3c3449512e6a95bf18c9e Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Thu, 31 May 2018 21:19:19 +0200 Subject: [PATCH 3/6] yescrypt: add support for yescryptr8, yescryptr16 and yescryptr32. Those are slight variations of the yescrypt algorithm, used notably by bitzeny (yescryptr8), yenten (yescryptr16), and wavi (yescryptr32). --- algo/yescrypt.c | 24 ++++++++++++++++++++++-- cpu-miner.c | 26 ++++++++++++++++++++++++++ miner.h | 3 +++ yescrypt/yescrypt-common.c | 26 ++++++++++++++++++++++++++ yescrypt/yescrypt-opt.c | 6 +++++- yescrypt/yescrypt-simd.c | 13 ++++++------- yescrypt/yescrypt.h | 7 +++++++ 7 files changed, 95 insertions(+), 10 deletions(-) diff --git a/algo/yescrypt.c b/algo/yescrypt.c index d90d5ada2..056abfc9f 100644 --- a/algo/yescrypt.c +++ b/algo/yescrypt.c @@ -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]; @@ -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; @@ -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)); +} diff --git a/cpu-miner.c b/cpu-miner.c index 224a91c8f..0a6e57004 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -141,6 +141,9 @@ enum algos { ALGO_X20R, ALGO_XEVAN, ALGO_YESCRYPT, + ALGO_YESCRYPTR8, + ALGO_YESCRYPTR16, + ALGO_YESCRYPTR32, ALGO_ZR5, ALGO_COUNT }; @@ -210,6 +213,9 @@ static const char *algo_names[] = { "x20r", "xevan", "yescrypt", + "yescryptr8", + "yescryptr16", + "yescryptr32", "zr5", "\0" }; @@ -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\ @@ -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: @@ -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: @@ -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; diff --git a/miner.h b/miner.h index f71596d87..9a792b2c7 100644 --- a/miner.h +++ b/miner.h @@ -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 */ diff --git a/yescrypt/yescrypt-common.c b/yescrypt/yescrypt-common.c index f68c1b8e3..a306d6819 100644 --- a/yescrypt/yescrypt-common.c +++ b/yescrypt/yescrypt-common.c @@ -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; @@ -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) { diff --git a/yescrypt/yescrypt-opt.c b/yescrypt/yescrypt-opt.c index e25d20b97..8862bce91 100644 --- a/yescrypt/yescrypt-opt.c +++ b/yescrypt/yescrypt-opt.c @@ -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 */ diff --git a/yescrypt/yescrypt-simd.c b/yescrypt/yescrypt-simd.c index 49fdb7132..dfc9c2c12 100644 --- a/yescrypt/yescrypt-simd.c +++ b/yescrypt/yescrypt-simd.c @@ -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 */ diff --git a/yescrypt/yescrypt.h b/yescrypt/yescrypt.h index db7221778..1775a48d8 100644 --- a/yescrypt/yescrypt.h +++ b/yescrypt/yescrypt.h @@ -39,6 +39,10 @@ extern "C" { #include /* 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): @@ -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 From a7df963504b81b676ddc22154df1abbfee9900d8 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 20 Jun 2021 21:40:10 +0200 Subject: [PATCH 4/6] yescrypt variants cputest --- cpu-miner.c | 6 +++--- miner.h | 3 +++ util.c | 9 +++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cpu-miner.c b/cpu-miner.c index 0a6e57004..5e8948d80 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -382,9 +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\ + 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\ diff --git a/miner.h b/miner.h index 9a792b2c7..34574030f 100644 --- a/miner.h +++ b/miner.h @@ -565,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); diff --git a/util.c b/util.c index e31f99553..5ba320b53 100644 --- a/util.c +++ b/util.c @@ -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)); From 9b94adcbea45f7449a877470bf406894d8bfde81 Mon Sep 17 00:00:00 2001 From: Divakar V Prabhu Date: Sat, 23 May 2020 21:23:08 +0530 Subject: [PATCH 5/6] Check for cpu temperature in thermal class --- sysinfos.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sysinfos.c b/sysinfos.c index c8f1057c7..3b6c5811b 100644 --- a/sysinfos.c +++ b/sysinfos.c @@ -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) { @@ -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; From d2927ed23b1d0eacd067c320fce64e6610737adb Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 20 Jun 2021 22:05:42 +0200 Subject: [PATCH 6/6] update Readme --- NEWS | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 6f21fd595..f9c2f544d 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/README.md b/README.md index b7edf9918..315a84a83 100644 --- a/README.md +++ b/README.md @@ -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..)