Test WIF decoding and encoding in highlevelcrypto #2208
|
@ -73,3 +73,13 @@ sample_sig = unhexlify(
|
||||||
sample_sig_sha1 = unhexlify(
|
sample_sig_sha1 = unhexlify(
|
||||||
'30460221008ad234687d1bdc259932e28ea6ee091b88b0900d8134902aa8c2fd7f016b96e'
|
'30460221008ad234687d1bdc259932e28ea6ee091b88b0900d8134902aa8c2fd7f016b96e'
|
||||||
'd022100dafb94e28322c2fa88878f9dcbf0c2d33270466ab3bbffaec3dca0a2d1ef9354')
|
'd022100dafb94e28322c2fa88878f9dcbf0c2d33270466ab3bbffaec3dca0a2d1ef9354')
|
||||||
|
|
||||||
|
# [chan] bitmessage
|
||||||
|
sample_wif_privsigningkey = unhexlify(
|
||||||
|
b'a2e8b841a531c1c558ee0680c396789c7a2ea3ac4795ae3f000caf9fe367d144')
|
||||||
|
sample_wif_privencryptionkey = unhexlify(
|
||||||
|
b'114ec0e2dca24a826a0eed064b0405b0ac148abc3b1d52729697f4d7b873fdc6')
|
||||||
|
sample_privsigningkey_wif = \
|
||||||
|
b'5K42shDERM5g7Kbi3JT5vsAWpXMqRhWZpX835M2pdSoqQQpJMYm'
|
||||||
|
sample_privencryptionkey_wif = \
|
||||||
|
b'5HwugVWm31gnxtoYcvcK7oywH2ezYTh6Y4tzRxsndAeMi6NHqpA'
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
import unittest
|
import unittest
|
||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
|
|
||||||
from pybitmessage import addresses
|
from pybitmessage import addresses, highlevelcrypto
|
||||||
|
|
||||||
from .samples import (
|
from .samples import (
|
||||||
sample_address, sample_daddr3_512, sample_daddr4_512,
|
sample_address, sample_daddr3_512, sample_daddr4_512,
|
||||||
sample_deterministic_addr4, sample_deterministic_addr3,
|
sample_deterministic_addr4, sample_deterministic_addr3,
|
||||||
sample_deterministic_ripe, sample_ripe)
|
sample_deterministic_ripe, sample_ripe,
|
||||||
|
sample_privsigningkey_wif, sample_privencryptionkey_wif,
|
||||||
|
sample_wif_privsigningkey, sample_wif_privencryptionkey)
|
||||||
|
|
||||||
sample_addr3 = sample_deterministic_addr3.split('-')[1]
|
sample_addr3 = sample_deterministic_addr3.split('-')[1]
|
||||||
sample_addr4 = sample_deterministic_addr4.split('-')[1]
|
sample_addr4 = sample_deterministic_addr4.split('-')[1]
|
||||||
|
@ -59,3 +61,26 @@ class TestAddresses(unittest.TestCase):
|
||||||
sample_addr4, addresses.encodeBase58(sample_daddr4_512))
|
sample_addr4, addresses.encodeBase58(sample_daddr4_512))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
sample_addr3, addresses.encodeBase58(sample_daddr3_512))
|
sample_addr3, addresses.encodeBase58(sample_daddr3_512))
|
||||||
|
|
||||||
|
def test_wif(self):
|
||||||
|
"""Decode WIFs of [chan] bitmessage and check the keys"""
|
||||||
|
self.assertEqual(
|
||||||
|
sample_wif_privsigningkey,
|
||||||
|
highlevelcrypto.decodeWalletImportFormat(
|
||||||
|
sample_privsigningkey_wif))
|
||||||
|
self.assertEqual(
|
||||||
|
sample_wif_privencryptionkey,
|
||||||
|
highlevelcrypto.decodeWalletImportFormat(
|
||||||
|
sample_privencryptionkey_wif))
|
||||||
|
self.assertEqual(
|
||||||
|
sample_privsigningkey_wif,
|
||||||
|
highlevelcrypto.encodeWalletImportFormat(
|
||||||
|
sample_wif_privsigningkey))
|
||||||
|
self.assertEqual(
|
||||||
|
sample_privencryptionkey_wif,
|
||||||
|
highlevelcrypto.encodeWalletImportFormat(
|
||||||
|
sample_wif_privencryptionkey))
|
||||||
|
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
highlevelcrypto.decodeWalletImportFormat(
|
||||||
|
sample_privencryptionkey_wif[:-2])
|
||||||
|
|
Reference in New Issue
Block a user