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

Common Motors pulls plug on Cruise, its self-driving robotaxi firm | US information

Common Motors introduced on Tuesday it should finish robotaxi growth at its money-losing Cruise enterprise, a blow to the ambitions of the most...

Will the way forward for transportation be robotaxis – or your individual self-driving automotive? | Expertise

Welcome again. This week in tech: Common Motors says goodbye to robotaxis however not self-driving automobiles; one girl’s combat to maintain AI out...

LA tech entrepreneur almost misses flight after getting trapped in robotaxi | Self-driving automobiles

A tech entrepreneur based mostly in Los Angeles turned trapped in a malfunctioning self-driving automobile for a number of minutes final month, inflicting...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here