当前位置: 首页>>代码示例>>Python>>正文


Python VerifyingKey.from_public_point方法代码示例

本文整理汇总了Python中ecdsa.VerifyingKey.from_public_point方法的典型用法代码示例。如果您正苦于以下问题:Python VerifyingKey.from_public_point方法的具体用法?Python VerifyingKey.from_public_point怎么用?Python VerifyingKey.from_public_point使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ecdsa.VerifyingKey的用法示例。


在下文中一共展示了VerifyingKey.from_public_point方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_material

# 需要导入模块: from ecdsa import VerifyingKey [as 别名]
# 或者: from ecdsa.VerifyingKey import from_public_point [as 别名]
 def create_material(self, bits, d=None, x=None, y=None):
     curve = self.curve_for_bits(bits)
     if d:
         return SigningKey.from_secret_exponent(d, curve)
     if x and y:
         point = ec.Point(curve.curve, x, y, curve.order)
         return VerifyingKey.from_public_point(point, curve)
开发者ID:hdknr,项目名称:jose,代码行数:9,代码来源:ec.py

示例2: from_point

# 需要导入模块: from ecdsa import VerifyingKey [as 别名]
# 或者: from ecdsa.VerifyingKey import from_public_point [as 别名]
    def from_point(cls, point, network=BitcoinMainNet, **kwargs):
        """Create a PublicKey from a point on the SECP256k1 curve.

        :param point: A point on the SECP256k1 curve.
        :type point: SECP256k1.point
        """
        verifying_key = VerifyingKey.from_public_point(point, curve=SECP256k1)
        return cls.from_verifying_key(verifying_key, network=network, **kwargs)
开发者ID:microfins,项目名称:bitmerchant,代码行数:10,代码来源:keys.py

示例3: from_sec

# 需要导入模块: from ecdsa import VerifyingKey [as 别名]
# 或者: from ecdsa.VerifyingKey import from_public_point [as 别名]
def from_sec(string, curve=curves.SECP256k1, hashfunc=sha1, validate_point=True):
    """Convert a public key in SEC binary format to a verifying key."""
    # based on code from https://github.com/richardkiss/pycoin
    if string.startswith(b("\x04")):
        # uncompressed
        return VerifyingKey.from_string(string[1:], curve, hashfunc, validate_point)
    elif string.startswith(b("\x02")) or string.startswith(b("\x03")):
        # compressed
        is_even = string.startswith(b("\x02"))
        x = string_to_number(string[1:])
        order = curve.order
        p = curve.curve.p()
        alpha = (pow(x, 3, p) + (curve.curve.a() * x) + curve.curve.b()) % p
        beta = square_root_mod_prime(alpha, p)
        if is_even == bool(beta & 1):
            y = p - beta
        else:
            y = beta
        if validate_point:
            assert ecdsa.point_is_valid(curve.generator, x, y)
        point = ellipticcurve.Point(curve.curve, x, y, order)
        return VerifyingKey.from_public_point(point, curve, hashfunc)
开发者ID:netkicorp,项目名称:addressimo,代码行数:24,代码来源:sec_util.py

示例4: get_ecdsa_verifying_key

# 需要导入模块: from ecdsa import VerifyingKey [as 别名]
# 或者: from ecdsa.VerifyingKey import from_public_point [as 别名]
 def get_ecdsa_verifying_key(pub):
     #some shenanigans required to validate a transaction sig; see
     #python.ecdsa PR #54. This will be a lot simpler when that's merged.
     #https://github.com/warner/python-ecdsa/pull/54/files
     if not pub[0] in ["\x02", "\x03"]:
         log.debug("Invalid pubkey")
         return None    
     is_even = pub.startswith('\x02')
     x = string_to_number(pub[1:])
     order = SECP256k1.order
     p = SECP256k1.curve.p()
     alpha = (pow(x, 3, p) + (SECP256k1.curve.a() * x) + SECP256k1.curve.b()) % p
     beta = square_root_mod_prime(alpha, p)
     if is_even == bool(beta & 1):
         y = p - beta
     else:
         y = beta
     if not point_is_valid(SECP256k1.generator, x, y):
         return None
     
     point = Point(SECP256k1.curve, x, y, order)
     return VerifyingKey.from_public_point(point, SECP256k1,
                                                hashfunc=hashlib.sha256)
开发者ID:AdamISZ,项目名称:joinmarket_core,代码行数:25,代码来源:btc.py

示例5: from_pair

# 需要导入模块: from ecdsa import VerifyingKey [as 别名]
# 或者: from ecdsa.VerifyingKey import from_public_point [as 别名]
 def from_pair(cls, pair):
     x, y = pair
     point = Point(curve=SECP256k1.curve, x=x, y=y, order=SECP256k1.order)
     key = VerifyingKey.from_public_point(point, curve=SECP256k1)
     return cls(key)
开发者ID:GemHQ,项目名称:coinop-py,代码行数:7,代码来源:keys.py


注:本文中的ecdsa.VerifyingKey.from_public_point方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。