1

Is there a calculation to convert Ethereum private keys to the public address, without being connected to the internet?

2 Answers 2

3

I found a solution using nodejs:

const createKeccakHash = require('keccak')
const secp256k1 = require('secp256k1')
const privateKey = new Buffer('<PRIVATE KEY>', 'hex');
let pubKey = secp256k1.publicKeyCreate(privateKey, false).slice(1);
//console.log(pubKey);
let address = createKeccakHash('keccak256').update(pubKey).digest().slice(-20).toString('hex');
console.log('0x'+address);
1
  • See my answer for an easier version.
    – user19510
    Commented Jan 14, 2018 at 6:02
3

Transforming a private key to a public key does not require the network. It's only cryptography. The network does not do any computation for you to give you the answer.

An easier solution using Node.js:

> const Wallet = require('ethereumjs-wallet');
undefined
> Wallet.fromPrivateKey(Buffer.from('208065a247edbe5df4d86fbdc0171303f23a76961be9f6013850dd2bdc759bbb', 'hex')).getAddress().toString('hex');
'0bed7abd61247635c1973eb38474a2516ed1d884'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.