Skip to content

Commit ebc2199

Browse files
committed
support for repr(VerifyingKey)
for hypothesis, falsifying examples are easier to check and reproduce when the key can be printed in form that can be put into code
1 parent fdec1bc commit ebc2199

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/ecdsa/keys.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ def __init__(self, _error__please_use_generate=None):
135135
self.default_hashfunc = None
136136
self.pubkey = None
137137

138+
def __repr__(self):
139+
pub_key = self.to_string("compressed")
140+
return "VerifyingKey.from_string({0!r}, {1!r}, {2})".format(
141+
pub_key, self.curve, self.default_hashfunc().name)
142+
138143
@classmethod
139144
def from_public_point(cls, point, curve=NIST192p, hashfunc=sha1):
140145
"""

0 commit comments

Comments
 (0)