Skip to content

Commit

Permalink
remove ecdsa and ruff it
Browse files Browse the repository at this point in the history
  • Loading branch information
dni committed Jul 19, 2024
1 parent 9ce4e66 commit 9f69073
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 33 deletions.
8 changes: 6 additions & 2 deletions bolt11/models/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
from hashlib import sha256

from coincurve import PrivateKey, PublicKey, verify_signature
from coincurve.ecdsa import deserialize_recoverable, recoverable_convert, cdata_to_der
from coincurve.ecdsa import cdata_to_der, deserialize_recoverable, recoverable_convert


def message(hrp: str, signing_data: bytes) -> bytes:
return bytearray([ord(c) for c in hrp]) + signing_data


@dataclass
class Signature:
"""An invoice signature."""
Expand Down Expand Up @@ -37,7 +39,9 @@ def verify(self, payee: str) -> bool:
sig = deserialize_recoverable(self.signature_data)
sig = recoverable_convert(sig)
sig = cdata_to_der(sig)
if not verify_signature(sig, message(self.hrp, self.signing_data), bytes.fromhex(payee)):
if not verify_signature(
sig, message(self.hrp, self.signing_data), bytes.fromhex(payee)
):
raise ValueError("Invalid signature")
return True

Expand Down
31 changes: 1 addition & 30 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ bolt11 = "bolt11.cli:main"
python = ">=3.8.1"
click = "*"
base58 = "*"
ecdsa = "*"
coincurve = "*"
bech32 = "*"
bitstring = "*"
Expand Down

0 comments on commit 9f69073

Please sign in to comment.