question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Derive child BIP32 extended private/public key

See original GitHub issue

First, I don’t know whether this tool is able to derive child BIP32 extended private/public key?

Second, is BIP32 Root Key used as an input field? This seems to be weird/confusing to me, because the the extended key fed by the user may not be the “root” key. I saw that BIP32 serielization format contains a “depth” field.

Did I misunderstand something?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
robertclarksoncommented, Apr 22, 2020

Thank you for such a good detailed answer

0reactions
wigy-opensource-developercommented, Apr 22, 2020

BIP32 defines a 4-byte prefix called “version bytes” for encoding extended public and private keys. BIP32 only defines these for BTC mainnet and testnet which end up base58 encoded as xprv, xpub, tprv and tpub. Even when you change to a different coin, their version bytes could be different (say IOP extended public keys start with dyw). BIP84 simply redefined these version bytes so the end-user can see from the first characters what kind of scripts are needed to spend coins that belong to those private keys.

If you decode both the xprv and zprv root keys, you will find out that they only differ in the first 4 bytes (version) and the last 4 bytes (checksum). Starting from mnemonic “steak road wreck man core squeeze bubble angry coffee race manual path defense beach chuckle” you get these bytes:

$ node
Welcome to Node.js v12.16.0.
Type ".help" for more information.
> bs58 = require('bs58')
{
  encode: [Function: encode],
  decodeUnsafe: [Function: decodeUnsafe],
  decode: [Function: decode]
}
> bs58.decode('xprv9s21ZrQH143K37Ty7J6oMLUbXcgwhyzN993gfq5Cg6dxmQEUe8jE4yQAsC9ErtA6Q2tvGdzactm2QyEra11b5nhJkBroxNkXPTWTbU773eD')
<Buffer 04 88 ad e4 00 00 00 00 00 00 00 00 00 69 d3 2e 8f b0 75 df 64 82 49 47 36 13 40 c3 a6 70 3c 3f 2c 62 51 15 65 6a e6 64 a9 a3 33 df 34 00 3e 21 e9 4d ... 32 more bytes>
> bs58.decode('zprvAWgYBBk7JR8GjhrCn1g3mWfbsYyqbDyMyN68EcryS7Pisbrw9T4MK6iSuc4QrhTwDK8XmbBhYDU8BYTz1PqcgG4WUsFf8CPVvudkNey7sso')
<Buffer 04 b2 43 0c 00 00 00 00 00 00 00 00 00 69 d3 2e 8f b0 75 df 64 82 49 47 36 13 40 c3 a6 70 3c 3f 2c 62 51 15 65 6a e6 64 a9 a3 33 df 34 00 3e 21 e9 4d ... 32 more bytes>
Read more comments on GitHub >

github_iconTop Results From Across the Web

The math behind BIP-32 child key derivation - Medium
Each node of the tree can be represented with an “extended private key”, which can be used to generate all children, grandchildren, etc....
Read more >
How to derive public child keys from public parent keys with ...
This gives us two ways to derive a child public key: either from the child private key, or directly from the parent public...
Read more >
Extended Keys - Learn Me A Bitcoin
Both extended private keys and extended public keys can derive children, each with their own unique index number. There are 3 methods for...
Read more >
BIP 0032 - Bitcoin Wiki
4.1 Conventions; 4.2 Extended keys; 4.3 Child key derivation (CKD) functions. 4.3.1 Private parent key → private child key; 4.3.2 Public parent key...
Read more >
4. Keys, Addresses, Wallets - Mastering Bitcoin [Book] - O'Reilly
In bitcoin, we use public key cryptography to create a key pair that controls access to bitcoins. The key pair consists of a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found