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


Python ellipticcurve.Point方法代码示例

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


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

示例1: __uncompress_public_key

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def __uncompress_public_key(public_key: bytes) -> bytes:
        """
        Uncompress the compressed public key.
        :param public_key: compressed public key
        :return: uncompressed public key
        """
        is_even = public_key.startswith(b'\x02')
        x = string_to_number(public_key[1:])

        curve = NIST256p.curve
        order = NIST256p.order
        p = curve.p()
        alpha = (pow(x, 3, p) + (curve.a() * x) + curve.b()) % p
        beta = square_root_mod_prime(alpha, p)
        if is_even == bool(beta & 1):
            y = p - beta
        else:
            y = beta
        point = Point(curve, x, y, order)
        return b''.join([number_to_string(point.x(), order), number_to_string(point.y(), order)]) 
开发者ID:ontio,项目名称:ontology-python-sdk,代码行数:22,代码来源:ecies.py

示例2: from_signature

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def from_signature(klass, sig, recid, h, curve):
        """ See http://www.secg.org/download/aid-780/sec1-v2.pdf, chapter 4.1.6 """
        from ecdsa import util, numbertheory
        import msqr
        curveFp = curve.curve
        G = curve.generator
        order = G.order()
        # extract r,s from signature
        r, s = util.sigdecode_string(sig, order)
        # 1.1
        x = r + (recid/2) * order
        # 1.3
        alpha = ( x * x * x  + curveFp.a() * x + curveFp.b() ) % curveFp.p()
        beta = msqr.modular_sqrt(alpha, curveFp.p())
        y = beta if (beta - recid) % 2 == 0 else curveFp.p() - beta
        # 1.4 the constructor checks that nR is at infinity
        R = Point(curveFp, x, y, order)
        # 1.5 compute e from message:
        e = string_to_number(h)
        minus_e = -e % order
        # 1.6 compute Q = r^-1 (sR - eG)
        inv_r = numbertheory.inverse_mod(r,order)
        Q = inv_r * ( s * R + minus_e * G )
        return klass.from_public_point( Q, curve ) 
开发者ID:mazaclub,项目名称:encompass,代码行数:26,代码来源:bitcoin.py

示例3: from_signature

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def from_signature(cls, sig, recid, h, curve):
        """ See http://www.secg.org/download/aid-780/sec1-v2.pdf, chapter 4.1.6 """
        curveFp = curve.curve
        G = curve.generator
        order = G.order()
        # extract r,s from signature
        r, s = util.sigdecode_string(sig, order)
        # 1.1
        x = r + (recid / 2) * order
        # 1.3
        alpha = (x * x * x + curveFp.a() * x + curveFp.b()) % curveFp.p()
        beta = msqr.modular_sqrt(alpha, curveFp.p())
        y = beta if (beta - recid) % 2 == 0 else curveFp.p() - beta
        # 1.4 the constructor checks that nR is at infinity
        R = Point(curveFp, x, y, order)
        # 1.5 compute e from message:
        e = string_to_number(h)
        minus_e = -e % order
        # 1.6 compute Q = r^-1 (sR - eG)
        inv_r = numbertheory.inverse_mod(r, order)
        Q = inv_r * (s * R + minus_e * G)
        return cls.from_public_point(Q, curve) 
开发者ID:UlordChain,项目名称:Uwallet,代码行数:24,代码来源:ulord.py

示例4: __init__

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def __init__(self, keyParRef, pkCASD, **kw):
        """ Constructor
keyParRef - Key Parameter Reference
pkCASD    - PK.CASD.ECKA (tuple long x, long y)
optional **kw: IIN, CIN (as strings)"""
        assert keyParRef in ECC_Curves, \
            "Unknown Key param reference 0x%02X" % keyParRef
        self.keyParRef = keyParRef
        self.generator = ECC_Curves[keyParRef]
        self.curve = self.generator.curve()
        self.bytelen = len(int2s(self.curve.p()))
        assert self.bytelen in (32, 48, 64, 66)  # currently allowed keys
        pkCASDxy = s2ECP(pkCASD)
        assert self.curve.contains_point(*pkCASDxy),\
            "PK.CASD.ECKA not on the curve"
        self.pkCASD = ellipticcurve.Point(self.curve, *pkCASDxy)
        for k in ('IIN', 'CIN'):
            if k in kw:
                assert isinstance(kw[k], str)
                self.__dict__[k] = kw[k] 
开发者ID:suma12,项目名称:asterix,代码行数:22,代码来源:APDU.py

示例5: generate_decrypt_aes_key

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def generate_decrypt_aes_key(private_key: bytes, encode_g_tilde: bytes):
        if not isinstance(private_key, bytes):
            raise SDKException(ErrorCode.other_error('the length of private key should be 32 bytes.'))
        if len(private_key) != 32:
            raise SDKException(ErrorCode.other_error('the length of private key should be 32 bytes.'))
        str_g_tilde_x = encode_g_tilde[1:33]
        str_g_tilde_y = encode_g_tilde[33:65]
        g_tilde_x = string_to_number(str_g_tilde_x)
        g_tilde_y = string_to_number(str_g_tilde_y)
        g_tilde = Point(NIST256p.curve, g_tilde_x, g_tilde_y, NIST256p.order)
        h_tilde = g_tilde * SigningKey.from_string(string=private_key, curve=NIST256p).privkey.secret_multiplier
        seed = b''.join([encode_g_tilde, number_to_string(h_tilde.x(), NIST256p.order)])
        aes_key = pbkdf2(seed, 32)
        return aes_key 
开发者ID:ontio,项目名称:ontology-python-sdk,代码行数:16,代码来源:ecies.py

示例6: create_point

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def create_point(self, x, y):
        """Create an ECDSA point on the SECP256k1 curve with the given coords.

        :param x: The x coordinate on the curve
        :type x: long
        :param y: The y coodinate on the curve
        :type y: long
        """
        if (not isinstance(x, six.integer_types) or
                not isinstance(y, six.integer_types)):
            raise ValueError("The coordinates must be longs.")
        return _ECDSA_Point(SECP256k1.curve, x, y) 
开发者ID:BlockIo,项目名称:multimerchant-python,代码行数:14,代码来源:keys.py

示例7: from_public_pair

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def from_public_pair(cls, pair, network=BitcoinMainNet, **kwargs):
        point = _ECDSA_Point(SECP256k1.curve, pair.x, pair.y)
        return cls.from_point(point, network=network, **kwargs) 
开发者ID:BlockIo,项目名称:multimerchant-python,代码行数:5,代码来源:keys.py

示例8: negative_point

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def negative_point(P):
    return Point( P.curve(), P.x(), -P.y(), P.order() ) 
开发者ID:mazaclub,项目名称:encompass,代码行数:4,代码来源:bitcoin.py

示例9: ser_to_point

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def ser_to_point(Aser):
    curve = curve_secp256k1
    generator = generator_secp256k1
    _r  = generator.order()
    assert Aser[0] in ['\x02','\x03','\x04']
    if Aser[0] == '\x04':
        return Point( curve, string_to_number(Aser[1:33]), string_to_number(Aser[33:]), _r )
    Mx = string_to_number(Aser[1:])
    return Point( curve, Mx, ECC_YfromX(Mx, curve, Aser[0]=='\x03')[0], _r ) 
开发者ID:mazaclub,项目名称:encompass,代码行数:11,代码来源:bitcoin.py

示例10: negative_point

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def negative_point(P):
    return Point(P.curve(), P.x(), -P.y(), P.order()) 
开发者ID:UlordChain,项目名称:Uwallet,代码行数:4,代码来源:ulord.py

示例11: ser_to_point

# 需要导入模块: from ecdsa import ellipticcurve [as 别名]
# 或者: from ecdsa.ellipticcurve import Point [as 别名]
def ser_to_point(Aser):
    curve = curve_secp256k1
    generator = generator_secp256k1
    _r = generator.order()
    assert Aser[0] in ['\x02', '\x03', '\x04']
    if Aser[0] == '\x04':
        return Point(curve, string_to_number(Aser[1:33]), string_to_number(Aser[33:]), _r)
    Mx = string_to_number(Aser[1:])
    return Point(curve, Mx, ECC_YfromX(Mx, curve, Aser[0] == '\x03')[0], _r) 
开发者ID:UlordChain,项目名称:Uwallet,代码行数:11,代码来源:ulord.py


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