Skip to content

Commit d156391

Browse files
python: Use vendored copy of secp256k1lab
Co-authored-by: Sebastian Falbesoner <[email protected]>
1 parent b66cebb commit d156391

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

python/.ruff.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[format]
2-
# Exclude the file taken from Bitcoin Core for now, in case we want to
3-
# contribute our changes back to upstream.
4-
exclude = ["secp256k1lab/secp256k1.py"]
2+
# Exclude vendored package.
3+
exclude = ["secp256k1lab/*"]

python/chilldkg_ref/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1+
from pathlib import Path
2+
import sys
3+
4+
15
__all__ = ["chilldkg"]
6+
7+
# Prefer the vendored copy of secp256k1lab.
8+
sys.path.insert(0, str(Path(__file__).parent / "../secp256k1lab/src"))

python/mypy.ini

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[mypy]
2+
# Include path to vendored copy of secp256k1lab, in order to
3+
# avoid "import-not-found" errors in mypy's `--strict` mode
4+
mypy_path = $MYPY_CONFIG_FILE_DIR/secp256k1lab/src

python/tests.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
from typing import Tuple, List, Optional
88
from secrets import token_bytes as random_bytes
99

10-
from secp256k1lab.secp256k1 import GE, G, Scalar
11-
from secp256k1lab.keys import pubkey_gen_plain
12-
1310
from chilldkg_ref.util import (
1411
FaultyParticipantOrCoordinatorError,
1512
FaultyCoordinatorError,
@@ -21,6 +18,11 @@
2118
import chilldkg_ref.encpedpop as encpedpop
2219
import chilldkg_ref.chilldkg as chilldkg
2320

21+
# Import from secp256k1lab after the chilldkg_ref imports because the latter
22+
# modifies sys.path to make sure the vendored copy of secp256k1lab is found.
23+
from secp256k1lab.secp256k1 import GE, G, Scalar
24+
from secp256k1lab.keys import pubkey_gen_plain
25+
2426
from example import simulate_chilldkg_full as simulate_chilldkg_full_example
2527

2628

0 commit comments

Comments
 (0)