mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
refresh/fix jha algo, keep only the last variant
This commit is contained in:
parent
21a859a108
commit
1c22ec4df6
10 changed files with 87 additions and 123 deletions
1
rc.local
1
rc.local
|
@ -43,6 +43,7 @@ screen -dmS nist5 $STRATUM_DIR/run.sh nist5
|
||||||
screen -dmS penta $STRATUM_DIR/run.sh penta
|
screen -dmS penta $STRATUM_DIR/run.sh penta
|
||||||
screen -dmS quark $STRATUM_DIR/run.sh quark
|
screen -dmS quark $STRATUM_DIR/run.sh quark
|
||||||
screen -dmS qubit $STRATUM_DIR/run.sh qubit
|
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 dmd-gr $STRATUM_DIR/run.sh dmd-gr
|
||||||
screen -dmS myr-gr $STRATUM_DIR/run.sh myr-gr
|
screen -dmS myr-gr $STRATUM_DIR/run.sh myr-gr
|
||||||
screen -dmS lbry $STRATUM_DIR/run.sh lbry
|
screen -dmS lbry $STRATUM_DIR/run.sh lbry
|
||||||
|
|
4
stratum/algos/common.h
Normal file
4
stratum/algos/common.h
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#define _ALIGN(x) __attribute__ ((aligned(x)))
|
||||||
|
|
||||||
|
extern void debuglog_hex(void *data, int len);
|
||||||
|
|
|
@ -1,135 +1,56 @@
|
||||||
#include "jha.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../sha3/sph_blake.h"
|
#include <sha3/sph_blake.h>
|
||||||
#include "../sha3/sph_groestl.h"
|
#include <sha3/sph_groestl.h>
|
||||||
#include "../sha3/sph_jh.h"
|
#include <sha3/sph_jh.h>
|
||||||
#include "../sha3/sph_keccak.h"
|
#include <sha3/sph_keccak.h>
|
||||||
#include "../sha3/sph_skein.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;
|
||||||
|
|
||||||
sph_blake512_context ctx_blake;
|
uint32_t _ALIGN(64) hash[16];
|
||||||
sph_groestl512_context ctx_groestl;
|
|
||||||
sph_jh512_context ctx_jh;
|
|
||||||
sph_keccak512_context ctx_keccak;
|
|
||||||
sph_skein512_context ctx_skein;
|
|
||||||
|
|
||||||
uint32_t hash[16];
|
// JHA v8: SHA3 512, on 80 bytes (not 88)
|
||||||
|
sph_keccak512_init(&ctx_keccak);
|
||||||
|
sph_keccak512(&ctx_keccak, input, 80);
|
||||||
|
sph_keccak512_close(&ctx_keccak, (&hash));
|
||||||
|
|
||||||
unsigned int round_mask = (
|
// Heavy & Light Pair Loop
|
||||||
(unsigned int)(((unsigned char *)input)[84]) << 0 |
|
for (int round = 0; round < 3; round++)
|
||||||
(unsigned int)(((unsigned char *)input)[85]) << 8 |
|
{
|
||||||
(unsigned int)(((unsigned char *)input)[86]) << 16 |
|
if (hash[0] & 0x01) {
|
||||||
(unsigned int)(((unsigned char *)input)[87]) << 24 );
|
sph_groestl512_init(&ctx_groestl);
|
||||||
|
sph_groestl512(&ctx_groestl, (&hash), 64);
|
||||||
|
sph_groestl512_close(&ctx_groestl, (&hash));
|
||||||
|
} else {
|
||||||
|
sph_skein512_init(&ctx_skein);
|
||||||
|
sph_skein512(&ctx_skein, (&hash), 64);
|
||||||
|
sph_skein512_close(&ctx_skein, (&hash));
|
||||||
|
}
|
||||||
|
|
||||||
//
|
if (hash[0] & 0x01) {
|
||||||
// JHA V7
|
sph_blake512_init(&ctx_blake);
|
||||||
//
|
sph_blake512(&ctx_blake, (&hash), 64);
|
||||||
if (round_mask == 7) {
|
sph_blake512_close(&ctx_blake, (&hash));
|
||||||
|
} else {
|
||||||
//
|
sph_jh512_init(&ctx_jh);
|
||||||
// Input Hashing with SHA3 512, 88 bytes
|
sph_jh512(&ctx_jh, (&hash), 64);
|
||||||
//
|
sph_jh512_close(&ctx_jh, (&hash));
|
||||||
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_close(&ctx_keccak, (&hash));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Heavy & Light Pair Loop
|
|
||||||
//
|
|
||||||
unsigned int round;
|
|
||||||
for (round = 0; round < 3; round++) {
|
|
||||||
if (hash[0] & 0x01) {
|
|
||||||
sph_groestl512_init(&ctx_groestl);
|
|
||||||
sph_groestl512 (&ctx_groestl, (&hash), 64);
|
|
||||||
sph_groestl512_close(&ctx_groestl, (&hash));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sph_skein512_init(&ctx_skein);
|
|
||||||
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_close(&ctx_blake, (&hash));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sph_jh512_init(&ctx_jh);
|
|
||||||
sph_jh512 (&ctx_jh, (&hash), 64);
|
|
||||||
sph_jh512_close(&ctx_jh, (&hash));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Return 256bit(32x8)
|
|
||||||
//
|
|
||||||
memcpy(output, hash, 32);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Wrong Round Mask Data
|
|
||||||
//
|
|
||||||
else {
|
|
||||||
|
|
||||||
memset(output, 0xFF, 32);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Return 256 bits (32x8)
|
||||||
|
memcpy(output, hash, 32);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ CFLAGS= $(CXXFLAGS) -std=gnu99
|
||||||
LDFLAGS=-O2 -lgmp
|
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 \
|
||||||
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 \
|
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 \
|
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 \
|
skein2.c zr5.c bmw.c luffa.c pentablake.c whirlpool.c whirlpoolx.c blakecoin.c \
|
||||||
|
|
|
@ -218,6 +218,11 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL
|
||||||
memset(block_hex, 0, block_size);
|
memset(block_hex, 0, block_size);
|
||||||
sprintf(block_hex, "%s%02x%s", submitvalues->header_be, (unsigned char)templ->txcount, submitvalues->coinbase);
|
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;
|
vector<string>::const_iterator i;
|
||||||
for(i = templ->txdata.begin(); i != templ->txdata.end(); ++i)
|
for(i = templ->txdata.begin(); i != templ->txdata.end(); ++i)
|
||||||
sprintf(block_hex+strlen(block_hex), "%s", (*i).c_str());
|
sprintf(block_hex+strlen(block_hex), "%s", (*i).c_str());
|
||||||
|
|
16
stratum/config.sample/jha.conf
Normal file
16
stratum/config.sample/jha.conf
Normal 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
|
||||||
|
|
|
@ -110,6 +110,8 @@ YAAMP_ALGO g_algos[] =
|
||||||
|
|
||||||
{"hmq1725", hmq17_hash, 0x10000, 0, 0},
|
{"hmq1725", hmq17_hash, 0x10000, 0, 0},
|
||||||
|
|
||||||
|
{"jha", jha_hash, 0x10000, 0},
|
||||||
|
|
||||||
{"lyra2", lyra2re_hash, 0x80, 0, 0},
|
{"lyra2", lyra2re_hash, 0x80, 0, 0},
|
||||||
{"lyra2v2", lyra2v2_hash, 0x100, 0, 0},
|
{"lyra2v2", lyra2v2_hash, 0x100, 0, 0},
|
||||||
{"lyra2z", lyra2z_hash, 0x100, 0, 0},
|
{"lyra2z", lyra2z_hash, 0x100, 0, 0},
|
||||||
|
|
|
@ -150,6 +150,7 @@ void sha256_double_hash_hex(const char *input, char *output, unsigned int len);
|
||||||
#include "algos/blake2.h"
|
#include "algos/blake2.h"
|
||||||
#include "algos/qubit.h"
|
#include "algos/qubit.h"
|
||||||
#include "algos/groestl.h"
|
#include "algos/groestl.h"
|
||||||
|
#include "algos/jha.h"
|
||||||
#include "algos/skein.h"
|
#include "algos/skein.h"
|
||||||
#include "algos/keccak.h"
|
#include "algos/keccak.h"
|
||||||
#include "algos/sha256t.h"
|
#include "algos/sha256t.h"
|
||||||
|
|
|
@ -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, ...)
|
void stratumlog(const char *format, ...)
|
||||||
{
|
{
|
||||||
char buffer[YAAMP_SMALLBUFSIZE];
|
char buffer[YAAMP_SMALLBUFSIZE];
|
||||||
|
|
|
@ -18,6 +18,7 @@ function yaamp_get_algos()
|
||||||
'deep',
|
'deep',
|
||||||
'hmq1725',
|
'hmq1725',
|
||||||
'keccak',
|
'keccak',
|
||||||
|
'jha',
|
||||||
'lbry',
|
'lbry',
|
||||||
'luffa',
|
'luffa',
|
||||||
'lyra2',
|
'lyra2',
|
||||||
|
@ -131,6 +132,7 @@ function getAlgoColors($algo)
|
||||||
'blake' => '#f0f0f0',
|
'blake' => '#f0f0f0',
|
||||||
'blakecoin' => '#f0f0f0',
|
'blakecoin' => '#f0f0f0',
|
||||||
'groestl' => '#d0a0a0',
|
'groestl' => '#d0a0a0',
|
||||||
|
'jha' => '#a0d0c0',
|
||||||
'dmd-gr' => '#a0c0f0',
|
'dmd-gr' => '#a0c0f0',
|
||||||
'myr-gr' => '#a0c0f0',
|
'myr-gr' => '#a0c0f0',
|
||||||
'hmq1725' => '#ffa0a0',
|
'hmq1725' => '#ffa0a0',
|
||||||
|
|
Loading…
Add table
Reference in a new issue