Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rc.local
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ screen -dmS argon2 $STRATUM_DIR/run.sh argon2
screen -dmS argon2d-dyn $STRATUM_DIR/run.sh argon2d-dyn
screen -dmS x22i $STRATUM_DIR/run.sh x22i
screen -dmS lbk3 $STRATUM_DIR/run.sh lbk3
screen -dmS x25x $STRATUM_DIR/run.sh x25x

2 changes: 1 addition & 1 deletion stratum/algos/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LDFLAGS=-O2 -lgmp

SOURCES=lyra2re.c lyra2v2.c lyra2v3.c Lyra2.c lyra2z.c Lyra2-z.c lyra2zz.c Lyra2-zz.c Sponge.c allium.c \
c11.c x11.c x12.c x13.c hsr14.c sm3.c x14.c x15.c x17.c \
x22i.c SWIFFTX/SWIFFTX.c \
x22i.c SWIFFTX/SWIFFTX.c x25x.c \
blake.c blakecoin.c blake2b.c blake2s.c jha.c keccak.c lbry.c tribus.c exosis.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 \
Expand Down
15 changes: 15 additions & 0 deletions stratum/algos/x22i.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,18 @@ void x22i_hash(const char* input, char* output, uint32_t len)

memcpy(output, hash, 32);
}

void hexlify(char *hex, const unsigned char *bin, int len)
{
hex[0] = 0;
for(int i=0; i < len; i++)
sprintf(hex+strlen(hex), "%02x", bin[i]);
}

void x22i_hash_hex(const char *input, char *output, unsigned int len)
{
char output1[32];

x22i_hash(input, output1, len);
hexlify(output, (unsigned char *)output1, 32);
}
1 change: 1 addition & 0 deletions stratum/algos/x22i.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extern "C" {
#include <stdint.h>

void x22i_hash(const char* input, char* output, uint32_t len);
void x22i_hash_hex(const char *input, char *output, unsigned int len);

#ifdef __cplusplus
}
Expand Down
169 changes: 169 additions & 0 deletions stratum/algos/x25x.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#include <string.h>

#include <sha3/sph_blake.h>
#include <sha3/sph_bmw.h>
#include <sha3/sph_groestl.h>
#include <sha3/sph_jh.h>
#include <sha3/sph_keccak.h>
#include <sha3/sph_skein.h>
#include <sha3/sph_luffa.h>
#include <sha3/sph_cubehash.h>
#include <sha3/sph_shavite.h>
#include <sha3/sph_simd.h>
#include <sha3/sph_echo.h>
#include <sha3/sph_hamsi.h>
#include <sha3/sph_fugue.h>
#include <sha3/sph_shabal.h>
#include <sha3/sph_whirlpool.h>
#include <sha3/sph_sha2.h>
#include <sha3/sph_haval.h>
#include <sha3/sph_tiger.h>
#include <sha3/sph_panama.h>
#include <sha3/blake2s.h>
#include <sha3/lane.h>

#include "SWIFFTX/SWIFFTX.h"
#include "gost.h"
#include "Lyra2.h"

void x25x_hash(const char* input, char* output, uint32_t len)
{
sph_blake512_context ctx_blake;
sph_bmw512_context ctx_bmw;
sph_groestl512_context ctx_groestl;
sph_jh512_context ctx_jh;
sph_keccak512_context ctx_keccak;
sph_skein512_context ctx_skein;
sph_luffa512_context ctx_luffa;
sph_cubehash512_context ctx_cubehash;
sph_shavite512_context ctx_shavite;
sph_simd512_context ctx_simd;
sph_echo512_context ctx_echo;
sph_hamsi512_context ctx_hamsi;
sph_fugue512_context ctx_fugue;
sph_shabal512_context ctx_shabal;
sph_whirlpool_context ctx_whirlpool;
sph_sha512_context ctx_sha512;
sph_haval256_5_context ctx_haval;
sph_tiger_context ctx_tiger;
sph_gost512_context ctx_gost;
sph_sha256_context ctx_sha;
sph_panama_context ctx_panama;

unsigned char hash[25][64] = { 0 };

sph_blake512_init(&ctx_blake);
sph_blake512(&ctx_blake, input, len);
sph_blake512_close (&ctx_blake, &hash[0]);

sph_bmw512_init(&ctx_bmw);
sph_bmw512(&ctx_bmw, &hash[0], 64);
sph_bmw512_close(&ctx_bmw, &hash[1]);

sph_groestl512_init(&ctx_groestl);
sph_groestl512(&ctx_groestl, &hash[1], 64);
sph_groestl512_close(&ctx_groestl, &hash[2]);

sph_skein512_init(&ctx_skein);
sph_skein512(&ctx_skein, &hash[2], 64);
sph_skein512_close(&ctx_skein, &hash[3]);

sph_jh512_init(&ctx_jh);
sph_jh512(&ctx_jh, &hash[3], 64);
sph_jh512_close(&ctx_jh, &hash[4]);

sph_keccak512_init(&ctx_keccak);
sph_keccak512(&ctx_keccak, &hash[4], 64);
sph_keccak512_close(&ctx_keccak, &hash[5]);

sph_luffa512_init(&ctx_luffa);
sph_luffa512(&ctx_luffa, &hash[5], 64);
sph_luffa512_close (&ctx_luffa, &hash[6]);

sph_cubehash512_init(&ctx_cubehash);
sph_cubehash512(&ctx_cubehash, &hash[6], 64);
sph_cubehash512_close(&ctx_cubehash, &hash[7]);

sph_shavite512_init(&ctx_shavite);
sph_shavite512(&ctx_shavite, &hash[7], 64);
sph_shavite512_close(&ctx_shavite, &hash[8]);

sph_simd512_init(&ctx_simd);
sph_simd512(&ctx_simd, &hash[8], 64);
sph_simd512_close(&ctx_simd, &hash[9]);

sph_echo512_init(&ctx_echo);
sph_echo512(&ctx_echo, &hash[9], 64);
sph_echo512_close(&ctx_echo, &hash[10]);

sph_hamsi512_init(&ctx_hamsi);
sph_hamsi512(&ctx_hamsi, &hash[10], 64);
sph_hamsi512_close(&ctx_hamsi, &hash[11]);

sph_fugue512_init(&ctx_fugue);
sph_fugue512(&ctx_fugue, &hash[11], 64);
sph_fugue512_close(&ctx_fugue, &hash[12]);

sph_shabal512_init(&ctx_shabal);
sph_shabal512(&ctx_shabal, (const void*) &hash[12], 64);
sph_shabal512_close(&ctx_shabal, &hash[13]);

sph_whirlpool_init(&ctx_whirlpool);
sph_whirlpool (&ctx_whirlpool, (const void*) &hash[13], 64);
sph_whirlpool_close(&ctx_whirlpool, &hash[14]);

sph_sha512_init(&ctx_sha512);
sph_sha512(&ctx_sha512,(const void*) &hash[14], 64);
sph_sha512_close(&ctx_sha512,(void*) &hash[15]);

unsigned char temp[SWIFFTX_OUTPUT_BLOCK_SIZE] = {0};
InitializeSWIFFTX();
ComputeSingleSWIFFTX((unsigned char*)&hash[12], temp, false);
memcpy((unsigned char*)&hash[16], temp, 64);

sph_haval256_5_init(&ctx_haval);
sph_haval256_5(&ctx_haval,(const void*) &hash[16], 64);
sph_haval256_5_close(&ctx_haval,&hash[17]);

sph_tiger_init(&ctx_tiger);
sph_tiger (&ctx_tiger, (const void*) &hash[17], 64);
sph_tiger_close(&ctx_tiger, (void*) &hash[18]);

LYRA2((void*) &hash[19], 32, (const void*) &hash[18], 32, (const void*) &hash[18], 32, 1, 4, 4);

sph_gost512_init(&ctx_gost);
sph_gost512 (&ctx_gost, (const void*) &hash[19], 64);
sph_gost512_close(&ctx_gost, (void*) &hash[20]);

sph_sha256_init(&ctx_sha);
sph_sha256 (&ctx_sha, (const void*) &hash[20], 64);
sph_sha256_close(&ctx_sha, (void*) &hash[21]);

sph_panama_init(&ctx_panama);
sph_panama (&ctx_panama, (const void*) &hash[21], 64 );
sph_panama_close(&ctx_panama, (void*) &hash[22]);

laneHash(512, (const BitSequence*) &hash[22], 512, (BitSequence*) &hash[23]);

// NEW simple shuffle algorithm, instead of just reversing
#define X25X_SHUFFLE_BLOCKS (24 /* number of algos so far */ * 64 /* output bytes per algo */ / 2 /* block size */)
#define X25X_SHUFFLE_ROUNDS 12

static const uint16_t x25x_round_const[X25X_SHUFFLE_ROUNDS] = {
0x142c, 0x5830, 0x678c, 0xe08c,
0x3c67, 0xd50d, 0xb1d8, 0xecb2,
0xd7ee, 0x6783, 0xfa6c, 0x4b9c
};

uint16_t* block_pointer = (uint16_t*)hash;
for (int r = 0; r < X25X_SHUFFLE_ROUNDS; r++) {
for (int i = 0; i < X25X_SHUFFLE_BLOCKS; i++) {
uint16_t block_value = block_pointer[X25X_SHUFFLE_BLOCKS - i - 1];
block_pointer[i] ^= block_pointer[block_value % X25X_SHUFFLE_BLOCKS] + (x25x_round_const[r] << (i % 16));
}
}

blake2s_simple((uint8_t*)&hash[24], (const void*)(&hash[0]), 64 * 24);

memcpy(output, &hash[24], 32);
}
11 changes: 11 additions & 0 deletions stratum/algos/x25x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

void x25x_hash(const char* input, char* output, uint32_t len);

#ifdef __cplusplus
}
#endif
4 changes: 4 additions & 0 deletions stratum/client_submit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL

merkle_hash((char *)submitvalues->header_bin, doublehash2, strlen(submitvalues->header_be)/2);

// isnt perfect, but it works
if(strcmp(coind->symbol, "SIN") == 0)
x22i_hash_hex((char *)submitvalues->header_bin, doublehash2, strlen(submitvalues->header_be)/2);

char hash1[1024];
memset(hash1, 0, 1024);

Expand Down
41 changes: 41 additions & 0 deletions stratum/coinbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,47 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
if (strlen(coind->charity_address) == 0)
sprintf(coind->charity_address, "EdFwYw4Mo2Zq6CFM2yNJgXvE2DTJxgdBRX");
}

if(strcmp(coind->symbol, "SIN") == 0)
{
int npayees = 1;
char payees[2];
char sinpayee[256] = {0};
char sinscript[1024] = {0};
char devpayee[256] = {0};
char devscript[1024] = {0};
const char *devpayaddr = json_get_string(json_result, "payee");
json_int_t devfee_amount = json_get_int(json_result, "payee_amount");
snprintf(devpayee, 255, "%s", devpayaddr);
base58_decode(devpayee, devscript);
npayees++;

available -= devfee_amount;
const char* mnpayaddrs[7] = {0};
json_value* masternodes = json_get_array(json_result, "masternode");
json_int_t mnamounts[7] = {0};
for(int i = 0; i < masternodes->u.array.length; i++) {
mnpayaddrs[i] = json_get_string(masternodes->u.array.values[i], "payee");
mnamounts[i] = json_get_int(masternodes->u.array.values[i], "amount");
available -= mnamounts[i];
npayees++;
}

sprintf(payees, "%02x", npayees);
strcat(templ->coinb2, payees);
job_pack_tx(coind, templ->coinb2, available, NULL);
job_pack_tx(coind, templ->coinb2, devfee_amount, devscript);
for(int i = 0; i < masternodes->u.array.length; i++) {
snprintf(sinpayee, 255, "%s", mnpayaddrs[i]);
base58_decode(sinpayee, sinscript);
job_pack_tx(coind, templ->coinb2, mnamounts[i], sinscript);
}

strcat(templ->coinb2, "00000000");
coind->reward = (double)available/100000000;
return;
}

else if(strcmp(coind->symbol, "DYN") == 0)
{
char script_dests[2048] = { 0 };
Expand Down
16 changes: 16 additions & 0 deletions stratum/config.sample/x25x.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[TCP]
server = yaamp.com
port = 5633
password = tu8tu5

[SQL]
host = yaampdb
database = yaamp
username = root
password = patofpaq

[STRATUM]
algo = x25x
difficulty = 0.0025
max_ttf = 50000

Loading