ethereumjs/keythereum

keythereum.recover() doesn't give me the private key

Fukunaga42 opened this issue · 2 comments

Maybe im wrong but I try to generate private key in order to be able to import them in metamask.
So I create:

var dk = keythereum.create();
var keyObject = keythereum.dump(password, dk.privateKey, dk.salt, dk.iv)

then I try to export private key in plain text by using recover:

var privateKey = keythereum.recover(password, keyObject);
var readablePrivKey = privateKey.toString('base64');
console.log(readablePrivKey);
> R4TKRCemmMaY8NtIipcrVKIQ+RumXvOOyg5VIG/lXuY=

I got this result which is not corresponding with the ethereum private key adress, so maybe i do something wrong but I try to understand.
Regards

I think that's your private key, just in base-64. If you'd prefer it in hex, do privateKey.toString('hex') instead of privateKey.toString('base64'). If you want the Ethereum address, use keythereum.privateKeyToAddress(privateKey).

Oh yes its working thank you ! don't know why i let base64 ..