I'm using eccrypto in my program. Bob encrypts a key in its NodeJS by eccrypto and Carol should decrypt it in its NodeJS by eccrypto too. The issue arises by decryption, encryption is successful but decryption is failed. Whenever the program runs eccrypto.decrypt() it throws this error on PowerShell:
secp256k1 unavailable, reverting to browser version
C:\...\node_modules\eccrypto\browser.js:16
throw new Error(message || "Assertion failed");
^
Error: Bad public key
at assert (C:\...\node_modules\eccrypto\browser.js:16:11)
at C:\...\node_modules\eccrypto\browser.js:190:5
at new Promise (<anonymous>)
at exports.derive (C:\...\node_modules\eccrypto\browser.js:188:10)
at Object.exports.decrypt (C:\...\node_modules\eccrypto\browser.js:246:10)
at Object.<anonymous> (C:\...\Alice.js:30:16)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
This is my whole code:
const eccrypto=require("eccrypto");
const publicKey="0439c1b6515b1e3be3320d5601762d1730d48d01849f006380d4db6b5fb23fc5281de13ffec39787b86fc98ce47aabb26071d53aa6d3e32bcbe4ff4aa517ca1310";
const privateKey="ab2...a";
let crypto="7b2296...5d7d7d";
const cryptoString=hexToString(crypto);
const cryptoObj=JSON.parse(cryptoString);
const privateKeyString=hexToString(privateKey);
eccrypto.decrypt(privateKeyString,cryptoObj).then(
console.log
);
function hexToString(hexString) {
return new Buffer.from(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
}
What is the problem and how can I solve it?
I'm using
eccryptoin my program. Bob encrypts a key in its NodeJS byeccryptoand Carol should decrypt it in its NodeJS byeccryptotoo. The issue arises by decryption, encryption is successful but decryption is failed. Whenever the program runseccrypto.decrypt()it throws this error on PowerShell:This is my whole code:
What is the problem and how can I solve it?