I was trying to use the private key module of the @tkey/private-keys, but I’m getting an error.
I’m using a simple node.js repo, I tried with javascript and typescript both failed. I’m using the latest version and tried older versions, always the same error.
const { PrivateKeyModule, SECP256K1Format } = require("@tkey/private-keys");
const { BN } = require("bn.js");
async function main() {
const privateKeyInput = new BN(
"4bd0041b7654a9b16a7268a5de7982f2422b15635c4fd170c140dc4897624390",
"hex"
);
console.log("privateKeyInput:", privateKeyInput);
const secp256k1 = new SECP256K1Format(privateKeyInput);
console.log("secp256k1.privateKey:", secp256k1.privateKey.toString("hex"));
const privateKeyModule = new PrivateKeyModule([secp256k1]);
const result1 = await privateKeyModule.getPrivateKeys();
console.log("result1:", result1);
const result2 = await privateKeyModule.getAccounts();
console.log("result2:", result2);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});