a
    db                     @   s  d dl Z zd dlZW n ey.   d dlZY n0 d dlmZmZ d dlmZ	 zd dlm
Z
 dZW n eyv   dZY n0 ddlmZ ddlmZmZmZ i Zere
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f i eee	jded ddd Z dd Z!e j"j#ddd e$e!edD d d e%d!D d"d#d$ Z&G d%d& d&ej'Z(G d'd( d(ej'Z)dS ))    N)givensettings)HealthCheckTF   )inverse_mod)CurveFpINFINITYPointZsuppress_health_checki  deadline      1(i&^#a;   9{uDjSg9g(B   +' 1t:_|v!a:@m   H<^W]dZ{cxW\Iq          
   Zmax_examples)Z	min_valueZ	max_valuec                 C   s&   t | t}t|  }|| tks"J d S N)r   rp192)multipleZinv_mp1 r   i/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/site-packages/ecdsa/test_ellipticcurve.pytest_p192_mult_tests.   s    
r   c                 c   s,   t }d}||kr(|V  ||  }|d7 }qd S )Nr   r   )r   )Zpointnretir   r   r   add_n_times7   s    r    zp, m, checkc                 C   s   g | ]\}}t ||fqS r   )g_23).0r   expr   r   r   
<listcomp>C       r$      c                 C   s   g | ]}d  |qS )zg_23 test with mult {0})format)r"   r   r   r   r   r$   D   r%   	   )idsc                 C   s   | | |ksJ d S r   r   )pmcheckr   r   r   test_add_and_mult_equivalenceA   s    r-   c                   @   s@   e Zd Zedd Zdd Zdd Zdd Zd	d
 Zdd Z	dS )	TestCurvec                 C   s   t ddd| _d S Nr   r   )r   c_23)clsr   r   r   
setUpClassK   s    zTestCurve.setUpClassc                 C   s   |  | jtddd d S r/   )assertEqualr0   r   selfr   r   r   test_equality_curvesO   s    zTestCurve.test_equality_curvesc                 C   s   t tdt}| | j| d S )Nr   )r   r*   bassertNotEqualr0   )r5   c192r   r   r   test_inequality_curvesR   s    z TestCurve.test_inequality_curvesc                 C   s   | j d i d S r   )r0   r4   r   r   r   ,test_usability_in_a_hashed_collection_curvesV   s    z6TestCurve.test_usability_in_a_hashed_collection_curvesc                 C   s   t | j d S r   )hashr0   r4   r   r   r   test_hashability_curvesY   s    z!TestCurve.test_hashability_curvesc                 C   s   t dddt dddt ddd  }}}t dddt ddd| j  }}}| ttt|||fd | ttt|||fd | td i|d i | ||d i d S )N   r   r         )r   r0   r3   lensetZassertDictEqualZassertIn)r5   Zne1Zne2Zne3Zeq1Zeq2Zeq3r   r   r   test_conflation_curves\   s    ("z TestCurve.test_conflation_curvesN)
__name__
__module____qualname__classmethodr2   r6   r:   r;   r=   rC   r   r   r   r   r.   J   s   
r.   c                   @   s`   e Zd Zedd Zdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd ZdS )	TestPointc                 C   sX   t ddd| _t| jddd| _d}d}d}d}d	}t |d
|| _t| j|||| _d S )Nr   r   r   r   r   r   r   r   r   r   )r   r0   r	   r!   r9   r   )r1   r*   r   r7   GxGyr   r   r   r2   f   s    zTestPoint.setUpClassc                 C   s   d}|| j  }| | d d}|| j  }| | d | | d d}d}|| j  ||  }| | d | | d d S )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   r3   xy)r5   dQkRu1u2tempr   r   r   	test_p192v   s,    

zTestPoint.test_p192c                 C   sD   t }| }| || | | |  | | |  d S r   )r   doubler3   rK   rL   )r5   r   p3r   r   r   test_double_infinity   s
    zTestPoint.test_double_infinityc                 C   sF   d\}}}}t | j||}| }| | | | | | d S )N)   r   r      )r	   r0   rU   r3   rK   rL   )r5   x1y1x3y3r   rV   r   r   r   test_double   s
    zTestPoint.test_doublec                 C   sH   d\}}}}}t | j||}|| }| | | | | | d S )N)rX   r   r?   r   rY   r	   r0   r3   rK   rL   )r5   rZ   r[   r+   r\   r]   r   rV   r   r   r   test_multiply   s
    zTestPoint.test_multiplyc           
      C   sX   d\}}}}}}t | j||}t | j||}|| }	| |	 | | |	 | dS ):We expect that on curve c, (x1,y1) + (x2, y2 ) = (x3, y3).)rX   r   r(   r         Nr_   
r5   rZ   r[   Zx2y2r\   r]   r   p2rV   r   r   r   test_add   s    zTestPoint.test_addc           
      C   sX   d\}}}}}}t | j||}t | j||}|| }	| |	 | | |	 | dS )ra   )rX   r   rX   r   r   rY   Nr_   rd   r   r   r   test_add_as_double   s    zTestPoint.test_add_as_doublec                 C   s   |  | jt| jddd d S )Nr   r   )r3   r!   r	   r0   r4   r   r   r   test_equality_points   s    zTestPoint.test_equality_pointsc                 C   s,   t ddd}t|ddd}| | j| d S Nd   r   )r   r	   r8   r!   )r5   cr*   r   r   r   test_inequality_points   s    z TestPoint.test_inequality_pointsc                 C   s   t ddd}| | j| d S rj   )r   r8   r!   )r5   rl   r   r   r   !test_inequality_points_diff_types   s    z+TestPoint.test_inequality_points_diff_typesN)rD   rE   rF   rG   r2   rT   rW   r^   r`   rg   rh   ri   rm   rn   r   r   r   r   rH   e   s   


rH   )*ZpytestZ	unittest2ZunittestImportErrorZ
hypothesisr   r   Zhypothesis.strategies
strategiesstr   Z
HC_PRESENTZnumbertheoryr   Zellipticcurver   r   r	   ZHYP_SETTINGSZtoo_slowr*   r   r7   rI   rJ   r9   r   r0   r!   dictZHYP_SLOW_SETTINGSZintegersr   r    markZparametrize	enumerateranger-   ZTestCaser.   rH   r   r   r   r   <module>   sP   


