Author

Topic: What's going wrong here? Different privkeys from same XPRV. (Read 274 times)

HCP
legendary
Activity: 2086
Merit: 4361
Yeah... ETH will most likely be using m/44'/60'/0'/0/0 by default...

If you copy/paste the xprv into the "BIP32 root key" box at the top of Ian Coleman website... click the "BIP44" tab... and then change the coin type at the top from BTC to ETH, you can see how the values change. However, you can also FORCE Ian Coleman to produce an ETH using m/44'/0'/0'/0/0 Wink

Again, copy/paste the xprv into the "BIP32 root key", set coin to ETH... but this time click the "BIP32" tab... make sure "Client" is "Custom" and then then type m/44'/0'/0'/0 into the "BIP32 Derivation Path" box... note that the "public" key will be the "same" (excluding the 0x of course Wink) for BTC and ETH:

BIP32 Root Key: xprvA1spA8iHkXqJwZHPeiEFDUkzmqgnF4LRLzDrioV98peEs2ykDutTjunz1H1jdiaPjMWG8ae6Por nnWoDAZfw15xxkxqk4tJoa5Tn4yZJ1x4
Quote from: CoinType = BTC
PATH: m/44'/0'/0'/0/0
ADDRESS: 1LwWkCJuLkyrdCvxKpsRaBL8jWggeSKn1e
PUBKEY: 03dbdb0a46453e066ff317295a9e947cf4661c61edde8ef4b922b907518497434b
PRIVKEY: L4Y4ZyYyNZQDd1jt1dtGvX5ADLCj87Pm9B7y3FiwmJYAX1U1c336
Quote from: CoinType = ETH
PATH: m/44'/0'/0'/0/0
ADDRESS: 0x745b10e4931DfC1138b8249d20026dE8Ea002694
PUBKEY: 0x03dbdb0a46453e066ff317295a9e947cf4661c61edde8ef4b922b907518497434b
PRIVKEY: 0xda4d6e39d2b6d948729d0a678745be93ddb3cdbfcae4fc73aa162d440a4931ba
copper member
Activity: 2324
Merit: 2142
Slots Enthusiast & Expert
eth would have a different coin type code than bitcoin so the derivation path will be different. find out what derivation path is used there. see bip44 for more details: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#Coin_type

I think you mean this https://github.com/satoshilabs/slips/blob/master/slip-0044.md link.
Ether is 60, other path stays the same.

Edit: I tried to look at your problem one more, it seems that your xprv is not a Bitcoin Master Private Key (depth 0) but a Bitcoin Derived Private Key (depth 4). Maybe use [derivePath(m)] will solve your problem. The iancoleman one is the correct one btw.
legendary
Activity: 3696
Merit: 1584
eth would have a different coin type code than bitcoin so the derivation path will be different. find out what derivation path is used there. see bip44 for more details: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#Coin_type
legendary
Activity: 1946
Merit: 1427
Okay.

I start with generating an bip32 xprv from https://iancoleman.io/bip39/

Code:
xprvA1spA8iHkXqJwZHPeiEFDUkzmqgnF4LRLzDrioV98peEs2ykDutTjunz1H1jdiaPjMWG8ae6PornnWoDAZfw15xxkxqk4tJoa5Tn4yZJ1x4

Code:
m/44'/0'/0'/0/0 1Bc7RvUdCSHEZmyXkdwTe1JYEFLdd3ebvw 024d27c803e9cb8092021bb74643e188233e0985be5b7130e6b0966dce6458d4f2 KxXviT8QiwyeRT4KP2cQjjSMPSQKTEhsGvGdQtGoxK4sRQZTsbLj

Code:
KxXviT8QiwyeRT4KP2cQjjSMPSQKTEhsGvGdQtGoxK4sRQZTsbLj
From WIF compressed to HEX;
Code:
27355B317CD6FFE47062B03BF2E9E01D8E31B0ADBA76F442A05BBF5F1B57208E
(Gives the following ETH adress )
Code:
0xEeC8a7981F2C9Eb03e2E8Ff1a915fa3E00367D94



I use the xpriv key in ethereumjs-wallet - https://github.com/ethereumjs/ethereumjs-wallet

Code:
var hdkey = require('ethereumjs-wallet/hdkey');

var extPrivKey = 'xprvA1spA8iHkXqJwZHPeiEFDUkzmqgnF4LRLzDrioV98peEs2ykDutTjunz1H1jdiaPjMWG8ae6PornnWoDAZfw15xxkxqk4tJoa5Tn4yZJ1x4';

var hdwallet = hdkey.fromExtendedKey(extPrivKey);
var wallet = hdwallet.getWallet();
var address = wallet.getAddress();
var privatekey = wallet.getPrivateKey();
console.log(`Address: 0x${address.toString('hex')}`);
console.log(`PrivateKey: ${privatekey.toString('hex')}`);[/size]
Code used for generation of m/44'/0'/0'/0/0 (?) - (Is this correct? it should generate the same index=0 as above tool, right?)

Gives;
Code:
Address: 0x03b82ba80f68502ee1f73e53a42175a89e718b66
PrivateKey: e174a4f2bc96cf67342c1bab1bfffa283c7a98cd08c61d6e829cdf683c13a844

Why are they different? - Am i missing something in their respective derivation methods?


This might not be the right section. Please move if it's not the appropriate section.
Jump to: