Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand Down Expand Up @@ -40,7 +40,7 @@ repos:
args: [--notice=COPYRIGHT]
files: python
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.0
rev: v2.3.3
hooks:
- id: autoflake
args:
Expand All @@ -54,31 +54,31 @@ repos:
language: python
types: [python]
- repo: https://github.com/asottile/pyupgrade
rev: v3.9.0
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py38-plus]
# exclude: *fixtures
language: python
types: [python]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 9.0.0a3
hooks:
- id: isort
name: isort (black profile, in place fixes)
args: ["--profile", "black", "--filter-files"]
language: python
types: [python]
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
rev: v1.7.8
hooks:
- id: docformatter
description: "Formats docstrings to follow PEP 257."
language: python
types: [python]
args: ["--in-place"]
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: v0.7.3
rev: v0.7.5
hooks:
- id: pydocstringformatter
language: python
Expand All @@ -97,13 +97,13 @@ repos:
language: python
types: [python]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.3.0
hooks:
- id: flake8
language: python
types: [python]
- repo: https://github.com/psf/black
rev: 23.7.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.5.1
hooks:
- id: black
name: black (in place fixes)
Expand All @@ -116,7 +116,7 @@ repos:
language: python
types: [python]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.9.4
hooks:
- id: bandit
name: bandit (btclib)
Expand All @@ -125,7 +125,7 @@ repos:
language: python
types: [python]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.9.4
hooks:
- id: bandit
name: bandit (tests)
Expand All @@ -138,7 +138,7 @@ repos:
language: python
types: [python]
- repo: https://github.com/PyCQA/pylint
rev: v3.0.0a6
rev: v4.0.6
hooks:
- id: pylint
args: [
Expand All @@ -147,20 +147,20 @@ repos:
language: python
types: [python]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
rev: v2.1.0
hooks:
- id: mypy
language: python
types: [python]
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
rev: "0.51"
hooks:
- id: check-manifest
description: Check the completeness of MANIFEST.in for Python packages.
language: python
pass_filenames: false
always_run: true
- repo: https://github.com/regebro/pyroma
rev: "4.2"
rev: "5.1b1"
hooks:
- id: pyroma
1 change: 1 addition & 0 deletions btclib/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

mypy aliases, documenting also coding input conventions.
"""

from __future__ import annotations

from io import BytesIO
Expand Down
1 change: 1 addition & 0 deletions btclib/b58.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Base58 encoding of public keys and scripts as addresses, private keys as
WIFs
"""

from __future__ import annotations

from btclib import b32
Expand Down
1 change: 1 addition & 0 deletions btclib/base58.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
it supports encoding bytes-like objects to ASCII bytes,
and decoding ASCII bytes-like objects or ASCII strings to bytes.
"""

from __future__ import annotations

from btclib.alias import Octets, String
Expand Down
1 change: 1 addition & 0 deletions btclib/bip32/bip32.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- [13:45] chain code
- [45:78] compressed pub_key or [0x00][prv_key]
"""

from __future__ import annotations

import copy
Expand Down
1 change: 1 addition & 0 deletions btclib/bip32/der_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- sequence of integer indexes (even a single int)
- bytes (multiples of 4-bytes index)
"""

from __future__ import annotations

from typing import Sequence, Union
Expand Down
5 changes: 3 additions & 2 deletions btclib/bip32/key_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# No part of btclib including this file, may be copied, modified, propagated,
# or distributed except according to the terms contained in the LICENSE file.
"""BIP32 key origin."""

from __future__ import annotations

from dataclasses import dataclass
Expand Down Expand Up @@ -138,7 +139,7 @@ def decode_hd_key_paths(map_: Mapping[Octets, BIP32KeyOrigin] | None) -> HdKeyPa


def encode_to_bip32_derivs(
hd_key_paths: Mapping[bytes, BIP32KeyOrigin]
hd_key_paths: Mapping[bytes, BIP32KeyOrigin],
) -> list[_BIP32Deriv]:
"""Return the json representation of the dataclass element."""
return [
Expand All @@ -152,7 +153,7 @@ def encode_to_bip32_derivs(


def _decode_from_bip32_deriv(
bip32_deriv: Mapping[str, str]
bip32_deriv: Mapping[str, str],
) -> tuple[bytes, BIP32KeyOrigin]:
# FIXME remove size checks to allow
# the instantiation of invalid master_fingerprint and pub_key
Expand Down
1 change: 1 addition & 0 deletions btclib/bip32/slip132.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

https://github.com/satoshilabs/slips/blob/master/slip-0132.md
"""

from __future__ import annotations

import contextlib
Expand Down
1 change: 1 addition & 0 deletions btclib/block/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

Dataclass encapsulating BlockHeader and list[Tx].
"""

from __future__ import annotations

from dataclasses import dataclass
Expand Down
1 change: 1 addition & 0 deletions btclib/block/block_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Dataclass encapsulating version, previous block hash, merkle root, time,
bits, and nonce.
"""

from __future__ import annotations

from dataclasses import dataclass
Expand Down
6 changes: 4 additions & 2 deletions btclib/ec/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# No part of btclib including this file, may be copied, modified, propagated,
# or distributed except according to the terms contained in the LICENSE file.
"""Elliptic curve classes and functions."""

from __future__ import annotations

import json
Expand Down Expand Up @@ -241,9 +242,10 @@ def double_mult(
def multi_mult(
scalars: Sequence[Integer], points: Sequence[Point], ec: Curve = secp256k1
) -> Point:
"""Return the multi scalar multiplication u1*Q1 + ... + un*Qn.
"""Return the multi scalar multiplication u1*Q1 + ...

Use Bos-Coster's algorithm for efficient computation.
+ un*Qn.
Use Bos-Coster's algorithm for efficient computation.
"""
if len(scalars) != len(points):
err_msg = "mismatch between number of scalars and points: "
Expand Down
12 changes: 7 additions & 5 deletions btclib/ec/curve_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
cyclic subgroup class CurveSubGroup and the cyclic subgroup class of
prime order Curve, see the btclib.ec.curve module.
"""

from __future__ import annotations

import functools
Expand Down Expand Up @@ -699,13 +700,14 @@ def _double_mult(
def _multi_mult(
scalars: Sequence[int], jac_points: Sequence[JacPoint], ec: CurveGroup
) -> JacPoint:
"""Return the multi scalar multiplication u1*Q1 + ... + un*Qn.
"""Return the multi scalar multiplication u1*Q1 + ...

Use Bos-Coster's algorithm for efficient computation.
+ un*Qn.
Use Bos-Coster's algorithm for efficient computation.

The input points are assumed to be on curve, the scalar coefficients
are assumed to have been reduced mod n if appropriate (e.g. cyclic
groups of order n).
The input points are assumed to be on curve, the scalar coefficients
are assumed to have been reduced mod n if appropriate (e.g. cyclic
groups of order n).
"""
# source: https://cr.yp.to/badbatch/boscoster2.py
if len(scalars) != len(jac_points):
Expand Down
1 change: 1 addition & 0 deletions btclib/ec/curve_group_f.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
These functions are meant to explore low-cardinality CurveGroup, for
didactical (and fun) reason only.
"""

from __future__ import annotations

from btclib.alias import INF, Point
Expand Down
1 change: 0 additions & 1 deletion btclib/ec/libsecp256k1.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# or distributed except according to the terms contained in the LICENSE file.
"""Helper functions to use the libsecp256k1 python bindings."""


from __future__ import annotations

import contextlib
Expand Down
1 change: 1 addition & 0 deletions btclib/ecc/bms.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@

https://github.com/bitcoin/bips/blob/master/bip-0137.mediawiki
"""

from __future__ import annotations

import base64
Expand Down
1 change: 1 addition & 0 deletions btclib/ecc/dh.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
The two entities must agree on the elliptic curve and key derivation
function to use.
"""

from __future__ import annotations

from hashlib import sha256
Expand Down
1 change: 1 addition & 0 deletions btclib/ecc/sign_to_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

with e = hash(R||commit_hash)) and W.x being known from the signature.
"""

from __future__ import annotations

from hashlib import sha256
Expand Down
1 change: 1 addition & 0 deletions btclib/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# No part of btclib including this file, may be copied, modified, propagated,
# or distributed except according to the terms contained in the LICENSE file.
"""Hash based helper functions."""

from __future__ import annotations

import hashlib
Expand Down
1 change: 1 addition & 0 deletions btclib/mnemonic/electrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

Electrum mnemonic is versioned, conveying BIP32 derivation rule too.
"""

from __future__ import annotations

import hmac
Expand Down
1 change: 1 addition & 0 deletions btclib/mnemonic/entropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

Output entropy is always raw.
"""

from __future__ import annotations

import math
Expand Down
1 change: 1 addition & 0 deletions btclib/mnemonic/mnemonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# No part of btclib including this file, may be copied, modified, propagated,
# or distributed except according to the terms contained in the LICENSE file.
"""Mnemonic sentence conversion from/to sequence of integer indexes."""

from __future__ import annotations

from os import path
Expand Down
1 change: 1 addition & 0 deletions btclib/number_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* minor improvements
* added extensive unit test
"""

from __future__ import annotations

from btclib.exceptions import BTClibValueError
Expand Down
1 change: 1 addition & 0 deletions btclib/psbt/psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki
"""

from __future__ import annotations

import base64
Expand Down
Loading
Loading