Added nMin and nMax config for scrypt-jane
parent
428853e02e
commit
cc7b70b8e7
|
@ -0,0 +1,8 @@
|
||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- '0.10'
|
||||||
|
deploy:
|
||||||
|
provider: npm
|
||||||
|
email: zone117x@gmail.com
|
||||||
|
api_key:
|
||||||
|
secure: D9lpUDAx1OudPBji3mapnAhOug3wcEBqFrNgWaFh5XiYesa/f/X0gMOJggLlvzyhLHKs8VdTHShdu3XzlC3EDwr5wCdgYO1JSOyDo93FG7Y/qhPDVFnzdtsKmr813Qtj2UDKIh2ZP+JnjKaITrvUwRmdi/8+B9Enr5o9ulFb/a0=
|
|
@ -46,10 +46,10 @@ extern "C" {
|
||||||
|
|
||||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
unsigned char GetNfactorJane(int nTimestamp, int nChainStartTime) {
|
unsigned char GetNfactorJane(int nTimestamp, int nChainStartTime, int nMin, int nMax) {
|
||||||
|
|
||||||
const unsigned char minNfactor = 4;
|
const unsigned char minNfactor = nMin;//4;
|
||||||
const unsigned char maxNfactor = 30;
|
const unsigned char maxNfactor = nMax;//30;
|
||||||
|
|
||||||
int l = 0, s, n;
|
int l = 0, s, n;
|
||||||
unsigned char N;
|
unsigned char N;
|
||||||
|
@ -166,15 +166,17 @@ Handle<Value> scryptn(const Arguments& args) {
|
||||||
if(!Buffer::HasInstance(target))
|
if(!Buffer::HasInstance(target))
|
||||||
return except("Argument should be a buffer object.");
|
return except("Argument should be a buffer object.");
|
||||||
|
|
||||||
Local<Number> num = args[1]->ToNumber();
|
Local<Number> num = args[1]->ToNumber();
|
||||||
int nFactor = num->Value();
|
unsigned int nFactor = num->Value();
|
||||||
|
|
||||||
char * input = Buffer::Data(target);
|
char * input = Buffer::Data(target);
|
||||||
char * output = new char[32];
|
char * output = new char[32];
|
||||||
|
|
||||||
//unsigned int N = 1 << (getNfactor(input) + 1);
|
//unsigned int N = 1 << (getNfactor(input) + 1);
|
||||||
|
unsigned int N = 1 << nFactor;
|
||||||
|
|
||||||
|
scrypt_N_1_1_256(input, output, N);
|
||||||
|
|
||||||
scrypt_N_1_1_256(input, output, nFactor);
|
|
||||||
|
|
||||||
Buffer* buff = Buffer::New(output, 32);
|
Buffer* buff = Buffer::New(output, 32);
|
||||||
return scope.Close(buff->handle_);
|
return scope.Close(buff->handle_);
|
||||||
|
@ -183,8 +185,8 @@ Handle<Value> scryptn(const Arguments& args) {
|
||||||
Handle<Value> scryptjane(const Arguments& args) {
|
Handle<Value> scryptjane(const Arguments& args) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
|
||||||
if (args.Length() < 3)
|
if (args.Length() < 5)
|
||||||
return except("You must provide two argument: buffer, timestamp as number, and nChainStarTime as number");
|
return except("You must provide two argument: buffer, timestamp as number, and nChainStarTime as number, nMin, and nMax");
|
||||||
|
|
||||||
Local<Object> target = args[0]->ToObject();
|
Local<Object> target = args[0]->ToObject();
|
||||||
|
|
||||||
|
@ -197,11 +199,16 @@ Handle<Value> scryptjane(const Arguments& args) {
|
||||||
Local<Number> num2 = args[2]->ToNumber();
|
Local<Number> num2 = args[2]->ToNumber();
|
||||||
int nChainStartTime = num2->Value();
|
int nChainStartTime = num2->Value();
|
||||||
|
|
||||||
|
Local<Number> num3 = args[3]->ToNumber();
|
||||||
|
int nMin = num3->Value();
|
||||||
|
|
||||||
|
Local<Number> num4 = args[4]->ToNumber();
|
||||||
|
int nMax = num4->Value();
|
||||||
|
|
||||||
char * input = Buffer::Data(target);
|
char * input = Buffer::Data(target);
|
||||||
char * output = new char[32];
|
char * output = new char[32];
|
||||||
|
|
||||||
scryptjane_hash(input, 80, (uint32_t *)output, GetNfactorJane(timestamp, nChainStartTime));
|
scryptjane_hash(input, 80, (uint32_t *)output, GetNfactorJane(timestamp, nChainStartTime, nMin, nMax));
|
||||||
|
|
||||||
Buffer* buff = Buffer::New(output, 32);
|
Buffer* buff = Buffer::New(output, 32);
|
||||||
return scope.Close(buff->handle_);
|
return scope.Close(buff->handle_);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "multi-hashing",
|
"name": "multi-hashing",
|
||||||
"version": "0.0.3",
|
"version": "0.0.5",
|
||||||
"main": "multihashing",
|
"main": "multihashing",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Matthew Little",
|
"name": "Matthew Little",
|
||||||
|
|
Loading…
Reference in New Issue