added support for blocks with more than 256 transactions

This commit is contained in:
wmpadmin 2018-06-08 18:22:56 +02:00
parent c098e72bcb
commit f60d5fa6ab
5 changed files with 16 additions and 13 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -372,12 +372,12 @@ void SubAndShiftAndMixAddRoundInPlace(uint32_t *temp, uint32_t *AesEncKey)
temp[3] = TestTable2[saved[3]] ^ TestTable3[saved[4]] ^ TestTable4[saved[5]] ^ TestTable1[state[12]] ^ AesEncKey[3];
}
void cryptonight_hash_ctx(void *output, const void *input, struct cryptonight_ctx *ctx, int variant)
void cryptonight_hash_ctx(void *output, const void *input, size_t len, struct cryptonight_ctx *ctx, int variant)
{
ctx->aes_ctx = (oaes_ctx *)oaes_alloc();
size_t i, j;
//hash_process(&ctx->state.hs, (const uint8_t*) input, 76);
keccak((const uint8_t *)input, 76, ctx->state.hs.b, 200);
keccak((const uint8_t *)input, len, ctx->state.hs.b, 200);
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
//int variant = ((const uint8_t *)input)[0] >= 7 ? ((const uint8_t *)input)[0] - 6 : 0;
@ -491,12 +491,12 @@ void cryptonight_hash_ctx(void *output, const void *input, struct cryptonight_ct
oaes_free((OAES_CTX **)&ctx->aes_ctx);
}
void cryptonight_hash_ctx_lite(void *output, const void *input, struct cryptonight_ctx_lite *ctx, int variant)
void cryptonight_hash_ctx_lite(void *output, const void *input, size_t len, struct cryptonight_ctx_lite *ctx, int variant)
{
ctx->aes_ctx = (oaes_ctx *)oaes_alloc();
size_t i, j;
//hash_process(&ctx->state.hs, (const uint8_t*) input, 76);
keccak((const uint8_t *)input, 76, ctx->state.hs.b, 200);
keccak((const uint8_t *)input, len, ctx->state.hs.b, 200);
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
VARIANT1_INIT();
@ -612,13 +612,13 @@ void cryptonight(void *output, const void *input, size_t len, int lite, int vari
if(lite)
{
struct cryptonight_ctx_lite *ctx = (struct cryptonight_ctx_lite *)malloc(sizeof(struct cryptonight_ctx_lite));
cryptonight_hash_ctx_lite(output, input, ctx, variant);
cryptonight_hash_ctx_lite(output, input, len, ctx, variant);
free(ctx);
}
else
{
struct cryptonight_ctx *ctx = (struct cryptonight_ctx *)malloc(sizeof(struct cryptonight_ctx));
cryptonight_hash_ctx(output, input, ctx, variant);
cryptonight_hash_ctx(output, input, len, ctx, variant);
free(ctx);
}

View File

@ -25,21 +25,24 @@ char* tohex(unsigned char * in)
char* hash_cn(char* hex, char* nonce,int lite, int variant)
{
unsigned char inp[76];
int len = strlen(hex) / 2;
unsigned char inp[len];
char *pos = hex;
for( size_t i = 0; i < 76; i++) { sscanf(pos, "%2hhx", &inp[i]); pos += 2; }
for( size_t i = 0; i < len; i++) { sscanf(pos, "%2hhx", &inp[i]); pos += 2; }
pos = nonce;
for(size_t i = 39; i < 43; i++) { sscanf(pos, "%2hhx", &inp[i]); pos += 2; }
unsigned char hash[76];
unsigned char hash[32];
if(variant == -1)
variant = ((const uint8_t *)inp)[0] >= 7 ? ((const uint8_t *)inp)[0] - 6 : 0;
cryptonight(hash, inp, 76, lite, variant);
cryptonight(hash, inp, len, lite, variant);
return tohex(hash);
}

View File

@ -100,7 +100,7 @@ namespace Server {
string blob = data["blob"].GetString ();
string target = data["target"].GetString ();
if (blob.Length != 152) return false;
if (blob.Length < 152 || blob.Length > 180) return false;
if (target.Length != 8) return false;
if (!Regex.IsMatch (blob, MainClass.RegexIsHex)) return false;