Crypto.py 文件源码

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

项目:neo-python 作者: CityOfZion 项目源码 文件源码
def VerifySignature(message, signature, public_key):

        Crypto.SetupSignatureCurve()

        if type(public_key) is EllipticCurve.ECPoint:

            pubkey_x = public_key.x.value.to_bytes(32, 'big')
            pubkey_y = public_key.y.value.to_bytes(32, 'big')

            public_key = pubkey_x + pubkey_y

        m = message
        try:
            m = binascii.unhexlify(message)
        except Exception as e:
            logger.error("could not get m: %s" % e)

        if len(public_key) == 33:

            public_key = bitcoin.decompress(public_key)
            public_key = public_key[1:]

        try:
            vk = VerifyingKey.from_string(public_key, curve=NIST256p, hashfunc=hashlib.sha256)
            res = vk.verify(signature, m, hashfunc=hashlib.sha256)
            return res
        except Exception as e:
            pass

        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号