How to decipher the encrypted message using elliptic curve using JavaScript library?

I have found a library about Elliptic Curve Cryptography in JavaScript. I have learned how to encrypt the message. But, I didn’t find how to decrypt it to the original message.

The code for encryption:

var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
var msg = "hello";

let myKey = ec.keyFromPrivate('29f3c33a550d3810e6b82b7b510672118aeabcf8b19e00172e4623cbf480d2b8');
const sig = myKey.sign(msg, 'base64');
var derSign = sig.toDER('hex');
console.log (derSign)



I want to return the signature to hello again. How I could do that, please?


I don’t see any encrypt and decrypt function in elliptic, even in source code of library. In your demo code, it’s a signature, not an encrypted message. You could use verify to validate the message whether is changed or not by some evil people..

console.log(myKey.verify(msg, derSign)); // true
console.log(myKey.verify(msg+"something_else", derSign)); // false

When the output is false, it’s mean you message is changed, and true mean the message is not changed. That’s how signature work, not encrypt or decrypt message.

So, if you want to encrypt and decrypt message with ecc, I guess you might use this library eccrypto.

Leave a Reply

Your email address will not be published. Required fields are marked *