I am questioning if it is attainable to make use of the Bitcoin private and non-private keys (normally used for signing) for textual content encryption. That is an instance in nodeJs:
import pkg from 'bitcore-lib'
const { PrivateKey, Networks } = pkg
const privateKey = new PrivateKey(Networks['livenet'])
const myObject = {
privateKey: privateKey,
P2PKHAddress: privateKey.toAddress(),
publicKey: privateKey.toPublicKey(),
wif: privateKey.toWIF()
}
It’s attainable to make use of publicKey
to encrypt a message and decrypt with privateKey
?
const encryptedText = encrypt('Hiya', publicKey)
const decryptedText = decrypt(encryptedText, privateKey)
assert decryptedText === 'Hiya'