Skip to content

Commit

Permalink
updated based on code review
Browse files Browse the repository at this point in the history
  • Loading branch information
eukreign committed Jan 17, 2022
1 parent ac201c7 commit 302461b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lbry/wallet/bip32.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,14 @@ def extended_key(self):
self.pubkey_bytes
)

def verify(self, signature, data) -> bool:
""" Verify that a signature is valid for data. """
def verify(self, signature, digest) -> bool:
""" Verify that a signature is valid for a 32 byte digest. """

if len(signature) != 64:
raise Exception('invalid signature length')
raise ValueError('Signature must be 64 bytes long.')

if len(digest) != 32:
raise ValueError('Digest must be 32 bytes long.')

key = self.verifying_key

Expand All @@ -163,7 +166,7 @@ def verify(self, signature, data) -> bool:
)

verified = libsecp256k1.secp256k1_ecdsa_verify(
key.context.ctx, normalized_signature, data, key.public_key
key.context.ctx, normalized_signature, digest, key.public_key
)

return bool(verified)
Expand Down

0 comments on commit 302461b

Please sign in to comment.