Skip to content

Commit

Permalink
python: Use vendored copy of secp256k1lab
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Falbesoner <[email protected]>
  • Loading branch information
real-or-random and theStack committed Feb 25, 2025
1 parent 7451bf0 commit def1dfc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
5 changes: 2 additions & 3 deletions python/.ruff.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[format]
# Exclude the file taken from Bitcoin Core for now, in case we want to
# contribute our changes back to upstream.
exclude = ["secp256k1lab/secp256k1.py"]
# Exclude vendored package.
exclude = ["secp256k1lab/*"]
7 changes: 7 additions & 0 deletions python/chilldkg_ref/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
from pathlib import Path
import sys


__all__ = ["chilldkg"]

# Prefer the vendored copy of secp256k1lab.
sys.path.insert(0, str(Path(__file__).parent / "../secp256k1lab/src"))
4 changes: 4 additions & 0 deletions python/mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[mypy]
# Include path to vendored copy of secp256k1lab, in order to
# avoid "import-not-found" errors in mypy's `--strict` mode
mypy_path = $MYPY_CONFIG_FILE_DIR/secp256k1lab/src
8 changes: 5 additions & 3 deletions python/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from typing import Tuple, List, Optional
from secrets import token_bytes as random_bytes

from secp256k1lab.secp256k1 import GE, G, Scalar
from secp256k1lab.keys import pubkey_gen_plain

from chilldkg_ref.util import (
FaultyParticipantOrCoordinatorError,
FaultyCoordinatorError,
Expand All @@ -21,6 +18,11 @@
import chilldkg_ref.encpedpop as encpedpop
import chilldkg_ref.chilldkg as chilldkg

# Import from secp256k1lab after the chilldkg_ref imports because the latter
# modifies sys.path to make sure the vendored copy of secp256k1lab is found.
from secp256k1lab.secp256k1 import GE, G, Scalar
from secp256k1lab.keys import pubkey_gen_plain

from example import simulate_chilldkg_full as simulate_chilldkg_full_example


Expand Down

0 comments on commit def1dfc

Please sign in to comment.