Skip to content

tests/test_jacobi.py:TestJacobi.test_add_scaled_points fail in python3-ecdsa 0.18.0 #360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Mingli-001 opened this issue Mar 14, 2025 · 1 comment

Comments

@Mingli-001
Copy link

Mingli-001 commented Mar 14, 2025

For some reason, I need to use python3-ecdsa 0.18.0, but the tests/test_jacobi.py failed as below.

======================================================== FAILURES ========================================================
_______________________________________ TestJacobi.test_add_different_scale_points _______________________________________

self = <tests.test_jacobi.TestJacobi testMethod=test_add_different_scale_points>

    @settings(max_examples=14)
>   @given(
        st.integers(
            min_value=1, max_value=int(generator_brainpoolp160r1.order())
        ),
        st.integers(
            min_value=1, max_value=int(generator_brainpoolp160r1.order())
        ),
        st.lists(
            st.integers(
                min_value=1, max_value=int(curve_brainpoolp160r1.p() - 1)
            ),
            min_size=2,
            max_size=2,
            unique=True,
        ),
    )

tests/test_jacobi.py:352: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_jacobi.py:375: in test_add_different_scale_points
    b = PointJacobi.from_affine(j_g * b_mul)
tests/ellipticcurve.py:735: in from_affine
    return PointJacobi(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.ellipticcurve.PointJacobi object at 0x7fcbf3fd9790>, curve = None, x = None, y = None, z = 1, order = None
generator = False

    def __init__(self, curve, x, y, z, order=None, generator=False):
        """
        Initialise a point that uses Jacobi representation internally.
    
        :param CurveFp curve: curve on which the point resides
        :param int x: the X parameter of Jacobi representation (equal to x when
          converting from affine coordinates
        :param int y: the Y parameter of Jacobi representation (equal to y when
          converting from affine coordinates
        :param int z: the Z parameter of Jacobi representation (equal to 1 when
          converting from affine coordinates
        :param int order: the point order, must be non zero when using
          generator=True
        :param bool generator: the point provided is a curve generator, as
          such, it will be commonly used with scalar multiplication. This will
          cause to precompute multiplication table generation for it
        """
        super(PointJacobi, self).__init__()
        self.__curve = curve
        if GMPY:  # pragma: no branch
>           self.__coords = (mpz(x), mpz(y), mpz(z))
E           TypeError: mpz() requires numeric or string argument
E           Falsifying example: test_add_different_scale_points(
E               a_mul=1,
E               b_mul=1332297598440044874827085038830181364212942568457,
E               new_z=[1, 2],
E               self=<tests.test_jacobi.TestJacobi testMethod=test_add_different_scale_points>,
E           )

tests/ellipticcurve.py:531: TypeError
___________________________________________ TestJacobi.test_add_scaled_points ____________________________________________

self = <tests.test_jacobi.TestJacobi testMethod=test_add_scaled_points>

    @settings(max_examples=10)
>   @given(
        st.integers(
            min_value=1, max_value=int(generator_brainpoolp160r1.order())
        ),
        st.integers(
            min_value=1, max_value=int(generator_brainpoolp160r1.order())
        ),
    )

tests/test_jacobi.py:236: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_jacobi.py:247: in test_add_scaled_points
    a = PointJacobi.from_affine(j_g * a_mul)
tests/ellipticcurve.py:735: in from_affine
    return PointJacobi(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.ellipticcurve.PointJacobi object at 0x7fcbf3f7f2d0>, curve = None, x = None, y = None, z = 1, order = None
generator = False

    def __init__(self, curve, x, y, z, order=None, generator=False):
        """
        Initialise a point that uses Jacobi representation internally.
    
        :param CurveFp curve: curve on which the point resides
        :param int x: the X parameter of Jacobi representation (equal to x when
          converting from affine coordinates
        :param int y: the Y parameter of Jacobi representation (equal to y when
          converting from affine coordinates
        :param int z: the Z parameter of Jacobi representation (equal to 1 when
          converting from affine coordinates
        :param int order: the point order, must be non zero when using
          generator=True
        :param bool generator: the point provided is a curve generator, as
          such, it will be commonly used with scalar multiplication. This will
          cause to precompute multiplication table generation for it
        """
        super(PointJacobi, self).__init__()
        self.__curve = curve
        if GMPY:  # pragma: no branch
>           self.__coords = (mpz(x), mpz(y), mpz(z))
E           TypeError: mpz() requires numeric or string argument
E           Falsifying example: test_add_scaled_points(
E               a_mul=1332297598440044874827085038830181364212942568457,
E               b_mul=1,
E               self=<tests.test_jacobi.TestJacobi testMethod=test_add_scaled_points>,
E           )

tests/ellipticcurve.py:531: TypeError
================================================ short test summary info =================================================
FAILED tests/test_jacobi.py::TestJacobi::test_add_different_scale_points - TypeError: mpz() requires numeric or string art
FAILED tests/test_jacobi.py::TestJacobi::test_add_scaled_points - TypeError: mpz() requires numeric or string argument
============================================= 2 failed, 49 passed in 38.90s ==============================================
@Mingli-001
Copy link
Author

Mingli-001 commented Mar 14, 2025

Seems 87a1596 has fixed the issue. Sorry for the noise!
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant