From 7a0112c6a9e95e1244dc1c5064d59e9e96797eac Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sat, 4 Jul 2015 16:28:13 +0200 Subject: [PATCH] add skein2 stratum support and change some algo colors --- rc.local | 3 +++ stratum/algos/makefile | 2 +- stratum/algos/skein2.c | 27 +++++++++++++++++++++++++++ stratum/algos/skein2.h | 16 ++++++++++++++++ stratum/stratum.cpp | 1 + stratum/stratum.h | 1 + web/yaamp/core/functions/yaamp.php | 26 ++++++++++++++++++++++---- 7 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 stratum/algos/skein2.c create mode 100644 stratum/algos/skein2.h diff --git a/rc.local b/rc.local index 03df3f9..4139fe0 100644 --- a/rc.local +++ b/rc.local @@ -26,6 +26,9 @@ screen -dmS neo /var/stratum/run.sh neo screen -dmS quark /var/stratum/run.sh quark #screen -dmS qubit /var/stratum/run.sh qubit screen -dmS lyra2 /var/stratum/run.sh lyra2 + +screen -dmS skein /var/stratum/run.sh skein +#screen -dmS skein2 /var/stratum/run.sh skein2 screen -dmS zr5 /var/stratum/run.sh zr5 screen -dmS drop /var/stratum/run.sh drop diff --git a/stratum/algos/makefile b/stratum/algos/makefile index 441f5e8..dd84444 100644 --- a/stratum/algos/makefile +++ b/stratum/algos/makefile @@ -9,7 +9,7 @@ LDFLAGS=-O2 SOURCES=Lyra2RE.c Lyra2.c Sponge.c blake.c scrypt.c c11.c x11.c x13.c sha256.c keccak.c \ x14.c x15.c nist5.c fresh.c quark.c neoscrypt.c scryptn.c qubit.c skein.c groestl.c \ - zr5.c drop.c + skein2.c zr5.c drop.c OBJECTS=$(SOURCES:.c=.o) OUTPUT=libalgos.a diff --git a/stratum/algos/skein2.c b/stratum/algos/skein2.c new file mode 100644 index 0000000..64262ce --- /dev/null +++ b/stratum/algos/skein2.c @@ -0,0 +1,27 @@ + +#include "skein2.h" + +#include +#include +#include +#include + +#include "../sha3/sph_skein.h" +#include "sha256.h" + +#include + +void skein2_hash(const char* input, char* output, uint32_t len) +{ + char temp[64]; + + sph_skein512_context ctx_skien; + sph_skein512_init(&ctx_skien); + sph_skein512(&ctx_skien, input, len); + sph_skein512_close(&ctx_skien, &temp); + + sph_skein512_init(&ctx_skien); + sph_skein512(&ctx_skien, &temp, 64); + sph_skein512_close(&ctx_skien, &output[0]); +} + diff --git a/stratum/algos/skein2.h b/stratum/algos/skein2.h new file mode 100644 index 0000000..6883c11 --- /dev/null +++ b/stratum/algos/skein2.h @@ -0,0 +1,16 @@ +#ifndef SKEIN2_H +#define SKEIN2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void skein2_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/stratum.cpp b/stratum/stratum.cpp index 025917d..1936c03 100644 --- a/stratum/stratum.cpp +++ b/stratum/stratum.cpp @@ -107,6 +107,7 @@ YAAMP_ALGO g_algos[] = {"skein", skein_hash, 1, 0, 0}, {"keccak", keccak_hash, 1, 0, 0}, + {"skein2", skein2_hash, 1, 0, 0}, {"zr5", zr5_hash, 1, 0, 0}, {"drop", drop_hash, 0x10000, 0x10000, 0}, diff --git a/stratum/stratum.h b/stratum/stratum.h index cfad329..6407dbd 100644 --- a/stratum/stratum.h +++ b/stratum/stratum.h @@ -135,6 +135,7 @@ void sha256_double_hash_hex(const char *input, char *output, unsigned int len); #include "algos/keccak.h" //#include "algos/whirlpoolx.h" +#include "algos/skein2.h" #include "algos/zr5.h" #include "algos/drop.h" //#include "jha.h" diff --git a/web/yaamp/core/functions/yaamp.php b/web/yaamp/core/functions/yaamp.php index b26d4cb..f62e763 100755 --- a/web/yaamp/core/functions/yaamp.php +++ b/web/yaamp/core/functions/yaamp.php @@ -2,7 +2,21 @@ function yaamp_get_algos() { - return array('sha256', /*'scrypt', 'scryptn',*/ 'neoscrypt', 'quark', 'lyra2', 'qubit', 'c11', 'x11', 'x13', 'x15', 'zr5', 'drop'); + return array( + 'sha256', + 'scrypt',// 'scryptn', + 'neoscrypt','lyra2', + 'quark', + 'qubit', + 'c11', + 'x11', + //'x13','x15', + //'groestl', << dmd-gr -m 256 + 'skein', + //'skein2', + 'drop', + 'zr5', + ); } function yaamp_get_algo_norm($algo) @@ -27,6 +41,7 @@ function yaamp_get_algo_norm($algo) 'groestl' => 5, 'blake' => 300, 'keccak' => 160, + 'skein2' => 300, 'zr5' => 5.5, 'drop' => 1.5, ); @@ -44,7 +59,7 @@ function getAlgoColors($algo) 'scrypt' => '#c0c0e0', 'neoscrypt' => '#a0d0f0', 'scryptn' => '#d0d0d0', - 'c11' => '#e0f0b0', + 'c11' => '#a0a0d0', 'x11' => '#f0f0a0', 'x13' => '#d0f0c0', 'x14' => '#a0f0c0', @@ -53,6 +68,8 @@ function getAlgoColors($algo) 'quark' => '#c0c0c0', 'qubit' => '#d0a0f0', 'lyra2' => '#80a0f0', + 'skein' => '#80a0a0', + 'skein2' => '#a0a0a0', 'zr5' => '#d0b0d0', 'drop' => '#d0b0d0', ); @@ -84,9 +101,10 @@ function getAlgoPort($algo) 'qubit' => 4733, 'zr5' => 4833, 'skein' => 4933, - 'groestl' => 5033, - 'keccak' => 5133, 'drop' => 5033, + 'keccak' => 5133, + 'skein2' => 5233, + 'groestl' => 5333, 'zr5' => 5533, );