I need help with an bitcoin open book exam 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 &quot;What is the address with the path m/0/2 for the following wallet: zpub6nQF4m3JT6hTkQ4o9Vc8LDMQx7nMkT5CsnPgVHnnrpF9JHeP6ioboEK2CXB34Xn6nzqcJnLPuMqQaKqBhwvZR7GJNvSeRUpDpCaVu3N3stz&quot;? 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?
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 = &quot;zpub6nQF4m3JT6hTkQ4o9Vc8LDMQx7nMkT5CsnPgVHnnrpF9JHeP6ioboEK2CXB34Xn6nzqcJnLPuMqQaKqBhwvZR7GJNvSeRUpDpCaVu3N3stz&quot;
Bitcoinex.ExtendedKey.parse_extended_key(zpub) 
|&gt; Bitcoinex.ExtendedKey.derive_public_child(0) 
|&gt; Bitcoinex.ExtendedKey.derive_public_child(2)