Skip to content

Commit 0a2d74b

Browse files
committed
test: VerifyingKey.from_string X9.62 inputs
more test coverage for VerifyingKey.from_string, to verify that the alternative inputs can handle bytearray too
1 parent ff37722 commit 0a2d74b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/ecdsa/test_keys.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,23 @@ def test_array_array_of_ints_memoryview(self):
7777
vk = VerifyingKey.from_string(buffer(arr))
7878

7979
self.assertEqual(self.vk.to_string(), vk.to_string())
80+
81+
def test_bytes_uncompressed(self):
82+
vk = VerifyingKey.from_string(b'\x04' + self.key_bytes)
83+
84+
self.assertEqual(self.vk.to_string(), vk.to_string())
85+
86+
def test_bytearray_uncompressed(self):
87+
vk = VerifyingKey.from_string(bytearray(b'\x04' + self.key_bytes))
88+
89+
self.assertEqual(self.vk.to_string(), vk.to_string())
90+
91+
def test_bytes_compressed(self):
92+
vk = VerifyingKey.from_string(b'\x02' + self.key_bytes[:24])
93+
94+
self.assertEqual(self.vk.to_string(), vk.to_string())
95+
96+
def test_bytearray_uncompressed(self):
97+
vk = VerifyingKey.from_string(bytearray(b'\x02' + self.key_bytes[:24]))
98+
99+
self.assertEqual(self.vk.to_string(), vk.to_string())

0 commit comments

Comments
 (0)