unit_tests.py ecc: Python 3.9 fixes; workflows: build secp256k1 extmod

This commit is contained in:
The MMGen Project 2024-01-26 11:48:00 +00:00
commit f979a3c052
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 12 additions and 12 deletions

View file

@ -17,6 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Ubuntu package dependencies
run: |
sudo apt-get install libsecp256k1-dev
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
@ -30,6 +34,7 @@ jobs:
python3 -m pip install gmpy2 cryptography pynacl ecdsa aiohttp requests pexpect scrypt semantic-version
python3 -m pip install pycryptodomex pysocks pycoin ipaddress varint pylint
python3 -m pip install --no-deps py_ecc==1.6.0 mypy_extensions==0.4.1 monero
python3 setup.py build_ext --inplace
- name: Check the code with Pylint static code analyzer
env:

View file

@ -1 +1 @@
14.1.dev4
14.1.dev5

View file

@ -28,13 +28,8 @@ class backend:
def __init__(self,cfg):
super().__init__(cfg)
# catch ImportError to satisfy pylint when testing repo with unbuilt secp256k1 extension mod:
try:
from .secp256k1 import pubkey_gen
self.pubkey_gen = pubkey_gen
except ImportError:
from ...util import die
die(3,'libsecp256k1.keygen.backend: you shouldn’t be seeing this')
from .secp256k1 import pubkey_gen
self.pubkey_gen = pubkey_gen
def to_pubkey(self,privkey):
return PubKey(

View file

@ -17,7 +17,7 @@ class unit_tests:
def pubkey_ops(self,name,ut):
vmsg(f' Generating pubkey, adding scalar 123456789 to pubkey:')
pk_addend_bytes = int.to_bytes(123456789,length=32)
pk_addend_bytes = int.to_bytes(123456789,length=32,byteorder='big')
for privkey in (
'beadcafe' * 8,
@ -46,15 +46,15 @@ class unit_tests:
def pubkey_errors(self,name,ut):
def gen1(): pubkey_gen(bytes(32),1)
def gen2(): pubkey_gen(secp256k1_group_order.to_bytes(length=32),1)
def gen3(): pubkey_gen((secp256k1_group_order+1).to_bytes(length=32),1)
def gen2(): pubkey_gen(secp256k1_group_order.to_bytes(length=32,byteorder='big'),1)
def gen3(): pubkey_gen((secp256k1_group_order+1).to_bytes(length=32,byteorder='big'),1)
def gen4(): pubkey_gen(bytes.fromhex('ff'*32),1)
def gen5(): pubkey_gen(bytes.fromhex('ab'*31),1)
def gen6(): pubkey_gen(bytes.fromhex('ab'*33),1)
pubkey_bytes = pubkey_gen(bytes.fromhex('beadcafe'*8), 1)
def tweak1(): pubkey_tweak_add(pubkey_bytes,bytes(32))
def tweak2(): pubkey_tweak_add(bytes.fromhex('03'*64),int.to_bytes(1,length=32))
def tweak2(): pubkey_tweak_add(bytes.fromhex('03'*64),int.to_bytes(1,length=32,byteorder='big'))
def check1(): pubkey_check(bytes.fromhex('04'*33))
def check2(): pubkey_check(bytes.fromhex('03'*65))