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

Self-Driving Truck Firm Strikes Into Ann Arbor

Exterior, friends mingled within the heat August solar whereas children, dad and mom, and even a number of four-legged mates loved the morning....

Tesla shareholders sue Elon Musk for allegedly hyping up faltering Robotaxi | Tesla

Tesla shareholders sued Elon Musk and the electrical automobile maker for allegedly concealing the numerous threat posed by firm’s self-driving automobiles.The proposed class-action...

Jury orders Tesla to pay greater than $200m to plaintiffs in lethal 2019 Autopilot crash | Tesla

A Florida jury ordered Tesla to pay greater than $200m to victims of a lethal crash involving its Autopilot driver help know-how.Friday’s verdict...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here