AntonKueltz / fastecdsa

Python library for fast elliptic curve crypto
https://pypi.python.org/pypi/fastecdsa
The Unlicense
270 stars 78 forks source link

Installation issue #59

Closed felmoudden closed 3 years ago

felmoudden commented 4 years ago

Hi,

I'm having difficulties to install it properly. I'm using a compiled version python 3.8.1 I first tried with

pip install fastecdsa

the install went fine but i got this error

from fastecdsa.point import Point Traceback (most recent call last): File "", line 1, in File "./fastecdsa-2.1.3/fastecdsa/point.py", line 1, in from fastecdsa import curvemath ImportError: ./fastecdsa-2.1.3/fastecdsa/curvemath.cpython-38-x86_64-linux-gnu.so: undefined symbol: mpz_clears

I also tried different versions but same issue. I also tried with the setup.py file

everything was fine except those warnings

Search "mpz" (10 hits in 1 file) new 6 (10 hits) Line 54: src/curveMath.c:35: warning: implicit declaration of function ‘mpz_inits’ Line 55: src/curveMath.c:58: warning: implicit declaration of function ‘mpz_clears’ Line 58: src/curve.c:15: warning: implicit declaration of function ‘mpz_clears’ Line 61: src/point.c:13: warning: implicit declaration of function ‘mpz_clears’ Line 66: src/_ecdsa.c:25: warning: implicit declaration of function ‘mpz_inits’ Line 67: src/_ecdsa.c:32: warning: implicit declaration of function ‘mpz_clears’ Line 70: src/curveMath.c:35: warning: implicit declaration of function ‘mpz_inits’ Line 71: src/curveMath.c:58: warning: implicit declaration of function ‘mpz_clears’ Line 74: src/curve.c:15: warning: implicit declaration of function ‘mpz_clears’ Line 77: src/point.c:13: warning: implicit declaration of function ‘mpz_clears’

When I use this command

python3.8.1/Python-3.8.1/build/bin/python3 setup.py test

I'm having almost all the tests failing for the same error

undefined symbol: mpz_clears

I have python-devel and gmp-devel installed but I think it's related to how I compiled Python 3.8.1

if you have some tips it will be great.

Thanks for your support.

EDIT

I think the issue is coming from the gmp lib on rhel6

nm -D ./python3.8.1/Python-3.8.1/build/lib/python3.8/site-packages/fastecdsa-2.1.3-py3.8-linux-x86_64.egg/fastecdsa/curvemath.cpython-38-x86_64-linux-gnu.so |grep clear

             U __gmpz_clear
             U mpz_clears

ldd ./python3.8.1/Python-3.8.1/build/lib/python3.8/site-packages/fastecdsa-2.1.3-py3.8-linux-x86_64.egg/fastecdsa/curvemath.cpython-38-x86_64-linux-gnu.so

    linux-vdso.so.1 =>  
    libgmp.so.3 => /usr/lib64/libgmp.so.3
    libpthread.so.0 => /lib64/libpthread.so.0 
    libc.so.6 => /lib64/libc.so.6 
    /lib64/ld-linux-x86-64.so.2 

nm -D /usr/lib64/libgmp.so.3|grep clear

000000347100a0e0 T gmp_randclear 000000347100ac90 T gmp_randclear_mt 000000347100bf80 T gmpf_clear 0000003471022a60 T gmpq_clear 0000003471013b60 T __gmpz_clear

rpm -qa|grep gmp

gmp-4.3.1-13.el6.x86_64 gmp-devel-4.3.1-13.el6.x86_64

I don't think there is a more recent version available en rhel6...

AntonKueltz commented 4 years ago

Yeah I think you're using a version of GMP that's old enough to not have mpz_clears yet (the 4.1 docs, seem to support this, there aren't any 4.3 docs that I could find).

You could try building GMP 6.x from source, that's the version that this library was written against. Otherwise you'd probably have to fork this and replace all the mpz_clears and mpz_inits calls to individual mpz_clear and mpz_init calls, which could get tedious fast.