當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。