0

The question is basically in the title. Can I (or it is possible to) extract the chain code from a ledger nano s device? It doesn't have to be the Master Chain Code. Any of them will do.

1

Yes. You can get the public key, chaincode, and address for any derivation path.

If you use the btchip-python library, you can use the getWalletPublicKey() method to retrieve a dictionary containing all three of those things.

0

Extracting BIP 32/39/44 chain code is agnostic as to whether a Ledger device or Trezor device is used. Remember the chain code is based upon open standards, specifally see https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format.

Here is how chain code can be found for the Bitcoin path m/44'/0'/0'/0 for the example at https://github.com/libbitcoin/libbitcoin-system/wiki/Altcoin-Version-Mappings#7-bitcoin-btc-bip-3944-technology-examples:

This is the level the chain code was determined for below:

% echo "radar blur cabbage chef fix engine embark joy scheme fiction master release" | bx mnemonic-to-seed | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 0 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx base58-decode | cut -c 9-10

04

This is the index the chain code was determined for below:

% echo "radar blur cabbage chef fix engine embark joy scheme fiction master release" | bx mnemonic-to-seed | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 0 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx base58-decode | cut -c 19-26

00000000

This is the chain code for the particular level and index:

% echo "radar blur cabbage chef fix engine embark joy scheme fiction master release" | bx mnemonic-to-seed | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 0 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx base58-decode | cut -c 27-90

6fbe96de86322b27a540572e2777562f55fb9810327917f9dd1163592952272a

This is the associated secp256k1 private key:

% echo "radar blur cabbage chef fix engine embark joy scheme fiction master release" | bx mnemonic-to-seed | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 0 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx base58-decode | cut -c 93-156

c227b3ba34eecfee2830b06bef3b35d5a88d4f6a9c5f34bd3d4e465e6c3ead1f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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