cn_fast_hash support
parent
1505af53f1
commit
edd4fa7b5c
|
@ -169,3 +169,9 @@ void cryptonight_hash(const char* input, char* output, uint32_t len) {
|
||||||
extra_hashes[state.hs.b[0] & 3](&state, 200, output);
|
extra_hashes[state.hs.b[0] & 3](&state, 200, output);
|
||||||
oaes_free(&aes_ctx);
|
oaes_free(&aes_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cryptonight_fast_hash(const char* input, char* output, uint32_t len) {
|
||||||
|
union hash_state state;
|
||||||
|
hash_process(&state, input, len);
|
||||||
|
memcpy(output, &state, HASH_SIZE);
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ extern "C" {
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void cryptonight_hash(const char* input, char* output, uint32_t len);
|
void cryptonight_hash(const char* input, char* output, uint32_t len);
|
||||||
|
void cryptonight_fast_hash(const char* input, char* output, uint32_t len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,8 +392,16 @@ Handle<Value> shavite3(const Arguments& args) {
|
||||||
Handle<Value> cryptonight(const Arguments& args) {
|
Handle<Value> cryptonight(const Arguments& args) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
|
||||||
|
bool fast = false;
|
||||||
|
|
||||||
if (args.Length() < 1)
|
if (args.Length() < 1)
|
||||||
return except("You must provide one argument.");
|
return except("You must provide one argument.");
|
||||||
|
|
||||||
|
if (args.Length() >= 2) {
|
||||||
|
if(!args[1]->IsBoolean())
|
||||||
|
return except("Argument 2 should be a boolean");
|
||||||
|
fast = args[1]->ToBoolean()->BooleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
Local<Object> target = args[0]->ToObject();
|
Local<Object> target = args[0]->ToObject();
|
||||||
|
|
||||||
|
@ -405,7 +413,10 @@ Handle<Value> cryptonight(const Arguments& args) {
|
||||||
|
|
||||||
uint32_t input_len = Buffer::Length(target);
|
uint32_t input_len = Buffer::Length(target);
|
||||||
|
|
||||||
cryptonight_hash(input, output, input_len);
|
if(fast)
|
||||||
|
cryptonight_fast_hash(input, output, input_len);
|
||||||
|
else
|
||||||
|
cryptonight_hash(input, output, input_len);
|
||||||
|
|
||||||
Buffer* buff = Buffer::New(output, 32);
|
Buffer* buff = Buffer::New(output, 32);
|
||||||
return scope.Close(buff->handle_);
|
return scope.Close(buff->handle_);
|
||||||
|
|
Loading…
Reference in New Issue