KeyPair.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:neo-python 作者: CityOfZion 项目源码 文件源码
def PrivateKeyFromWIF(wif):
        """
        Get the private key from a WIF key

        Args:
            wif (str): The wif key

        Returns:
            bytes: The private key
        """
        if wif is None or len(wif) is not 52:
            raise ValueError('Please provide a wif with a length of 52 bytes (LEN: {0:d})'.format(len(wif)))

        data = base58.b58decode(wif)

        length = len(data)

        if length is not 38 or data[0] is not 0x80 or data[33] is not 0x01:
            raise ValueError("Invalid format!")

        checksum = Crypto.Hash256(data[0:34])[0:4]

        if checksum != data[34:]:
            raise ValueError("Invalid WIF Checksum!")

        return data[1:33]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号