1

I am completely new to bitcoin and by extension cryptocurrency, but I am slowly getting my head around certain things. My problem is I am currently doing an open book exam and I am free to use any resources available to me. One of the questions asked was "What is the address with the path m/0/2 for the following wallet: zpub6nQF4m3JT6hTkQ4o9Vc8LDMQx7nMkT5CsnPgVHnnrpF9JHeP6ioboEK2CXB34Xn6nzqcJnLPuMqQaKqBhwvZR7GJNvSeRUpDpCaVu3N3stz"? Is there a way to find this out or is this a trick question since from the hours of research I have done so far I have found that zpub and xpub keys are used to generate actual public addresses. Can you please point me in the right direction?

1
  • 1
    According to BIP 84, maybe 2nd receiving address derived from this ZPUB is asked in the question – Prayank Jan 30 at 18:01
1

BIP 84 specifies how zpubs work. BIP 32 specifies how derivation paths work.

According to these BIPs, the zpub will be used as the master public key, and the CPK (Child Public Key) function should be applied to the zpub to yield the specific public key you desire.

BIP 84 specifies that zpubs are used to derive P2WPKH addresses, so the public key should be converted to a SegWit address (bc1...).

If you are familiar with Elixir, you can use this library, to which I've added bip32 support.

https://github.com/sachinmeier/bitcoinex/tree/sachin--add-bip32

zpub = "zpub6nQF4m3JT6hTkQ4o9Vc8LDMQx7nMkT5CsnPgVHnnrpF9JHeP6ioboEK2CXB34Xn6nzqcJnLPuMqQaKqBhwvZR7GJNvSeRUpDpCaVu3N3stz"
Bitcoinex.ExtendedKey.parse_extended_key(zpub) 
|> Bitcoinex.ExtendedKey.derive_public_child(0) 
|> Bitcoinex.ExtendedKey.derive_public_child(2)
1
  • This will yield the public key at m/0/2. From there you have to turn a public key into a P2WPKH address. Take the hash160 of the pubkey, and then add a zero to the beginning and encode it using Bech32. All of this is possible using the same library. – Sachin Meier Mar 2 at 22:17

Your Answer

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