Input mpub is master xpub key string.
        Input priv is xprv string.
        Path is the path string (e.g. 'm/3/6/2') from the mpub to the
        priv. Path cannot contain any hardened keys.

def crack(mpub,priv,pathtopriv):
        '''
        Input mpub is master xpub key string.
        Input priv is xprv string.
        Path is the path string (e.g. 'm/3/6/2') from the mpub to the
        priv. Path cannot contain any hardened keys.
        '''

        mpub = str(mpub)
        priv = b58d(priv)
        if int(priv[18:26],16) >= 2147483648:
            raise Exception("Private key input is hardened.  Cannot crack up a level from a hardened key.")
        pathtopriv = pathtopriv.lower()
        if 'h' in pathtopriv or "'" in pathtopriv:
            raise Exception("Path input indicates a hardened key. Cannot crack up a level from hardened keys.")
        for c in pathtopriv:
            if c not in "1234567890mh/":
                raise Exception("Path wrong format")
        assert pathtopriv[0] == 'm'
        if pathtopriv[-1] == "/":
            pathtopriv = pathtopriv[:-1]
        pathlist = pathtopriv.split("/")
        pathlist = pathlist[1:]
        assert int(pathlist[-1]) == int(priv[18:26],16)
        counter = len(pathlist)
        xpublist = [mpub]
        for i in range(counter-1):
            mpub = BIP32.ckd(mpub,int(pathlist[i]))
            xpublist.append(mpub)
        xpublist.reverse()
        for i in range(counter):
            newpub = b58d(xpublist[i])
            tmp = hexstrlify(hmac.new(unhexlify(newpub[-130:-66]), \
                              unhexlify(newpub[-66:] + priv[18:26]), \
                               hashlib.sha512).digest())
            tmppriv = subtractprivkeys(priv[-64:],tmp[:64])
            priv = priv[:8] + newpub[8:-66] + '00' + tmppriv
            pathlist = pathlist[:-1]
        return b58e(priv)