Bitcoin Forum
October 19, 2019, 02:02:23 PM *
News: Latest Bitcoin Core release: 0.18.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Import Android wallet to Trezor [SOLVED]  (Read 90 times)
d4n13
Full Member
***
Offline Offline

Activity: 210
Merit: 101


“Create Your Decentralized Life”


View Profile
December 23, 2017, 04:11:55 AM
Last edit: December 27, 2017, 10:16:10 PM by d4n13
 #1

Anyone try this.... thought it might be fun.

So I saw in decrypt threads that someone was able to extract the BIP32 key and derivation path.  Since both of these can be loaded into a Trezor, has anyone tried this to see if they get the proper key data?  I plan to... but not till next year.  Too much to do right now.  Maybe we can get a thread started to try to figure out the gotchas before I dig to deep.

Thx

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

Posts: 1571493743

View Profile Personal Message (Offline)

Ignore
1571493743
Reply with quote  #2

1571493743
Report to moderator
1571493743
Hero Member
*
Offline Offline

Posts: 1571493743

View Profile Personal Message (Offline)

Ignore
1571493743
Reply with quote  #2

1571493743
Report to moderator
1571493743
Hero Member
*
Offline Offline

Posts: 1571493743

View Profile Personal Message (Offline)

Ignore
1571493743
Reply with quote  #2

1571493743
Report to moderator
HCP
Legendary
*
Offline Offline

Activity: 1120
Merit: 1838

<insert witty quote here>


View Profile
December 23, 2017, 12:44:31 PM
 #2

I was under the impression that you cannot use a "custom derivation path" in a Trezor... for BTC it will always use m/44'/0'/0' as it is a BIP44 compatible hardware wallet.

Your seed will still likely work, as it is still a BIP39 seed...  but without the ability to specify the "non-BIP44" derivation path that Android Bitcoin Wallet uses, you will NOT be able to seed the same addresses as generated by the Android app.

d4n13
Full Member
***
Offline Offline

Activity: 210
Merit: 101


“Create Your Decentralized Life”


View Profile
December 23, 2017, 04:13:31 PM
 #3

trezorctl allows any derivation

HCP
Legendary
*
Offline Offline

Activity: 1120
Merit: 1838

<insert witty quote here>


View Profile
December 27, 2017, 12:07:32 AM
Merited by EcuaMobi (1)
 #4

Unfortunately, I don't think it will work. Undecided

The "load_device" command will allow you to load the mnemonic or xprv...
Code:
Usage: trezorctl load_device [OPTIONS]

  Load custom configuration to the device.

Options:
  -m, --mnemonic TEXT
  -e, --expand
  -x, --xprv TEXT
  -p, --pin TEXT
  -r, --passphrase-protection
  -l, --label TEXT
  -i, --ignore-checksum
  -s, --slip0014
  --help                       Show this message and exit.

but there is no command that you can issue that will cough up private keys etc... The best I can see is get_address, command which will return an address for a specified coin type and derivation path, but I don't see a way to get the private key data... Sad
Code:
Usage: trezorctl get_address [OPTIONS]

  Get address for specified path.

Options:
  -c, --coin TEXT
  -n, --address TEXT              BIP-32 path, e.g. m/44'/0'/0'/0/0
                                  [required]
  -t, --script-type [address|segwit|p2shsegwit]
  -d, --show-display
  --help                          Show this message and exit.

Only the "pubkey" using get_public_node:
Code:
Usage: trezorctl get_public_node [OPTIONS]

  Get public node of given path.

Options:
  -c, --coin TEXT
  -n, --address TEXT  BIP-32 path, e.g. m/44'/0'/0'  [required]
  -e, --curve TEXT
  -d, --show-display
  --help              Show this message and exit.

which returns the following:
Code:
node.public_key: 03edc955f8d1d49d6fdc11c183063f58320c969c7b5d7e6f5705523b9ef19bbd24
node.depth: 2
node.chain_code: 7551a39e04e7fa60643409a92f5135240673c0a2ddf4970bd14ee22f6a953945
node.child_num: 0
node.fingerprint: df26a6b1
xpub: xpub6BQmKf6WWF63QP6zTEZF4cmbdfS7ziZWh3NECMeV69cFhD2u3aMZPb9ptVy8g1zx9WYwRMNzkxDs7s2vHiXyaGtagcy26XSXyk5vXC2838q

d4n13
Full Member
***
Offline Offline

Activity: 210
Merit: 101


“Create Your Decentralized Life”


View Profile
December 27, 2017, 10:04:41 PM
Last edit: December 27, 2017, 10:14:52 PM by d4n13
 #5

Yep... totally works...  Here's the howto.

Required tools:
  • The wallet backup file
  • A trezor your willing to wipe
  • A laptop with Python

Walk through

Code:
pip install git+git://github.com/trezor/python-trezor.git@888b6f9
pip install protobuf pylibscrypt
git clone https://github.com/gurnec/decrypt_bitcoinj_seed.git
cd decrypt_bitcoinj_seed
git checkout a9e6ae3
git checkout -b commit_a9e6ae3
pythonw decrypt_bitcoinj_seed.pyw
<answer questions>
<copy mnemonic>
trezorctl wipe_device
trezorctl load_device -m "<aquired mnemonic from decrypt_bitcoinj_seed.pyw>"
trezorctl get_address -n "m/0'/0/0"

Few things to note
  • The last step above should match the first receiving address you android wallet generated.
  • Decrypting a wallet exposes the keys to memory and a host of other attack vectors.  Know the risks, or try this on an empty wallet.
  • Wiping a trezor will force you to recover it through recovery.  If you forgot your trezor mnemonic, things will end poorly.
  • Trezor SW uses a different derivation path than this android wallet.  You will need to use trezor python tools or API libraries to do anything useful.
  • The above checks out the specific revisions on these repos as of Dec 24th (approx).  If you want new code, be aware.


HCP
Legendary
*
Offline Offline

Activity: 1120
Merit: 1838

<insert witty quote here>


View Profile
December 28, 2017, 08:45:40 AM
 #6

Oh... right, so you weren't actually after the key data... you just wanted to load a BIP39 seed with a custom derivation path and then use that in conjuction with your Trezor on an ongoing basis...

sorry, got confused when you said:
... Since both of these can be loaded into a Trezor, has anyone tried this to see if they get the proper key data?

Given that the "sign_transaction" command will also accept the m/0'/0 address argument, there should be no issues making your Trezor work like this... except of course the fact that you need to use trezorctl to do anything with it Tongue

Still, nice to know that it can be done... that's another plus for Trezor!

d4n13
Full Member
***
Offline Offline

Activity: 210
Merit: 101


“Create Your Decentralized Life”


View Profile
December 28, 2017, 08:55:43 PM
 #7

Oh... right, so you weren't actually after the key data...

Sure I was.  I wanted the Trezor to obtain the proper key data.  Never thought the Trezor would give that data to me.

Reason I went on the BIP39 route instead of the BIP32 route was the availability of decrypt_bitcoinj_seed.  I have a hate in my heart for Java, and there is a special spot in heaven for those that labor through it.  A python / nodejs solution was much more to my liking.

If you wanted to do the BIP32 route, I believe that the BIP32 xpriv is extractable from the protobuf as well.  I generated some random BIP32 nodes and verified that Trezor accepted them just fine.

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!