How to get the Extended Public Key Hello I have the following code that generates a Public Key, Private Key and BTC Address.

import hashlib
import ecdsa
from base58 import b58encode_check, b58decode_check
import os


def pubkey_to_address(pubkey: bytes) -&gt; str:
    if 'ripemd160' not in hashlib.algorithms_available:
        raise RuntimeError('missing ripemd160 hash algorithm')

    sha = hashlib.sha256(pubkey).digest()
    ripe = hashlib.new('ripemd160', sha).digest()
    return b58encode_check(b'\x00' + ripe)


def generate_new_keys() -&gt; list:
    signing_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1)
    verifying_key = signing_key.get_verifying_key()
    my_address = pubkey_to_address(verifying_key.to_string())

    return signing_key.to_string(), verifying_key, my_address


So when I use this function (generate_new_keys) I will get all the important keys.

Now I'd like to get my Extended Public Key to generate more subaddresses. Any idea where to start? 

I've tried this library but It seems unsafe for BTC: https://github.com/ranaroussi/pywallet
You can try this (disclaimer: I wrote it) and do the following:

from btctools import Xprv

&gt;&gt;&gt; xprv = Xprv.from_mnemonic('impulse prize erode winner pupil fun off addict ...')
&gt;&gt;&gt; xpub = xprv.to_xpub()
&gt;&gt;&gt; xpub.encode()    
'xpub661MyMwAqRbcFJwcugErEvzSgeKwGgHeLyzWKKK4C3edVRDbCU8o2pueJ5S26cXgPQQVRxQXyuoKrScnNKzohc4YNefs4zXg8tAhSLfnFo7'

&gt;&gt;&gt; xpub/0/0/1 
Xpub(path=M/0/0/1, key=039ec9190c3469b70f55a50466c7514b881ebe83b6215e94ed727854e1724ca811)

&gt;&gt;&gt; xpub.address('P2PKH') 
'1Fh2JwDc87R2BSXmcRYQPgRR5ntn5LuabK'