Ë
    V.jG  ã            	       ó   — d Z ddlZ G d„ de«      Zdedefd„Zdedefd	„Zded
edefd„Zdededej                  eeef   fd„Z	dededefd„Z
dej                  e   dej                  e   defd„Zedk(  rddlZ ej                  «        yy)z/Common functionality shared by several modules.é    Nc                   ó6   ‡ — e Zd Zddededededdf
ˆ fd„Zˆ xZS )	ÚNotRelativePrimeErrorÚaÚbÚdÚmsgÚreturnNc                 ób   •— t         ‰| �  |xs d|||fz  «       || _        || _        || _        y )Nz.%d and %d are not relatively prime, divider=%i)ÚsuperÚ__init__r   r   r   )Úselfr   r   r   r   Ú	__class__s        €úLC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\rsa/common.pyr   zNotRelativePrimeError.__init__   s:   ø€ Ü‰Ñ˜Ò\Ð PÐTUÐWXÐZ[ÐS\Ñ \Ô]ØˆŒØˆŒØˆ�ó    )Ú )Ú__name__Ú
__module__Ú__qualname__ÚintÚstrr   Ú__classcell__)r   s   @r   r   r      s0   ø„ ñ˜#ð  #ð ¨#ð °Cð À÷ ñ r   r   Únumr	   c                 óv   — 	 | j                  «       S # t        $ r}t        dt        | «      z  «      |‚d}~ww xY w)a÷  
    Number of bits needed to represent a integer excluding any prefix
    0 bits.

    Usage::

        >>> bit_size(1023)
        10
        >>> bit_size(1024)
        11
        >>> bit_size(1025)
        11

    :param num:
        Integer value. If num is 0, returns 0. Only the absolute value of the
        number is considered. Therefore, signed integers will be abs(num)
        before the number's bit length is determined.
    :returns:
        Returns the number of bits in the integer.
    z,bit_size(num) only supports integers, not %rN)Ú
bit_lengthÚAttributeErrorÚ	TypeErrorÚtype)r   Úexs     r   Úbit_sizer      s?   € ð,\Ø�~‰~ÓÐøÜò \ÜÐFÌÈcËÑRÓSÐY[Ð[ûð\ús   ‚ ’	8›3³8Únumberc                 ó8   — | dk(  ryt        t        | «      d«      S )a”  
    Returns the number of bytes required to hold a specific long number.

    The number of bytes is rounded up.

    Usage::

        >>> byte_size(1 << 1023)
        128
        >>> byte_size((1 << 1024) - 1)
        128
        >>> byte_size(1 << 1024)
        129

    :param number:
        An unsigned integer
    :returns:
        The number of bytes required to hold a specific long number.
    r   é   é   )Úceil_divr   )r    s    r   Ú	byte_sizer%   8   s    € ð( �‚{ØÜ”H˜VÓ$ aÓ(Ð(r   Údivc                 ó2   — t        | |«      \  }}|r|dz  }|S )av  
    Returns the ceiling function of a division between `num` and `div`.

    Usage::

        >>> ceil_div(100, 7)
        15
        >>> ceil_div(100, 10)
        10
        >>> ceil_div(1, 4)
        1

    :param num: Division's numerator, a number
    :param div: Division's divisor, a number

    :return: Rounded up result of the division between the parameters.
    r"   )Údivmod)r   r&   ÚquantaÚmods       r   r$   r$   Q   s%   € ô$ ˜˜cÓ"�K€FˆCÙ
Ø�!‰ˆØ€Mr   r   r   c                 ó¢   — d}d}d}d}| }|}|dk7  r&| |z  }|| |z  }} |||z  z
  |}}|||z  z
  |}}|dk7  rŒ&|dk  r||z  }|dk  r||z  }| ||fS )z;Returns a tuple (r, i, j) such that r = gcd(a, b) = ia + jbr   r"   © )	r   r   ÚxÚyÚlxÚlyÚoaÚobÚqs	            r   Úextended_gcdr4   i   s˜   € ð 	
€AØ	€AØ	
€BØ	
€BØ	
€BØ	
€BØ
ˆqŠ&Ø�‰FˆØ�Q˜‘UˆAˆØ˜!˜a™%‘L 1ˆBˆØ˜!˜a™%‘L 1ˆBˆð	 ˆq‹&ð
 
ˆA‚vØ
ˆb‰ˆØ	ˆA‚vØ
ˆb‰ˆØˆb�"ˆ9Ðr   r-   Únc                 óJ   — t        | |«      \  }}}|dk7  rt        | ||«      ‚|S )z‘Returns the inverse of x % n under multiplication, a.k.a x^-1 (mod n)

    >>> inverse(7, 4)
    3
    >>> (inverse(143, 4) * 143) % 4
    1
    r"   )r4   r   )r-   r5   ÚdividerÚinvÚ_s        r   Úinverser:   �   s2   € ô % Q¨Ó*Ñ€Wˆc�1à�!‚|Ü# A q¨'Ó2Ð2à€Jr   Úa_valuesÚmodulo_valuesc                 óŒ   — d}d}|D ]  }||z  }Œ	 t        || «      D ]$  \  }}||z  }t        ||«      }|||z  |z  z   |z  }Œ& |S )a…  Chinese Remainder Theorem.

    Calculates x such that x = a[i] (mod m[i]) for each i.

    :param a_values: the a-values of the above equation
    :param modulo_values: the m-values of the above equation
    :returns: x such that x = a[i] (mod m[i]) for each i


    >>> crt([2, 3], [3, 5])
    8

    >>> crt([2, 3, 2], [3, 5, 7])
    23

    >>> crt([2, 3, 0], [7, 11, 15])
    135
    r"   r   )Úzipr:   )	r;   r<   Úmr-   ÚmoduloÚm_iÚa_iÚM_ir8   s	            r   ÚcrtrD   ’   sk   € ð( 	
€AØ	€AãˆØ	ˆV‰‰ð  ô ˜-¨Ö2‰
ˆˆcØ�3‰hˆÜ�c˜3Óˆà��s‘˜S‘Ñ  AÑ%‰ð	 3ð €Hr   Ú__main__)Ú__doc__ÚtypingÚ
ValueErrorr   r   r   r%   r$   ÚTupler4   r:   ÚIterablerD   r   ÚdoctestÚtestmodr,   r   r   Ú<module>rM      së   ðñ 6ã ô˜Jô ð\�#ð \˜#ó \ð8)�cð )˜có )ð2�#ð ˜Cð  Có ð0�Cð ˜Cð  F§L¡L°°c¸3°Ñ$?ó ð0ˆsð �sð ˜só ð" �&—/‘/ #Ñ&ð  °v·±ÀsÑ7Kð  ÐPSó  ðF ˆzÒÛà€G‡O�OÕð r   