Skip to content

Commit 04b2edf

Browse files
committed
Initial x13 support
1 parent eae9eb7 commit 04b2edf

File tree

7 files changed

+40964
-0
lines changed

7 files changed

+40964
-0
lines changed

binding.gyp

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"hefty1.c",
1919
"shavite3.c",
2020
"cryptonight.c",
21+
"x13.c",
2122
"sha3/sph_hefty1.c",
2223
"sha3/sph_fugue.c",
2324
"sha3/aes_helper.c",
@@ -32,6 +33,7 @@
3233
"sha3/sph_shavite.c",
3334
"sha3/sph_simd.c",
3435
"sha3/sph_skein.c",
36+
"sha3/hamsi.c",
3537
"crypto/oaes_lib.c",
3638
"crypto/c_keccak.c",
3739
"crypto/c_groestl.c",

multihashing.cc

+24
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern "C" {
1818
#include "hefty1.h"
1919
#include "shavite3.h"
2020
#include "cryptonight.h"
21+
#include "x13.h"
2122
}
2223

2324
using namespace node;
@@ -422,6 +423,28 @@ Handle<Value> cryptonight(const Arguments& args) {
422423
return scope.Close(buff->handle_);
423424
}
424425

426+
Handle<Value> x13(const Arguments& args) {
427+
HandleScope scope;
428+
429+
if (args.Length() < 1)
430+
return except("You must provide one argument.");
431+
432+
Local<Object> target = args[0]->ToObject();
433+
434+
if(!Buffer::HasInstance(target))
435+
return except("Argument should be a buffer object.");
436+
437+
char * input = Buffer::Data(target);
438+
char output[32];
439+
440+
uint32_t input_len = Buffer::Length(target);
441+
442+
x13_hash(input, output, input_len);
443+
444+
Buffer* buff = Buffer::New(output, 32);
445+
return scope.Close(buff->handle_);
446+
}
447+
425448
void init(Handle<Object> exports) {
426449
exports->Set(String::NewSymbol("quark"), FunctionTemplate::New(quark)->GetFunction());
427450
exports->Set(String::NewSymbol("x11"), FunctionTemplate::New(x11)->GetFunction());
@@ -439,6 +462,7 @@ void init(Handle<Object> exports) {
439462
exports->Set(String::NewSymbol("hefty1"), FunctionTemplate::New(hefty1)->GetFunction());
440463
exports->Set(String::NewSymbol("shavite3"), FunctionTemplate::New(shavite3)->GetFunction());
441464
exports->Set(String::NewSymbol("cryptonight"), FunctionTemplate::New(cryptonight)->GetFunction());
465+
exports->Set(String::NewSymbol("x13"), FunctionTemplate::New(x13)->GetFunction());
442466
}
443467

444468
NODE_MODULE(multihashing, init)

0 commit comments

Comments
 (0)