1

Given the XPub and an address, can I write an algorithm to say whether or not that public key was derived from that XPub and consequently belongs to the same user?

  • You'll need to clarify your question, what do you mean by "all of the addresses on the blockchain"? An xpub can generate child pub keys: an example use case would be a business's server providing payment addresses to customers, without requiring any private keys to be stored on that server. – chytrik Jan 16 '18 at 3:21
  • @chytrik Hey made some clarifications, thanks for the comment – Kyle Graham Jan 16 '18 at 13:26
1

Given the XPub and an address, can I write an algorithm to say whether or not that public key was derived from that XPub and consequently belongs to the same user?

[Edit: my terminology was off, answer edited substantially to be correct]

Given the xpub and an address, you would indeed be able to discern whether the two are related.

BIP32 is the specification that describes hierarchical deterministic (HD) wallets. To extend a parent public key, it is combined with the chain code and the index, then hashed through HMAC-SHA512. The hash output is split in two, and the 'left half of the hash' is added to the parent public key, to produce the child public key.

So by knowing the xpub (parent public key + chaincode), you can write an algorithm to determine if the two addresses have a parent/child relationship, and you would be able to find additional child addresses.

Without the xpub, remember that BIP32 derived keys are otherwise indistinguishable from any other keys. So you can not just look at an arbitrary address and know with certainty how it was derived.

  • The xpub includes the chaincode. – Pieter Wuille Apr 3 '18 at 2:07
  • @PieterWuille my mistake, I've edited my answer to be more correct – chytrik Apr 3 '18 at 2:22

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.