예제 #1
0
        def T(keydata: str, compressed: str, uncompressed: str) -> None:
            k = CBitcoinKey.from_secret_bytes(x(keydata))
            k_u = CBitcoinKey.from_secret_bytes(x(keydata), False)

            self.assertTrue(k.is_compressed())
            self.assertEqual(k.pub, x(compressed))

            k2 = CBitcoinKey(str(k))
            self.assertTrue(k2.is_compressed())
            self.assertEqual(k, k2)

            k = k.to_uncompressed()
            self.assertEqual(k, k_u)
            self.assertEqual(len(k), 32)
            self.assertFalse(k.is_compressed())
            self.assertEqual(k.pub, x(uncompressed))

            k2 = CBitcoinKey(str(k))
            self.assertFalse(k2.is_compressed())
            self.assertEqual(k, k2)

            k = k.to_compressed()
            self.assertEqual(len(k), 33)
            self.assertEqual(k[-1], 1)
            self.assertTrue(k.is_compressed())
            self.assertEqual(k.pub, x(compressed))
예제 #2
0
 def T(base58_privkey: str, expected_hex_pubkey: str, expected_is_compressed_value: bool) -> None:
     key = CBitcoinKey(base58_privkey)
     self.assertEqual(b2x(key.pub), expected_hex_pubkey)
     self.assertEqual(key.is_compressed(), expected_is_compressed_value)