8
  1. what is difference between Master Public Key (MPK) and Public Key?
  2. what is difference between Master Private Key and Private Key?
  3. should I use master public key (MPK) when generating address or public key?

1 Answer 1

12

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).

It contains:

  • The depth in the hierarchy (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:

  1. Take the extended master private key (m/)
  2. Derive an account extended private key (m/0')
  3. Take this account extended private key (m/0') and derive the first extended private key on the next level (m/0'/0).
  4. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.