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.– chytrikJan 16, 2018 at 3:21
-
@chytrik Hey made some clarifications, thanks for the comment– Kyle GrahamJan 16, 2018 at 13:26
1 Answer
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.
-
1
-