Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#95)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/PyCQA/docformatter: v1.5.1 → v1.6.0.rc1](PyCQA/docformatter@v1.5.1...v1.6.0.rc1)
- [github.com/pycqa/pydocstyle: 6.2.3 → 6.3.0](PyCQA/pydocstyle@6.2.3...6.3.0)
- [github.com/pycqa/pylint: v2.15.10 → v2.16.0b1](pylint-dev/pylint@v2.15.10...v2.16.0b1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] committed Jan 29, 2023
1 parent c8acd88 commit bdf95e1
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 31 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Expand Up @@ -70,7 +70,7 @@ repos:
language: python
types: [python]
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.1
rev: v1.6.0.rc1
hooks:
- id: docformatter
description: "Formats docstrings to follow PEP 257."
Expand All @@ -84,7 +84,7 @@ repos:
language: python
types: [python]
- repo: https://github.com/pycqa/pydocstyle
rev: 6.2.3
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies: [tomli]
Expand Down Expand Up @@ -138,7 +138,7 @@ repos:
language: python
types: [python]
- repo: https://github.com/pycqa/pylint
rev: v2.15.10
rev: v2.16.0b1
hooks:
- id: pylint
args: [
Expand Down
4 changes: 2 additions & 2 deletions btclib/block/block.py
Expand Up @@ -50,10 +50,10 @@ def vsize(self) -> int:
def height(self) -> int | None:
"""Return the height committed into a BIP34 coinbase script_sig.
Version 2 blocks commit block height into the coinbase script_sig.
Version 2 blocks commit block height into the coinbase
script_sig.
https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki
Block 227,835 (2013-03-24 15:49:13 GMT) was the last version 1 block.
"""
if not self.transactions[0].is_coinbase():
Expand Down
3 changes: 2 additions & 1 deletion btclib/block/block_header.py
Expand Up @@ -70,7 +70,8 @@ def difficulty(self) -> float:
It represents the average number of hash function evaluations
required to satisfy the BlockHeader target,
expressed as multiple of the genesis block difficulty used as unit.
expressed as multiple of the genesis block difficulty used as
unit.
The difficulty of the genesis block is 2^32 (4*2^30),
i.e. 4 GigaHash function evaluations.
Expand Down
5 changes: 3 additions & 2 deletions btclib/ec/curve_group.py
Expand Up @@ -530,7 +530,8 @@ 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)
(see
https://eprint.iacr.org/2014/140.pdf)
as it prevents branch prediction avoiding any if.
The input point is assumed to be on curve and
Expand Down Expand Up @@ -675,8 +676,8 @@ def _double_mult(
Strauss algorithm consists of a single 'double & add' loop
for the parallel calculation of u*H and v*Q, efficiently
using a single 'doubling' for both scalar multiplications (see
https://stackoverflow.com/questions/50993471/ec-scalar-multiplication-with-strauss-shamir-method).
https://stackoverflow.com/questions/50993471/ec-scalar-multiplication-with-strauss-shamir-method).
The Shamir trick adds the precomputation of H+Q,
which is to be added in the loop when the binary digits
of u and v are both equal to 1 (on average 1/4 of the cases).
Expand Down
3 changes: 2 additions & 1 deletion btclib/ecc/dh.py
Expand Up @@ -34,7 +34,8 @@ def ansi_x9_63_kdf(z: bytes, size: int, hf: HashF, shared_info: bytes | None) ->
Return a keying data octet sequence of the requested size according
to ANSI-X9.63-KDF specifications for the key derivation function.
http://www.secg.org/sec1-v2.pdf, section 3.6.1
http://www.secg.org/sec1-v2.pdf,
section 3.6.1
"""
hf_size = hf().digest_size
max_size = hf_size * (2**32 - 1)
Expand Down
1 change: 1 addition & 0 deletions btclib/number_theory.py
Expand Up @@ -46,6 +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
"""
a %= m
Expand Down
3 changes: 2 additions & 1 deletion btclib/psbt/psbt.py
Expand Up @@ -439,7 +439,8 @@ def extract_tx(psbt: Psbt, check_validity: bool = True) -> Tx:
The Transaction Extractor must only accept a PSBT.
It checks whether all inputs have complete scriptSigs
and scriptWitnesses by checking for the presence of
0x07 Finalized scriptSig and 0x08 Finalized scriptWitness typed records.
0x07 Finalized scriptSig and 0x08 Finalized scriptWitness typed
records.
If they do, the Transaction Extractor should construct
complete scriptSigs and scriptWitnesses and encode them
Expand Down
4 changes: 2 additions & 2 deletions btclib/tx/tx.py
Expand Up @@ -14,12 +14,12 @@
vin (list[TxIn]), and vout (list[TxOut]).
https://en.bitcoin.it/wiki/Transaction
https://learnmeabitcoin.com/guide/coinbase-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://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
"""
Expand Down
3 changes: 2 additions & 1 deletion btclib/utils.py
Expand Up @@ -82,7 +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)
Expand Down
2 changes: 0 additions & 2 deletions tests/bip32/test_bip32.py
Expand Up @@ -184,7 +184,6 @@ def test_invalid_bip32_xkeys() -> None:
https://github.com/bitcoin/bips/pull/921
"""

filename = path.join(data_folder, "bip32_invalid_keys.json")
with open(filename, encoding="ascii") as file_:
test_vectors = json.load(file_)
Expand Down Expand Up @@ -356,7 +355,6 @@ def test_crack() -> None:

def test_bips_pr905() -> None:
"""Https://github.com/bitcoin/bips/pull/905."""

seed = "57fb1e450b8afb95c62afbcd49e4100d6790e0822b8905608679180ac34ca0bd45bf7ccc6c5f5218236d0eb93afc78bd117b9f02a6b7df258ea182dfaef5aad7"
xroot = rootxprv_from_seed(seed)
der_path = "m/44H/60H/0H"
Expand Down
3 changes: 0 additions & 3 deletions tests/block/test_block.py
Expand Up @@ -25,7 +25,6 @@

def test_block_1() -> None:
"""Test first block after genesis."""

fname = "block_1.bin"
filename = path.join(path.dirname(__file__), "_data", fname)
with open(filename, "rb") as file_:
Expand Down Expand Up @@ -123,7 +122,6 @@ def test_exceptions() -> None:

def test_block_170() -> None:
"""Test first block with a transaction."""

fname = "block_170.bin"
filename = path.join(path.dirname(__file__), "_data", fname)
with open(filename, "rb") as file_:
Expand Down Expand Up @@ -202,7 +200,6 @@ def test_block_200000() -> None:

def test_block_481824() -> None:
"""Test first block with segwit transaction as seen from legacy nodes."""

for i, fname in enumerate(["block_481824.bin", "block_481824_complete.bin"]):
filename = path.join(path.dirname(__file__), "_data", fname)
with open(filename, "rb") as file_:
Expand Down
2 changes: 0 additions & 2 deletions tests/ecc/test_bms.py
Expand Up @@ -528,7 +528,6 @@ def test_vector_python_bitcoinlib() -> None:
- https://github.com/petertodd/python-bitcoinlib/blob/master/bitcoin/tests/test_data/bms.json
"""

fname = "bms.json"
filename = path.join(path.dirname(__file__), "_data", fname)
with open(filename, encoding="ascii") as file_:
Expand Down Expand Up @@ -577,7 +576,6 @@ def test_vector_python_bitcoinlib() -> None:

def test_ledger() -> None:
"""Hybrid ECDSA Bitcoin message signature generated by Ledger."""

mnemonic = (
"barely sun snack this snack relief pipe attack disease boss enlist lawsuit"
)
Expand Down
2 changes: 0 additions & 2 deletions tests/ecc/test_dh.py
Expand Up @@ -64,7 +64,6 @@ def test_gec_2() -> None:
- http://read.pudn.com/downloads168/doc/772358/TestVectorsforSEC%201-gec2.pdf
"""

# 4.1.1
ec = CURVES["secp160r1"]
hf = sha1
Expand Down Expand Up @@ -121,7 +120,6 @@ def test_capv() -> None:
- https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/component-testing
- https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/components/800-135testvectors/ansx963_2001.zip
"""

# fmt: off
test_vectors = [
(sha1, 128, "1c7d7b5f0597b03d06a018466ed1a93e30ed4b04dc64ccdd", None, "bf71dffd8f4d99223936beb46fee8ccc"),
Expand Down
1 change: 0 additions & 1 deletion tests/ecc/test_pedersen.py
Expand Up @@ -28,7 +28,6 @@ def test_second_generator() -> None:
About compressed encoding of the second generator:
- https://github.com/garyyu/rust-secp256k1-zkp/wiki/Pedersen-Commitment
"""

H = (
0x50929B74C1A04954B78B4B6035E97A5E078A5A0F28EC96D547BFEE9ACE803AC0,
0x31D3C6863973926E049E637CB1B5F40A36DAC28AF1766968C30C2313F3A38904,
Expand Down
1 change: 0 additions & 1 deletion tests/ecc/test_ssa.py
Expand Up @@ -297,7 +297,6 @@ def test_musig() -> None:
- https://blockstream.com/2018/01/23/musig-key-aggregation-schnorr-signatures.html
- https://medium.com/@snigirev.stepan/how-schnorr-signatures-may-improve-bitcoin-91655bcb4744
"""

ec = CURVES["secp256k1"]

msg_hash = hf(b"message to sign").digest()
Expand Down
1 change: 0 additions & 1 deletion tests/mnemonic/test_electrum.py
Expand Up @@ -98,7 +98,6 @@ def test_mnemonic_from_entropy() -> None:

def test_p2wpkh_p2sh() -> None:
"""Test generation of a p2wpkh-p2sh wallet."""

# https://bitcoinelectrum.com/creating-a-p2sh-segwit-wallet-with-electrum/
# https://www.youtube.com/watch?v=-1DBJWwA2Cw

Expand Down
1 change: 0 additions & 1 deletion tests/psbt/test_psbt.py
Expand Up @@ -30,7 +30,6 @@

def test_vectors_bip174() -> None:
"""Test https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki."""

data_folder = path.join(path.dirname(__file__), "_data")
filename = path.join(data_folder, "bip174_test_vectors.json")
with open(filename, encoding="ascii") as file_:
Expand Down
1 change: 0 additions & 1 deletion tests/script/test_script_pub_key.py
Expand Up @@ -520,7 +520,6 @@ def test_p2ms_3() -> None:

def test_bip67() -> None:
"""BIP67 test vectors https://en.bitcoin.it/wiki/BIP_0067."""

data_folder = path.join(path.dirname(__file__), "_data")
filename = path.join(data_folder, "bip67_test_vectors.json")
with open(filename, encoding="ascii") as file_:
Expand Down
3 changes: 0 additions & 3 deletions tests/test_b32.py
Expand Up @@ -61,7 +61,6 @@ def test_has_segwit_prefix() -> None:

def test_valid_address() -> None:
"""Test whether valid addresses decode to the correct output."""

valid_bc_addresses: list[tuple[str, str]] = [
(
"BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4",
Expand Down Expand Up @@ -111,7 +110,6 @@ def test_valid_address() -> None:

def test_invalid_address() -> None:
"""Test whether invalid addresses fail to decode."""

invalid_addresses: list[tuple[str, str]] = [
("tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty", "invalid hrp: "),
(
Expand Down Expand Up @@ -195,7 +193,6 @@ def test_invalid_address() -> None:

def test_invalid_address_enc() -> None:
"""Test whether address encoding fails on invalid input."""

invalid_address_enc: list[tuple[str, int, int, str]] = [
("MAINNET", 0, 20, "'MAINNET'"),
("mainnet", 0, 21, "invalid size: "),
Expand Down
1 change: 0 additions & 1 deletion tests/test_bech32.py
Expand Up @@ -50,7 +50,6 @@

def test_bech32() -> None:
"""Test bech32 checksum."""

valid_checksum = [
"A12UEL5L",
"a12uel5l",
Expand Down

0 comments on commit bdf95e1

Please sign in to comment.