diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a43c556c..b3dfb8c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -70,7 +70,7 @@ repos: language: python types: [python] - repo: https://github.com/PyCQA/docformatter - rev: v1.6.0.rc1 + rev: v1.5.1 hooks: - id: docformatter description: "Formats docstrings to follow PEP 257." diff --git a/README.md b/README.md index 6f858bde..2e9488bd 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,10 @@ without care for backward compatibility; moreover, some of its algorithms could be broken using side-channel attacks. The library is not limited to the bitcon elliptic curve secp256k1; -anyway, for this curve FFI bindings to +anyway, FFI bindings to [libsecp256k1](https://github.com/bitcoin-core/secp256k1) (the optimized C library used by Bitcoin Core) -are available and used by default. +are available for this curve and used by default. Included features are: diff --git a/btclib/ec/curve_group.py b/btclib/ec/curve_group.py index 4914812b..e1dc1bc6 100644 --- a/btclib/ec/curve_group.py +++ b/btclib/ec/curve_group.py @@ -530,9 +530,9 @@ def mult_mont_ladder(m: int, Q: JacPoint, ec: CurveGroup) -> JacPoint: Jacobian coordinates. It is constant-time and resistant to the FLUSH+RELOAD attack, - (see - https://eprint.iacr.org/2014/140.pdf) as it prevents branch prediction avoiding any if. + See: + - https://eprint.iacr.org/2014/140.pdf The input point is assumed to be on curve and the m coefficient is assumed to have been reduced mod n diff --git a/btclib/ecc/bms.py b/btclib/ecc/bms.py index 8a64643c..c1a0ac1c 100644 --- a/btclib/ecc/bms.py +++ b/btclib/ecc/bms.py @@ -342,5 +342,5 @@ def verify(msg: Octets, addr: String, sig: Sig | String, lower_s: bool = True) - assert_as_valid(msg, addr, sig, lower_s) except Exception: # pylint: disable=broad-except return False - else: - return True + + return True diff --git a/btclib/ecc/dsa.py b/btclib/ecc/dsa.py index 01a49265..331c0cb9 100644 --- a/btclib/ecc/dsa.py +++ b/btclib/ecc/dsa.py @@ -391,8 +391,8 @@ def verify_( assert_as_valid_(msg_hash, key, sig, lower_s, hf) except Exception: # pylint: disable=broad-except return False - else: - return True + + return True def verify( diff --git a/btclib/ecc/ssa.py b/btclib/ecc/ssa.py index 5812b82a..00424f08 100644 --- a/btclib/ecc/ssa.py +++ b/btclib/ecc/ssa.py @@ -322,8 +322,8 @@ def verify_( assert_as_valid_(msg_hash, Q, sig, hf) except Exception: # pylint: disable=broad-except return False - else: - return True + + return True def verify(msg: Octets, Q: BIP340PubKey, sig: Sig | Octets, hf: HashF = sha256) -> bool: diff --git a/btclib/number_theory.py b/btclib/number_theory.py index c828688b..8fe5560f 100644 --- a/btclib/number_theory.py +++ b/btclib/number_theory.py @@ -46,8 +46,7 @@ def mod_inv(a: int, m: int) -> int: m does not have to be a prime. Based on Extended Euclidean Algorithm, see: - - https://en.wikibooks.org/wiki/Algorithm_Implementation/Mathematics/Extended_Euclidean_algorithm + - https://en.wikibooks.org/wiki/Algorithm_Implementation/Mathematics/Extended_Euclidean_algorithm """ a %= m g, x, _ = xgcd(a, m) diff --git a/btclib/tx/tx.py b/btclib/tx/tx.py index 6d621f86..4fc63412 100644 --- a/btclib/tx/tx.py +++ b/btclib/tx/tx.py @@ -13,15 +13,15 @@ Dataclass encapsulating version, lock_time, vin (list[TxIn]), and vout (list[TxOut]). -https://en.bitcoin.it/wiki/Transaction - https://learnmeabitcoin.com/guide/coinbase-transaction -https://bitcoin.stackexchange.com/questions/20721/what-is-the-format-of-the-coinbase-transaction +- https://en.bitcoin.it/wiki/Transaction +- https://learnmeabitcoin.com/guide/coinbase-transaction +- https://bitcoin.stackexchange.com/questions/20721/what-is-the-format-of-the-coinbase-transaction For TxIn.sequence and TX.lock_time see: -https://developer.bitcoin.org/devguide/transactions.html - https://medium.com/summa-technology/bitcoins-time-locks-27e0c362d7a1 -https://bitcoin.stackexchange.com/questions/40764/is-my-understanding-of-locktime-correct -https://en.bitcoin.it/wiki/Timelock +- https://developer.bitcoin.org/devguide/transactions.html +- https://medium.com/summa-technology/bitcoins-time-locks-27e0c362d7a1 +- https://bitcoin.stackexchange.com/questions/40764/is-my-understanding-of-locktime-correct +- https://en.bitcoin.it/wiki/Timelock """ from __future__ import annotations diff --git a/btclib/utils.py b/btclib/utils.py index 0734406c..706b0810 100644 --- a/btclib/utils.py +++ b/btclib/utils.py @@ -82,8 +82,8 @@ def int_from_bits(octets: Octets, nlen: int) -> int: bits on the left, while int_from_bits will discard some bits on the right. i.to_bytes is the reverse of int_from_bits only when nlen is a multiple of 8 and bit sequences already have length nlen. - See - https://tools.ietf.org/html/rfc6979#section-2.3.5. + See: + - https://tools.ietf.org/html/rfc6979#section-2.3.5 """ octets = bytes_from_octets(octets) i = int.from_bytes(octets, byteorder="big", signed=False)