
    tZhd                        d dl Z d dlZ	 d dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZmZmZmZ ddlmZmZmZmZ ddlmZmZmZmZmZmZmZ ddlm Z  ddl!m"Z" i Z#ejH                  dkD  rd	e#d
<   i Z%dejL                  v rde%d<   nde%d<    G d dejN                        Z( G d dejN                        Z)y# e$ r d dlZY w xY w)    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                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z edXi e  e! e"jF                  d e$ e%jL                         dz
                    d                Z' edXi e  e! e"jF                  d e$ e%jL                         dz
                     e(d       e( e$ e%jL                                     d!                             Z) edXi e  e! e"jF                  d e$ e%jL                         dz
               e"jF                  d e$ e%jL                         dz
                     e(d"d"      d#                      Z* edXi e  e! e"jF                  d e$ e%jL                         dz
               e"jF                  d e$ e%jL                         dz
               e"jF                  d e$ e+jX                         dz
                    d$               Z-e.j^                  j`                   edXi e  e! e"jF                  d e$ e%jL                         dz
               e"jF                  d e$ e%jL                         dz
               e"jF                  d e$ e+jX                         dz
                     e(ddd       e(d"d"d"       e(d% e$ e%jL                         d%z
        d       e(d% e$ e%jL                         d%z
        d"      d&                                                  Z1d' Z2e.j^                  j`                   edXi e  e! e"jF                  d e$ e%jL                         dz
               e"jF                  d e$ e%jL                         dz
               e"jf                   e"jF                  d e$ e+jX                         dz
              d%d%d()             e(d%d%d%dg       e(d%d%d%d"g       e(d% e$ e%jL                         d%z
        d%d"g       e(d% e$ e%jL                         d%z
        d%dg      d*                                                  Z4d+ Z5d, Z6d- Z7d. Z8d/ Z9d0 Z:d1 Z;d2 Z<d3 Z=d4 Z>d5 Z?d6 Z@d7 ZAd8 ZBd9 ZCd: ZDd; ZEd< ZFd= ZG e! e"jF                  d e$ eHjL                         dz
               e"jF                  d e$ eHjL                         dz
               e"jF                  d e$ eHjL                         dz
                     e(d>d%d?      d@               ZIdA ZJdB ZKdC ZLdD ZMdE ZNdF ZOdG ZPdH ZQdI ZRdJ ZSdK ZTdL ZUdM ZVdN ZWe.j^                  j`                   edXi eXe.j^                  j                   eZj                         dOk(  dPQ       e! e"jF                  ddR            dS                             Z\e.j^                  j`                  e.j^                  j                   eZj                         dTk(  xs  eZj                         dOk(  dUQ      dV               Z^yW)Y
TestJacobic                 F   t               }d}d}d}d}t        |||||      }| j                  |j                         |       | j	                  |j                         |       | j                  |j                         |       | j                  |j                         |       y )Nr      r      )objectr	   assertEqualorderassertIscurvexy)selfr#   r$   r%   zr!   pjs          m/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/ecdsa/test_jacobi.pytest___init__zTestJacobi.test___init__,   s    1a/U+bhhj%(##    c                     t        j                  t              }t        j                  t              }| j	                  t
              5  ||z    d d d        y # 1 sw Y   y xY wN)r	   from_affiner   r   assertRaises
ValueErrorr&   p_ap_bs      r)   test_add_with_different_curvesz)TestJacobi.test_add_with_different_curves9   sL    %%m4%%m4z* 	#I	 	 	s   AA c                 8    | j                  t        t               y r-   )assertNotEqualr   r   r&   s    r)   test_compare_different_curvesz(TestJacobi.test_compare_different_curves@   s    M=9r+   c                 Z    t        j                  t              }| j                  |d       y )Nvaluer	   r.   r   r6   r&   r(   s     r)   test_equality_with_non_pointz'TestJacobi.test_equality_with_non_pointC   s"    $$]3B(r+   c                     t        j                  t              }|j                         }| j	                  t        |       y r-   r	   r.   r   	to_affiner    r&   r(   pws      r)   test_conversionzTestJacobi.test_conversionH   s-    $$]3\\^+r+   c                 6   t        j                  t              }t        j                         }|j                         }| j	                  |j                         |j                                | j	                  |j                         |j                                y r-   )r	   r.   r   doubler    r$   r%   rA   s      r)   test_single_doublezTestJacobi.test_single_doubleN   sc    $$]3!!#YY[((r+   c                 t    t        t        ddd      }|j                         }| j                  |t               y Nr   r   r	   r   rE   r"   r
   r<   s     r)   test_double_with_zero_pointz&TestJacobi.test_double_with_zero_pointW   +    Aq!,YY[b(#r+   c                 t    t        t        ddd      }|j                         }| j                  |t               y Nr   rI   r<   s     r)   &test_double_with_zero_equivalent_pointz1TestJacobi.test_double_with_zero_equivalent_point^   rK   r+   c                     t        t        ddt        j                               }|j                         }| j	                  |t
               y rH   r	   r   prE   r"   r
   r<   s     r)   <test_double_with_zero_equivalent_point_non_zero_z_non_zero_yzGTestJacobi.test_double_with_zero_equivalent_point_non_zero_z_non_zero_ye   1    Aq)++-8YY[b(#r+   c                     t        t        ddt        j                               }|j                         }| j	                  |t
               y rM   rP   r<   s     r)   1test_double_with_zero_equivalent_point_non_zero_zz<TestJacobi.test_double_with_zero_equivalent_point_non_zero_zl   rS   r+   c                     t        j                  t              }|j                         }| j	                  ||       | j	                  ||       y r-   r?   r&   r(   pas      r)   test_compare_with_affine_pointz)TestJacobi.test_compare_with_affine_points   s=    $$]3\\^R R r+   c                 t    t        t        ddd      }|j                         }| j                  |t               y rM   )r	   r   r@   r"   r
   rW   s      r)   test_to_affine_with_zero_pointz)TestJacobi.test_to_affine_with_zero_pointz   s+    Aq!,\\^b(#r+   c                     t        j                  t              }|j                         }||z   }| j	                  ||j                                y r-   r	   r.   r   r@   r    rE   r&   r(   rX   ss       r)   test_add_with_affine_pointz%TestJacobi.test_add_with_affine_point   <    $$]3\\^GBIIK(r+   c                     t        j                  t              }|j                         }||z   }| j	                  ||j                                y r-   r]   r^   s       r)   test_radd_with_affine_pointz&TestJacobi.test_radd_with_affine_point   ra   r+   c                 l    t        j                  t              }|t        z   }| j	                  ||       y r-   )r	   r.   r   r
   r    )r&   r(   r_   s      r)   test_add_with_infinityz!TestJacobi.test_add_with_infinity   s+    $$]3MBr+   c                     t        j                  t              j                         }t        t        ddd      }||z   }| j                  ||       y rM   )r	   r.   r   r@   r   r"   )r&   rX   r(   r_   s       r)   test_add_zero_point_to_affinez(TestJacobi.test_add_zero_point_to_affine   sB    $$]3==?Aq!,Gar+   c                 l    t        j                  t              }|dz  }| j                  |t               y rM   )r	   r.   r   r"   r
   r<   s     r)   test_multiply_by_zeroz TestJacobi.test_multiply_by_zero   s)    $$]3!Vb(#r+   c                 ^    t        t        ddd      }|dz  }| j                  |t               y rH   )r	   r   r"   r
   r<   s     r)   test_zero_point_multiply_by_onez*TestJacobi.test_zero_point_multiply_by_one   s)    Aq!,!Vb(#r+   c                 
   t        j                  t              }t        dz  }|dz  }| j                  |j	                         |j	                                | j                  |j                         |j                                y Nr   r	   r.   r   r    r$   r%   rA   s      r)   test_multiply_by_onezTestJacobi.test_multiply_by_one   ]    $$]3Q!V((r+   c                 
   t        j                  t              }t        dz  }|dz  }| j                  |j	                         |j	                                | j                  |j                         |j                                y Nr   rn   rA   s      r)   test_multiply_by_twozTestJacobi.test_multiply_by_two   rp   r+   c                 v    t        j                  t              }t        dz  }d|z  }| j                  ||       y rr   r	   r.   r   r    rA   s      r)   test_rmul_by_twozTestJacobi.test_rmul_by_two   s5    $$]3QVR r+   c                 b    t        j                  t              }| j                  |t               y r-   )r	   r.   r   r6   r
   r<   s     r)   #test_compare_non_zero_with_infinityz.TestJacobi.test_compare_non_zero_with_infinity   s"    $$]3B)r+   c                 T    t        t        ddd      }| j                  |t               y )Nr   r   r	   r   r    r
   r<   s     r)   -test_compare_non_zero_bad_scale_with_infinityz8TestJacobi.test_compare_non_zero_bad_scale_with_infinity   s"    Aq!,X&r+   c                     t        ddd      }t        |ddd      }| j                  |j                  dd             | j	                  |t
               y N   r   r   r   r	   
assertTruecontains_pointr6   r
   r&   c_23r(   s      r)   "test_eq_x_0_on_curve_with_infinityz-TestJacobi.test_eq_x_0_on_curve_with_infinity   I    r1a q!Q'++Aq12B)r+   c                     t        ddd      }t        |ddd      }| j                  |j                  dd             | j	                  |t
               y )Nr~   r   r   r   r   r   s      r)   "test_eq_y_0_on_curve_with_infinityz-TestJacobi.test_eq_y_0_on_curve_with_infinity   r   r+   c                 z    t        ddd      }t        |ddd      }t        |ddd      }| j                  ||       y )Nr~   r   r      )r   r	   r6   )r&   r   r2   r3   s       r)   test_eq_with_same_x_different_yz*TestJacobi.test_eq_with_same_x_different_y   s@    r1a $2q)$1a(C%r+   c                 T    t        t        ddd      }| j                  |t               y rM   rz   r<   s     r)   %test_compare_zero_point_with_infinityz0TestJacobi.test_compare_zero_point_with_infinity   s"    Aq!,X&r+   c                     t        j                  t              }|j                         }|dz  }| j	                  ||       y rr   )r	   r.   r   rE   r    )r&   r(   dblmlpls       r)   !test_compare_double_with_multiplyz,TestJacobi.test_compare_double_with_multiply   s6    $$]3iikAvd#r+   r   r   )	min_value	max_valuec                 &   t        j                  t              }|j                         |z  }||z  }| j	                  |j                         |j                         f|j                         |j                         f       | j	                  ||       y r-   )r	   r.   r   r@   r    r$   r%   )r&   mulr(   rB   s       r)   test_multiplicationszTestJacobi.test_multiplications   sp     $$%>?\\^c!#X"$$&"$$&)BDDFBDDF+;<R r+   c                     t         }| j                  |j                         t        j                  t               }||z  }||z  }| j                  ||       y r-   )r   r   _PointJacobi__precomputer	   r.   r    )r&   r   precompr(   abs         r)   test_precomputezTestJacobi.test_precompute  sN     ,889$$%>?cMHAr+   r   c                     t        j                  t              }t        j                  ||z        }t        j                  ||z        }||z   }| j                  ||||z   z         y r-   )r	   r.   r   r    )r&   a_mulb_mulj_gr   r   cs          r)   test_add_scaled_pointsz!TestJacobi.test_add_scaled_points  s_     %%&?@##C%K0##C%K0EC55=12r+   c                    t        j                  t              }t        j                  ||z        }t        j                  ||z        }t        j                         }t        t        ||             ||z  |z  }t        t        |j                         |z  |z  |j                         |z  |z  |z  |      }||z   }	| j                  |	|||z   z         y r-   
r	   r.   r   r   rQ   r   r   r$   r%   r    
r&   r   r   new_zr   r   r   rQ   new_zzr   s
             r)   test_add_one_scaled_pointz$TestJacobi.test_add_one_scaled_point(  s     %%&?@##C%K0##C%K0!##%{5!$%"!CCEFNQCCEFNU"Q&	
 EC55=12r+   r   c                 &   t        j                  t              }t        j                  ||z        }t        j                  ||z        }t        j                         }t        t        ||             ||z  |z  }t        t        |j                         |z  |z  |j                         |z  |z  |z  |      }t        t        |j                         |z  |z  |j                         |z  |z  |z  |      }||z   }	| j                  |	|||z   z         y r-   r   r   s
             r)   test_add_same_scale_pointsz%TestJacobi.test_add_same_scale_pointsH  s      %%&?@##C%K0##C%K0!##%{5!$%"!CCEFNQCCEFNU"Q&	
 !CCEFNQCCEFNU"Q&	
 EC55=12r+   c                    t         }t        j                         }|dz  }|j                          d}t	        t        |j                         |dz  z  |z  |j                         |dz  z  |z  |      }t	        t        |j                         |dz  z  |z  |j                         |dz  z  |z  |      }||z   }| j                  |||z          y )N      r   r   r   r   rQ   scaler	   r$   r%   r    )r&   r   rQ   r   z1r$   r%   r   s           r)   !test_add_same_scale_points_staticz,TestJacobi.test_add_same_scale_points_statics  s    '!##%"H		!CCEBEMACCEBEMA	
 !CCEBEMACCEBEMA	
 EAE"r+   T)min_sizemax_sizeuniquec                    t        j                  t              }t        j                  ||z        }t        j                  ||z        }t        j                         }t        t        |d   |             t        t        |d   |             |d   |d   z  |z  }|d   |d   z  |z  }	t        t        |j                         |z  |z  |j                         |z  |d   z  |z  |d         }t        t        |j                         |	z  |z  |j                         |	z  |d   z  |z  |d         }||z   }
| j                  |
|||z   z         y rH   r   )r&   r   r   r   r   r   r   rQ   new_zz0new_zz1r   s              r)   test_add_different_scale_pointsz*TestJacobi.test_add_different_scale_points  sG   . %%&?@##C%K0##C%K0!##%{58Q'({58Q'((U1X%)(U1X%)!CCEGOaCCEGOeAh&*!H	
 !CCEGOaCCEGOeAh&*!H	
 EC55=12r+   c                    t         }t        j                         }|dz  }|j                          d}t	        t        |j                         |dz  z  |z  |j                         |dz  z  |z  |      }d}t	        t        |j                         |dz  z  |z  |j                         |dz  z  |z  |      }||z   }| j                  |||z          y )Nr   r   r   r      r   )	r&   r   rQ   r   r   r$   z2r%   r   s	            r)   &test_add_different_scale_points_staticz1TestJacobi.test_add_different_scale_points_static  s    '!##%"H		!CCEBEMACCEBEMA	
 !CCEBEMACCEBEMA	
 EAE"r+   c                    t         }t        j                         }|dz  }|j                          |dz  }d}t	        t        |j                         |dz  z  |z  |j                         |dz  z  |z  |      }t	        t        |j                         |dz  z  |z  |j                         |dz  z  |z  |      }||z   }| j                  |||z          y )Nr      r   r   r   r   )	r&   r   rQ   r   r   r'   r$   r%   r   s	            r)   +test_add_different_points_same_scale_staticz6TestJacobi.test_add_different_points_same_scale_static  s    '!##%"H		"H!CCEAqDL1CCEAqDL1	
 !CCEAqDL1CCEAqDL1	
 EAE"r+   c                 v   t         }t        j                         }d}||z  }|j                          t	        t        |j                         |dz  z  |z  |j                         |dz  z  |z  |      }t	        t        |j                         |j                         d      }||z   }| j                  |||z          y )Nr   r   r   r   )r   r   rQ   r   r	   r$   r%   r    )r&   r   rQ   r'   r   r$   r%   r   s           r)   5test_add_same_point_different_scale_second_z_1_staticz@TestJacobi.test_add_same_point_different_scale_second_z_1_static  s    MMO!G		CCEAqDL1CCEAqDL1	
 CCECCE	
 EAE"r+   c                 .   t         }d}||z  }|j                          | }t        t        |j	                         |j                         d      }t        t        |j	                         |j                         d      }| j                  t        ||z          y )Nr   r   )r   r   r	   r   r$   r%   r    r
   )r&   r   r'   r   r   r$   r%   s          r)   test_add_to_infinity_staticz&TestJacobi.test_add_to_infinity_static  s    !G		BCCECCE	
 CCECCE	
 	1q5)r+   c                 l    t        j                  t              }| j                  |dz  ||z   |z          y )Nr   ru   r&   r   s     r)   test_add_point_3_timesz!TestJacobi.test_add_point_3_times  s.    %%m4q#)c/2r+   c                     t        t        t        j                         t        j                         d      }| j                  |t        j                         z  t               y rm   )r	   r   r   r$   r%   r    r!   r
   r   s     r)   test_mul_without_orderz!TestJacobi.test_mul_without_order#  s>    )]__%68I1M}2244h?r+   c                     t        j                  t              }| j                  ||j	                  dt
        d             y rm   r	   r.   r   r    mul_addr
   r   s     r)   test_mul_add_infzTestJacobi.test_mul_add_inf(  s/    %%m4ckk!Xq9:r+   c                     t        j                  t              }| j                  |dz  |j	                  d|d             y )Nr   r   r	   r.   r   r    r   r   s     r)   test_mul_add_samezTestJacobi.test_mul_add_same-  s3    %%m4q#++aa"89r+   c                 "   t        j                  t        d      }t        j                  |dz  d      }| j                  |dz  ||z          | j                  |dz  |dz  |dz  z          | j                  |dz  |j	                  d|d             y )NT      i     r   r	   r.   r   r    r   r&   r   r   s      r)   test_mul_add_precomputez"TestJacobi.test_mul_add_precompute2  s    %%&?F##C#It4sC!G,,cAgAo>,ckk!Q.BCr+   c                 "   t        j                  t        d      }t        j                  |dz  d      }| j                  |dz  ||z          | j                  |dz  |dz  |dz  z          | j                  |dz  |j	                  d|d             y )NTr   r         r   r   s      r)   test_mul_add_precompute_largez(TestJacobi.test_mul_add_precompute_large:  s    %%&?F##C#It4sC!G,()3<!f*+D	
 	()3;;vq&+I	
r+   c                     t        j                  t              }|dz  }|j                  d|d      }| j	                  ||       y )Nr   r   r   )r	   r.   r   r   r    )r&   r   r   r   s       r)   test_mul_add_to_mulzTestJacobi.test_mul_add_to_mulF  s=    %%m4!GKK3"Ar+   c                     t        j                  t              }|dz  }| j                  |j	                  d|d      |dz         y )Nr   r   r   r   )r&   r   w_as      r)   test_mul_add_differntz TestJacobi.test_mul_add_differntN  s<    %%m4AgQQ/q9r+   c                     t        j                  t              }|dz  }|dz  }| j                  |j	                  d|d      |dz  |dz  z          y )Nr   r   r   r   )r&   r   r   w_bs       r)   test_mul_add_slightly_differentz*TestJacobi.test_mul_add_slightly_differentU  sN    %%m4AgAgQQ/q371BCr+   c                     t        j                  t              }t        dz  }t        dz  }|dz  }|j                  d|d      }| j	                  |j                         ||z          y )Nr   i        r	   r.   r   r   r    r@   r&   r   r   r   j_brets         r)   test_mul_addzTestJacobi.test_mul_add]  s[    %%m4c!{+Djkk#sD)#)4r+   c                     t        j                  t              }t        dz  }t        dz  }|dz  }|j                  d|d      }| j	                  |j                         ||z          y )Nr   r   r   r   r   s         r)   test_mul_add_zerozTestJacobi.test_mul_add_zeroh  s[    %%m4c!x(Djkk#sA&#)4r+   c                    t        j                  t              }t        j                  |dz        }| j                  |dz  ||z          | j                  |dz  |dz  |dz  z          | j                  |dz  |j	                  d|d             y )Nr   r   r   r   r   r   r   s      r)   test_mul_add_largezTestJacobi.test_mul_add_larget  s    %%m4##C#I.sC!G,()3<!f*+D	
 	()3;;vq&+I	
r+   c                     t        j                  t              }t        j                         }t        j                  t        dz        }| j	                  |j                  |dz  ||dz        t               y )Nr   )r	   r.   r   r!   r    r   r
   )r&   r   r!   r   s       r)   $test_mul_add_with_infinity_as_resultz/TestJacobi.test_mul_add_with_infinity_as_result  sZ    %%m4##%##MC$78US[!Uc\BHMr+   c                    t        t        t        j                         t        j                         d      }t        j
                         }t        dz  }|j                          t        t        |j                         |j	                         d      }| j                  |j                  |dz  ||dz        t               y )Nr   "   )
r	   r   r   r$   r%   r!   r   r    r   r
   )r&   r   r!   r   r   s        r)   test_mul_add_without_orderz%TestJacobi.test_mul_add_without_order  s    )]__%68I1M##%b 			3557CEEGQ7URZERK@(Kr+   c                     t        j                  t        dz        }d| z  }| j                  |j	                  d|d      t
               y )N   r   r   r   )r&   r   dbl_negs      r)   ,test_mul_add_with_doubled_negation_of_itselfz7TestJacobi.test_mul_add_with_doubled_negation_of_itself  s?    %%mb&89t*Q3X>r+   i  i  c                     t        j                  t              }t        |z  }|j                  |||      }| j	                  |||z  ||z  z          y r-   )r	   r.   r   r   r    )r&   mul1mul2mul3r2   r3   ress          r)   test_mul_add_randomzTestJacobi.test_mul_add_random  sM     %%o6$kk$T*cDj3:56r+   c                     t        t        dddd      dddd      }t        t        dddd      dddd      }| j                  ||       y Nr~   r   r   r   r#   r$   r%   r'   r!   )r	   r   r    )r&   pj1pj2s      r)   test_equalityzTestJacobi.test_equality  sL    Aq! 4Q!1MAq! 4Q!1Mc"r+   c                 Z    t        j                  t              }| j                  |d       y )Nr   r;   r   s     r)   !test_equality_with_invalid_objectz,TestJacobi.test_equality_with_invalid_object  s"    %%m4C$r+   c                     t        j                  t              }t        j                  t              }| j	                  ||       y r-   )r	   r.   r   r   r6   r1   s      r)   test_equality_with_wrong_curvesz*TestJacobi.test_equality_with_wrong_curves  s2    %%m4%%m4C%r+   c           	          t        t        dddd      dddd      }|j                  ddddddd      \  }}}| j                  |||fd       y )	Nr~   r   r   r   r   r   r   )r   r   r   )r	   r   _addr    )r&   r  r$   r%   r'   s        r)   test_add_with_point_at_infinityz*TestJacobi.test_add_with_point_at_infinity  sU    Aq! 4Q!1M((1aAq!R01a!QI.r+   c                 ^   t        ddd      }t        |ddd      }|j                         }| j                  |j	                         |j                         fd       | j                  |t               |j                         }| j                  |t               | j                  |t               y Nr~   r   r      r   r   )	r   r	   rE   r    r$   r%   r6   r
   r"   r&   r   rQ   p2p3s        r)   test_double_to_infinityz"TestJacobi.test_double_to_infinity  s    r1a b"a(XXZ"$$&"$$&)62B)YY[X&b(#r+   c                     t        ddd      }t        |ddd      }|j                         }| j                  |j	                         |j                         fd       y )Nr~   r   r   	   )r      )r   r	   rE   r    r$   r%   )r&   c_23_2rQ   r  s       r)   test_double_to_x_0zTestJacobi.test_double_to_x_0  sL    Q"1a(XXZ"$$&"$$&)73r+   c                 2   t        ddd      }t        |ddd      }|dz  }| j                  |j                         |j	                         fd       | j                  |t               |dz  }| j                  |t               | j                  |t               y )Nr~   r   r   r  r   r  r   r	   r    r$   r%   r6   r
   r"   r  s        r)   test_mul_to_infinityzTestJacobi.test_mul_to_infinity  s    r1a b"a(U"$$&"$$&)62B)!VX&b(#r+   c                 2   t        ddd      }t        |ddd      }||z   }| j                  |j                         |j	                         fd       | j                  |t               ||z   }| j                  |t               | j                  |t               y r  r  r  s        r)   test_add_to_infinityzTestJacobi.test_add_to_infinity  s    r1a b"a(U"$$&"$$&)62B)"WX&b(#r+   c                     t        ddd      }t        |ddd      }|dz  }| j                  |j                         |j	                         fd       y )Nr~   r   r  r   r   r   r   r   r	   r    r$   r%   r&   r   rQ   r  s       r)   test_mul_to_x_0zTestJacobi.test_mul_to_x_0  sJ    r1a aA&V"$$&"$$&)73r+   c                     t        ddd      }t        |ddd      }|dz  }| j                  |j                         |j	                         fd       y )Nr~   r   r  r      r  r  r   s       r)   test_mul_to_y_0zTestJacobi.test_mul_to_y_0  sJ    r1a aA&V"$$&"$$&)62r+   c                     t        ddd      }t        |ddd      }|dz  |z   }| j                  |j                         |j	                         fd       y )Nr~   r   r  r   r   r  r  r   s       r)   test_add_to_x_0zTestJacobi.test_add_to_x_0  sN    r1a aA&VaZ"$$&"$$&)73r+   c                     t        ddd      }t        |ddd      }|dz  |z   }| j                  |j                         |j	                         fd       y )Nr~   r   r  r   r   r  r  r   s       r)   test_add_to_y_0zTestJacobi.test_add_to_y_0  sN    r1a aA&VaZ"$$&"$$&)62r+   c                 |    t        ddd      }t        |ddd      }|dz  |dz  z   }| j                  |t               y )Nr~   r   r  r   r     )r   r	   r"   r
   )r&   r   rQ   r   s       r)   test_add_diff_z_to_infinityz&TestJacobi.test_add_diff_z_to_infinity  s?    r1a aA&FQUNa"r+   c                     t        t        dddd      dddd      }| j                  t        j                  t        j
                  |            |       y r   )r	   r   r    pickleloadsdumpsr<   s     r)   test_picklezTestJacobi.test_pickle  sA    wr1a3qA!Lfll2&67<r+   PyPyz!threading on PyPy breaks coverage)reasonr   c                 "   t         dz   t         }t        |j                         |j                         |j	                         d|j                         d      }| j                  |j                  g        d }g }t        |      D ])  }|j                  t        j                  ||f             + |D ]  }|j                            ||       |D ]  }|j                           | j                  |j                  t         j                         y )Nr   r   Tc                 `    | j                         }t        d      D ]  }| t        |      z    y )Nr   r!   ranger   	generatorr!   _s      r)   runnerz.TestJacobi.test_multithreading.<locals>.runner  .    OO%E2Y -Ie,,-r+   targetargs)r   r	   r#   r$   r%   r!   r    r   r6  append	threadingThreadstartjoin)r&   
thread_numgenr:  threadsr9  ts          r)   test_multithreadingzTestJacobi.test_multithreading  s     	! #))+suuwCIIKN55r:	-
 z" 	IANN9++6GH	I  	AGGI	 	s 	AFFH	 	((44	
r+   WindowszFthere are no signals on Windows, and threading breaks coverage on PyPyc                 
   d}t         dz   t         }t        |j                         |j                         |j	                         d|j                         d      }| j                  |j                  g        d }d }g }t        |      D ])  }|j                  t        j                  ||f             + t        j                         }|j                          t        j                         }|j                          t        j                         }	|	j                          |j                  t        j                  ||||	f             |D ]  }
|
j                           | j                  t               5  |j                          |j#                           ||       |	j                          d d d        |D ]  }
|
j%                           | j                  |j                  t         j                         y # 1 sw Y   KxY w)Nr   r   r   Tc                 `    | j                         }t        d      D ]  }| t        |      z    y )N2   r5  r7  s      r)   r:  z>TestJacobi.test_multithreading_with_interrupts.<locals>.runnerE  r;  r+   c                     | j                          |j                          t        j                  t        j                         t
        j                         |j                          y r-   )releaseacquireoskillgetpidsignalSIGINT)barrier_startbarrier_end	lock_exits      r)   interrupterzCTestJacobi.test_multithreading_with_interrupts.<locals>.interrupterJ  s>    !!#!GGBIIK/r+   r<  )r   r	   r#   r$   r%   r!   r    r   r6  r?  r@  rA  LockrO  rB  r/   KeyboardInterruptrN  rC  )r&   rD  rE  r:  rX  rF  r9  rU  rV  rW  rG  s              r)   #test_multithreading_with_interruptsz.TestJacobi.test_multithreading_with_interrupts3  s    
! #))+suuwCIIKN55r:	-
	  z" 	IANN9++6GH	I "(nn&NN$	"#[)<	
  	AGGI	 01 	 !!#!3K 	   	AFFH	 	((44	
	  	 s   69G99HN )___name__
__module____qualname__r*   r4   r8   r=   rC   rF   rJ   rN   rR   rU   rY   r[   r`   rc   re   rg   ri   rk   ro   rs   rv   rx   r{   r   r   r   r   r   r   SLOW_SETTINGSr   stintegersintr   r!   r   r   r   r   r   rQ   r   pytestmarkslowr   r   listsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r
  r  r  r  r  r!  r$  r&  r(  r+  r0  NO_OLD_SETTINGSskipifplatformpython_implementationrH  systemr[  r\  r+   r)   r   r   +   sT   $:)
,)$$$$!$)) $$))!*
'**&'
$ 
3'F'@'F'F'H1'L#M	

! ! 
3'F'@'F'F'H1'L#M	

 QZS0*00234 5   
3'F'@'F'F'H1'L#M	
 	3'F'@'F'F'H1'L#M	
	 Q]3  3 
3'F'@'F'F'H1'L#M	
 	3'F'@'F'F'H1'L#M	
 	a3/F/D/F/F/H1/L+MN3 3, [[
3'F'@'F'F'H1'L#M	
 	3'F'@'F'F'H1'L#M	
 	a3/F/D/F/F/H1/L+MN Q1Q1Q3-3359:A>Q3-3359:A>3 ? ?    38#. [[
3'F'@'F'F'H1'L#M	
 	3'F'@'F'F'H1'L#M	
 	BKKs+B+@+B+B+Dq+H'I 	
  QAq6QAq6Q3-3359:QFCQ3-3359:QFC3 D D  !  ,3<#0#0#0*03
@
;
:
D

:D	5
5

N
L? a3/D/D/D/F/J+KLa3/D/D/D/F/J+KLa3/D/D/D/F/J+KL
 S!T7 7#
%
&/$4$$4343#= [[  [[&&&(F22   ;2;;b12
 3	 ! 
@ [[[[Y& 	6)8))+v5  ;
 ;
r+   r   c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
TestZeroCurvez.Tests with curve that has (0, 0) on the curve.c                 (    t        ddd      | _        y r}   )r   r#   r7   s    r)   setUpzTestZeroCurve.setUp{  s    RA&
r+   c                 Z    | j                  | j                  j                  dd             y rM   )r   r#   r   r7   s    r)   test_zero_point_on_curvez&TestZeroCurve.test_zero_point_on_curve~  s    

11!Q78r+   c                     t        | j                  ddd      }|j                         }| j                  |t               | j                  d|j                         |j                         f       y )Nr   r  r   r   r	   r#   rE   r6   r
   r    r$   r%   r&   rQ   ds      r)   test_double_to_0_0_pointz&TestZeroCurve.test_double_to_0_0_point  sQ    

Ar1-HHJAx(!##%0r+   c                     d}t        | j                  d|dz  z  d|dz  z  |      }|j                         }| j                  |t               | j                  d|j                         |j                         f       y )Nr   r   r  r   rt  ru  )r&   r'   rQ   rw  s       r)   'test_double_to_0_0_point_with_non_one_zz5TestZeroCurve.test_double_to_0_0_point_with_non_one_z  sf    

A1Hb1a4i;HHJAx(!##%0r+   c                     t        | j                  ddd      }|dz  }| j                  |t               | j	                  d|j                         |j                         f       y )Nr   r   r   r   rt  )r	   r#   r6   r
   r    r$   r%   rv  s      r)   test_mul_to_0_0_pointz#TestZeroCurve.test_mul_to_0_0_point  sO    

BA.FAx(!##%0r+   c                     t        | j                  ddd      }|j                         }| j                  |t               y rH   )r	   r#   rE   r"   r
   rv  s      r)   test_double_of_0_0_pointz&TestZeroCurve.test_double_of_0_0_point  s/    

Aq!,HHJa"r+   c                     t        | j                  ddd      }t        | j                  dd      }t        d      D ]  }| j	                  ||z  ||z          y )Nr   r   r      )r	   r#   r   r6  r    )r&   rQ   p_cis       r)   "test_compare_to_old_implementationz0TestZeroCurve.test_compare_to_old_implementation  sS    

BA.DJJB'r 	-AQUC!G,	-r+   N)r]  r^  r_  __doc__rp  rr  rx  rz  r|  r~  r  r\  r+   r)   rn  rn  x  s(    8'9111#-r+   rn  )*r-  sys	unittest2unittestImportErrorrP  rS  rd  r@  rj  hypothesis.strategies
strategiesra  
hypothesisr   r   r   r   ellipticcurver   r	   r
   r   ecdsar   r   r   r   r   r   r   numbertheoryr   utilr   rh  version_infor`  argvTestCaser   rn  r\  r+   r)   <module>r     s     
  
     " 7 7 @ @   &  f"&OJ sxx$%M.!$&M.!J
"" J
Z.-H%% .-e  s   B: :	CC