
    E#iI              
           S SK Jr  SSKJr  \\\4   rS\S\S\S\4S jrS	 rS
\S\S\S\4S jrS\S\S\4S jr	S\S\S\S\4S jr
S\S\S\S\S\4
S jrg)    )Tuple   igcdexnmpreturnc                 <    [        X5      u  p4nUS:X  d   eX-  U-  $ )zC
Finds a nonnegative integer 0 <= x < p such that (m * x) % p == n
   r   )r   r   r	   abcs         n/home/james-whalen/.local/lib/python3.13/site-packages/ccxt/static_dependencies/starkware/crypto/math_utils.pydiv_modr      s(     QlGA!6M6EQ;    c                 h    [        U [        5      (       a  [        U[        5      (       d   eU * U-  * $ )N)
isinstanceint)xys     r   div_ceilr   !   s/    a*Q"4"444bQY<r   point1point2c                     U S   US   -
  U-  S:w  d   e[        U S   US   -
  U S   US   -
  U5      nX3-  U S   -
  US   -
  U-  nX0S   U-
  -  U S   -
  U-  nXE4$ )z
Gets two points on an elliptic curve mod p and returns their sum.
Assumes the points are given in affine form (x, y) and have different x coordinates.
r   r   r   )r   r   r	   r   r   r   s         r   ec_addr   %   s    
 1Iq	!Q&!+++q	F1I%vay6!9'<a@A	
	VAY	&!+A	
Qi!m	vay	(A-A4Kr   pointc                     U u  p#X#* U-  4$ )z$
Given a point (x,y) return (x, -y)
 )r   r	   r   r   s       r   ec_negr!   1   s     DAax=r   alphac                     U S   U-  S:w  d   e[        SU S   -  U S   -  U-   SU S   -  U5      nX3-  SU S   -  -
  U-  nX0S   U-
  -  U S   -
  U-  nXE4$ )z
Doubles a point on an elliptic curve with the equation y^2 = x^3 + alpha*x + beta mod p.
Assumes the point is given in affine form (x, y) and has y != 0.
r   r   r      r   )r   r"   r	   r   r   r   s         r   	ec_doubler%   9   s    
 8a<1E!HuQx'%/U1XqAA	
U1X	"A	
Ahl	eAh	&!+A4Kr   c                     U S:X  a  U$ U S-  S:X  a  [        U S-  [        XU5      X#5      $ [        [        U S-
  XU5      X5      $ )z
Multiplies by m a point on the elliptic curve with equation y^2 = x^3 + alpha*x + beta mod p.
Assumes the point is given in affine form (x, y) and that 0 < m < order(point).
r   r$   r   )ec_multr%   r   )r   r   r"   r	   s       r   r'   r'   E   sO    
 	Av1uzqAvyq95DD'!a%q15<<r   N)typingr   sympy.core.intfuncr   r   ECPointr   r   r   r!   r%   r'   r    r   r   <module>r+      s   $  ( S/s s s s 	7 	G 	 	 	' c g 	W 	S 	S 	W 		=s 	=7 	=3 	=3 	=7 	=r   