The basic examples show how to get the private key/public address, but how do I get the public key?
@harryio what do you need the public key for? (I ask simply so I can determine what format you might need)
@dcousens um I want to encrypt some data, so that it could be later decrypted using the private key..
let kp = bitcoin.ECPair.makeRandom()
console.log(kp.getPublicKeyBuffer())
// this is the serialized public key, potentially ready for use in other ECC libraries
console.log(kp.Q)
// the ECPoint used by bitcoinjs-lib... see https://www.npmjs.com/package/ecurve
thanks, please close the issue
@dcousens can I convert the buffer to hex and store it in the database for later use?
harryio of course you can, check buffer docs at nodejs.org
let kp = bitcoin.ECPair.makeRandom()
console.log(kp.getPublicKeyBuffer().toString('hex'))
@harrio: > um I want to encrypt some data, so that it could be later decrypted using the private key..
What are you trying to do here? There are more sound ways to implement encryption (not that you should) than by using this libraries public/private key, it already seems the wrong way to go.
Most helpful comment