pull/594/head
pubkey 3 years ago
parent 04426e525d
commit 3c26820796
  1. 4
      dist/es/encrypt-with-public-key.js
  2. 4
      dist/lib/encrypt-with-public-key.js
  3. 2
      package.json

@ -1,11 +1,11 @@
import { encrypt } from 'eccrypto';
import { decompress } from './public-key';
export default function encryptWithPublicKey(publicKey, message) {
export default function encryptWithPublicKey(publicKey, message, opts) {
// ensure its an uncompressed publicKey
publicKey = decompress(publicKey); // re-add the compression-flag
var pubString = '04' + publicKey;
return encrypt(Buffer.from(pubString, 'hex'), Buffer.from(message)).then(function (encryptedBuffers) {
return encrypt(Buffer.from(pubString, 'hex'), Buffer.from(message), opts ? opts : {}).then(function (encryptedBuffers) {
var encrypted = {
iv: encryptedBuffers.iv.toString('hex'),
ephemPublicKey: encryptedBuffers.ephemPublicKey.toString('hex'),

@ -9,12 +9,12 @@ var _eccrypto = require("eccrypto");
var _publicKey = require("./public-key");
function encryptWithPublicKey(publicKey, message) {
function encryptWithPublicKey(publicKey, message, opts) {
// ensure its an uncompressed publicKey
publicKey = (0, _publicKey.decompress)(publicKey); // re-add the compression-flag
var pubString = '04' + publicKey;
return (0, _eccrypto.encrypt)(Buffer.from(pubString, 'hex'), Buffer.from(message)).then(function (encryptedBuffers) {
return (0, _eccrypto.encrypt)(Buffer.from(pubString, 'hex'), Buffer.from(message), opts ? opts : {}).then(function (encryptedBuffers) {
var encrypted = {
iv: encryptedBuffers.iv.toString('hex'),
ephemPublicKey: encryptedBuffers.ephemPublicKey.toString('hex'),

@ -1,6 +1,6 @@
{
"name": "eth-crypto",
"version": "2.2.0",
"version": "2.3.0",
"description": "Cryptographic functions for ethereum and how to use them with web3 and solidity",
"keywords": [
"ethereum",

Loading…
Cancel
Save