Description
// According to website (https://nodejs.org/api/crypto.html#crypto_class_sign) In following code //console.log() print false which is a wrong output.
//but it should print true when sign.write() and verify.write() have same data as input
const crypto = require('crypto');
const { privateKey, publicKey } = crypto.generateKeyPairSync('ec', {
namedCurve: 'sect239k1'
});
const sign = crypto.createSign('SHA256');
sign.write('some data to sign');
sign.end();
const signature = sign.sign(privateKey, 'hex');
const verify = crypto.createVerify('SHA256');
verify.write('some data to sign');
verify.end();
console.log(verify.verify(publicKey, signature));
// Prints: true or false
//solution
//please update verify.verify(publicKey,signature) to verify.verify(publicKey,signature,'hex')
//or
//update sign.sign(privateKey, 'hex') to sign.sign(privateKey)
// then above code print right output on specified inputs.