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


Python ECC.construct方法代码示例

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


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

示例1: create_ref_keys

# 需要导入模块: from Cryptodome.PublicKey import ECC [as 别名]
# 或者: from Cryptodome.PublicKey.ECC import construct [as 别名]
def create_ref_keys():
    key_lines = load_file("ecc_p256.txt").splitlines()
    private_key_d = bytes_to_long(compact(key_lines[2:5]))
    public_key_xy = compact(key_lines[6:11])
    assert bord(public_key_xy[0]) == 4  # Uncompressed
    public_key_x = bytes_to_long(public_key_xy[1:33])
    public_key_y = bytes_to_long(public_key_xy[33:])

    return (ECC.construct(curve="P-256", d=private_key_d),
            ECC.construct(curve="P-256", point_x=public_key_x, point_y=public_key_y))
开发者ID:FndNur1Labs,项目名称:PokemonGo-DesktopMap,代码行数:12,代码来源:test_import_ECC.py

示例2: test_equality

# 需要导入模块: from Cryptodome.PublicKey import ECC [as 别名]
# 或者: from Cryptodome.PublicKey.ECC import construct [as 别名]
    def test_equality(self):

        private_key = ECC.construct(d=3, curve="P-256")
        private_key2 = ECC.construct(d=3, curve="P-256")
        private_key3 = ECC.construct(d=4, curve="P-256")

        public_key = private_key.public_key()
        public_key2 = private_key2.public_key()
        public_key3 = private_key3.public_key()

        self.assertEqual(private_key, private_key2)
        self.assertNotEqual(private_key, private_key3)

        self.assertEqual(public_key, public_key2)
        self.assertNotEqual(public_key, public_key3)

        self.assertNotEqual(public_key, private_key)
开发者ID:FndNur1Labs,项目名称:PokemonGo-DesktopMap,代码行数:19,代码来源:test_ECC.py

示例3: test_construct

# 需要导入模块: from Cryptodome.PublicKey import ECC [as 别名]
# 或者: from Cryptodome.PublicKey.ECC import construct [as 别名]
    def test_construct(self):

        key = ECC.construct(curve="P-256", d=1)
        self.failUnless(key.has_private())
        self.assertEqual(key.pointQ, _curve.G)

        key = ECC.construct(curve="P-256", point_x=_curve.Gx, point_y=_curve.Gy)
        self.failIf(key.has_private())
        self.assertEqual(key.pointQ, _curve.G)

        # Other names
        ECC.construct(curve="secp256r1", d=1)
        ECC.construct(curve="prime256v1", d=1)
开发者ID:FndNur1Labs,项目名称:PokemonGo-DesktopMap,代码行数:15,代码来源:test_ECC.py

示例4: int

# 需要导入模块: from Cryptodome.PublicKey import ECC [as 别名]
# 或者: from Cryptodome.PublicKey.ECC import construct [as 别名]
                                 {'result': lambda x: x,
                                  'qx': lambda x: int(x, 16),
                                  'qy': lambda x: int(x, 16),
                                  })

for idx, tv in enumerate(test_vectors_verify):

    if isinstance(tv, basestring):
        res = re.match("\[P-256,(SHA-[0-9]+)\]", tv)
        assert res
        hash_name = res.group(1).replace("-", "")
        hash_module = load_hash_by_name(hash_name)
        continue

    hash_obj = hash_module.new(tv.msg)
    key = ECC.construct(curve="P-256", point_x=tv.qx, point_y=tv.qy)
    verifier = DSS.new(key, 'fips-186-3')

    def positive_test(self, verifier=verifier, hash_obj=hash_obj, signature=tv.r+tv.s):
        verifier.verify(hash_obj, signature)

    def negative_test(self, verifier=verifier, hash_obj=hash_obj, signature=tv.r+tv.s):
        self.assertRaises(ValueError, verifier.verify, hash_obj, signature)

    if tv.result.startswith('p'):
        setattr(FIPS_ECDSA_Tests, "test_verify_positive_%d" % idx, positive_test)
    else:
        setattr(FIPS_ECDSA_Tests, "test_verify_negative_%d" % idx, negative_test)


test_vectors_sign = load_tests(("Cryptodome", "SelfTest", "Signature", "test_vectors", "ECDSA"),
开发者ID:FndNur1Labs,项目名称:PokemonGo-DesktopMap,代码行数:33,代码来源:test_dss.py


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