Bitcoin Forum
November 18, 2024, 05:56:16 AM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Derivation path of trezor wallet  (Read 260 times)
keshamambo (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
May 14, 2018, 10:21:28 AM
 #1

Hi everyone! I'm trying to derive my private key for BTC from Trezor with 24 seed.
I'm lost as I can not find the right private key for the right Address that holds the funds. (Derivation path m/44'/0'/0' is not match)
Maybe problem in bitcore.io libriary?
Can anyone help me find the derivation path BTC of trezor wallet?(1.6.1)
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4361

<insert witty quote here>


View Profile
May 14, 2018, 11:06:26 AM
Last edit: May 14, 2018, 11:19:44 AM by HCP
Merited by suchmoon (5), ABCbits (1)
 #2

Do your Trezor addresses begin with a "3" (SegWit P2SH-P2WPKH address) or do they begin with a "1".

If your Trezor addresses begin with a "3", try the derivation path: m/49'/0'/0' (depending on what tool/application you're attempting to use, you may need to use m/49'/0'/0'/0)
If they begin with a "1", then the derivation path should be: m/44'/0'/0' (again, maybe try m/44'/0'/0'/0 depending on what software you're using)

Also, if you have been "spending" coins from this wallet... it's possible your coins are in a "change" address... so try m/49'/0'/0'/1 and m/44'/0'/0'/1 in that case.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
keshamambo (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
May 14, 2018, 12:01:45 PM
 #3

I use bitcore.io library:

var code = new Mnemonic(mnemonic);
var hdPrivateKey = code.toHDPrivateKey();
var derived = hdPrivateKey.derive("m/49'/0'/0'");
var address = derived.privateKey.toAddress().toString();
console.log("address:", address);

but still using m/49(not m/44) I get the adresses which beginning from "1".(but I need "3"). Where is my fault?
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
May 14, 2018, 12:39:57 PM
 #4

I use bitcore.io library:

~snip~

but still using m/49(not m/44) I get the adresses which beginning from "1".(but I need "3"). Where is my fault?

According to the official documentary of the bitcore.io libary (https://bitcore.io/api/lib/address#new_Address_new) the only way to create a nested P2SH address is to call new Address(data, network, [type]).

The function hdPrivateKey.derive(arg, hardened) seems to not be supporting nested P2SH. (https://bitcore.io/api/lib/hd-keys#HDPrivateKey+derive).

I might just not have found the correct function. But it seems that this is currently not possible with this libary  Huh


Is there a specific reason you want to use javascript? This python libary does give you the ability to derive the desired P2SH address from your mnemonic seed.

HeRetiK
Legendary
*
Offline Offline

Activity: 3122
Merit: 2178


Playgram - The Telegram Casino


View Profile
May 14, 2018, 12:51:19 PM
 #5

I might just not have found the correct function. But it seems that this is currently not possible with this libary  Huh

It does indeed look that way. There's a couple of discussions on their GitHub about adding SegWit support, none of which lead to any meaningful results. Their release history also doesn't include anything about P2SH SegWit addresses:

https://github.com/bitpay/bitcore-lib/releases

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

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
 
Playgram.io
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀

▄▄▄░░
▀▄







▄▀
▀▀▀░░
▄▄▄███████▄▄▄
▄▄███████████████▄▄
▄███████████████████▄
▄██████████████▀▀█████▄
▄██████████▀▀█████▐████▄
██████▀▀████▄▄▀▀█████████
████▄▄███▄██▀█████▐██████
█████████▀██████████████
▀███████▌▐██████▐██████▀
▀███████▄▄███▄████████▀
▀███████████████████▀
▀▀███████████████▀▀
▀▀▀███████▀▀▀
██████▄▄███████▄▄████████
███▄███████████████▄░░▀█▀
███████████░█████████░░
░█████▀██▄▄░▄▄██▀█████░
█████▄░▄███▄███▄░▄█████
███████████████████████
███████████████████████
██░▄▄▄░██░▄▄▄░██░▄▄▄░██
██░░░░██░░░░██░░░░████
██░░░░██░░░░██░░░░████
██▄▄▄▄▄██▄▄▄▄▄██▄▄▄▄▄████
███████████████████████
███████████████████████
 
PLAY NOW

on Telegram
[/
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4361

<insert witty quote here>


View Profile
May 15, 2018, 12:21:36 AM
 #6

Where is my fault?
Your "fault" is here:
Quote
I use bitcore.io library:

Unfortunately, they just don't support SegWit. You could probably hack the code and add in support to generate P2SH-P2WPKH addresses from the private keys generated from your Seed Mnemonic, but unless you're simply using this library to generate addresses and NOTHING else, that's probably a bad idea... as there is no guarantee the rest of the library will know what to do with any generated address.

If you tell us what exactly you are trying to achieve, we might be able to offer alternatives to bitcore library.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
keshamambo (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
May 19, 2018, 04:33:58 PM
 #7

I use bitcore.io library:

~snip~

but still using m/49(not m/44) I get the adresses which beginning from "1".(but I need "3"). Where is my fault?

According to the official documentary of the bitcore.io libary (https://bitcore.io/api/lib/address#new_Address_new) the only way to create a nested P2SH address is to call new Address(data, network, [type]).

The function hdPrivateKey.derive(arg, hardened) seems to not be supporting nested P2SH. (https://bitcore.io/api/lib/hd-keys#HDPrivateKey+derive).

I might just not have found the correct function. But it seems that this is currently not possible with this libary  Huh


Is there a specific reason you want to use javascript? This python libary does give you the ability to derive the desired P2SH address from your mnemonic seed.

I have tried the library you have suggested, but the docs there are full mess, and I was not able to grasp the way to generate private key from mnemonic.
Could you, please, tip me on the code or at least methods I should use?

If not, may be you can give another library on Java or JavaScript.
Thank you!
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4361

<insert witty quote here>


View Profile
May 20, 2018, 06:33:21 AM
 #8

It's not exactly a "library" as such... but Ian Coleman's BIP39 tool (written in Javascript) supports converting from BIP39 seed mnemonics into private/public keys and addresses for various address schemes (P2PKH, P2SH-P2WPKH, bech32 etc) using fully customisable derivation paths.

To get the "3"-type address that a Trezor seed would generate, you'd just select the "BIP49" tab in the middle of the page... and you should find the keys/addresses that match the ones generated by the Trezor. You may need to also change the "External/Internal" value from 0 to 1 to find "change" addresses.

You don't need to run this off his website either, as the full source is available for you to compile yourself and/or you can just download the standalone html page and run it offline.

Are you just wanting to recovery funds from a "lost" (or otherwise unavailable) device? or is this an ongoing need to want to be able to programmatically derive the private keys from the seed mnemonic? Either way, the website as it is should be able to help you recover funds... and the underlying javascript source code might help to understand the methods used to go from "seed mnemonic" -> "seed" -> "child key".

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!