cryptography – Tips on how to encrypt messages with Pub/Priv keys

on

|

views

and

comments


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'

Share this
Tags

Must-read

US regulators launch investigation into self-driving Teslas after collection of crashes | Self-driving automobiles

US vehicle security regulators have opened an investigation into Tesla automobiles outfitted with its full self-driving know-how over traffic-safety violations after a collection...

Tesla debuts ‘inexpensive’ Mannequin Y and three in US that strike some as too costly | US information

Tesla rolled out “inexpensive” variations of its best-selling Mannequin Y SUV and its Mannequin 3 sedan, however the beginning costs of US$39,990 and...

‘Supply robots will occur’: Skype co-founder on his fast-growing enterprise Starship | Retail trade

City dwellers around the globe have lengthy been used to speedy supply of takeaway meals and, more and more, groceries. However what they...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here