Author

Topic: [ANN] Node.js ECIES. Encrypt messages to Bitcoin Addresses! (Read 4638 times)

legendary
Activity: 1611
Merit: 1001
awesome, I always wondered if this was possible!
full member
Activity: 144
Merit: 100
Maybe it is better to post it at Bitcoin dev discussion or  projects discussion
member
Activity: 114
Merit: 10
Hey BitcoinTalk!

Just thought I'd show you all my latest invention. Node-ECIES is a Node.js implementation of ECIES, a little known elliptic curve encryption system using ECDH and a Symmetric Cipher (not sure which one, maybe AES). What that means in English, is that given a Bitcoin address' public key, you can encrypt messages to it. Now, this is not all my work, all I did was put a wrapper around node-cryptopp, which in turn is a set of bindings for Crypto++. What I did do is figure out how to use node-cryptopp to do ECIES. Note that you can't send messages to bitcoin addresses, only to public keys, which are available if the user has sent bitcoins from their address.

You can query for the public key by doing: https://blockchain.info/q/pubkeyaddr/1Bardi4eoUvJomBEtVoxPcP8VK26E3Ayxn

Usage:
Code:
var bitcoin = require('bitcoinjs-lib'),
     ecies = require('ecies');
var text = 'Secret ECIES Test Message!';
/* sha256('correct horse battery staple') */
var publicKey = '0478d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71a1518063243acd4dfe96b66e3f2ec8013c8e072cd09b3834a19f81f659cc3455';
var privateKey = bitcoin.ECKey('5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS').toHex();
var cipherText = ecies.encrypt(text, publicKey, 'secp256k1');
var decryptedText = ecies.decrypt(cipherText, privateKey, 'secp256k1');
console.log(text, '->', cipherText, '->', decryptedText);

Install:
Code:
npm install ecies

Source Code
NPM

And of course, where would I be without a selfish request for donations. Coins sent to the address in the signature pay for me to create implementations in different languages.

Have a nice day.
Jump to: