From 3d56378873f703a5cf4fca15d917b80ad73f5ee3 Mon Sep 17 00:00:00 2001 From: Suml Noether Date: Sun, 25 Mar 2018 16:17:16 +0000 Subject: [PATCH 1/6] Removing that extra comma. --- multihashing.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multihashing.cpp b/multihashing.cpp index 74f245a4..bfd01988 100644 --- a/multihashing.cpp +++ b/multihashing.cpp @@ -21,7 +21,7 @@ extern "C" { #include "cryptonight.h" #include "x13.h" #include "nist5.h" - #include "sha1.h", + #include "sha1.h" #include "x15.h" #include "fresh.h" } @@ -581,4 +581,4 @@ NAN_MODULE_INIT(Init) { } NODE_MODULE(multihashing, Init) -} \ No newline at end of file +} From efcfc5ee11b152a2aaa4a2b6f74fd01778e22ae2 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Fri, 26 Jan 2018 16:14:28 +0000 Subject: [PATCH 2/6] Monero Cryptonight variants, and add one for v7 --- cryptonight.c | 29 ++++++++++++++++++++++++++++- cryptonight.h | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/cryptonight.c b/cryptonight.c index a2642268..753d34d7 100644 --- a/cryptonight.c +++ b/cryptonight.c @@ -1,7 +1,11 @@ // Copyright (c) 2012-2013 The Cryptonote developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +// Portions Copyright (c) 2018 The Monero developers +#include +#include +#include #include "crypto/oaes_lib.h" #include "crypto/c_keccak.h" #include "crypto/c_groestl.h" @@ -22,6 +26,24 @@ #define INIT_SIZE_BLK 8 #define INIT_SIZE_BYTE (INIT_SIZE_BLK * AES_BLOCK_SIZE) +#define VARIANT1_1(p) \ + do if (variant > 0) \ + { \ + uint8_t tmp = ((const uint8_t*)p)[11]; \ + uint8_t tmp1 = (tmp>>4)&1, tmp2 = (tmp>>5)&1, tmp3 = tmp1^tmp2; \ + uint8_t tmp0 = nonce_flag ? tmp3 : tmp1 + 1; \ + ((uint8_t*)p)[11] = (tmp & 0xef) | (tmp0<<4); \ + } while(0) + +#define VARIANT1_2(p) VARIANT1_1(p) +#define VARIANT1_INIT() \ + if (variant > 0 && len < 43) \ + { \ + fprintf(stderr, "Cryptonight variants need at least 43 bytes of data"); \ + _exit(1); \ + } \ + const uint8_t nonce_flag = variant > 0 ? ((const uint8_t*)input)[39] & 0x01 : 0 + #pragma pack(push, 1) union cn_slow_hash_state { union hash_state hs; @@ -124,7 +146,7 @@ struct cryptonight_ctx { oaes_ctx* aes_ctx; }; -void cryptonight_hash(const char* input, char* output, uint32_t len) { +void cryptonight_hash(const char* input, char* output, uint32_t len, int variant) { struct cryptonight_ctx *ctx = alloca(sizeof(struct cryptonight_ctx)); hash_process(&ctx->state.hs, (const uint8_t*) input, len); memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE); @@ -132,6 +154,8 @@ void cryptonight_hash(const char* input, char* output, uint32_t len) { ctx->aes_ctx = (oaes_ctx*) oaes_alloc(); size_t i, j; + VARIANT1_INIT(); + oaes_key_import_data(ctx->aes_ctx, ctx->aes_key, AES_KEY_SIZE); for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { for (j = 0; j < INIT_SIZE_BLK; j++) { @@ -156,10 +180,13 @@ void cryptonight_hash(const char* input, char* output, uint32_t len) { j = e2i(ctx->a); aesb_single_round(&ctx->long_state[j * AES_BLOCK_SIZE], ctx->c, ctx->a); xor_blocks_dst(ctx->c, ctx->b, &ctx->long_state[j * AES_BLOCK_SIZE]); + VARIANT1_1((uint8_t*)&ctx->long_state[j * AES_BLOCK_SIZE]); /* Iteration 2 */ mul_sum_xor_dst(ctx->c, ctx->a, &ctx->long_state[e2i(ctx->c) * AES_BLOCK_SIZE]); copy_block(ctx->b, ctx->c); + VARIANT1_2((uint8_t*) + &ctx->long_state[e2i(ctx->c) * AES_BLOCK_SIZE]); } memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE); diff --git a/cryptonight.h b/cryptonight.h index 86fedca6..7d99ec07 100644 --- a/cryptonight.h +++ b/cryptonight.h @@ -7,7 +7,7 @@ extern "C" { #include -void cryptonight_hash(const char* input, char* output, uint32_t len); +void cryptonight_hash(const char* input, char* output, uint32_t len, int variant); void cryptonight_fast_hash(const char* input, char* output, uint32_t len); #ifdef __cplusplus From 2a5f5923a33f8fee53bd2cb92df02116829e0c61 Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Mon, 19 Mar 2018 16:29:01 +0000 Subject: [PATCH 3/6] Updating the monero v1 pow algorithm to the most recent changes --- cryptonight.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cryptonight.c b/cryptonight.c index 753d34d7..b72de195 100644 --- a/cryptonight.c +++ b/cryptonight.c @@ -29,20 +29,25 @@ #define VARIANT1_1(p) \ do if (variant > 0) \ { \ - uint8_t tmp = ((const uint8_t*)p)[11]; \ - uint8_t tmp1 = (tmp>>4)&1, tmp2 = (tmp>>5)&1, tmp3 = tmp1^tmp2; \ - uint8_t tmp0 = nonce_flag ? tmp3 : tmp1 + 1; \ - ((uint8_t*)p)[11] = (tmp & 0xef) | (tmp0<<4); \ + const uint8_t tmp = ((const uint8_t*)(p))[11]; \ + static const uint32_t table = 0x75310; \ + const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; \ + ((uint8_t*)(p))[11] = tmp ^ ((table >> index) & 0x30); \ } while(0) -#define VARIANT1_2(p) VARIANT1_1(p) +#define VARIANT1_2(p) \ + do if (variant > 0) \ + { \ + ((uint64_t*)p)[1] ^= tweak1_2; \ + } while(0) + #define VARIANT1_INIT() \ if (variant > 0 && len < 43) \ { \ fprintf(stderr, "Cryptonight variants need at least 43 bytes of data"); \ _exit(1); \ } \ - const uint8_t nonce_flag = variant > 0 ? ((const uint8_t*)input)[39] & 0x01 : 0 + const uint64_t tweak1_2 = variant > 0 ? *(const uint64_t*)(((const uint8_t*)input)+35) ^ ctx->state.hs.w[24] : 0 #pragma pack(push, 1) union cn_slow_hash_state { From d5f8a1dedf5471f4de63c29e9b367672118b9061 Mon Sep 17 00:00:00 2001 From: Suml Noether Date: Sun, 25 Mar 2018 17:33:01 +0000 Subject: [PATCH 4/6] Added support for cryptonight v7 and the associated tests. --- multihashing.cpp | 47 +++++++++++++++++++++++--------------- tests/cryptonight-tests.js | 16 +++++++++++++ tests/test.js | 17 ++++++++++++++ 3 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 tests/cryptonight-tests.js create mode 100644 tests/test.js diff --git a/multihashing.cpp b/multihashing.cpp index bfd01988..5c5cfb04 100644 --- a/multihashing.cpp +++ b/multihashing.cpp @@ -49,7 +49,7 @@ NAN_METHOD(quark) { char * input = node::Buffer::Data(target); Nan::MaybeLocal dest = Nan::NewBuffer(32); char* output = node::Buffer::Data(dest.ToLocalChecked()); - + uint32_t input_len = node::Buffer::Length(target); quark_hash(input, output, input_len); @@ -86,18 +86,18 @@ NAN_METHOD(scrypt) { if(!node::Buffer::HasInstance(target)) return except("Argument should be a buffer object."); - + Local numn = info[1]->ToNumber(); unsigned int nValue = numn->Value(); Local numr = info[2]->ToNumber(); unsigned int rValue = numr->Value(); - + char * input = node::Buffer::Data(target); Nan::MaybeLocal dest = Nan::NewBuffer(32); char* output = node::Buffer::Data(dest.ToLocalChecked()); uint32_t input_len = node::Buffer::Length(target); - + scrypt_N_R_1_256(input, output, nValue, rValue, input_len); info.GetReturnValue().Set(dest.ToLocalChecked()); @@ -216,7 +216,7 @@ NAN_METHOD(skein) { char* output = node::Buffer::Data(dest.ToLocalChecked()); uint32_t input_len = node::Buffer::Length(target); - + skein_hash(input, output, input_len); info.GetReturnValue().Set(dest.ToLocalChecked()); @@ -235,7 +235,7 @@ NAN_METHOD(groestl) { char * input = node::Buffer::Data(target); Nan::MaybeLocal dest = Nan::NewBuffer(32); char* output = node::Buffer::Data(dest.ToLocalChecked()); - + uint32_t input_len = node::Buffer::Length(target); groestl_hash(input, output, input_len); @@ -256,7 +256,7 @@ NAN_METHOD(groestlmyriad) { char * input = node::Buffer::Data(target); Nan::MaybeLocal dest = Nan::NewBuffer(32); char* output = node::Buffer::Data(dest.ToLocalChecked()); - + uint32_t input_len = node::Buffer::Length(target); groestlmyriad_hash(input, output, input_len); @@ -277,7 +277,7 @@ NAN_METHOD(blake) { char * input = node::Buffer::Data(target); Nan::MaybeLocal dest = Nan::NewBuffer(32); char* output = node::Buffer::Data(dest.ToLocalChecked()); - + uint32_t input_len = node::Buffer::Length(target); blake_hash(input, output, input_len); @@ -298,7 +298,7 @@ NAN_METHOD(fugue) { char * input = node::Buffer::Data(target); Nan::MaybeLocal dest = Nan::NewBuffer(32); char* output = node::Buffer::Data(dest.ToLocalChecked()); - + uint32_t input_len = node::Buffer::Length(target); fugue_hash(input, output, input_len); @@ -319,7 +319,7 @@ NAN_METHOD(qubit) { char * input = node::Buffer::Data(target); Nan::MaybeLocal dest = Nan::NewBuffer(32); char* output = node::Buffer::Data(dest.ToLocalChecked()); - + uint32_t input_len = node::Buffer::Length(target); qubit_hash(input, output, input_len); @@ -340,7 +340,7 @@ NAN_METHOD(hefty1) { char * input = node::Buffer::Data(target); Nan::MaybeLocal dest = Nan::NewBuffer(32); char* output = node::Buffer::Data(dest.ToLocalChecked()); - + uint32_t input_len = node::Buffer::Length(target); hefty1_hash(input, output, input_len); @@ -361,7 +361,7 @@ NAN_METHOD(shavite3) { char * input = node::Buffer::Data(target); Nan::MaybeLocal dest = Nan::NewBuffer(32); char* output = node::Buffer::Data(dest.ToLocalChecked()); - + uint32_t input_len = node::Buffer::Length(target); shavite3_hash(input, output, input_len); @@ -371,14 +371,20 @@ NAN_METHOD(shavite3) { NAN_METHOD(cryptonight) { bool fast = false; + uint32_t cn_variant = 0; if (info.Length() < 1) return except("You must provide one argument."); - + if (info.Length() >= 2) { - if(!info[1]->IsBoolean()) - return except("Argument 2 should be a boolean"); - fast = info[1]->ToBoolean()->BooleanValue(); + if (info.Length() >= 2) { + if(info[1]->IsBoolean()) + fast = info[1]->ToBoolean()->BooleanValue(); + else if(info[1]->IsUint32()) + cn_variant = info[1]->ToUint32()->Uint32Value(); + else + return except("Argument 2 should be a boolean or uint32_t"); + } } Local target = info[0]->ToObject(); @@ -389,13 +395,16 @@ NAN_METHOD(cryptonight) { char * input = node::Buffer::Data(target); Nan::MaybeLocal dest = Nan::NewBuffer(32); char* output = node::Buffer::Data(dest.ToLocalChecked()); - + uint32_t input_len = node::Buffer::Length(target); if(fast) cryptonight_fast_hash(input, output, input_len); - else - cryptonight_hash(input, output, input_len); + else { + if (cn_variant > 0 && input_len < 43) + return except("Argument must be 43 bytes for monero variant 1+"); + cryptonight_hash(input, output, input_len, cn_variant); + } info.GetReturnValue().Set(dest.ToLocalChecked()); } diff --git a/tests/cryptonight-tests.js b/tests/cryptonight-tests.js new file mode 100644 index 00000000..4c6d3bfa --- /dev/null +++ b/tests/cryptonight-tests.js @@ -0,0 +1,16 @@ +const multiHashing = require('../build/Release/multihashing'); +const assert = require('assert'); + +var cn_data = new Buffer("6465206f6d6e69627573206475626974616e64756d", "hex"); +var cnv1_data = new Buffer("0100fb8e8ac805899323371bb790db19218afd8db8e3755d8b90f39b3d5506a9abce4fa912244500000000ee8146d49fa93ee724deb57d12cbc6c6f3b924d946127c7a97418f9348828f0f02", "hex"); +var cn_hash = new Buffer("2f8e3df40bd11f9ac90c743ca8e32bb391da4fb98612aa3b6cdc639ee00b31f5", "hex"); +var cnv1_hash = new Buffer("c9fae8425d8688dc236bcdbc42fdb42d376c6ec190501aa84b04a4b4cf1ee122", "hex"); + +hashedData = multiHashing['cryptonight'](cn_data); +hashedData_v1 = multiHashing['cryptonight'](cnv1_data, 1); + +console.log(hashedData); +console.log(hashedData_v1); + +assert.deepEqual(hashedData, cn_hash); +assert.deepEqual(hashedData_v1, cnv1_hash); diff --git a/tests/test.js b/tests/test.js new file mode 100644 index 00000000..6ffa56d9 --- /dev/null +++ b/tests/test.js @@ -0,0 +1,17 @@ +var multiHashing = require('../build/Release/multihashing'); + +var algorithms = ['keccak', 'groestl', 'skein', 'blake', 'cryptonight', 'cryptonight v7']; + +var data = new Buffer("7000000001e980924e4e1109230383e66d62945ff8e749903bea4336755c00000000000051928aff1b4d72416173a8c3948159a09a73ac3bb556aa6bfbcad1a85da7f4c1d13350531e24031b939b9e2b", "hex"); + +var hashedData = algorithms.map(function(algo){ + if (algo === 'cryptonight v7'){ + return multiHashing['cryptonight'](data, 1); + } + else{ + return multiHashing[algo](data); + } +}); + + +console.log(hashedData); From 11f2d42f7f51297143a8d8563aa88a44a0bb2a8c Mon Sep 17 00:00:00 2001 From: Suml Noether Date: Sun, 25 Mar 2018 18:31:41 +0000 Subject: [PATCH 5/6] Added support for cryptonight light and the variant. --- README.md | 2 ++ cryptonight.c | 27 +++++++++++++++-------- cryptonight.h | 2 +- multihashing.cpp | 44 +++++++++++++++++++++++++++++++++++++- tests/cryptonight-tests.js | 18 +++++++++++----- 5 files changed, 77 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index d593a28e..ff57f7ed 100644 --- a/README.md +++ b/README.md @@ -79,3 +79,5 @@ Credits * [bcrypt](http://en.wikipedia.org/wiki/Bcrypt) - Niels Provos and David Mazières * [X11](http://www.darkcoin.io/), [Hefty1](http://heavycoin.github.io/about.html), [Quark](http://www.qrk.cc/) creators (they just mixed together a bunch of the above algos) * [PhearZero](https://github.com/PhearZero) Michael J Feher +* [codebling](https://github.com/codebling) CodeBling +* [Monero](https://github.com/monero-project/monero) The Monero Project diff --git a/cryptonight.c b/cryptonight.c index b72de195..2d0ca800 100644 --- a/cryptonight.c +++ b/cryptonight.c @@ -21,6 +21,12 @@ #define MEMORY (1 << 21) /* 2 MiB */ #define ITER (1 << 20) +#define MASK 0x1FFFF + +#define LITE_MEMORY (1 << 20) /* 2 MiB */ +#define LITE_ITER (1 << 19) +#define LITE_MASK 0xFFFF + #define AES_BLOCK_SIZE 16 #define AES_KEY_SIZE 32 /*16*/ #define INIT_SIZE_BLK 8 @@ -84,8 +90,8 @@ static void (* const extra_hashes[4])(const void *, size_t, char *) = { extern int aesb_single_round(const uint8_t *in, uint8_t*out, const uint8_t *expandedKey); extern int aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *expandedKey); -static inline size_t e2i(const uint8_t* a) { - return (*((uint64_t*) a) / AES_BLOCK_SIZE) & (MEMORY / AES_BLOCK_SIZE - 1); +static inline size_t e2i(const uint8_t* a, size_t mask) { + return (*((uint64_t*) a) / AES_BLOCK_SIZE) & mask; } static void mul(const uint8_t* a, const uint8_t* b, uint8_t* res) { @@ -151,18 +157,21 @@ struct cryptonight_ctx { oaes_ctx* aes_ctx; }; -void cryptonight_hash(const char* input, char* output, uint32_t len, int variant) { +void cryptonight_hash(const char* input, char* output, uint32_t len, int variant, int lite) { struct cryptonight_ctx *ctx = alloca(sizeof(struct cryptonight_ctx)); hash_process(&ctx->state.hs, (const uint8_t*) input, len); memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE); memcpy(ctx->aes_key, ctx->state.hs.b, AES_KEY_SIZE); ctx->aes_ctx = (oaes_ctx*) oaes_alloc(); size_t i, j; + size_t memory = lite ? LITE_MEMORY : MEMORY; + size_t iterations = lite ? LITE_ITER : ITER; + size_t mask = lite ? LITE_MASK : MASK; VARIANT1_INIT(); oaes_key_import_data(ctx->aes_ctx, ctx->aes_key, AES_KEY_SIZE); - for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { + for (i = 0; i < memory / INIT_SIZE_BYTE; i++) { for (j = 0; j < INIT_SIZE_BLK; j++) { aesb_pseudo_round(&ctx->text[AES_BLOCK_SIZE * j], &ctx->text[AES_BLOCK_SIZE * j], @@ -176,27 +185,27 @@ void cryptonight_hash(const char* input, char* output, uint32_t len, int variant ctx->b[i] = ctx->state.k[16 + i] ^ ctx->state.k[48 + i]; } - for (i = 0; i < ITER / 2; i++) { + for (i = 0; i < iterations / 2; i++) { /* Dependency chain: address -> read value ------+ * written value <-+ hard function (AES or MUL) <+ * next address <-+ */ /* Iteration 1 */ - j = e2i(ctx->a); + j = e2i(ctx->a, mask); aesb_single_round(&ctx->long_state[j * AES_BLOCK_SIZE], ctx->c, ctx->a); xor_blocks_dst(ctx->c, ctx->b, &ctx->long_state[j * AES_BLOCK_SIZE]); VARIANT1_1((uint8_t*)&ctx->long_state[j * AES_BLOCK_SIZE]); /* Iteration 2 */ mul_sum_xor_dst(ctx->c, ctx->a, - &ctx->long_state[e2i(ctx->c) * AES_BLOCK_SIZE]); + &ctx->long_state[e2i(ctx->c, mask) * AES_BLOCK_SIZE]); copy_block(ctx->b, ctx->c); VARIANT1_2((uint8_t*) - &ctx->long_state[e2i(ctx->c) * AES_BLOCK_SIZE]); + &ctx->long_state[e2i(ctx->c, mask) * AES_BLOCK_SIZE]); } memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE); oaes_key_import_data(ctx->aes_ctx, &ctx->state.hs.b[32], AES_KEY_SIZE); - for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { + for (i = 0; i < memory / INIT_SIZE_BYTE; i++) { for (j = 0; j < INIT_SIZE_BLK; j++) { xor_blocks(&ctx->text[j * AES_BLOCK_SIZE], &ctx->long_state[i * INIT_SIZE_BYTE + j * AES_BLOCK_SIZE]); diff --git a/cryptonight.h b/cryptonight.h index 7d99ec07..d4165e38 100644 --- a/cryptonight.h +++ b/cryptonight.h @@ -7,7 +7,7 @@ extern "C" { #include -void cryptonight_hash(const char* input, char* output, uint32_t len, int variant); +void cryptonight_hash(const char* input, char* output, uint32_t len, int variant, int lite); void cryptonight_fast_hash(const char* input, char* output, uint32_t len); #ifdef __cplusplus diff --git a/multihashing.cpp b/multihashing.cpp index 5c5cfb04..9001c2ae 100644 --- a/multihashing.cpp +++ b/multihashing.cpp @@ -403,7 +403,47 @@ NAN_METHOD(cryptonight) { else { if (cn_variant > 0 && input_len < 43) return except("Argument must be 43 bytes for monero variant 1+"); - cryptonight_hash(input, output, input_len, cn_variant); + cryptonight_hash(input, output, input_len, cn_variant, 0); + } + + info.GetReturnValue().Set(dest.ToLocalChecked()); +} + +NAN_METHOD(cryptonightlite) { + bool fast = false; + uint32_t cn_variant = 0; + + if (info.Length() < 1) + return except("You must provide one argument."); + + if (info.Length() >= 2) { + if (info.Length() >= 2) { + if(info[1]->IsBoolean()) + fast = info[1]->ToBoolean()->BooleanValue(); + else if(info[1]->IsUint32()) + cn_variant = info[1]->ToUint32()->Uint32Value(); + else + return except("Argument 2 should be a boolean or uint32_t"); + } + } + + Local target = info[0]->ToObject(); + + if(!node::Buffer::HasInstance(target)) + return except("Argument should be a buffer object."); + + char * input = node::Buffer::Data(target); + Nan::MaybeLocal dest = Nan::NewBuffer(32); + char* output = node::Buffer::Data(dest.ToLocalChecked()); + + uint32_t input_len = node::Buffer::Length(target); + + if(fast) + cryptonight_fast_hash(input, output, input_len); + else { + if (cn_variant > 0 && input_len < 43) + return except("Argument must be 43 bytes for aeon variant 1+"); + cryptonight_hash(input, output, input_len, cn_variant, 1); } info.GetReturnValue().Set(dest.ToLocalChecked()); @@ -575,6 +615,8 @@ NAN_MODULE_INIT(Init) { GetFunction(New(shavite3)).ToLocalChecked()); Nan::Set(target, New("cryptonight").ToLocalChecked(), GetFunction(New(cryptonight)).ToLocalChecked()); + Nan::Set(target, New("cryptonight-lite").ToLocalChecked(), + GetFunction(New(cryptonightlite)).ToLocalChecked()); Nan::Set(target, New("x13").ToLocalChecked(), GetFunction(New(x13)).ToLocalChecked()); Nan::Set(target, New("boolberry").ToLocalChecked(), diff --git a/tests/cryptonight-tests.js b/tests/cryptonight-tests.js index 4c6d3bfa..41ecb3ad 100644 --- a/tests/cryptonight-tests.js +++ b/tests/cryptonight-tests.js @@ -2,15 +2,23 @@ const multiHashing = require('../build/Release/multihashing'); const assert = require('assert'); var cn_data = new Buffer("6465206f6d6e69627573206475626974616e64756d", "hex"); -var cnv1_data = new Buffer("0100fb8e8ac805899323371bb790db19218afd8db8e3755d8b90f39b3d5506a9abce4fa912244500000000ee8146d49fa93ee724deb57d12cbc6c6f3b924d946127c7a97418f9348828f0f02", "hex"); +var xmrig_data = new Buffer("0100fb8e8ac805899323371bb790db19218afd8db8e3755d8b90f39b3d5506a9abce4fa912244500000000ee8146d49fa93ee724deb57d12cbc6c6f3b924d946127c7a97418f9348828f0f02", "hex"); var cn_hash = new Buffer("2f8e3df40bd11f9ac90c743ca8e32bb391da4fb98612aa3b6cdc639ee00b31f5", "hex"); -var cnv1_hash = new Buffer("c9fae8425d8688dc236bcdbc42fdb42d376c6ec190501aa84b04a4b4cf1ee122", "hex"); +var xmrig_cnvariant1_hash = new Buffer("c9fae8425d8688dc236bcdbc42fdb42d376c6ec190501aa84b04a4b4cf1ee122", "hex"); +var xmrig_cnlite_hash = new Buffer("28a22bad3f93d1408fca472eb5ad1cbe75f21d053c8ce5b3af105a57713e21dd", "hex"); +var xmrig_cnlitevariant1_hash = new Buffer("87c4e570653eb4c2b42b7a0d546559452dfab573b82ec52f152b7ff98e79446f", "hex"); hashedData = multiHashing['cryptonight'](cn_data); -hashedData_v1 = multiHashing['cryptonight'](cnv1_data, 1); +cn_variant1Data = multiHashing['cryptonight'](xmrig_data, 1); +cnlite_data = multiHashing['cryptonight-lite'](xmrig_data, 0); +cnlite_variant1Data = multiHashing['cryptonight-lite'](xmrig_data, 1); console.log(hashedData); -console.log(hashedData_v1); +console.log(cn_variant1Data); +console.log(cnlite_data); +console.log(cnlite_variant1Data); assert.deepEqual(hashedData, cn_hash); -assert.deepEqual(hashedData_v1, cnv1_hash); +assert.deepEqual(cn_variant1Data, xmrig_cnvariant1_hash); +assert.deepEqual(cnlite_data, xmrig_cnlite_hash); +assert.deepEqual(cnlite_variant1Data, xmrig_cnlitevariant1_hash); From fe46cc79cefab16aa7302ed1041a1e0f92aece3a Mon Sep 17 00:00:00 2001 From: Suml Noether Date: Sun, 25 Mar 2018 18:39:50 +0000 Subject: [PATCH 6/6] Updated the README.md with install instructions. --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ff57f7ed..430871ae 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,12 @@ Algorithms Usage ----- -Install +Install on Ubuntu 16.04 ```bash -npm install multi-hashing +sudo apt-get nodejs nodejs-dev node-gyp npm +sudo ln -s /usr/bin/nodejs /usr/bin/node +npm install git+https://github.com/sumlnoether/node-multi-hashing-node8.git ``` So far this native Node.js addon can do the following hashing algos