|
|
@ -9,7 +9,7 @@ |
|
|
|
#include <vector> |
|
|
|
using namespace v8; |
|
|
|
|
|
|
|
int verifyEH(const char *hdr, const std::vector<unsigned char> &soln, unsigned int n, unsigned int k){ |
|
|
|
int verifyEH(const char *hdr, const std::vector<unsigned char> &soln, unsigned int n = 200, unsigned int k = 9){ |
|
|
|
// Hash state
|
|
|
|
crypto_generichash_blake2b_state state; |
|
|
|
EhInitialiseState(n, k, state); |
|
|
@ -40,6 +40,9 @@ void Verify(const v8::FunctionCallbackInfo<Value>& args) { |
|
|
|
Isolate* isolate = Isolate::GetCurrent(); |
|
|
|
HandleScope scope(isolate); |
|
|
|
|
|
|
|
unsigned int n = 200; |
|
|
|
unsigned int k = 9; |
|
|
|
|
|
|
|
if (args.Length() < 2) { |
|
|
|
isolate->ThrowException(Exception::TypeError( |
|
|
|
String::NewFromUtf8(isolate, "Wrong number of arguments"))); |
|
|
@ -48,8 +51,11 @@ void Verify(const v8::FunctionCallbackInfo<Value>& args) { |
|
|
|
|
|
|
|
Local<Object> header = args[0]->ToObject(); |
|
|
|
Local<Object> solution = args[1]->ToObject(); |
|
|
|
unsigned int n = args[2]->Uint32Value(); |
|
|
|
unsigned int k = args[3]->Uint32Value(); |
|
|
|
|
|
|
|
if (args.Length() == 4) { |
|
|
|
n = args[2]->Uint32Value(); |
|
|
|
k = args[3]->Uint32Value(); |
|
|
|
} |
|
|
|
|
|
|
|
if(!node::Buffer::HasInstance(header) || !node::Buffer::HasInstance(solution)) { |
|
|
|
isolate->ThrowException(Exception::TypeError( |
|
|
|