HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/ecdsa/__pycache__/test_jacobi.cpython-310.pyc
o

�h�d�@s6ddlZddlZzddlZWn
eyddlZYnwddlZddlZddlZddlZddl	Z	ddl
mZddl
mZmZmZmZddlmZmZmZmZddlmZmZmZmZmZmZmZddlm Z ddl!m"Z"iZ#ej$dkrwd	e#d
<iZ%dej&vr�de%d
<nde%d
<Gdd�dej'�Z(Gdd�dej'�Z)dS)�N)�given�assume�settings�example�)�CurveFp�PointJacobi�INFINITY�Point)�
generator_256�	curve_256�
generator_224�generator_brainpoolp160r1�curve_brainpoolp160r1�generator_112r2�curve_112r2)�inverse_mod)�	randrange)��i��deadlinez--fastr�max_examples�
c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zed�ie ��e!e"j#d9e$e%�&�d:�d;��d<d=���Z'ed�ie ��e!e"j#d9e$e%�&�d:�d;��e(d9�e(e$e%�&���d>d?�����Z)ed�ie ��e!e"j#d:e$e%�&�d:�d;�e"j#d:e$e%�&�d:�d;��e(d@d@�dAdB����Z*ed�ie ��e!e"j#d:e$e%�&�d:�d;�e"j#d:e$e%�&�d:�d;�e"j#d:e$e+�,�d:�d;��dCdD���Z-e.j/j0ed�ie ��e!e"j#d:e$e%�&�d:�d;�e"j#d:e$e%�&�d:�d;�e"j#d:e$e+�,�d:�d;��e(d:d:d:�e(d@d@d@�e(dEe$e%�&�dE�d:�e(dEe$e%�&�dE�d@�dFdG��������Z1dHdI�Z2e.j/j0ed�ie ��e!e"j#d:e$e%�&�d:�d;�e"j#d:e$e%�&�d:�d;�e"j3e"j#d:e$e+�,�d:�d;�dEdEdJdK��e(dEdEdEd:g�e(dEdEdEd@g�e(dEe$e%�&�dE�dEd@g�e(dEe$e%�&�dE�dEd:g�dLdM��������Z4dNdO�Z5dPdQ�Z6dRdS�Z7dTdU�Z8dVdW�Z9dXdY�Z:dZd[�Z;d\d]�Z<d^d_�Z=d`da�Z>dbdc�Z?ddde�Z@dfdg�ZAdhdi�ZBdjdk�ZCdldm�ZDdndo�ZEdpdq�ZFdrds�ZGe!e"j#d9e$eH�&�d:�d;�e"j#d9e$eH�&�d:�d;�e"j#d9e$eH�&�d:�d;��e(dtdEdu�dvdw���ZIdxdy�ZJdzd{�ZKd|d}�ZLd~d�ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWe.j/j0ed�ieX��e.j/jYeZ�[�d�kd�d��e!e"j#d:d�d;��d�d������Z\e.j/j0e.j/jYeZ�]�d�k�p�eZ�[�d�kd�d��d�d����Z^d�S)��
TestJacobicCsjt�}d}d}d}d}t|||||�}|�|��|�|�|��|�|�|��|�|�|��|�dS)Nr�r�)�objectr�assertEqual�order�assertIs�curve�x�y)�selfr r!r"�zr�pj�r&�D/usr/local/CyberCP/lib/python3.10/site-packages/ecdsa/test_jacobi.py�
test___init__,szTestJacobi.test___init__cCsLt�t�}t�t�}|�t��
||Wd�dS1swYdS�N)r�from_affinerr
�assertRaises�
ValueError�r#�p_a�p_br&r&r'�test_add_with_different_curves9s



"�z)TestJacobi.test_add_with_different_curvescCs|�tt�dSr))�assertNotEqualrr
�r#r&r&r'�test_compare_different_curves@sz(TestJacobi.test_compare_different_curvescC�t�t�}|�|d�dS)N�value�rr*rr1�r#r%r&r&r'�test_equality_with_non_pointC�
z'TestJacobi.test_equality_with_non_pointcCs"t�t�}|��}|�t|�dSr)�rr*r�	to_affiner�r#r%�pwr&r&r'�test_conversionHs
zTestJacobi.test_conversioncCsFt�t�}t��}|��}|�|��|���|�|��|���dSr))rr*r�doublerr!r"r<r&r&r'�test_single_doubleN�

zTestJacobi.test_single_doublecCs&ttddd�}|��}|�|t�dS�Nrr�rrr?rr	r7r&r&r'�test_double_with_zero_pointW�z&TestJacobi.test_double_with_zero_pointcCs&ttddd�}|��}|�|t�dS�NrrCr7r&r&r'�&test_double_with_zero_equivalent_point^rEz1TestJacobi.test_double_with_zero_equivalent_pointcCs*ttddt���}|��}|�|t�dSrB�rr�pr?rr	r7r&r&r'�<test_double_with_zero_equivalent_point_non_zero_z_non_zero_ye�zGTestJacobi.test_double_with_zero_equivalent_point_non_zero_z_non_zero_ycCs*ttddt���}|��}|�|t�dSrFrHr7r&r&r'�1test_double_with_zero_equivalent_point_non_zero_zlrKz<TestJacobi.test_double_with_zero_equivalent_point_non_zero_zcCs.t�t�}|��}|�||�|�||�dSr)r:�r#r%�par&r&r'�test_compare_with_affine_pointss
z)TestJacobi.test_compare_with_affine_pointcCs&ttddd�}|��}|�|t�dSrF)rrr;rr	rMr&r&r'�test_to_affine_with_zero_pointzrEz)TestJacobi.test_to_affine_with_zero_pointcCs.t�t�}|��}||}|�||���dSr)�rr*rr;rr?�r#r%rN�sr&r&r'�test_add_with_affine_point��
z%TestJacobi.test_add_with_affine_pointcCs.t�t�}|��}||}|�||���dSr)rQrRr&r&r'�test_radd_with_affine_point�rUz&TestJacobi.test_radd_with_affine_pointcCs"t�t�}|t}|�||�dSr))rr*rr	r)r#r%rSr&r&r'�test_add_with_infinity��
z!TestJacobi.test_add_with_infinitycCs4t�t���}ttddd�}||}|�||�dSrF)rr*rr;rr)r#rNr%rSr&r&r'�test_add_zero_point_to_affine�sz(TestJacobi.test_add_zero_point_to_affinecCs"t�t�}|d}|�|t�dSrF)rr*rrr	r7r&r&r'�test_multiply_by_zero�rXz TestJacobi.test_multiply_by_zerocCs&ttddd�}|d}|�|t�dSrB)rrrr	r7r&r&r'�test_zero_point_multiply_by_one�rEz*TestJacobi.test_zero_point_multiply_by_onecC�Ft�t�}td}|d}|�|��|���|�|��|���dS�Nr�rr*rrr!r"r<r&r&r'�test_multiply_by_one�rAzTestJacobi.test_multiply_by_onecCr\�Nrr^r<r&r&r'�test_multiply_by_two�rAzTestJacobi.test_multiply_by_twocCs*t�t�}td}d|}|�||�dSr`�rr*rrr<r&r&r'�test_rmul_by_two�s
zTestJacobi.test_rmul_by_twocCst�t�}|�|t�dSr))rr*rr1r	r7r&r&r'�#test_compare_non_zero_with_infinity�r9z.TestJacobi.test_compare_non_zero_with_infinitycCsttddd�}|�|t�dS)Nrr�rrrr	r7r&r&r'�-test_compare_non_zero_bad_scale_with_infinity�sz8TestJacobi.test_compare_non_zero_bad_scale_with_infinitycCs<tddd�}t|ddd�}|�|�dd��|�|t�dS�N�rr�rr�
assertTrue�contains_pointr1r	�r#�c_23r%r&r&r'�"test_eq_x_0_on_curve_with_infinity��z-TestJacobi.test_eq_x_0_on_curve_with_infinitycCs<tddd�}t|ddd�}|�|�dd��|�|t�dS)Nrhrrrrirlr&r&r'�"test_eq_y_0_on_curve_with_infinity�roz-TestJacobi.test_eq_y_0_on_curve_with_infinitycCs8tddd�}t|ddd�}t|ddd�}|�||�dS)Nrhrr�)rrr1)r#rmr.r/r&r&r'�test_eq_with_same_x_different_y�sz*TestJacobi.test_eq_with_same_x_different_ycCsttddd�}|�|t�dSrFrer7r&r&r'�%test_compare_zero_point_with_infinity�sz0TestJacobi.test_compare_zero_point_with_infinitycCs*t�t�}|��}|d}|�||�dSr`)rr*rr?r)r#r%�dbl�mlplr&r&r'�!test_compare_double_with_multiply�s
z,TestJacobi.test_compare_double_with_multiplyrr)�	min_value�	max_valuecCsRt�t�}|��|}||}|�|��|��f|��|��f�|�||�dSr))rr*rr;rr!r")r#�mulr%r=r&r&r'�test_multiplications�s

$zTestJacobi.test_multiplicationscCs:t}|�|j�t�t�}||}||}|�||�dSr))rrj�_PointJacobi__precomputerr*r)r#ry�precompr%�a�br&r&r'�test_precomputes	
zTestJacobi.test_precomputercCsFt�t�}t�||�}t�||�}||}|�||||�dSr))rr*rr)r#�a_mul�b_mul�j_gr}r~�cr&r&r'�test_add_scaled_pointss

z!TestJacobi.test_add_scaled_pointsc
Cs�t�t�}t�||�}t�||�}t��}tt||��|||}tt|��|||��||||�}||}	|�	|	|||�dSr)�
rr*rrrIrrr!r"r�
r#r�r��new_zr�r}r~rI�new_zzr�r&r&r'�test_add_one_scaled_point(s
�z$TestJacobi.test_add_one_scaled_pointrc
Cs�t�t�}t�||�}t�||�}t��}tt||��|||}tt|��|||��||||�}tt|��|||��||||�}||}	|�	|	|||�dSr)r�r�r&r&r'�test_add_same_scale_pointsHs(
��z%TestJacobi.test_add_same_scale_pointscCs�t}t��}|d}|��d}tt|��|d||��|d||�}tt|��|d||��|d||�}||}|�|||�dS)N��
rr�rrrI�scalerr!r"r)r#r�rIr}�z1r!r"r�r&r&r'�!test_add_same_scale_points_staticss&��z,TestJacobi.test_add_same_scale_points_staticT)�min_size�max_size�uniquecCs�t�t�}t�||�}t�||�}t��}tt|d|��tt|d|��|d|d|}|d|d|}	tt|��|||��||d||d�}tt|��|	||��|	|d||d�}||}
|�	|
|||�dSrBr�)r#r�r�r�r�r}r~rI�new_zz0�new_zz1r�r&r&r'�test_add_different_scale_points�s,
��z*TestJacobi.test_add_different_scale_pointsc	Cs�t}t��}|d}|��d}tt|��|d||��|d||�}d}tt|��|d||��|d||�}||}|�|||�dS)Nr�r�rr�r�)	r#r�rIr}r�r!�z2r"r�r&r&r'�&test_add_different_scale_points_static�s(��z1TestJacobi.test_add_different_scale_points_staticc	Cs�t}t��}|d}|��|d}d}tt|��|d||��|d||�}tt|��|d||��|d||�}||}|�|||�dS)Nr��r�rrr�)	r#r�rIr}r~r$r!r"r�r&r&r'�+test_add_different_points_same_scale_static�s(��z6TestJacobi.test_add_different_points_same_scale_staticcCs�t}t��}d}||}|��tt|��|d||��|d||�}tt|��|��d�}||}|�|||�dS)Nr�rrr)rrrIr�rr!r"r)r#r�rIr$r}r!r"r�r&r&r'�5test_add_same_point_different_scale_second_z_1_static�s&��z@TestJacobi.test_add_same_point_different_scale_second_z_1_staticcCs^t}d}||}|��|}tt|��|��d�}tt|��|��d�}|�t||�dS)Nr�r)rr�rrr!r"rr	)r#r�r$r}r~r!r"r&r&r'�test_add_to_infinity_statics$��z&TestJacobi.test_add_to_infinity_staticcCs&t�t�}|�|d|||�dS)Nrrb�r#r�r&r&r'�test_add_point_3_timess
z!TestJacobi.test_add_point_3_timescCs.ttt��t��d�}|�|t��t�dSr])rrrr!r"rrr	r�r&r&r'�test_mul_without_order#sz!TestJacobi.test_mul_without_ordercCs$t�t�}|�||�dtd��dSr]�rr*rr�mul_addr	r�r&r&r'�test_mul_add_inf(s
zTestJacobi.test_mul_add_infcCs(t�t�}|�|d|�d|d��dS)Nrr�rr*rrr�r�r&r&r'�test_mul_add_same-s
zTestJacobi.test_mul_add_samecC�jt�td�}t�|dd�}|�|d||�|�|d|d|d�|�|d|�d|d��dS)NT��i��r�rr*rrr��r#r�r~r&r&r'�test_mul_add_precompute2s
z"TestJacobi.test_mul_add_precomputecCr�)NTr�r���������r�r�r&r&r'�test_mul_add_precompute_large:s��z(TestJacobi.test_mul_add_precompute_largecCs0t�t�}|d}|�d|d�}|�||�dS)Nrrr)rr*rr�r)r#r�r}r~r&r&r'�test_mul_add_to_mulFs
zTestJacobi.test_mul_add_to_mulcCs0t�t�}|d}|�|�d|d�|d�dS)Nrrrr�)r#r��w_ar&r&r'�test_mul_add_differntNs
z TestJacobi.test_mul_add_differntcCs@t�t�}|d}|d}|�|�d|d�|d|d�dS)Nrrrr�)r#r�r��w_br&r&r'�test_mul_add_slightly_differentUs
&z*TestJacobi.test_mul_add_slightly_differentcCsHt�t�}td}td}|d}|�d|d�}|�|��||�dS)Nr�i������rr*rr�rr;�r#r�r�r��j_b�retr&r&r'�test_mul_add]s
zTestJacobi.test_mul_addcCsHt�t�}td}td}|d}|�d|d�}|�|��||�dS)Nr�rr�r�r�r&r&r'�test_mul_add_zerohs
zTestJacobi.test_mul_add_zerocCsft�t�}t�|d�}|�|d||�|�|d|d|d�|�|d|�d|d��dS)Nr�r�r�r�r�r�r�r&r&r'�test_mul_add_largets
��zTestJacobi.test_mul_add_largecCsBt�t�}t��}t�td�}|�|�|d||d�t�dS)Nr�)rr*rrrr�r	)r#r�rr~r&r&r'�$test_mul_add_with_infinity_as_result�s
"z/TestJacobi.test_mul_add_with_infinity_as_resultcCsfttt��t��d�}t��}td}|��tt|��|��d�}|�|�|d||d�t	�dS)Nr�")
rrrr!r"rr�rr�r	)r#r�rr�r~r&r&r'�test_mul_add_without_order�s"z%TestJacobi.test_mul_add_without_ordercCs2t�td�}d|}|�|�d|d�t�dS)N�rrr�)r#r��dbl_negr&r&r'�,test_mul_add_with_doubled_negation_of_itself�s
z7TestJacobi.test_mul_add_with_doubled_negation_of_itselfi�i�cCs<t�t�}t|}|�|||�}|�|||||�dSr))rr*rr�r)r#�mul1�mul2�mul3r.r/�resr&r&r'�test_mul_add_random�s
zTestJacobi.test_mul_add_randomcCsHttdddd�ddddd�}ttdddd�ddddd�}|�||�dS�Nrhrrr�r r!r"r$r)rrr)r#�pj1�pj2r&r&r'�
test_equality�szTestJacobi.test_equalitycCr4)Nr�r6r�r&r&r'�!test_equality_with_invalid_object�r9z,TestJacobi.test_equality_with_invalid_objectcCs$t�t�}t�t�}|�||�dSr))rr*rr
r1r-r&r&r'�test_equality_with_wrong_curves�s

z*TestJacobi.test_equality_with_wrong_curvesc	CsNttdddd�ddddd�}|�ddddddd�\}}}|�|||fd�dS)	Nrhrrrr�r�r)rrr)rr�_addr)r#r�r!r"r$r&r&r'�test_add_with_point_at_infinity�sz*TestJacobi.test_add_with_point_at_infinitycCsjtddd�}t|ddd�}|��}|�|��|��fd�|�|t�|��}|�|t�|�|t�dS�Nrhrr���rr)	rrr?rr!r"r1r	r�r#rmrI�p2�p3r&r&r'�test_double_to_infinity��z"TestJacobi.test_double_to_infinitycCs>tddd�}t|ddd�}|��}|�|��|��fd�dS)Nrhrr�	)r�)rrr?rr!r")r#�c_23_2rIr�r&r&r'�test_double_to_x_0�szTestJacobi.test_double_to_x_0cCsjtddd�}t|ddd�}|d}|�|��|��fd�|�|t�|d}|�|t�|�|t�dS)Nrhrr�r�rr��rrrr!r"r1r	rr�r&r&r'�test_mul_to_infinity�r�zTestJacobi.test_mul_to_infinitycCsjtddd�}t|ddd�}||}|�|��|��fd�|�|t�||}|�|t�|�|t�dSr�r�r�r&r&r'�test_add_to_infinity�r�zTestJacobi.test_add_to_infinitycC�>tddd�}t|ddd�}|d}|�|��|��fd�dS)Nrhrr�rr��rrq�rrrr!r"�r#rmrIr�r&r&r'�test_mul_to_x_0��zTestJacobi.test_mul_to_x_0cCr�)Nrhrr�r�r�r�r�r&r&r'�test_mul_to_y_0�r�zTestJacobi.test_mul_to_y_0cC�Btddd�}t|ddd�}|d|}|�|��|��fd�dS)Nrhrr�rr�r�r�r�r&r&r'�test_add_to_x_0��zTestJacobi.test_add_to_x_0cCr�)Nrhrr�rr�r�r�r�r&r&r'�test_add_to_y_0�r�zTestJacobi.test_add_to_y_0cCs:tddd�}t|ddd�}|d|d}|�|t�dS)Nrhrr�rr��)rrrr	)r#rmrIr�r&r&r'�test_add_diff_z_to_infinitysz&TestJacobi.test_add_diff_z_to_infinitycCs8ttdddd�ddddd�}|�t�t�|��|�dSr�)rrr�pickle�loads�dumpsr7r&r&r'�test_pickleszTestJacobi.test_pickle�PyPyz!threading on PyPy breaks coverage)�reasonrcCs�tdt}t|��|��|��d|��d�}|�|jg�dd�}g}t|�D]
}|�	t
j||fd��q(|D]}|��q8||�|D]}|�
�qE|�|jtj�dS)NrrTcS�&|��}td�D]}|t|�qdS)Nr�r�ranger��	generatorr�_r&r&r'�runner��z.TestJacobi.test_multithreading.<locals>.runner��target�args)rrr r!r"rrr{r��append�	threading�Thread�start�join)r#�
thread_num�genr��threadsr��tr&r&r'�test_multithreadings"	"

�zTestJacobi.test_multithreading�WindowszFthere are no signals on Windows, and threading breaks coverage on PyPycCsDd}tdt}t|��|��|��d|��d�}|�|jg�dd�}dd�}g}t|�D]
}|�	t
j||fd	��q.t
��}|�
�t
��}|�
�t
��}	|	�
�|�	t
j||||	fd	��|D]}
|
��qc|�t��|�
�|��||�|	�
�Wd�n1s�wY|D]}
|
��q�|�|jtj�dS)
NrrrTcSr�)N�2r�r�r&r&r'r�Er�z>TestJacobi.test_multithreading_with_interrupts.<locals>.runnercSs.|��|��t�t��tj�|��dSr))�release�acquire�os�kill�getpid�signal�SIGINT)�
barrier_start�barrier_end�	lock_exitr&r&r'�interrupterJszCTestJacobi.test_multithreading_with_interrupts.<locals>.interrupterr�)rrr r!r"rrr{r�rrr�Lockrrr+�KeyboardInterruptr
r)r#rrr�rrr�rrrr	r&r&r'�#test_multithreading_with_interrupts3sH"��

�	
�z.TestJacobi.test_multithreading_with_interruptsNr&)_�__name__�
__module__�__qualname__r(r0r3r8r>r@rDrGrJrLrOrPrTrVrWrYrZr[r_rarcrdrfrnrprrrsrvr�
SLOW_SETTINGSr�st�integers�intrrrzrrr�rrIr��pytest�mark�slowr�r��listsr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r��NO_OLD_SETTINGS�skipif�platform�python_implementationr
�systemrr&r&r&r'r+sD
			��	��
���	���	���
	
�����	�




� 
�rc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�
TestZeroCurvez.Tests with curve that has (0, 0) on the curve.cCstddd�|_dSrg)rr r2r&r&r'�setUp{szTestZeroCurve.setUpcCs|�|j�dd��dSrF)rjr rkr2r&r&r'�test_zero_point_on_curve~sz&TestZeroCurve.test_zero_point_on_curvecCs@t|jddd�}|��}|�|t�|�d|��|��f�dS)Nrr��rr�rr r?r1r	rr!r"�r#rI�dr&r&r'�test_double_to_0_0_point��z&TestZeroCurve.test_double_to_0_0_pointcCsTd}t|jd|dd|d|�}|��}|�|t�|�d|��|��f�dS)Nrrr�rr.r/)r#r$rIr1r&r&r'�'test_double_to_0_0_point_with_non_one_z�s
 z5TestZeroCurve.test_double_to_0_0_point_with_non_one_zcCs@t|jddd�}|d}|�|t�|�d|��|��f�dS)Nr�r�rr�r.)rr r1r	rr!r"r0r&r&r'�test_mul_to_0_0_point�r3z#TestZeroCurve.test_mul_to_0_0_pointcCs(t|jddd�}|��}|�|t�dSrB)rr r?rr	r0r&r&r'�test_double_of_0_0_point�sz&TestZeroCurve.test_double_of_0_0_pointcCsDt|jddd�}t|jdd�}td�D]}|�||||�qdS)Nr�r�r�)rr r
r�r)r#rI�p_c�ir&r&r'�"test_compare_to_old_implementation�s
�z0TestZeroCurve.test_compare_to_old_implementationN)rrr�__doc__r,r-r2r4r5r6r:r&r&r&r'r+xs	r+)*r��sys�	unittest2�unittest�ImportErrorrrr"rr(�hypothesis.strategies�
strategiesr�
hypothesisrrrr�
ellipticcurverrr	r
�ecdsarrr
rrrr�numbertheoryr�utilrr&�version_infor�argv�TestCaserr+r&r&r&r'�<module>sB�$	


S