Browse Source

getting closer

pull/123/head
notgiven688 3 years ago
parent
commit
c5780333c3
6 changed files with 18 additions and 12 deletions
  1. +2
    -2
      hash_cn/webassembly/aeon/cryptonight.c
  2. +1
    -1
      hash_cn/webassembly/aeon/cryptonight.h
  3. +6
    -3
      hash_cn/webassembly/aeon/main.c
  4. +2
    -2
      hash_cn/webassembly/xmr/cryptonight.c
  5. +1
    -1
      hash_cn/webassembly/xmr/cryptonight.h
  6. +6
    -3
      hash_cn/webassembly/xmr/main.c

+ 2
- 2
hash_cn/webassembly/aeon/cryptonight.c View File

@ -361,7 +361,7 @@ 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)
void cryptonight_hash_ctx(void *output, const void *input, struct cryptonight_ctx *ctx, int variant)
{
ctx->aes_ctx = (oaes_ctx *)oaes_alloc();
size_t i, j;
@ -369,7 +369,7 @@ void cryptonight_hash_ctx(void *output, const void *input, struct cryptonight_ct
keccak((const uint8_t *)input, 76, 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;
//int variant = ((const uint8_t *)input)[0] >= 7 ? ((const uint8_t *)input)[0] - 6 : 0;
//int variant = 1;
VARIANT1_INIT();

+ 1
- 1
hash_cn/webassembly/aeon/cryptonight.h View File

@ -5,7 +5,7 @@
extern "C" {
#endif
void cryptonight(void *output, const void *input, size_t len);
void cryptonight(void *output, const void *input, size_t len, int variant);
struct cryptonight_ctx;
#ifdef __cplusplus

+ 6
- 3
hash_cn/webassembly/aeon/main.c View File

@ -23,7 +23,7 @@ char* tohex(unsigned char * in)
return &output[0];
}
char* hash_cn(char* hex, char* nonce)
char* hash_cn(char* hex, char* nonce, int variant)
{
unsigned char inp[76];
@ -35,9 +35,12 @@ char* hash_cn(char* hex, char* nonce)
for(size_t i = 39; i < 43; i++) { sscanf(pos, "%2hhx", &inp[i]); pos += 2; }
unsigned char hash[76];
cryptonight(hash, inp, 76);
if(variant == -1)
variant = ((const uint8_t *)inp)[0] >= 7 ? ((const uint8_t *)inp)[0] - 6 : 0;
cryptonight(hash, inp, 76, variant);
return tohex(hash);
}

+ 2
- 2
hash_cn/webassembly/xmr/cryptonight.c View File

@ -361,7 +361,7 @@ 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)
void cryptonight_hash_ctx(void *output, const void *input, struct cryptonight_ctx *ctx, int variant)
{
ctx->aes_ctx = (oaes_ctx *)oaes_alloc();
size_t i, j;
@ -369,7 +369,7 @@ void cryptonight_hash_ctx(void *output, const void *input, struct cryptonight_ct
keccak((const uint8_t *)input, 76, 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;
//int variant = ((const uint8_t *)input)[0] >= 7 ? ((const uint8_t *)input)[0] - 6 : 0;
//int variant = 1;
VARIANT1_INIT();

+ 1
- 1
hash_cn/webassembly/xmr/cryptonight.h View File

@ -5,7 +5,7 @@
extern "C" {
#endif
void cryptonight(void *output, const void *input, size_t len);
void cryptonight(void *output, const void *input, size_t len, int variant);
struct cryptonight_ctx;
#ifdef __cplusplus

+ 6
- 3
hash_cn/webassembly/xmr/main.c View File

@ -23,7 +23,7 @@ char* tohex(unsigned char * in)
return &output[0];
}
char* hash_cn(char* hex, char* nonce)
char* hash_cn(char* hex, char* nonce, int variant)
{
unsigned char inp[76];
@ -35,9 +35,12 @@ char* hash_cn(char* hex, char* nonce)
for(size_t i = 39; i < 43; i++) { sscanf(pos, "%2hhx", &inp[i]); pos += 2; }
unsigned char hash[76];
cryptonight(hash, inp, 76);
if(variant == -1)
variant = ((const uint8_t *)inp)[0] >= 7 ? ((const uint8_t *)inp)[0] - 6 : 0;
cryptonight(hash, inp, 76, variant);
return tohex(hash);
}

Loading…
Cancel
Save