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

GM’s Cruise admits submitting false report back to robotaxi security investigation | Basic Motors

Basic Motors’ self-driving automotive unit, Cruise, admitted on Thursday to submitting a false report back to affect a federal investigation and pays a...

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...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here