- what is difference between Master Public Key (MPK) and Public Key?
- what is difference between Master Private Key and Private Key?
- should I use master public key (MPK) when generating address or public key?
With "Master public key" you probably refer to deterministic key derivation after bip32.
The correct term is "Master extended private key" (acronym xpriv) and "Master extended public key" (acronym xpub).
The acronyms are "xpriv" and "xpub" because the base58 check prefix results in those 4 characters for a mainnet extended pub/priv key.
The difference between a extended public key and a normal public key is that it also contains information about the bip32 chain (deterministic chain/hierarchy).
- The depth in the hirarchy (1byte 0x00 for master nodes, 0x01 for level-1 derived keys, ....)
- A fingerprint (4 bytes, possible identifier)
- The chaincode (32 bytes, = link used for the hierarchy)
- The child index ("number" of the key at the current hierarchy level)
- The private or public key (32bytes for private-, 33bytes for public-key)
A normal private- or public-key only contains the last element (32/33byte [public|private]key).
A (simplified) example how you would generate addresses:
- Take the extended master private key (
- Derive an account extended private key (
- Take this account extended private key (
m/0') and derive the first extended private key on the next level (
- Use the extended private key of (
m/0'/0) to generate the extended public key and take out the "normal public key" (33 bytes) and encode a P2PKH address (or P2WPKH, multisig, etc.) out of it.