Open bitsanity opened 3 years ago
I do not understand, instanceof
does not work in nwjs
?
Oops accidentally hit close. fanatid - yes correct for some reason the instanceof operator is failing for Uint8Array - sees as object for some reason.
The workaround/fix works for me. I get the signature imported ok.
I am having this error, why not use the node implementation?
const isuint8 = require('util').types.isUint8Array;
in:
privateKeyVerify (seckey) {
isUint8Array('private key', seckey, 32)
return secp256k1.privateKeyVerify(seckey) === 0
},
I tested for a Buffer in the console, and it works,
isuint8(value)
>true
value instanceof Uint8Array
>false
value
>Buffer(32) [86, 56, 62, 77, 229, 4, 46, 49, 85, 225, 47, 117, 104, 122, 39, 225, 167, 132, 235, 238, 234, 100, 41, 84, 208, >162, 176, 13, 122, 151, 47, 92]
Using secp256k1 npm module within nwjs-sdk-v0.51.2-linux-x64
Result
Error: Expected signature to be an Uint8Array", source: [...]/node_modules/secp256k1/lib/index.js (18)
Origin of the Error
Root Cause
The instanceof operator returns false. The typeof operator returns object, so javascript is seeing value as an object not as a Uint8Array.
Workaround/Fix