ECIES encrypt/decrypt library for Ethereum
const ecies = require("eth-ecies");
let plaintext = new Buffer(`{foo:"bar",baz:42}`);
let encryptedMsg = ecies.encrypt(ethPubKey, plaintext);
// encrypted message is a 113+ byte buffer
const ecies = require("eth-ecies");
let plaintext = ecies.decrypt(ethPrivKey, encryptedMsg);
To derive the public key from a private key, you can use ethereumjs-util
module
The ECIES implementation uses fixed Diffie-Hellman (ephemeral-static) key exchange and provides no Perfect Forward Secrecy (PFS). A quick rundown of the implementation can be found here
- Encrypted file storage
- Encrypted emails (where forward secrecy is not desirable, e.g. being able to read past emails)
- Instant messaging for casual conversations