
    tZh^"              
       "   d dl Z 	 d dlZd dlmZmZ d dlmZ	 	 d dlm
Z
 dZddlmZ ddlmZmZmZmZ i Zere
j(                  ged	<   d
ed<   dZdZdZdZdZ eede      Z eeeee      Z eddd      Z eeddd      Z ee      Zded<    ed&i e e e	j@                  dedz
              d               Z!d Z"e jF                  jI                  d e% e"ed            D  cg c]
  \  } }e| |f c}}  e&d      D cg c]  }djO                  |       c}      d        Z( G d  d!ejR                        Z* G d" d#ejR                        Z+ G d$ d%ejR                        Z,y# e$ r d dlZY jw xY w# e$ r dZY aw xY wc c}} w c c}w )'    N)givensettings)HealthCheckTF   )inverse_mod)CurveFpINFINITYPoint	CurveEdTwsuppress_health_checki  deadline      1(i&^#a;   9{uDjSg9g(B   +' 1t:_|v!a:@m   H<^W]dZ{cxW\Iq             max_examples)	min_value	max_valuec                 R    t        | t              }t        | z  }||z  t        k(  sJ y N)r   rp192)multipleinv_mp1s      t/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/ecdsa/test_ellipticcurve.pytest_p192_mult_testsr#   .   s+     !$E	B:    c              #   P   K   t         }d}||k  r| || z   }|dz  }||k  ry y w)Nr   r   )r	   )pointnretis       r"   add_n_timesr*   7   s7     
C	A
q&	Ek	Q q&s   !&&zp, m, check   	   zg_23 test with mult {0})idsc                     | |z  |k(  sJ y r    )pmchecks      r"   test_add_and_mult_equivalencer3   A   s     q5E>>r$   c                   L    e Zd Zed        Zd Zd Zd Zd Zd Z	d Z
d Zd	 Zy
)	TestCurvec                 (    t        ddd      | _        y Nr   r   )r   c_23clss    r"   
setUpClasszTestCurve.setUpClassK   s    2q!$r$   c                 R    | j                  | j                  t        ddd             y r7   )assertEqualr8   r   selfs    r"   test_equality_curveszTestCurve.test_equality_curvesO   s    GB1$56r$   c                 f    t        t        dt              }| j                  | j                  |       y )Nr   )r   r0   bassertNotEqualr8   )r?   c192s     r"   test_inequality_curvesz TestCurve.test_inequality_curvesR   s$    q"a DIIt,r$   c                 \    t        ddd      }t        ddd      }| j                  ||       y )Nr   r   r   )r   rC   )r?   arB   s      r"    test_inequality_curves_by_b_onlyz*TestCurve.test_inequality_curves_by_b_onlyV   s.    B1B1Aq!r$   c                      | j                   d i y r   r8   r>   s    r"   ,test_usability_in_a_hashed_collection_curvesz6TestCurve.test_usability_in_a_hashed_collection_curves[       	Dr$   c                 .    t        | j                         y r   hashr8   r>   s    r"   test_hashability_curvesz!TestCurve.test_hashability_curves^       TYYr$   c           
         t        ddd      t        ddd      t        ddd      }}}t        ddd      t        ddd      | j                  }}}| j                  t        t	        t        |||f            d       | j                  t        t	        t        |||f            d       | j                  t        d i|d i       | j                  ||d i       y )N   r   r   r      )r   r8   r=   lensetassertDictEqualassertIn)r?   ne1ne2ne3eq1eq2eq3s          r"   test_conflation_curvesz TestCurve.test_conflation_curvesa   s    Aq)72q!+<gb!Q>O#SAq)72q!+<dii#SS$S#!678!<S$S#!678!<dD\C;7cC;'r$   c                 N    | j                  t        | j                        d       y )NzCurveFp(p=23, a=1, b=1)r=   strr8   r>   s    r"   test___str__zTestCurve.test___str__i   s    TYY)BCr$   c                 V    t        dddd      }| j                  t        |      d       y )Nr   r   rT   zCurveFp(p=23, a=1, b=1, h=4))r   r=   rb   r?   cs     r"   test___str___with_cofactorz$TestCurve.test___str___with_cofactorl   s'    B1a Q!?@r$   N)__name__
__module____qualname__classmethodr;   r@   rE   rH   rK   rP   r_   rc   rg   r/   r$   r"   r5   r5   J   s>    % %7-"
(DAr$   r5   c                   4    e Zd Zed        Zd Zd Zd Zd Zy)TestCurveEdTwc                 (    t        ddd      | _        y r7   )r   r8   r9   s    r"   r;   zTestCurveEdTw.setUpClassr   s    RA&r$   c                 N    | j                  t        | j                        d       y )NzCurveEdTw(p=23, a=1, d=1)ra   r>   s    r"   rc   zTestCurveEdTw.test___str__v   s    TYY)DEr$   c                 V    t        dddd      }| j                  t        |      d       y )Nr   r   rT   zCurveEdTw(p=23, a=1, d=1, h=4))r   r=   rb   re   s     r"   rg   z(TestCurveEdTw.test___str___with_cofactory   s'    b!Q"Q!ABr$   c                      | j                   d i y r   rJ   r>   s    r"   rK   z:TestCurveEdTw.test_usability_in_a_hashed_collection_curves}   rL   r$   c                 .    t        | j                         y r   rN   r>   s    r"   rP   z%TestCurveEdTw.test_hashability_curves   rQ   r$   N)	rh   ri   rj   rk   r;   rc   rg   rK   rP   r/   r$   r"   rm   rm   q   s*    ' 'FCr$   rm   c                       e Zd Ze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y)	TestPointc                     t        ddd      | _        t        | j                  ddd      | _        d}d}d}d}d	}t        |d
|      | _        t        | j                  |||      | _        y )Nr   r   r   r   r   r   r   r   r   r   )r   r8   r
   g_23rD   r   )r:   r0   r   rB   GxGys         r"   r;   zTestPoint.setUpClass   si    2q!$2q!,FF ???1b!$2r1-r$   c                    d}|| j                   z  }| j                  |j                         d       d}|| j                   z  }| j                  |j                         d       | j                  |j                         d       d}d}|| j                   z  ||z  z   }| j                  |j                         d       | j                  |j                         d       y )Nl   uH=.t.#",W}7?jl   Z`uSG;R-]]0sk	+l   N/vZL_~XXw]ol   ~n&DJ,6'1a47b?`l   5XD+8n#w}rO	l   WTY>n+BtC*Yql   !M_JT96wfF[,z=)r   r=   xy)r?   dQkRu1u2temps           r"   	test_p192zTestPoint.test_p192   s     F		MCCEE	
 G		MCCEE	
 	CCEE	
 HGDII~Q&FFHH	
 	FFHH	
r$   c                    t         }|j                         }| j                  ||       | j                  |j                         |j                                | j                  |j	                         |j	                                y r   )r	   doubler=   rz   r{   )r?   r!   p3s      r"   test_double_infinityzTestPoint.test_double_infinity   sZ    YY[R ((r$   c                     d\  }}}}t        | j                  ||      }|j                         }| j                  |j	                         |       | j                  |j                         |       y )N)   
   r      )r
   r8   r   r=   rz   r{   )r?   x1y1x3y3r!   r   s          r"   test_doublezTestPoint.test_double   sX    'BB499b"%YY[$$r$   c                 V   t        | j                  dd      }|j                         }| j                  |j	                         |j                         fd       | j                  |t               |j                         }| j                  |t               | j                  |t               y N      rT   r   )	r
   r8   r   r=   rz   r{   rC   r	   assertIsr?   r!   p2r   s       r"   test_double_to_infinityz!TestPoint.test_double_to_infinity   sy    499b"%YY["$$&"$$&)62B)YY[X&b(#r$   c                 *   t        | j                  dd      }||z   }| j                  |j                         |j	                         fd       | j                  |t               ||z   }| j                  |t               | j                  |t               y r   r
   r8   r=   rz   r{   rC   r	   r   r   s       r"   test_add_self_to_infinityz#TestPoint.test_add_self_to_infinity   su    499b"%"W"$$&"$$&)62B)"WX&b(#r$   c                 *   t        | j                  dd      }|dz  }| j                  |j                         |j	                         fd       | j                  |t               |dz  }| j                  |t               | j                  |t               y )Nr   r   r   r   r   r   s       r"   test_mul_to_infinityzTestPoint.test_mul_to_infinity   su    499b"%!V"$$&"$$&)62B)!VX&b(#r$   c                     d\  }}}}}t        | j                  ||      }||z  }| j                  |j                         |       | j                  |j	                         |       y )N)r   r   r   r   r   r
   r8   r=   rz   r{   )r?   r   r   r1   r   r   r!   r   s           r"   test_multiplyzTestPoint.test_multiply   sY    -B2r499b"%!V$$r$   c                     d\  }}}}}}t        | j                  ||      }t        | j                  ||      }||z   }	| j                  |	j                         |       | j                  |	j	                         |       y):We expect that on curve c, (x1,y1) + (x2, y2 ) = (x3, y3).)r   r   r,   r      r   Nr   
r?   r   r   x2y2r   r   r!   r   r   s
             r"   test_addzTestPoint.test_add   o     "7BBB499b"%499b"%"W$$r$   c                     d\  }}}}}}t        | j                  ||      }t        | j                  ||      }||z   }	| j                  |	j                         |       | j                  |	j	                         |       y)r   )r   r   r   r   r   r   Nr   r   s
             r"   test_add_as_doublezTestPoint.test_add_as_double   r   r$   c           	      h    | j                  | j                  t        | j                  ddd             y )Nr   r   )r=   rv   r
   r8   r>   s    r"   test_equality_pointszTestPoint.test_equality_points   s%    E$))RA$>?r$   c                 r    t        ddd      }t        |ddd      }| j                  | j                  |       y Nd   r   )r   r
   rC   rv   )r?   rf   r0   s      r"   test_inequality_pointsz TestPoint.test_inequality_points   s4    CS!!S#s#DIIq)r$   c                 V    t        ddd      }| j                  | j                  |       y r   )r   rC   rv   re   s     r"   !test_inequality_points_diff_typesz+TestPoint.test_inequality_points_diff_types   s$    CS!DIIq)r$   c                     t        | j                  dd      }t        | j                  dd      }| j                  ||       y )N   rT      )r
   r8   rC   )r?   r!   r   s      r"   test_inequality_diff_yz TestPoint.test_inequality_diff_y  s6    499a#499a$B#r$   c                     t        | j                  dd      }| j                  |t        j                  | j                  |j	                                      y Nr   r   )r
   r8   r=   
from_bytesto_bytesr?   r0   s     r"   test_to_bytes_from_bytesz"TestPoint.test_to_bytes_from_bytes	  s;    $))Q#E,,TYY

EFr$   c                 f    t        | j                  dd      }| j                  t        || z          y r   )r
   r8   r=   r	   r   s     r"   test_add_to_neg_selfzTestPoint.test_add_to_neg_self  s*    $))Q#18,r$   c                 d    t        | j                  dd      }| j                  ||t        z          y r   )r
   r8   r   r	   r   s     r"   test_add_to_infinityzTestPoint.test_add_to_infinity  s&    $))Q#aX&r$   c                 >    | j                  t        t        dz         y )Nr   )r   r	   r>   s    r"   test_mul_infinity_by_scalarz%TestPoint.test_mul_infinity_by_scalar  s    h2.r$   c                 d    t        | j                  dd      }| j                  |dz  | dz         y )Nr   r      )r
   r8   r=   r   s     r"   test_mul_by_negativezTestPoint.test_mul_by_negative  s.    $))Q#R1"*r$   c                 B    | j                  t        t              d       y )Ninfinity)r=   rb   r	   r>   s    r"   test_str_infinityzTestPoint.test_str_infinity   s    X
3r$   c                 h    t        | j                  dd      }| j                  t        |      d       y )Nr   r   z(3,10))r
   r8   r=   rb   r   s     r"   test_str_pointzTestPoint.test_str_point#  s(    $))Q#Q*r$   N)rh   ri   rj   rk   r;   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r/   r$   r"   rt   rt      sz    . .
8)%$$$%%%@*
*$G
-
'
/+
4+r$   rt   r/   )-pytest	unittest2unittestImportError
hypothesisr   r   hypothesis.strategies
strategiesstr   
HC_PRESENTnumbertheoryr   ellipticcurver   r	   r
   r   HYP_SETTINGStoo_slowr0   r   rB   rw   rx   rD   r   r8   rv   dictHYP_SLOW_SETTINGSintegersr#   r*   markparametrize	enumeraterangeformatr3   TestCaser5   rm   rt   )r'   expr)   s   000r"   <module>r      s     ' "&J & > > -8-A-A,BL()#L ?> 777q"aT2r1r1aT2q! & $% . ! 
{r{{Q!a%01 2  "+Ka,@"AB3dAs^B6;Ah?	"	)	)!	,?  

$A!! $ANH%% &b+!! b+    Jj C?s.   E( E8 &FF(	E54E58FF