Closed piano-man closed 6 years ago
Both encrypt
and decrypt
in eth-ecies
are synchronous. Try removing the async/await?
Also, which line is causing the error? Can you show the stack trace?
Removed async and await.Still getting the same error .Plus in nodejs it works with async await too. The exact line where the error occurs is this(the one where the decrypt function of the ecies library is called):- let decryptedData = ecies.decrypt(userPrivateKey, bufferEncryptedData);
NOTE:- I have this line at the top of my code to import the library const ecies = require("eth-ecies");
This is the bn.js file (as shown in the browser console)which throws the error(at line 6) (function (module, exports) { 'use strict'; // Utils function assert (val, msg) { if (!val) throw new Error(msg || 'Assertion failed'); }
Can you paste the stack trace?
What exactly do i paste as the stack trace ?The browser console?if not then how do i get it ?
here is the trace :-
thanks for your help! :smile: _
The stack trace before minifying your js bundle? Do you have source maps? if you use create react app it should print stack trace in console or on screen.
Anyway, I suspect it's the BN.toBuffer
function, at assert(typeof Buffer !== 'undefined');
. It has something to do with the Buffer polyfill. A fix is on the way. Thanks for the issue.
Version 1.0.3 uses safe-buffer
and it should have fixed this issue. Please update the package
Thanks a lot.It works perfectly now :)
I've been running into this error when i try to use the decrypt function in my react-app.The same code works perfectly on my node-js server but throws this error in the react app. The code is given below: