+
    @iVF                        R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
HtHt ^RIHt ^RIHt R%t]P$                  ! ]!  tR&tR't]P,                  R(8  d   R tMR t]P,                  R)8  d   R	 tMR
 tR tR*R lt ! R R4      tR tR tR t]3R lt]3R lt R t!R t"R t#R t$R t%R t&R t'R t(R t)R t*R t+R t, ! R  R!]-4      t.R" t/R# t0R$ t1R# )+a  
This module includes some utility functions.

The methods most typically used are the sigencode and sigdecode functions
to be used with :func:`~ecdsa.keys.SigningKey.sign` and
:func:`~ecdsa.keys.VerifyingKey.verify`
respectively. See the :func:`sigencode_strings`, :func:`sigdecode_string`,
:func:`sigencode_der`, :func:`sigencode_strings_canonize`,
:func:`sigencode_string_canonize`, :func:`sigencode_der_canonize`,
:func:`sigdecode_strings`, :func:`sigdecode_string`, and
:func:`sigdecode_der` functions.
)divisionN)sha256)PY2int2bytenext)der)normalise_bytesc                    \        \        P                  V R4      4      R,          P                  \	        V 4      ^,          4      # )-Convert a bytestring to string of 0's and 1'sbig   NN)binint
from_byteszfilllenent_256s   &H/var/www/html/photoedit/myenv/lib/python3.14/site-packages/ecdsa/util.pyentropy_to_bitsr   4   s1    3>>'51226<<S\A=MNN    c                2    RP                  R V  4       4      # )r
    c              3   v   "   T F/  p\        \        V4      4      R ,          P                  ^4      x  K1  	  R# 5i)r   N)r   ordr   ).0xs   & r   	<genexpr>"entropy_to_bits.<locals>.<genexpr><   s*     AAs3q6{2,,Q//s   79)joinr   s   &r   r   r   :   s    wwAAAAr   c                 8    \        \        V 4      4      ^,
          # r   )r   r   r   s   &r   
bit_lengthr$   A   s    3q6{Qr   c                 6    V P                  4       ;'       g    ^#    )r$   r#   s   &r   r$   r$   F   s    ||~"""r   c                 B    ^\        RV ,          4      ,           ^,          # )r'   z%x)r   )orders   &r   orderlenr*   J   s    D5L!!a''r   c                   V ^8  g   Q hVf   \         P                  p\        V ^,
          4      pV^,          ^,           p V! V4      p\        V4      p\	        VRV ^R7      ^,           p^ Tu;8  d   V 8  g   K<   V#  KB  )a  Return a random integer k such that 1 <= k < order, uniformly
distributed across that range. Worst case should be a mean of 2 loops at
(2**k)+2.

Note that this function is not declared to be forwards-compatible: we may
change the behavior in future releases. The entropy= argument (which
should get a callable that behaves like os.urandom) can be used to
achieve stability within a given release (for repeatable unit tests), but
should not be used as a long-term-compatible key generation algorithm.
N)base)osurandomr$   r   r   )r)   entropyupper_2	upper_256r   ent_2rand_nums   &&     r   	randranger4   N   s     199**#G1q I
)$(uXgQ/!3x%O  r   c                   2   a  ] tR t^ft o R tR tR tRtV tR# )PRNGc                2    V P                  V4      V n        R # N)block_generator	generator)selfseeds   &&r   __init__PRNG.__init__l   s    --d3r   c                    \        V4       Uu. uF  p\        V P                  4      NK  	  pp\        '       d   R P	                  V4      # \        V4      # u upi )r   )ranger   r:   r   r    bytes)r;   numbytesias   &&  r   __call__PRNG.__call__o   sD    +0?;?aT$..!?;3771:8O <s   Ac              #     "   ^ p \        RW!3,          P                  4       4      P                  4        F  pVx  K	  	  V^,          pKF  5i)    z
prng-%d-%s)r   encodedigest)r;   r<   counterbytes   &&  r   r9   PRNG.block_generatorw   sM     /779fh 
 qLGs   A	A)r:   N)	__name__
__module____qualname____firstlineno__r=   rE   r9   __static_attributes____classdictcell__)__classdict__s   @r   r6   r6   f   s     4 r   r6   c                     \        V 4      ! ^\        V4      ,          4      p\        \        P                  ! V4      ^4      V^,
          ,          ^,           p^Tu;8:  d   V8  g   M Q ^W134       hV# r"   )r6   r*   r   binasciihexlify)r<   r)   r,   numbers   &&  r   %randrange_from_seed__overshoot_modulorY      sb     :a(5/)*D(""4("-;q@F2F 22Mr   c                 "    ^V ,          ^,
          # r&    )numbitss   &r   lsb_of_onesr]      s    LAr   c                     \        \        P                  ! V ^,
          ^4      ^,           4      pV^,          pV^,          pWV3# r&   )r   mathlog)r)   bitsrA   	extrabitss   &   r   bits_and_bytesrc      s=    txx	1%)*DAIEqI	!!r   c                 ,   \        V4      w  r4pV'       d
   V^,          pV! V 4      P                  4       RV pRV\        V4      ,
          ,          V,           p^\        \        P
                  ! V4      ^4      ,           p^Tu;8:  d	   V8  g   Q h Q hV# )r'   N )rc   rJ   r   r   rV   rW   )r<   r)   hashmodra   _bytesrb   r,   rX   s   &&&     r   #randrange_from_seed__truncate_bytesrh      s     -U3D)!4=!'6*DVc$i'(4/DX%%d+R00FMr   c                    \        \        P                  ! V^,
          ^4      ^,           4      pV^,           ^,          pV! V 4      P                  4       RV pRV\	        V4      ,
          ,          V,           p^V,          V,
          pV'       d:   \        \        V^ ,          4      \        V4      ,          4      VR,          ,           p^\        \        P                  ! V4      ^4      ,           p^Tu;8:  d	   V8  g   Q h Q hV# )r'   Nre   :r'   NN)
r   r_   r`   rJ   r   r   r   r]   rV   rW   )r<   r)   rf   ra   maxbytesr,   topbitsrX   s   &&&     r   "randrange_from_seed__truncate_bitsrl      s     txx	1%)*DqQH4=!)8,DXD	)*T1D(lT!GDG{7';;<tBxGX%%d+R00FMr   c                    V^8  g   Q h\        V4      w  r#p\        V 4      p RpV'       d+   \        \        V! ^4      4      \	        V4      ,          4      p\        We! V4      ,           4      ^,           p^Tu;8:  d   V8  g   Kd   V#  Kj  )r'   r   )rc   r6   r   r   r]   string_to_number)r<   r)   ra   rA   rb   generate	extrabyteguesss   &&      r    randrange_from_seed__trytryagainrr      s     199+E2DDzH
	 Xa[!1K	4J!JKI Xe_!<=AL r   c                     \        V4      pR \        ^V,          4      ,           R,           p\        P                  ! W0,          P	                  4       4      p\        V4      V8X  g   Q \        V4      V34       hV# )%0r   )r*   strrV   	unhexlifyrI   r   numr)   lfmt_strstrings   &&   r   number_to_stringr|      sb    ASQZ#%G 6 6 89Fv;!-c&k1--Mr   c                     \        V4      pR \        ^V,          4      ,           R,           p\        P                  ! W0,          P	                  4       4      pVRV # )rt   r   N)r*   ru   rV   rv   rI   rw   s   &&   r   number_to_string_cropr~      sI    ASQZ#%G 6 6 89F"1:r   c                 B    \        \        P                  ! V 4      ^4      #    )r   rV   rW   )r{   s   &r   rn   rn      s    x',,r   c                     \        V4      p\        V 4      V8X  g   Q \        V 4      V34       h\        \        P                  ! V 4      ^4      # r   )r*   r   r   rV   rW   )r{   r)   ry   s   && r   string_to_number_fixedlenr      sC    Av;!-c&k1--x',,r   c                4    \        W4      p\        W4      pW43# )a*  
Encode the signature to a pair of strings in a tuple

Encodes signature into raw encoding (:term:`raw encoding`) with the
``r`` and ``s`` parts of the signature encoded separately.

It's expected that this function will be used as a ``sigencode=`` parameter
in :func:`ecdsa.keys.SigningKey.sign` method.

:param int r: first parameter of the signature
:param int s: second parameter of the signature
:param int order: the order of the curve over which the signature was
    computed

:return: raw encoding of ECDSA signature
:rtype: tuple(bytes, bytes)
)r|   rsr)   r_strs_strs   &&&  r   sigencode_stringsr      s     $ Q&EQ&E>r   c                .    \        WV4      w  r4W4,           # )a  
Encode the signature to raw format (:term:`raw encoding`)

It's expected that this function will be used as a ``sigencode=`` parameter
in :func:`ecdsa.keys.SigningKey.sign` method.

:param int r: first parameter of the signature
:param int s: second parameter of the signature
:param int order: the order of the curve over which the signature was
    computed

:return: raw encoding of ECDSA signature
:rtype: bytes
)r   r   s   &&&  r   sigencode_stringr     s    " %Q51LE=r   c                    \         P                  ! \         P                  ! V 4      \         P                  ! V4      4      # )aO  
Encode the signature into the ECDSA-Sig-Value structure using :term:`DER`.

Encodes the signature to the following :term:`ASN.1` structure::

    Ecdsa-Sig-Value ::= SEQUENCE {
        r       INTEGER,
        s       INTEGER
    }

It's expected that this function will be used as a ``sigencode=`` parameter
in :func:`ecdsa.keys.SigningKey.sign` method.

:param int r: first parameter of the signature
:param int s: second parameter of the signature
:param int order: the order of the curve over which the signature was
    computed

:return: DER encoding of ECDSA signature
:rtype: bytes
)r   encode_sequenceencode_integerr   r   r)   s   &&&r   sigencode_derr     s-    , s11!4c6H6H6KLLr   c                0    W^,          8  d	   W,
          p V # )a  
Internal function for ensuring that the ``s`` value of a signature is in
the "canonical" format.

:param int s: the second parameter of ECDSA signature
:param int order: the order of the curve over which the signatures was
    computed

:return: canonical value of s
:rtype: int
r[   )r   r)   s   &&r   	_canonizer   3  s     	A:~IHr   c                0    \        W4      p\        WV4      # )a  
Encode the signature to a pair of strings in a tuple

Encodes signature into raw encoding (:term:`raw encoding`) with the
``r`` and ``s`` parts of the signature encoded separately.

Makes sure that the signature is encoded in the canonical format, where
the ``s`` parameter is always smaller than ``order / 2``.
Most commonly used in bitcoin.

It's expected that this function will be used as a ``sigencode=`` parameter
in :func:`ecdsa.keys.SigningKey.sign` method.

:param int r: first parameter of the signature
:param int s: second parameter of the signature
:param int order: the order of the curve over which the signature was
    computed

:return: raw encoding of ECDSA signature
:rtype: tuple(bytes, bytes)
)r   r   r   s   &&&r   sigencode_strings_canonizer   D  s    , 	!AQ5))r   c                0    \        W4      p\        WV4      # )aC  
Encode the signature to raw format (:term:`raw encoding`)

Makes sure that the signature is encoded in the canonical format, where
the ``s`` parameter is always smaller than ``order / 2``.
Most commonly used in bitcoin.

It's expected that this function will be used as a ``sigencode=`` parameter
in :func:`ecdsa.keys.SigningKey.sign` method.

:param int r: first parameter of the signature
:param int s: second parameter of the signature
:param int order: the order of the curve over which the signature was
    computed

:return: raw encoding of ECDSA signature
:rtype: bytes
)r   r   r   s   &&&r   sigencode_string_canonizer   ^  s    & 	!AA%((r   c                0    \        W4      p\        WV4      # )a  
Encode the signature into the ECDSA-Sig-Value structure using :term:`DER`.

Makes sure that the signature is encoded in the canonical format, where
the ``s`` parameter is always smaller than ``order / 2``.
Most commonly used in bitcoin.

Encodes the signature to the following :term:`ASN.1` structure::

    Ecdsa-Sig-Value ::= SEQUENCE {
        r       INTEGER,
        s       INTEGER
    }

It's expected that this function will be used as a ``sigencode=`` parameter
in :func:`ecdsa.keys.SigningKey.sign` method.

:param int r: first parameter of the signature
:param int s: second parameter of the signature
:param int order: the order of the curve over which the signature was
    computed

:return: DER encoding of ECDSA signature
:rtype: bytes
)r   r   r   s   &&&r   sigencode_der_canonizer   u  s    4 	!Au%%r   c                       ] tR tRtRtRtR# )MalformedSignaturei  a*  
Raised by decoding functions when the signature is malformed.

Malformed in this context means that the relevant strings or integers
do not match what a signature over provided curve would create. Either
because the byte strings have incorrect lengths or because the encoded
values are too large.
r[   N)rN   rO   rP   rQ   __doc__rR   r[   r   r   r   r     s     	r   r   c                    \        V 4      p \        V4      p\        V 4      ^V,          8X  g,   \        RP	                  ^V,          \        V 4      4      4      h\        V RV V4      p\        WR V4      pW43# )a  
Decoder for :term:`raw encoding`  of ECDSA signatures.

raw encoding is a simple concatenation of the two integers that comprise
the signature, with each encoded using the same amount of bytes depending
on curve size/order.

It's expected that this function will be used as the ``sigdecode=``
parameter to the :func:`ecdsa.keys.VerifyingKey.verify` method.

:param signature: encoded signature
:type signature: bytes like object
:param order: order of the curve over which the signature was computed
:type order: int

:raises MalformedSignature: when the encoding of the signature is invalid

:return: tuple with decoded ``r`` and ``s`` values of signature
:rtype: tuple of ints
zWInvalid length of signature, expected {0} bytes long, provided string is {1} bytes longN)r   r*   r   r   formatr   )	signaturer)   ry   r   r   s   &&   r   sigdecode_stringr     sx    *  	*IAy>QU" 006q1uc)n0M
 	
 	")BQ-7A!)B-7A4Kr   c                   \        V 4      ^8X  g$   \        RP                  \        V 4      4      4      hV w  r#\        V4      p\        V4      p\	        V4      p\        V4      V8X  g%   \        RP                  V\        V4      4      4      h\        V4      V8X  g%   \        RP                  V\        V4      4      4      h\        W!4      p\        W14      pWV3# )a  
Decode the signature from two strings.

First string needs to be a big endian encoding of ``r``, second needs to
be a big endian encoding of the ``s`` parameter of an ECDSA signature.

It's expected that this function will be used as the ``sigdecode=``
parameter to the :func:`ecdsa.keys.VerifyingKey.verify` method.

:param list rs_strings: list of two bytes-like objects, each encoding one
    parameter of signature
:param int order: order of the curve over which the signature was computed

:raises MalformedSignature: when the encoding of the signature is invalid

:return: tuple with decoded ``r`` and ``s`` values of signature
:rtype: tuple of ints
z3Invalid number of strings provided: {0}, expected 2zjInvalid length of first string ('r' parameter), expected {0} bytes long, provided string is {1} bytes longzkInvalid length of second string ('s' parameter), expected {0} bytes long, provided string is {1} bytes long)r   r   r   r   r*   r   )
rs_stringsr)   r   r   ry   r   r   s   &&     r   sigdecode_stringsr     s    & z?a AHHJ
 	

  NUE"EE"EAu:? 3u:.
 	

 u:? 3u:.
 	

 	"%/A!%/A4Kr   c                   \        V 4      p \        P                  ! V 4      w  r#VR8w  d2   \        P                  ! R\        P
                  ! V4      ,          4      h\        P                  ! V4      w  rE\        P                  ! V4      w  rcVR8w  d2   \        P                  ! R\        P
                  ! V4      ,          4      hWF3# )a  
Decoder for DER format of ECDSA signatures.

DER format of signature is one that uses the :term:`ASN.1` :term:`DER`
rules to encode it as a sequence of two integers::

    Ecdsa-Sig-Value ::= SEQUENCE {
        r       INTEGER,
        s       INTEGER
    }

It's expected that this function will be used as as the ``sigdecode=``
parameter to the :func:`ecdsa.keys.VerifyingKey.verify` method.

:param sig_der: encoded signature
:type sig_der: bytes like object
:param order: order of the curve over which the signature was computed
:type order: int

:raises UnexpectedDER: when the encoding of signature is invalid

:return: tuple with decoded ``r`` and ``s`` values of signature
:rtype: tuple of ints
r   ztrailing junk after DER sig: %sz#trailing junk after DER numbers: %s)r   r   remove_sequenceUnexpectedDERrV   rW   remove_integer)sig_derr)   r   emptyr   restr   s   &&     r   sigdecode_derr     s    2 g&G++G4J|-0@0@0GG
 	
   ,GA!!$'HA|1H4D4DU4KK
 	
 4Kr   )r'   r   iH  i='  r   r'   )r'         r'      )r'   r   r   r'      )r   )r      r8   )2r   
__future__r   r-   r_   rV   syshashlibr   sixr   r   r   r   r   _compatr   oid_ecPublicKey
encode_oidencoded_oid_ecPublicKeyoid_ecDH	oid_ecMQVversion_infor   r$   r*   r4   r6   rY   r]   rc   rh   rl   rr   r|   r~   rn   r   r   r   r   r   r   r   r   	Exceptionr   r   r   r   r[   r   r   <module>r      s     	   
  # #  $ +../:   	tOB
 f
#(0 6
"& >D  =C &--.*M2"*4).&<
	 
	B+\&r   