4

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?

Dalton Cézane
  • 3,672
  • 2
  • 35
  • 60

2 Answers2

3

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.

Dalton Cézane
  • 3,672
  • 2
  • 35
  • 60
1

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.

Fabio
  • 11
  • 1