Reputation: 3782
I am trying to use the ecdsa module to sign some data with a crypto ecdh private key. My code is below:
shaMsg = crypto.createHash('sha256').update(myData).digest();
signed = ecdsa.sign(shaMsg, myECDHKey);
I am facing the following problem:
ERROR: Server - Caught exception: Error: Expected property "1" of type BigInteger, got Buffer
Can anyone help me?
Upvotes: 4
Views: 1575
Reputation: 11
I got it working with:
var BigInteger = require('bigi');
var signature = ecdsa.sign(shaMsg, BigInteger.fromBuffer(privateKey));
But couldn´t verify with publicKey of type Buffer it expects Point.
Upvotes: 1
Reputation: 3782
As I did not receive any answer, I tried with other modules and get what I wanted with the elliptic
module:
var EC = require("elliptic").ec;
var ec = new EC("secp256k1");
var shaMsg = crypto.createHash("sha256").update(myData.toString()).digest();
var mySign = ec.sign(shaMsg, privateKey, {canonical: true});
I hope it can help someone else.
Upvotes: 3