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

‘Lidar is lame’: why Elon Musk’s imaginative and prescient for a self-driving Tesla taxi faltered | Tesla

After years of promising traders that thousands and thousands of Tesla robotaxis would quickly fill the streets, Elon Musk debuted his driverless automobile...

Common Motors names new CEO of troubled self-driving subsidiary Cruise | GM

Common Motors on Tuesday named a veteran know-how government with roots within the online game business to steer its troubled robotaxi service Cruise...

Meet Mercy and Anita – the African employees driving the AI revolution, for simply over a greenback an hour | Synthetic intelligence (AI)

Mercy craned ahead, took a deep breath and loaded one other process on her pc. One after one other, disturbing photographs and movies...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here