2323sample_privencryptionkey = \
2424 b'4b0b73a54e19b059dc274ab69df095fe699f43b17397bca26fdf40f4d7400a3a'
2525
26+ # [chan] bitmessage
27+ sample_wif_privsigningkey = \
28+ b'a2e8b841a531c1c558ee0680c396789c7a2ea3ac4795ae3f000caf9fe367d144'
29+ sample_wif_privencryptionkey = \
30+ b'114ec0e2dca24a826a0eed064b0405b0ac148abc3b1d52729697f4d7b873fdc6'
31+
2632sample_factor = \
2733 66858749573256452658262553961707680376751171096153613379801854825275240965733
2834# G * sample_factor
@@ -40,6 +46,38 @@ def test_base10_multiply(self):
4046 sample_point ,
4147 arithmetic .base10_multiply (arithmetic .G , sample_factor ))
4248
49+ def test_base58 (self ):
50+ """Test encoding/decoding base58 using arithmetic functions"""
51+ self .assertEqual (
52+ arithmetic .decode (arithmetic .changebase (
53+ b'2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK' , 58 , 256 ), 256 ),
54+ 25152821841976547050350277460563089811513157529113201589004 )
55+ self .assertEqual (
56+ arithmetic .decode (arithmetic .changebase (
57+ b'2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN' , 58 , 256 ), 256 ),
58+ 18875720106589866286514488037355423395410802084648916523381 )
59+ self .assertEqual (
60+ arithmetic .changebase (arithmetic .encode (
61+ 25152821841976547050350277460563089811513157529113201589004 ,
62+ 256 ), 256 , 58 ), b'2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK' )
63+ self .assertEqual (
64+ arithmetic .changebase (arithmetic .encode (
65+ 18875720106589866286514488037355423395410802084648916523381 ,
66+ 256 ), 256 , 58 ), b'2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN' )
67+
68+ def test_wif (self ):
69+ """Decode WIFs of [chan] bitmessage and check the keys"""
70+ self .assertEqual (
71+ sample_wif_privsigningkey ,
72+ arithmetic .changebase (arithmetic .changebase (
73+ b'5K42shDERM5g7Kbi3JT5vsAWpXMqRhWZpX835M2pdSoqQQpJMYm' , 58 , 256
74+ )[1 :- 4 ], 256 , 16 ))
75+ self .assertEqual (
76+ sample_wif_privencryptionkey ,
77+ arithmetic .changebase (arithmetic .changebase (
78+ b'5HwugVWm31gnxtoYcvcK7oywH2ezYTh6Y4tzRxsndAeMi6NHqpA' , 58 , 256
79+ )[1 :- 4 ], 256 , 16 ))
80+
4381 def test_decode (self ):
4482 """Decode sample privsigningkey from hex to int and compare to factor"""
4583 self .assertEqual (
0 commit comments