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

Why I can’t wait to get right into a driverless automotive | Self-driving automobiles

Adrian Chiles (Driverless automobiles are taking us on a street to nowhere, 10 September) needs to know who requested for driverless automobiles. I...

Self-driving vehicles needs to be taxed to offset job losses, thinktank urges | Self-driving vehicles

Taxes on self-driving vehicles needs to be launched now within the UK to offset the rise in congestion and threats to jobs they...

Driverless vehicles are taking us on a street to nowhere | Adrian Chiles

I’ve discovered a hill to die on. Driverless vehicles. Why? Actually, why? If driverless vehicles are the reply, then what's the query? Who...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here