refresh/fix jha algo, keep only the last variant

This commit is contained in:
Tanguy Pruvot 2017-05-08 06:21:59 +02:00
parent 21a859a108
commit 1c22ec4df6
10 changed files with 87 additions and 123 deletions

View file

@ -43,6 +43,7 @@ screen -dmS nist5 $STRATUM_DIR/run.sh nist5
screen -dmS penta $STRATUM_DIR/run.sh penta
screen -dmS quark $STRATUM_DIR/run.sh quark
screen -dmS qubit $STRATUM_DIR/run.sh qubit
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

4
stratum/algos/common.h Normal file
View file

@ -0,0 +1,4 @@
#define _ALIGN(x) __attribute__ ((aligned(x)))
extern void debuglog_hex(void *data, int len);

View file

@ -1,135 +1,56 @@
#include "jha.h"
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "../sha3/sph_blake.h"
#include "../sha3/sph_groestl.h"
#include "../sha3/sph_jh.h"
#include "../sha3/sph_keccak.h"
#include "../sha3/sph_skein.h"
#include <sha3/sph_blake.h>
#include <sha3/sph_groestl.h>
#include <sha3/sph_jh.h>
#include <sha3/sph_keccak.h>
#include <sha3/sph_skein.h>
#include "jha.h"
#include "common.h"
void jha_hash(const char* input, char* output, uint32_t len) {
void jha_hash(const char* input, char* output, uint32_t len)
{
sph_blake512_context ctx_blake;
sph_groestl512_context ctx_groestl;
sph_jh512_context ctx_jh;
sph_keccak512_context ctx_keccak;
sph_skein512_context ctx_skein;
uint32_t hash[16];
uint32_t _ALIGN(64) hash[16];
unsigned int round_mask = (
(unsigned int)(((unsigned char *)input)[84]) << 0 |
(unsigned int)(((unsigned char *)input)[85]) << 8 |
(unsigned int)(((unsigned char *)input)[86]) << 16 |
(unsigned int)(((unsigned char *)input)[87]) << 24 );
//
// JHA V7
//
if (round_mask == 7) {
//
// Input Hashing with SHA3 512, 88 bytes
//
// JHA v8: SHA3 512, on 80 bytes (not 88)
sph_keccak512_init(&ctx_keccak);
sph_keccak512 (&ctx_keccak, input, 88);
sph_keccak512_close(&ctx_keccak, hash);
//
// Variable Rounds Loop
//
unsigned int rounds = hash[0] & 7;
unsigned int round;
for (round = 0; round < rounds; round++) {
switch (hash[0] & 3) {
case 0:
sph_blake512_init(&ctx_blake);
sph_blake512 (&ctx_blake, hash, 64);
sph_blake512_close(&ctx_blake, hash);
break;
case 1:
sph_groestl512_init(&ctx_groestl);
sph_groestl512 (&ctx_groestl, hash, 64);
sph_groestl512_close(&ctx_groestl, hash);
break;
case 2:
sph_jh512_init(&ctx_jh);
sph_jh512 (&ctx_jh, hash, 64);
sph_jh512_close(&ctx_jh, hash);
break;
case 3:
sph_skein512_init(&ctx_skein);
sph_skein512 (&ctx_skein, hash, 64);
sph_skein512_close(&ctx_skein, hash);
break;
}
}
//
// Return 256bit(32x8)
//
memcpy(output, hash, 32);
}
//
// JHA V8
//
else if (round_mask == 8) {
//
// Input Hashing with SHA3 512, 80 bytes
//
sph_keccak512_init(&ctx_keccak);
sph_keccak512 (&ctx_keccak, input, 80);
sph_keccak512(&ctx_keccak, input, 80);
sph_keccak512_close(&ctx_keccak, (&hash));
//
// Heavy & Light Pair Loop
//
unsigned int round;
for (round = 0; round < 3; round++) {
for (int round = 0; round < 3; round++)
{
if (hash[0] & 0x01) {
sph_groestl512_init(&ctx_groestl);
sph_groestl512 (&ctx_groestl, (&hash), 64);
sph_groestl512(&ctx_groestl, (&hash), 64);
sph_groestl512_close(&ctx_groestl, (&hash));
}
else {
} else {
sph_skein512_init(&ctx_skein);
sph_skein512 (&ctx_skein, (&hash), 64);
sph_skein512(&ctx_skein, (&hash), 64);
sph_skein512_close(&ctx_skein, (&hash));
}
if (hash[0] & 0x01) {
sph_blake512_init(&ctx_blake);
sph_blake512 (&ctx_blake, (&hash), 64);
sph_blake512(&ctx_blake, (&hash), 64);
sph_blake512_close(&ctx_blake, (&hash));
}
else {
} else {
sph_jh512_init(&ctx_jh);
sph_jh512 (&ctx_jh, (&hash), 64);
sph_jh512(&ctx_jh, (&hash), 64);
sph_jh512_close(&ctx_jh, (&hash));
}
}
//
// Return 256bit(32x8)
//
// Return 256 bits (32x8)
memcpy(output, hash, 32);
}
//
// Wrong Round Mask Data
//
else {
memset(output, 0xFF, 32);
}
}

View file

@ -9,7 +9,7 @@ CFLAGS= $(CXXFLAGS) -std=gnu99
LDFLAGS=-O2 -lgmp
SOURCES=lyra2re.c lyra2v2.c Lyra2.c lyra2z.c Lyra2z.c Sponge.c \
blake.c scrypt.c c11.c x11.c x13.c sha256.c sha256t.c keccak.c deep.c \
blake.c scrypt.c c11.c x11.c x13.c sha256.c sha256t.c jha.c keccak.c deep.c \
x14.c x15.c x17.c nist5.c fresh.c quark.c neoscrypt.c scryptn.c qubit.c skein.c groestl.c \
bitcore.c timetravel.c xevan.c bastion.c hmq17.c \
skein2.c zr5.c bmw.c luffa.c pentablake.c whirlpool.c whirlpoolx.c blakecoin.c \

View file

@ -218,6 +218,11 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL
memset(block_hex, 0, block_size);
sprintf(block_hex, "%s%02x%s", submitvalues->header_be, (unsigned char)templ->txcount, submitvalues->coinbase);
if (g_current_algo->name && !strcmp("jha", g_current_algo->name)) {
// block header of 88 bytes
sprintf(block_hex, "%s8400000008000000%02x%s", submitvalues->header_be, (unsigned char)templ->txcount, submitvalues->coinbase);
}
vector<string>::const_iterator i;
for(i = templ->txdata.begin(); i != templ->txdata.end(); ++i)
sprintf(block_hex+strlen(block_hex), "%s", (*i).c_str());

View file

@ -0,0 +1,16 @@
[TCP]
server = yaamp.com
port = 4633
password = tu8tu5
[SQL]
host = yaampdb
database = yaamp
username = root
password = patofpaq
[STRATUM]
algo = jha
difficulty = 128
max_ttf = 400000

View file

@ -110,6 +110,8 @@ YAAMP_ALGO g_algos[] =
{"hmq1725", hmq17_hash, 0x10000, 0, 0},
{"jha", jha_hash, 0x10000, 0},
{"lyra2", lyra2re_hash, 0x80, 0, 0},
{"lyra2v2", lyra2v2_hash, 0x100, 0, 0},
{"lyra2z", lyra2z_hash, 0x100, 0, 0},

View file

@ -150,6 +150,7 @@ void sha256_double_hash_hex(const char *input, char *output, unsigned int len);
#include "algos/blake2.h"
#include "algos/qubit.h"
#include "algos/groestl.h"
#include "algos/jha.h"
#include "algos/skein.h"
#include "algos/keccak.h"
#include "algos/sha256t.h"

View file

@ -161,6 +161,18 @@ void debuglog(const char *format, ...)
}
}
void debuglog_hex(void *data, int len)
{
uint8_t* const bin = (uint8_t*) data;
char *hex = (char*) calloc(1, len*2 + 2);
if (!hex) return;
for(int i=0; i < len; i++)
sprintf(hex+strlen(hex), "%02x", bin[i]);
strcpy(hex+strlen(hex), "\n");
debuglog(hex);
free(hex);
}
void stratumlog(const char *format, ...)
{
char buffer[YAAMP_SMALLBUFSIZE];

View file

@ -18,6 +18,7 @@ function yaamp_get_algos()
'deep',
'hmq1725',
'keccak',
'jha',
'lbry',
'luffa',
'lyra2',
@ -131,6 +132,7 @@ function getAlgoColors($algo)
'blake' => '#f0f0f0',
'blakecoin' => '#f0f0f0',
'groestl' => '#d0a0a0',
'jha' => '#a0d0c0',
'dmd-gr' => '#a0c0f0',
'myr-gr' => '#a0c0f0',
'hmq1725' => '#ffa0a0',