0

I'm using https://iancoleman.io/bip39/#english to generate a random 12 word mneumonic with the following settings.

  • Mneumonic language: English
  • Coin: Ethereum
  • Derivation Path: BIP44

It generated the following mneumonic movie diesel same toe bachelor acquire roast ghost siege thought possible scale

The first address - public key - private key is the following
Address: 0x67D8641084F8088D5996E39Bae07F9Dc4130307F
Public Key: 0x030c8931742732ca2e0956ecf385acc886a54428ad84eb884aa2c72f1008a2c858
Private Key: 0x78f7e532bf8d7c79d8ef42c75a361f53a8db8c38e4cb1828788ef119c48f6896
I wrote this to generate the same public key from the private key.

var Wallet = require('ethereumjs-wallet')
var EthUtil = require('ethereumjs-util')

// Get a wallet instance from a private key
const privateKeyBuffer = EthUtil.toBuffer(
  '0x78f7e532bf8d7c79d8ef42c75a361f53a8db8c38e4cb1828788ef119c48f6896'
)
const wallet = Wallet.fromPrivateKey(privateKeyBuffer)

// Get a public key
const publicKey = wallet.getPublicKeyString()
console.log(publicKey)

the log statment prints 0x0c8931742732ca2e0956ecf385acc886a54428ad84eb884aa2c72f1008a2c8582bc50fd34eb9e111ae2969205d7af28e9b5050be4ae6ca43df74fc65b9af5803 This is not the same public key for the corresponding private key, why is this?

1
  • 0x030c8931742732ca2e0956ecf385acc886a54428ad84eb884aa2c72f1008a2c858 is not a valid public key. Mar 3, 2020 at 13:13

1 Answer 1

0

Public Key: 0x030c8931742732ca2e0956ecf385acc886a54428ad84eb884aa2c72f1008a2c858

A public key consists of 512 bits, represented with a string of 128 hexadecimal characters.

Hence the above is not a valid public key.

0x0c8931742732ca2e0956ecf385acc886a54428ad84eb884aa2c72f1008a2c8582bc50fd34eb9e111ae2969205d7af28e9b5050be4ae6ca43df74fc65b9af5803 is not the same public key for the corresponding private key

This is in fact the correct public key for the private key given in the question.

2
  • In that case I must've misunderstood something from the website i was using and what it really generates. EthUtil.privateToAddress(privateKeyBuffer) does return the same address as the website does. Isn't the address supposed to match the last 20bytes of the public key though?
    – Conviley
    Mar 3, 2020 at 13:38
  • @Conviley: 40 bytes. And I'm pretty sure that it's supposed to be the hash of those 40 bytes. Mar 3, 2020 at 14:33

Your Answer

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

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