Open
Description
Using secp256k1 npm module within nwjs-sdk-v0.51.2-linux-x64
let sigbytes = [an ECDSA signature in DER format, 71 bytes]
let dersig = Uint8Array.from( sigbytes );
let sigobj = SECP256K1.signatureImport( dersig );
Result
Error: Expected signature to be an Uint8Array", source: [...]/node_modules/secp256k1/lib/index.js (18)
Origin of the Error
function isUint8Array (name, value, length) {
assert(value instanceof Uint8Array, `Expected ${name} to be an Uint8Array`)
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
function isUint8Array (name, value, length) {
assert(value instanceof Uint8Array || value.constructor.name === 'Uint8Array', `Expected ${name} to be an Uint8Array`)
Metadata
Metadata
Assignees
Labels
No labels