示例#1
0
 def test_public_key_uncompressed(self):
     base_key = BaseKey(WALLET_FORMAT_MAIN)
     assert base_key.public_key == PUBLIC_KEY_UNCOMPRESSED
示例#2
0
 def test_init_from_key(self):
     pk = ECPrivateKey()
     base_key = BaseKey(pk)
     assert base_key._pk == pk
示例#3
0
 def test_init_wif_error(self):
     with pytest.raises(TypeError):
         BaseKey(b"\x00")
示例#4
0
 def test_equal(self):
     assert BaseKey(WALLET_FORMAT_COMPRESSED_MAIN) == BaseKey(
         WALLET_FORMAT_COMPRESSED_MAIN)
示例#5
0
    def test_init_default(self):
        base_key = BaseKey()

        assert isinstance(base_key._pk, ECPrivateKey)
        assert len(base_key.public_key) == 33
示例#6
0
 def test_to_int(self):
     base_key = BaseKey(WALLET_FORMAT_MAIN)
     assert base_key.to_int() == PRIVATE_KEY_NUM
示例#7
0
 def test_is_compressed(self):
     assert BaseKey(WALLET_FORMAT_COMPRESSED_MAIN).is_compressed() is True
     assert BaseKey(WALLET_FORMAT_MAIN).is_compressed() is False
示例#8
0
 def test_to_bytes(self):
     base_key = BaseKey(WALLET_FORMAT_MAIN)
     assert base_key.to_bytes() == PRIVATE_KEY_BYTES
示例#9
0
 def test_verify_failure(self):
     base_key = BaseKey()
     data = os.urandom(200)
     signature = base_key.sign(data)
     assert not base_key.verify(signature, data[::-1])
示例#10
0
 def test_verify_success(self):
     base_key = BaseKey()
     data = os.urandom(200)
     signature = base_key.sign(data)
     assert base_key.verify(signature, data)
示例#11
0
 def test_sign(self):
     base_key = BaseKey()
     data = os.urandom(200)
     signature = base_key.sign(data)
     assert verify_sig(signature, data, base_key.public_key)
示例#12
0
 def test_public_point(self):
     base_key = BaseKey(WALLET_FORMAT_MAIN)
     assert base_key.public_point == Point(PUBLIC_KEY_X, PUBLIC_KEY_Y)
     assert base_key.public_point == Point(PUBLIC_KEY_X, PUBLIC_KEY_Y)