我想使用ECDSA(prime256v1曲线)在Node中生成数字签名 私钥是通过以下OpenSSL命令生成的:
$ openssl ecparam -name prime256v1 -genkey -out private_key.pem
以下是用于签署消息的正确Node代码吗?
import crypto from 'crypto'
const sign = (privateKey, messageString) => {
const buffer = Buffer.from(messageString, 'utf8')
const signature = crypto.sign('sha256', buffer, privateKey)
return signature.toString('base64')
}