import unicodedata
import hashlib


def bip39toseed(sentence, passphrase=None):
    """Compute the deterministic key (seed) associated with a sentence of BIP-0039 mnemonics"""
    sentence = unicodedata.normalize('NFKD', sentence)
    salt = b'mnemonic'
    if passphrase:
        passphrase = unicodedata.normalize('NFKD', passphrase)
        salt += passphrase.encode('utf-8')
    return hashlib.pbkdf2_hmac('sha512', sentence.encode('utf-8'), salt, 2048, 64)