Пример #1
0
class BitcoinCompressedPublicKeyTest(unittest.TestCase):
    def setUp(self):
        self.reference = {
            'hex_public_key':
            '02068fd9d47283fb310e6dfb66b141dd78fbabc76d073d48cddc770ffb2bd262d7',
            'bin_public_key':
            '\x02\x06\x8f\xd9\xd4r\x83\xfb1\x0em\xfbf\xb1A\xddx\xfb\xab\xc7m\x07=H\xcd\xdcw\x0f\xfb+\xd2b\xd7',
            'hex_hash160': '25488b0d3bb770d6e0ef07e1f19d33ab59931dee',
            'bin_hash160':
            '%H\x8b\r;\xb7p\xd6\xe0\xef\x07\xe1\xf1\x9d3\xabY\x93\x1d\xee',
            'address': '14Q8uVAX29RUMvqPGXL5sg6NiwwMRFCm8C',
        }
        self.public_key = BitcoinPublicKey(self.reference['hex_public_key'])

    def tearDown(self):
        pass

    def test_address(self):
        self.assertEqual(self.public_key.address(), self.reference['address'])

    def test_bin_hash160(self):
        self.assertEqual(self.public_key.bin_hash160(),
                         self.reference['bin_hash160'])

    def test_hex_hash160(self):
        self.assertEqual(self.public_key.hash160(),
                         self.reference['hex_hash160'])

    def test_bin_public_key(self):
        self.assertEqual(self.public_key.to_bin(),
                         self.reference['bin_public_key'])

    def test_hex_public_key(self):
        self.assertEqual(self.public_key.to_hex(),
                         self.reference['hex_public_key'])
Пример #2
0
class BitcoinUncompressedPublicKeyTest(unittest.TestCase):
    reference = _reference_info

    def setUp(self):
        self.public_key = BitcoinPublicKey(self.reference['hex_public_key'])

    def tearDown(self):
        pass

    def test_address(self):
        self.assertEqual(self.public_key.address(), self.reference['address'])

    def test_hex_hash160(self):
        self.assertEqual(self.public_key.hash160(),
                         self.reference['hex_hash160'])

    def test_hex_public_key(self):
        self.assertEqual(self.public_key.to_hex(),
                         self.reference['hex_public_key'])

    def test_pem_public_key(self):
        self.assertEqual(self.public_key.to_pem(),
                         self.reference['pem_public_key'])

    def test_der_public_key(self):
        self.assertEqual(self.public_key.to_der(),
                         self.reference['der_public_key'])
Пример #3
0
 def setUp(self):
     self.reference = {
         'hex_public_key':
         '02068fd9d47283fb310e6dfb66b141dd78fbabc76d073d48cddc770ffb2bd262d7',
         'bin_public_key':
         '\x02\x06\x8f\xd9\xd4r\x83\xfb1\x0em\xfbf\xb1A\xddx\xfb\xab\xc7m\x07=H\xcd\xdcw\x0f\xfb+\xd2b\xd7',
         'hex_hash160': '25488b0d3bb770d6e0ef07e1f19d33ab59931dee',
         'bin_hash160':
         '%H\x8b\r;\xb7p\xd6\xe0\xef\x07\xe1\xf1\x9d3\xabY\x93\x1d\xee',
         'address': '14Q8uVAX29RUMvqPGXL5sg6NiwwMRFCm8C',
     }
     self.public_key = BitcoinPublicKey(self.reference['hex_public_key'])
Пример #4
0
 def setUp(self):
     self.public_key = BitcoinPublicKey(self.reference['hex_public_key'])
Пример #5
0
 def test_create_pubkey_from_bin_compressed_format(self):
     public_key_string = '\x02\x06\x8f\xd9\xd4r\x83\xfb1\x0em\xfbf\xb1A\xddx\xfb\xab\xc7m\x07=H\xcd\xdcw\x0f\xfb+\xd2b\xd7'
     self.assertEqual(self.address_compressed,
                      BitcoinPublicKey(public_key_string).address())
Пример #6
0
 def test_create_pubkey_from_hex_compressed_format(self):
     public_key_string = '02068fd9d47283fb310e6dfb66b141dd78fbabc76d073d48cddc770ffb2bd262d7'
     self.assertEqual(self.address_compressed,
                      BitcoinPublicKey(public_key_string).address())
Пример #7
0
 def test_create_pubkey_from_bin_ecdsa_format(self):
     public_key_string = '\x06\x8f\xd9\xd4r\x83\xfb1\x0em\xfbf\xb1A\xddx\xfb\xab\xc7m\x07=H\xcd\xdcw\x0f\xfb+\xd2b\xd7\xb2\x83/\x87\xf6\x83\x10\x0b\x89\xc2\xe9S\x14\xde\xee\xac\xbcd\t\xaf\x1e6\xc3\xae?\xd8\xc5\xf2\xf2C\xcf\xec'
     self.assertEqual(self.address_uncompressed,
                      BitcoinPublicKey(public_key_string).address())
Пример #8
0
 def test_create_pubkey_from_hex_ecdsa_format(self):
     public_key_string = '068fd9d47283fb310e6dfb66b141dd78fbabc76d073d48cddc770ffb2bd262d7b2832f87f683100b89c2e95314deeeacbc6409af1e36c3ae3fd8c5f2f243cfec'
     self.assertEqual(self.address_uncompressed,
                      BitcoinPublicKey(public_key_string).address())