From 94d3ba16240ea7163c035c17791c23db94f493d4 Mon Sep 17 00:00:00 2001 From: pyritepirate <44350183+pyritepirate@users.noreply.github.com> Date: Mon, 31 Dec 2018 03:58:07 +0100 Subject: [PATCH] sha256q algo (#332) --- stratum/algos/makefile | 2 +- stratum/algos/sha256q.c | 32 ++++++++++++++++++++++++++++++ stratum/algos/sha256q.h | 16 +++++++++++++++ stratum/config.sample/sha256q.conf | 17 ++++++++++++++++ stratum/stratum.cpp | 2 ++ stratum/stratum.h | 1 + web/yaamp/core/functions/yaamp.php | 4 ++++ 7 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 stratum/algos/sha256q.c create mode 100644 stratum/algos/sha256q.h create mode 100644 stratum/config.sample/sha256q.conf diff --git a/stratum/algos/makefile b/stratum/algos/makefile index 61999a4b9..d8edf0b44 100644 --- a/stratum/algos/makefile +++ b/stratum/algos/makefile @@ -15,7 +15,7 @@ SOURCES=lyra2re.c lyra2v2.c Lyra2.c lyra2z.c Lyra2-z.c Sponge.c allium.c \ deep.c fresh.c groestl.c neoscrypt.c nist5.c quark.c qubit.c skein.c skein2.c \ bitcore.c timetravel.c x11evo.c x16r.c x16s.c xevan.c bastion.c hmq17.c sonoa.c \ bmw.c luffa.c pentablake.c vitalium.c whirlpool.c whirlpoolx.c zr5.c \ - scrypt.c scryptn.c sha256.c sha256t.c \ + scrypt.c scryptn.c sha256.c sha256t.c sha256q.c \ yescrypt.c yescrypt-opt.c sha256_Y.c \ a5a.c a5amath.c m7m.c magimath.cpp velvet.c \ argon2a.c blake2/blake2b.c ar2/argon2.c ar2/core.c ar2/encoding.c ar2/opt.c ar2/thread.c ar2/ar2-scrypt-jane.c \ diff --git a/stratum/algos/sha256q.c b/stratum/algos/sha256q.c new file mode 100644 index 000000000..1cd7f4d26 --- /dev/null +++ b/stratum/algos/sha256q.c @@ -0,0 +1,32 @@ + +#include +#include +#include +#include + +#include "sha256.h" + +#include + +void sha256q_hash(const char* input, char* output, uint32_t len) +{ + unsigned char hash[64]; + + SHA256_CTX ctx_sha256; + SHA256_Init(&ctx_sha256); + SHA256_Update(&ctx_sha256, input, len); + SHA256_Final(hash, &ctx_sha256); + + SHA256_Init(&ctx_sha256); + SHA256_Update(&ctx_sha256, hash, 32); + SHA256_Final(hash, &ctx_sha256); + + SHA256_Init(&ctx_sha256); + SHA256_Update(&ctx_sha256, hash, 32); + SHA256_Final(hash, &ctx_sha256); + + SHA256_Init(&ctx_sha256); + SHA256_Update(&ctx_sha256, hash, 32); + SHA256_Final((unsigned char*)output, &ctx_sha256); +} + diff --git a/stratum/algos/sha256q.h b/stratum/algos/sha256q.h new file mode 100644 index 000000000..23fd6c1b9 --- /dev/null +++ b/stratum/algos/sha256q.h @@ -0,0 +1,16 @@ +#ifndef SHA256Q_H +#define SHA256Q_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void sha256q_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/config.sample/sha256q.conf b/stratum/config.sample/sha256q.conf new file mode 100644 index 000000000..8b4c0d171 --- /dev/null +++ b/stratum/config.sample/sha256q.conf @@ -0,0 +1,17 @@ +[TCP] +server = yaamp.com +port = 3337 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = sha256q +difficulty = 1 +max_ttf = 40000 +reconnect = 1 + diff --git a/stratum/stratum.cpp b/stratum/stratum.cpp index b8e38c23f..47979ee0b 100644 --- a/stratum/stratum.cpp +++ b/stratum/stratum.cpp @@ -195,6 +195,8 @@ YAAMP_ALGO g_algos[] = {"sha256t", sha256t_hash, 1, 0, 0}, // sha256 3x + {"sha256q", sha256q_hash, 1, 0, 0}, // sha256 4x + {"sib", sib_hash, 1, 0, 0}, {"whirlcoin", whirlpool_hash, 1, 0, sha256_hash_hex }, /* old sha merkleroot */ diff --git a/stratum/stratum.h b/stratum/stratum.h index 636141af5..5aa4a75ba 100644 --- a/stratum/stratum.h +++ b/stratum/stratum.h @@ -180,6 +180,7 @@ void sha256_double_hash_hex(const char *input, char *output, unsigned int len); #include "algos/skein.h" #include "algos/keccak.h" #include "algos/sha256t.h" +#include "algos/sha256q.h" #include "algos/skunk.h" #include "algos/timetravel.h" #include "algos/bitcore.h" diff --git a/web/yaamp/core/functions/yaamp.php b/web/yaamp/core/functions/yaamp.php index aaf31000a..f604ca22d 100755 --- a/web/yaamp/core/functions/yaamp.php +++ b/web/yaamp/core/functions/yaamp.php @@ -6,6 +6,7 @@ function yaamp_get_algos() return array( 'sha256', 'sha256t', + 'sha256q', 'scrypt', 'scryptn', 'allium', @@ -84,6 +85,7 @@ function yaamp_algo_mBTC_factor($algo) switch($algo) { case 'sha256': case 'sha256t': + case 'sha256q': case 'blake': case 'blakecoin': case 'blake2s': @@ -144,6 +146,7 @@ function getAlgoColors($algo) $a = array( 'sha256' => '#d0d0a0', 'sha256t' => '#d0d0f0', + 'sha256q' => '#9696dd', 'scrypt' => '#c0c0e0', 'neoscrypt' => '#a0d0f0', 'scryptn' => '#d0d0d0', @@ -226,6 +229,7 @@ function getAlgoPort($algo) $a = array( 'sha256' => 3333, 'sha256t' => 3339, + 'sha256q' => 3337, 'lbry' => 3334, 'scrypt' => 3433, 'timetravel' => 3555,