I'm trying to convert ethereum private key to DER format but get an error. Below are the steps:
First I use web3 to create new ethereum account that has the following key:
private key = 0x45a84f0899393274a9aa0ba3b86277543fc7f3ac508390a3b492fb88ac189dd1
Run key-encoder code:
var KeyEncoder = require('key-encoder').default,
keyEncoder = new KeyEncoder('secp256k1')
var rawPrivateKey = '0x45a84f0899393274a9aa0ba3b86277543fc7f3ac508390a3b492fb88ac189dd1',
var pemPrivateKey = keyEncoder.encodePrivate(rawPrivateKey, 'raw', 'pem', 'pkcs8') //default is 'pkcs1'
console.log(pemPrivateKey)
I save it to eth_private.pem file. Then I try to use openssl tool to covnert it to DER with this command:
openssl pkcs8 -inform PEM -outform DER -topk8 -nocrypt -in eth_private.pem -out eth_private.der
I'm trying to convert ethereum private key to DER format but get an error. Below are the steps:
First I use web3 to create new ethereum account that has the following key: private key =
0x45a84f0899393274a9aa0ba3b86277543fc7f3ac508390a3b492fb88ac189dd1
Run key-encoder code:
It outputs:
I save it to
eth_private.pem
file. Then I try to use openssl tool to covnert it to DER with this command:openssl pkcs8 -inform PEM -outform DER -topk8 -nocrypt -in eth_private.pem -out eth_private.der
It raises this error:
I'm not sure if the problem with the private key cause it works when I try the private key in project sample.