From b43d6465486572b3451c34bf373eada3a5262145 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 6 May 2018 16:50:23 +0200 Subject: [PATCH] handle allium algo, kind of double lyra2 --- rc.local | 3 +- stratum/algos/allium.c | 46 ++++++++++++++++++++++++++++++ stratum/algos/allium.h | 16 +++++++++++ stratum/algos/makefile | 2 +- stratum/config.sample/allium.conf | 15 ++++++++++ stratum/stratum.cpp | 1 + stratum/stratum.h | 1 + web/yaamp/core/functions/yaamp.php | 3 ++ 8 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 stratum/algos/allium.c create mode 100644 stratum/algos/allium.h create mode 100644 stratum/config.sample/allium.conf diff --git a/rc.local b/rc.local index 9da2b84..dec3336 100644 --- a/rc.local +++ b/rc.local @@ -49,7 +49,8 @@ screen -dmS jha $STRATUM_DIR/run.sh jha #screen -dmS dmd-gr $STRATUM_DIR/run.sh dmd-gr screen -dmS myr-gr $STRATUM_DIR/run.sh myr-gr screen -dmS lbry $STRATUM_DIR/run.sh lbry -screen -dmS lyra2 $STRATUM_DIR/run.sh lyra2 +screen -dmS allium $STRATUM_DIR/run.sh allium +#screen -dmS lyra2 $STRATUM_DIR/run.sh lyra2 screen -dmS lyra2v2 $STRATUM_DIR/run.sh lyra2v2 screen -dmS zero $STRATUM_DIR/run.sh lyra2z diff --git a/stratum/algos/allium.c b/stratum/algos/allium.c new file mode 100644 index 0000000..4c3569d --- /dev/null +++ b/stratum/algos/allium.c @@ -0,0 +1,46 @@ +#include + +#include "sha3/sph_blake.h" +#include "sha3/sph_groestl.h" +#include "sha3/sph_skein.h" +#include "sha3/sph_keccak.h" +#include "sha3/sph_cubehash.h" + +#include "Lyra2.h" + +void allium_hash(const char* input, char* output, uint32_t len) +{ + uint32_t hashA[8], hashB[8]; + + sph_blake256_context ctx_blake; + sph_keccak256_context ctx_keccak; + sph_cubehash512_context ctx_cubehash; + sph_skein256_context ctx_skein; + sph_groestl256_context ctx_groestl; + + sph_blake256_init(&ctx_blake); + sph_blake256(&ctx_blake, input, 80); + sph_blake256_close(&ctx_blake, hashA); + + sph_keccak256_init(&ctx_keccak); + sph_keccak256(&ctx_keccak, hashA, 32); + sph_keccak256_close(&ctx_keccak, hashB); + + LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8); + + sph_cubehash256_init(&ctx_cubehash); + sph_cubehash256(&ctx_cubehash, hashA, 32); + sph_cubehash256_close(&ctx_cubehash, hashB); + + LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8); + + sph_skein256_init(&ctx_skein); + sph_skein256(&ctx_skein, hashA, 32); + sph_skein256_close(&ctx_skein, hashB); + + sph_groestl256_init(&ctx_groestl); + sph_groestl256(&ctx_groestl, hashB, 32); + sph_groestl256_close(&ctx_groestl, hashA); + + memcpy(output, hashA, 32); +} diff --git a/stratum/algos/allium.h b/stratum/algos/allium.h new file mode 100644 index 0000000..3705161 --- /dev/null +++ b/stratum/algos/allium.h @@ -0,0 +1,16 @@ +#ifndef ALLIUM_H +#define ALLIUM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void allium_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/makefile b/stratum/algos/makefile index c6e5200..e2a7141 100644 --- a/stratum/algos/makefile +++ b/stratum/algos/makefile @@ -8,7 +8,7 @@ CXXFLAGS = -O2 -I.. -march=native CFLAGS= $(CXXFLAGS) -std=gnu99 LDFLAGS=-O2 -lgmp -SOURCES=lyra2re.c lyra2v2.c Lyra2.c lyra2z.c Lyra2z.c Sponge.c \ +SOURCES=lyra2re.c lyra2v2.c Lyra2.c lyra2z.c Lyra2z.c Sponge.c allium.c \ blake.c scrypt.c c11.c x11.c x12.c x13.c sha256.c sha256t.c jha.c keccak.c deep.c tribus.c \ hsr14.c sm3.c \ x14.c x15.c x17.c nist5.c fresh.c quark.c neoscrypt.c scryptn.c qubit.c skein.c groestl.c \ diff --git a/stratum/config.sample/allium.conf b/stratum/config.sample/allium.conf new file mode 100644 index 0000000..ec9d41f --- /dev/null +++ b/stratum/config.sample/allium.conf @@ -0,0 +1,15 @@ +[TCP] +server = yaamp.com +port = 4443 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = allium +difficulty = 0.01 +max_ttf = 4000000 diff --git a/stratum/stratum.cpp b/stratum/stratum.cpp index 8f6f09e..73717ae 100644 --- a/stratum/stratum.cpp +++ b/stratum/stratum.cpp @@ -133,6 +133,7 @@ YAAMP_ALGO g_algos[] = {"jha", jha_hash, 0x10000, 0}, + {"allium", allium_hash, 1, 0, 0}, {"lyra2", lyra2re_hash, 0x80, 0, 0}, {"lyra2v2", lyra2v2_hash, 0x100, 0, 0}, {"lyra2z", lyra2z_hash, 0x100, 0, 0}, diff --git a/stratum/stratum.h b/stratum/stratum.h index 6604d1a..fdbf124 100644 --- a/stratum/stratum.h +++ b/stratum/stratum.h @@ -164,6 +164,7 @@ void sha256_double_hash_hex(const char *input, char *output, unsigned int len); #include "algos/hsr14.h" #include "algos/quark.h" #include "algos/neoscrypt.h" +#include "algos/allium.h" #include "algos/lyra2re.h" #include "algos/lyra2v2.h" #include "algos/lyra2z.h" diff --git a/web/yaamp/core/functions/yaamp.php b/web/yaamp/core/functions/yaamp.php index 0167c94..e7adae2 100755 --- a/web/yaamp/core/functions/yaamp.php +++ b/web/yaamp/core/functions/yaamp.php @@ -8,6 +8,7 @@ function yaamp_get_algos() 'sha256t', 'scrypt', 'scryptn', + 'allium', 'argon2', 'bastion', 'bitcore', @@ -148,6 +149,7 @@ function getAlgoColors($algo) 'x16s' => '#f0b080', 'x17' => '#f0b0a0', 'xevan' => '#f0b0a0', + 'allium' => '#80a0d0', 'argon2' => '#e0d0e0', 'bastion' => '#e0b0b0', 'blake' => '#f0f0f0', @@ -227,6 +229,7 @@ function getAlgoPort($algo) 'neoscrypt' => 4233, 'argon2' => 4234, 'scryptn' => 4333, + 'allium' => 4443, 'lyra2' => 4433, 'lyra2v2' => 4533, 'lyra2z' => 4553,