diff --git a/bolt11/models/signature.py b/bolt11/models/signature.py index ec16f5c..3c92f5c 100644 --- a/bolt11/models/signature.py +++ b/bolt11/models/signature.py @@ -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.""" @@ -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 diff --git a/poetry.lock b/poetry.lock index 29d92b2..720a7e8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -471,24 +471,6 @@ files = [ {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, ] -[[package]] -name = "ecdsa" -version = "0.19.0" -description = "ECDSA cryptographic signature library (pure python)" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.6" -files = [ - {file = "ecdsa-0.19.0-py2.py3-none-any.whl", hash = "sha256:2cea9b88407fdac7bbeca0833b189e4c9c53f2ef1e1eaa29f6224dbc809b707a"}, - {file = "ecdsa-0.19.0.tar.gz", hash = "sha256:60eaad1199659900dd0af521ed462b793bbdf867432b3948e87416ae4caf6bf8"}, -] - -[package.dependencies] -six = ">=1.9.0" - -[package.extras] -gmpy = ["gmpy"] -gmpy2 = ["gmpy2"] - [[package]] name = "exceptiongroup" version = "1.2.2" @@ -828,17 +810,6 @@ files = [ {file = "ruff-0.0.283.tar.gz", hash = "sha256:6ee6928ad7b6b2b103d3b41517ff252cb81506dacbef01bab31fcfd0de39c5bb"}, ] -[[package]] -name = "six" -version = "1.16.0" -description = "Python 2 and 3 compatibility utilities" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, -] - [[package]] name = "tomli" version = "2.0.1" @@ -884,4 +855,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" python-versions = ">=3.8.1" -content-hash = "1c2eed4c7d750b8b135c6429988a591ba0876bd419806693332ab310627f2bea" +content-hash = "db57b22c672ef7b83b9ddd63d1b2fd8e4cf5e2ab8a4cb9912f8b812131694f10" diff --git a/pyproject.toml b/pyproject.toml index ec17d80..f1ff151 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,6 @@ bolt11 = "bolt11.cli:main" python = ">=3.8.1" click = "*" base58 = "*" -ecdsa = "*" coincurve = "*" bech32 = "*" bitstring = "*"