current position:Home>Abnormal address generated by Ethereum web Wallet

Abnormal address generated by Ethereum web Wallet

2022-02-03 23:54:21 Q & A of Denglian community

var Crypto = require('crypto')var secp256k1 = require('secp256k1')var createKeccakHash = require('keccak')

// One 32 Random number of bytes (1~2^256-1), Just use him as a private key var privateKey = Crypto.randomBytes(32);

// from secp256k1 Elliptic curve algorithm first calculates the public key var pubKey = secp256k1.publicKeyCreate(privateKey, false).slice(1);

// Conduct keccak256 hash After operation and retrieval 40 You get var address = createKeccakHash('keccak256').update(pubKey).digest().slice(-20);

console.log(privateKey.toString('hex'));console.log("0x" + address.toString('hex'));

Error report in execution PS D:\webprojects\wallet> node raw.jsD:\webprojects\wallet\node_modules\keccak\lib\api\keccak.js:41if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')^

TypeError: Data must be a string or a bufferat Keccak.update (D:\webprojects\wallet\node_modules\?[4mkeccak?[24m\lib\api\keccak.js:41:67)at Object.<anonymous> (D:\webprojects\wallet\raw.js:12:45)?[90m at Module._compile (internal/modules/cjs/loader.js:1156:30)?[39m?[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)?[39m?[90m at Module.load (internal/modules/cjs/loader.js:1000:32)?[39m?[90m at Function.Module._load (internal/modules/cjs/loader.js:899:14)?[39m?[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)?[39m?[90m at internal/main/run_main_module.js:18:47?[39m






Other answers 1:


Other answers 2:


Other answers 3:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032354195559.html

Random recommended