Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions signing/sawtooth_signing/secp256k1.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,19 @@ def as_bytes(self):

@staticmethod
def from_hex(hex_str):
parse_exception = True
try:
public_key = __PK__.deserialize(binascii.unhexlify(hex_str))

return Secp256k1PublicKey(
secp256k1.PublicKey(public_key, ctx=__CTX__))
except Exception as e:
parse_exception = True
raise ParseError('Unable to parse public key: {}'.format(e))

else:
parse_exception = False
return Secp256k1PublicKey(
secp256k1.PublicKey(public_key, ctx=__CTX__))
finally:
if parse_exception is True:
return Secp256k1PublicKey(secp256k1.PublicKey())

class Secp256k1Context(Context):
def __init__(self):
Expand Down