+
    ^eòjk,  ã                   ó†   € R t ^ RIHt ^ RIHt ^ RIHt ^ t^tRR lt	R t
^ RIHt ]! ]R,          4      tRR	 ltR
 tR tR# )zHFunctions to create and test prime numbers.

:undocumented: __package__
)ÚRandom)ÚInteger)Ú
iter_rangeNc                óì  € \        V \        4      '       g   \        V 4      p V R9   d   \        # V P                  4       '       d   \        # \        ^4      p\        V ^,
          4      pVf    \
        P                  ! 4       P                  p\        V4      p^ pVP                  4       '       d   V^,          pV^,          pK*  \        V4       FŸ  p^pWƒV39   d>   \        P                  ! ^V ^,
          VR7      p^Tu;8:  d   V ^,
          8:  d   K@  Q h Q h\        W…V 4      p	W“V39   d   K`  \        ^V4       F)  p
\        V	^V 4      p	W”8X  d    K…  W“8X  g   K!  \        u u # 	  \        u # 	  \        # )a  Perform a Miller-Rabin primality test on an integer.

The test is specified in Section C.3.1 of `FIPS PUB 186-4`__.

:Parameters:
  candidate : integer
    The number to test for primality.
  iterations : integer
    The maximum number of iterations to perform before
    declaring a candidate a probable prime.
  randfunc : callable
    An RNG function where bases are taken from.

:Returns:
  ``Primality.COMPOSITE`` or ``Primality.PROBABLY_PRIME``.

.. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
)Úmin_inclusiveÚmax_inclusiveÚrandfunc©é   é   é   é   )Ú
isinstancer   ÚPROBABLY_PRIMEÚis_evenÚ	COMPOSITEr   ÚnewÚreadr   Úrandom_rangeÚpow)Ú	candidateÚ
iterationsr   ÚoneÚ	minus_oneÚmÚaÚiÚbaseÚzÚjs   &&&        ÚŒ/opt/data/installs/351f81cc06284494/environments/aa258815729c481f8402f54f4c368f83/venv/lib/python3.14/site-packages/Crypto/Math/Primality.pyÚmiller_rabin_testr!   -   sX  € ô( �i¤×)Ò)Ü˜IÓ&ˆ	à�LÔ ÜÐà×Ñ×ÒÜÐä
�!‹*€CÜ˜	 A�Ó&€IàÒÜ—:’:“<×$Ñ$ˆô 	�	Ó€AØ	€AØ
�)‰)�+Š+Ø	ˆa�ˆØ	ˆQ�Šô
 ˜
Ö#ˆð ˆØ˜IÐ&Ô&Ü×'Ò'°aØ"+¨a¥-Ø%ô'ˆDð ˜Ö- 	¨A¥Ö-Ð.Ñ-Ð.Ð-ô �˜Ó#ˆØ�iÐ Ô Ùô ˜A˜qÖ!ˆAÜ�A�q˜)Ó$ˆAØŒ~ÚØŽxÜ Ô ñ "ô Òñ/ $ô4 Ðó    c                óþ  € \        V \        4      '       g   \        V 4      p V R9   d   \        # V P                  4       '       g   V P	                  4       '       d   \
        # R pV! 4        F<  pWV) 39   d   K  \        P                  ! W 4      pV^ 8X  d	   \
        u # VR8X  g   K<   M	  V ^,           pVP                  4       ^,
          p\        ^4      p\        ^4      p\        ^ 4      p\        ^ 4      p	\        V^,
          RR4       EF\  p
VP                  V4       W‡,          pW€,          pV	P                  V4       W–,          p	V	X,          p	V	P                  Ww4       V	P                  4       '       d	   W�,          p	V	^,          p	W�,          p	VP                  V
4      '       d�   VP                  V4       Wi,          pVP                  4       '       d	   W`,          pV^,          pW`,          pVP                  V	4       VP                  W‚4       VP                  4       '       d	   Wp,          pV^,          pWp,          pEK:  VP                  V4       VP                  V	4       EK_  	  V^ 8X  d   \        # \
        # )a?  Perform a Lucas primality test on an integer.

The test is specified in Section C.3.3 of `FIPS PUB 186-4`__.

:Parameters:
  candidate : integer
    The number to test for primality.

:Returns:
  ``Primality.COMPOSITE`` or ``Primality.PROBABLY_PRIME``.

.. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
c               3   óV   "  € ^p  V x € V ^ 8”  d   V ^,          p M	V ^,          p V ) p K$  5i)r   © )Úvalues    r    Ú	alternateÚlucas_test.<locals>.alternate�   s2   é € ØˆØØŠKØ�qŒyØ˜•
‘à˜•
�Ø�FŠEùs   ‚')r	   éÿÿÿÿ)r   r   r   r   Úis_perfect_squarer   Újacobi_symbolÚsize_in_bitsr   ÚsetÚmultiply_accumulateÚis_oddÚget_bit)r   r'   ÚDÚjsÚKÚrÚU_iÚV_iÚU_tempÚV_tempr   s   &          r    Ú
lucas_testr9   w   s  € ô �i¤×)Ò)Ü˜IÓ&ˆ	ð �LÔ ÜÐØ×Ñ×Ò˜i×9Ñ9×;Ò;ÜÐòñ Ž[ˆØ˜Q˜B˜ÔÙÜ×"Ò" 1Ó0ˆØ�Œ7ÜÒØ�Ž8Ùñ ð 	�A�€Aà	�‰Ó˜1Õ€Aô �!‹*€CÜ
�!‹*€CÜ�Q‹Z€FÜ�Q‹Z€Fä˜˜A�˜r 2×&ˆð 	�
‰
�3ŒØ�ˆØÕˆà�
‰
�3ŒØ�ˆØ�!�ˆØ×"Ñ" 3Ô,Ø�=‰=�?Š?ØÕˆFØ�1�ˆØÕˆà�9‰9�Q�<Š<à�G‰G�FŒOØ�MˆCØ�z‰z�|Š|ØÕ �Ø�A�IˆCØÕˆCà�G‰G�FŒOØ×#Ñ# FÔ.Ø�z‰z�|Š|ØÕ �Ø�A�IˆCØÕ‹Cà�G‰G�FŒOØ�G‰G�F�OñC 'ðF ˆa„xÜÐÜÐr"   )Ú
sieve_base:Néd   Nc                ó6  a€ Vf    \         P                  ! 4       P                  p\        V \        4      '       g   \	        V 4      p \        V 4      \        9   d   \        #  \        V P                  \        4       RpT P                  4       o \        \        T3R lT4      4      ^ ,          ^,          p\!        YTR7      \        8X  d   \        # \#        T 4      \        8X  d   \        # \        #   \         d
    \        u # i ; i  \         d    ^p Lbi ; i)a°  Test if a number is prime.

A number is qualified as prime if it passes a certain
number of Miller-Rabin tests (dependent on the size
of the number, but such that probability of a false
positive is less than 10^-30) and a single Lucas test.

For instance, a 1024-bit candidate will need to pass
4 Miller-Rabin tests.

:Parameters:
  candidate : integer
    The number to test for primality.
  randfunc : callable
    The routine to draw random bytes from to select Miller-Rabin bases.
:Returns:
  ``PROBABLE_PRIME`` if the number if prime with very high probability.
  ``COMPOSITE`` if the number is a composite.
  For efficiency reasons, ``COMPOSITE`` is also returned for small primes.
c                 ó   <€ SV ^ ,          8  # )é    r%   )ÚxÚbit_sizes   &€r    Ú<lambda>Ú%test_probable_prime.<locals>.<lambda>  s   ø€ ¨h¸¸1½ªor"   ©r   )
)éÜ   é   )i  é   )i†  é   )i   é
   )il  é   )iä  é   )iz  r   )i°  é   )i¤  r   )it  r   )r   r   r   r   r   ÚintÚ_sieve_baser   ÚmapÚfail_if_divisible_byÚ
ValueErrorr   r,   ÚlistÚfilterÚ
IndexErrorr!   r9   )r   r   Ú	mr_rangesÚmr_iterationsr@   s   &&  @r    Útest_probable_primerV   Þ   s  ø€ ð, ÒÜ—:’:“<×$Ñ$ˆä�i¤×)Ò)Ü˜IÓ&ˆ	ô ˆ9ƒ~œÔ$ÜÐðÜˆI×*Ñ*¬KÔ8ð'€Ið ×%Ñ%Ó'€HðÜœVÔ$=Ø$-ó/ó 0Ø01õ3Ø34õ6ˆô
 ˜Ø"*ô,Ü/8ô9äÐÜ�)Ó¤	Ô)ÜÐÜÐøô- ô ÜÒðûô ô ØŠðús$   Á!C1 Â'D Ã1DÄDÄDÄDc                 óæ  € V P                  RR4      pV P                  RR4      pV P                  RR 4      pV '       d!   \        RV P                  4       ,           4      hVf   \        R4      hV^ 8  d   \        R4      hVf    \        P                  ! 4       P
                  p\        pV\        8X  d=   \        P                  ! VVR	7      ^,          pV! V4      '       g   K:  \        WR4      pKG  X# )
a  Generate a random probable prime.

The prime will not have any specific properties
(e.g. it will not be a *strong* prime).

Random numbers are evaluated for primality until one
passes all tests, consisting of a certain number of
Miller-Rabin tests with random bases followed by
a single Lucas test.

The number of Miller-Rabin iterations is chosen such that
the probability that the output number is a non-prime is
less than 1E-30 (roughly 2^{-100}).

This approach is compliant to `FIPS PUB 186-4`__.

:Keywords:
  exact_bits : integer
    The desired size in bits of the probable prime.
    It must be at least 160.
  randfunc : callable
    An RNG function where candidate primes are taken from.
  prime_filter : callable
    A function that takes an Integer as parameter and returns
    True if the number can be passed to further primality tests,
    False if it should be immediately discarded.

:Return:
    A probable prime in the range 2^exact_bits > p > 2^(exact_bits-1).

.. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
Ú
exact_bitsNr   Úprime_filterc                 ó   € R # )Tr%   )r?   s   &r    rA   Ú)generate_probable_prime.<locals>.<lambda><  s   € ¹r"   úUnknown parameters: zMissing exact_bits parameterzPrime number is not big enough.©rX   r   )
ÚpoprP   Úkeysr   r   r   r   r   ÚrandomrV   )ÚkwargsrX   r   rY   Úresultr   s   ,     r    Úgenerate_probable_primerc     sÒ   € ðD —‘˜L¨$Ó/€JØ�z‰z˜* dÓ+€HØ—:‘:˜n©nÓ=€LßÜÐ/°&·+±+³-Õ?Ó@Ð@àÒÜÐ7Ó8Ð8Ø�CÔÜÐ:Ó;Ð;àÒÜ—:’:“<×$Ñ$ˆä€FØ
”IÔ
Ü—N’N¨jØ,4ô6Ø89õ:ˆ	á˜I×&Ò&ÙÜ$ YÓ9ŠØÐr"   c                 ó˜  € V P                  RR4      pV P                  RR4      pV '       d!   \        RV P                  4       ,           4      hVf    \        P                  ! 4       P
                  p\        pV\        8X  dJ   \        V^,
          VR7      pV^,          ^,           pVP                  4       V8w  d   KF  \        WRR7      pKT  X# )as  Generate a random, probable safe prime.

Note this operation is much slower than generating a simple prime.

:Keywords:
  exact_bits : integer
    The desired size in bits of the probable safe prime.
  randfunc : callable
    An RNG function where candidate primes are taken from.

:Return:
    A probable safe prime in the range
    2^exact_bits > p > 2^(exact_bits-1).
rX   Nr   r\   r]   rC   )
r^   rP   r_   r   r   r   r   rc   r,   rV   )ra   rX   r   rb   Úqr   s   ,     r    Úgenerate_probable_safe_primerf   R  s£   € ð  —‘˜L¨$Ó/€JØ�z‰z˜* dÓ+€HßÜÐ/°&·+±+³-Õ?Ó@Ð@àÒÜ—:’:“<×$Ñ$ˆä€FØ
”IÔ
Ü#¨z¸A­~ÈÔQˆØ˜•E˜A•Iˆ	Ø×!Ñ!Ó# zÔ1ÙÜ$ YÔBŠØÐr"   )N)Ú__doc__ÚCryptor   ÚCrypto.Math.Numbersr   ÚCrypto.Util.py3compatr   r   r   r!   r9   ÚCrypto.Util.numberr:   Ú_sieve_base_larger-   rM   rV   rc   rf   r%   r"   r    Ú<module>rm      sU   ðñ>õ
 Ý 'å ,à€	Ø€ôGòT^õB ?ñ Ð# DÕ)Ó*€ô7òt7ôtr"   