Bitcoin Forum
January 20, 2020, 05:30:28 AM *
News: Latest Bitcoin Core release: 0.19.0.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What's going wrong here? Different privkeys from same XPRV.  (Read 162 times)
AdolfinWolf
Legendary
*
Offline Offline

Activity: 1288
Merit: 1129


people run from rain but sit in bathtubs of water


View Profile
October 26, 2018, 12:12:13 PM
Last edit: October 26, 2018, 12:28:17 PM by AdolfinWolf
 #1

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.

1579498228
Hero Member
*
Offline Offline

Posts: 1579498228

View Profile Personal Message (Offline)

Ignore
1579498228
Reply with quote  #2

1579498228
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1579498228
Hero Member
*
Offline Offline

Posts: 1579498228

View Profile Personal Message (Offline)

Ignore
1579498228
Reply with quote  #2

1579498228
Report to moderator
1579498228
Hero Member
*
Offline Offline

Posts: 1579498228

View Profile Personal Message (Offline)

Ignore
1579498228
Reply with quote  #2

1579498228
Report to moderator
1579498228
Hero Member
*
Offline Offline

Posts: 1579498228

View Profile Personal Message (Offline)

Ignore
1579498228
Reply with quote  #2

1579498228
Report to moderator
Abdussamad
Legendary
*
Offline Offline

Activity: 2352
Merit: 1232



View Profile
October 26, 2018, 03:33:32 PM
 #2

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
mu_enrico
Copper Member
Hero Member
*****
Offline Offline

Activity: 756
Merit: 1117


Mention mu_enrico and I will be there to answer


View Profile WWW
October 26, 2018, 05:15:14 PM
Last edit: October 27, 2018, 01:42:46 AM by mu_enrico
 #3

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.

.
.
.
▄███████████████████▄
█████████████████████
████████████▀▀░░░░███
███████████▌░░░░░░███
███████████░░░░██████
███████████░░░░██████
████████░░░░░░░░░░▐██
████████░░░░░░░░░░███

███████████░░░░██████

███████████░░░░██████

███████████░░░░██████

███████████░░░░██████

▀██████████░░░░█████▀
▄███████████████████▄
█████████████████████
█████████████████████
████▀██████▀░░░▀▀▄███
████░░▀▀███░░░░░░▄███
████▀░░░░░░░░░░░▐████
████▄░░░░░░░░░░░█████
█████▀░░░░░░░░░▄█████

████▀█▄░░░░░░░▄██████

█████▄░░░░░▄▄████████

█████████████████████

█████████████████████

▀███████████████████▀
▄███████████████████▄
█████▀▀▀▀▀▀▀▀▀▀▀█████
███░░░▄▄▄▄▄▄▄▄▄░░░███
██░░▄█████████▀▀▄░░██
██░░███▀▀░░░▀▀▄▄█░░██
██░░██▀░▄███▄░▀██░░██
██░░██░░█████░░██░░██
██░░██▄░▀███▀░▄██░░██

██░░███▄▄░░░▄▄███░░██

██░░▀███████████▀░░██

███░░░▀▀▀▀▀▀▀▀▀░░░███

█████▄▄▄▄▄▄▄▄▄▄▄█████

▀███████████████████▀
▄███████████████████▄
█████████████████████
█████████████████████
██████████████▀▀▀████
██████████▀▀░░░░▐████
██████▀▀░░░▄▀░░░█████
████░░░░▄▄▀░░░░▐█████
██████▄▐█░░░░░░██████

███████▌▌░░░░░▐██████

████████▄██▄▄░███████

█████████████████████

█████████████████████

▀███████████████████▀
.
HCP
Legendary
*
Offline Offline

Activity: 1218
Merit: 2138

<insert witty quote here>


View Profile
October 30, 2018, 09:03:07 PM
Merited by AdolfinWolf (1)
 #4

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

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!