libertylocked / eth-ecies

Ethereum ECIES library, for easy encryption using Ethereum keys

Home Page:https://www.npmjs.com/package/eth-ecies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error while running code example

HugoSanchez opened this issue · comments

Hi,

I just ran your code example and get the following error:

TypeError [ERR_INVALID_ARG_TYPE]: The "list[1]" argument must be one of type Array, Buffer, or Uint8Array. Received type string

This is the code that I'm running:

const ecies = require("eth-ecies");

const ethPubKey = "1e7bcc70c72770dbb72fea022e8a6d07f814d2ebe4de9ae3f7af75bf706902a7b73ff919898c836396a6b0c96812c3213b99372050853bd1678da0ead14487d7"
let plaintext = new Buffer(`{foo:"bar",baz:42}`);
let encryptedMsg = ecies.encrypt(ethPubKey, plaintext);

console.log(encryptedMsg)

The pub key must be a byte buffer. Try using something like Buffer.from("DEADBEEF", "hex")