Skip to content

Commit 17a09a6

Browse files
author
Lee Miller
committed
Moved samples into the samples module
1 parent 5a48ee0 commit 17a09a6

2 files changed

Lines changed: 54 additions & 39 deletions

File tree

src/pyelliptic/tests/samples.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,43 @@
22

33
from binascii import unhexlify
44

5+
6+
# These keys are from addresses test script
7+
sample_pubsigningkey = (
8+
b'044a367f049ec16cb6b6118eb734a9962d10b8db59c890cd08f210c43ff08bdf09d'
9+
b'16f502ca26cd0713f38988a1237f1fc8fa07b15653c996dc4013af6d15505ce')
10+
sample_pubencryptionkey = (
11+
b'044597d59177fc1d89555d38915f581b5ff2286b39d022ca0283d2bdd5c36be5d3c'
12+
b'e7b9b97792327851a562752e4b79475d1f51f5a71352482b241227f45ed36a9')
13+
sample_privsigningkey = \
14+
b'93d0b61371a54b53df143b954035d612f8efa8a3ed1cf842c2186bfd8f876665'
15+
sample_privencryptionkey = \
16+
b'4b0b73a54e19b059dc274ab69df095fe699f43b17397bca26fdf40f4d7400a3a'
17+
18+
# [chan] bitmessage
19+
sample_privsigningkey_wif = \
20+
b'5K42shDERM5g7Kbi3JT5vsAWpXMqRhWZpX835M2pdSoqQQpJMYm'
21+
sample_privencryptionkey_wif = \
22+
b'5HwugVWm31gnxtoYcvcK7oywH2ezYTh6Y4tzRxsndAeMi6NHqpA'
23+
sample_wif_privsigningkey = \
24+
b'a2e8b841a531c1c558ee0680c396789c7a2ea3ac4795ae3f000caf9fe367d144'
25+
sample_wif_privencryptionkey = \
26+
b'114ec0e2dca24a826a0eed064b0405b0ac148abc3b1d52729697f4d7b873fdc6'
27+
28+
sample_factor = \
29+
66858749573256452658262553961707680376751171096153613379801854825275240965733
30+
# G * sample_factor
31+
sample_point = (
32+
33567437183004486938355437500683826356288335339807546987348409590129959362313,
33+
94730058721143827257669456336351159718085716196507891067256111928318063085006
34+
)
35+
36+
sample_deterministic_addr3 = b'2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
37+
sample_deterministic_addr4 = b'2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'
38+
sample_daddr3_512 = 18875720106589866286514488037355423395410802084648916523381
39+
sample_daddr4_512 = 25152821841976547050350277460563089811513157529113201589004
40+
41+
542
# pubkey K
643
sample_pubkey = unhexlify(
744
'0409d4e5c0ab3d25fe'

src/pyelliptic/tests/test_arithmetic.py

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,13 @@
1010
except ImportError:
1111
from pybitmessage.pyelliptic import arithmetic
1212

13-
14-
# These keys are from addresses test script
15-
sample_pubsigningkey = (
16-
b'044a367f049ec16cb6b6118eb734a9962d10b8db59c890cd08f210c43ff08bdf09d'
17-
b'16f502ca26cd0713f38988a1237f1fc8fa07b15653c996dc4013af6d15505ce')
18-
sample_pubencryptionkey = (
19-
b'044597d59177fc1d89555d38915f581b5ff2286b39d022ca0283d2bdd5c36be5d3c'
20-
b'e7b9b97792327851a562752e4b79475d1f51f5a71352482b241227f45ed36a9')
21-
sample_privsigningkey = \
22-
b'93d0b61371a54b53df143b954035d612f8efa8a3ed1cf842c2186bfd8f876665'
23-
sample_privencryptionkey = \
24-
b'4b0b73a54e19b059dc274ab69df095fe699f43b17397bca26fdf40f4d7400a3a'
25-
26-
# [chan] bitmessage
27-
sample_wif_privsigningkey = \
28-
b'a2e8b841a531c1c558ee0680c396789c7a2ea3ac4795ae3f000caf9fe367d144'
29-
sample_wif_privencryptionkey = \
30-
b'114ec0e2dca24a826a0eed064b0405b0ac148abc3b1d52729697f4d7b873fdc6'
31-
32-
sample_factor = \
33-
66858749573256452658262553961707680376751171096153613379801854825275240965733
34-
# G * sample_factor
35-
sample_point = (
36-
33567437183004486938355437500683826356288335339807546987348409590129959362313,
37-
94730058721143827257669456336351159718085716196507891067256111928318063085006
13+
from .samples import (
14+
sample_deterministic_addr3, sample_deterministic_addr4,
15+
sample_daddr3_512, sample_daddr4_512,
16+
sample_factor, sample_point, sample_pubsigningkey, sample_pubencryptionkey,
17+
sample_privsigningkey, sample_privencryptionkey,
18+
sample_privsigningkey_wif, sample_privencryptionkey_wif,
19+
sample_wif_privsigningkey, sample_wif_privencryptionkey
3820
)
3921

4022

@@ -50,33 +32,29 @@ def test_base58(self):
5032
"""Test encoding/decoding base58 using arithmetic functions"""
5133
self.assertEqual(
5234
arithmetic.decode(arithmetic.changebase(
53-
b'2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK', 58, 256), 256),
54-
25152821841976547050350277460563089811513157529113201589004)
35+
sample_deterministic_addr4, 58, 256), 256), sample_daddr4_512)
5536
self.assertEqual(
5637
arithmetic.decode(arithmetic.changebase(
57-
b'2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN', 58, 256), 256),
58-
18875720106589866286514488037355423395410802084648916523381)
38+
sample_deterministic_addr3, 58, 256), 256), sample_daddr3_512)
5939
self.assertEqual(
60-
arithmetic.changebase(arithmetic.encode(
61-
25152821841976547050350277460563089811513157529113201589004,
62-
256), 256, 58), b'2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK')
40+
arithmetic.changebase(
41+
arithmetic.encode(sample_daddr4_512, 256), 256, 58),
42+
sample_deterministic_addr4)
6343
self.assertEqual(
64-
arithmetic.changebase(arithmetic.encode(
65-
18875720106589866286514488037355423395410802084648916523381,
66-
256), 256, 58), b'2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN')
44+
arithmetic.changebase(
45+
arithmetic.encode(sample_daddr3_512, 256), 256, 58),
46+
sample_deterministic_addr3)
6747

6848
def test_wif(self):
6949
"""Decode WIFs of [chan] bitmessage and check the keys"""
7050
self.assertEqual(
7151
sample_wif_privsigningkey,
7252
arithmetic.changebase(arithmetic.changebase(
73-
b'5K42shDERM5g7Kbi3JT5vsAWpXMqRhWZpX835M2pdSoqQQpJMYm', 58, 256
74-
)[1:-4], 256, 16))
53+
sample_privsigningkey_wif, 58, 256)[1:-4], 256, 16))
7554
self.assertEqual(
7655
sample_wif_privencryptionkey,
7756
arithmetic.changebase(arithmetic.changebase(
78-
b'5HwugVWm31gnxtoYcvcK7oywH2ezYTh6Y4tzRxsndAeMi6NHqpA', 58, 256
79-
)[1:-4], 256, 16))
57+
sample_privencryptionkey_wif, 58, 256)[1:-4], 256, 16))
8058

8159
def test_decode(self):
8260
"""Decode sample privsigningkey from hex to int and compare to factor"""

0 commit comments

Comments
 (0)