Amine Merad
Amine Merad

Reputation: 1

TypeError: Cannot read properties of undefined (reading 'randomPrivateKey') in ethereum-cryptography/secp256k1 module

When attempting to call the randomPrivateKey function from the 'secp256k1' module, I have an issue that is preventing me from generating a private key.

const secp = require("ethereum-cryptography/secp256k1");
const { keccak256 } = require("ethereum-cryptography/keccak");
const { toHex } = require("ethereum-cryptography/utils")

const privateKey = secp.utils.randomPrivateKey();
console.log('Private key:', toHex(privateKey));

const publicKey = secp.getPublicKey(privateKey);
console.log('Public key:', toHex(publicKey));

const address = (keccak256(publicKey.slice(1)).slice(-20));
console.log('Ethereum public key:', toHex(address));

This is the error I am getting:

TypeError: Cannot read properties of undefined (reading 'randomPrivateKey')

This is the version of ethereum-cryptography am using :

[email protected] : ecdsa-node\server
└── [email protected]

Upvotes: 0

Views: 153

Answers (0)

Related Questions