Ë
    }×<i"  ã                   óX   — d Z ddlZddlmZ ddlmZmZmZ ddlm	Z	 g d¢Z
d„ Zd	„ Zdd
„Zy)a  
RFC 6979:
    Deterministic Usage of the Digital Signature Algorithm (DSA) and
    Elliptic Curve Digital Signature Algorithm (ECDSA)

    http://tools.ietf.org/html/rfc6979

Many thanks to Coda Hale for his implementation in Go language:
    https://github.com/codahale/rfc6979
é    N)Úhexlifyé   )Únumber_to_stringÚnumber_to_string_cropÚ
bit_length)Úhmac_compat)r   Úbits2intÚbits2octetsÚ
generate_kc                 óf   — t        t        | «      d«      }t        | «      dz  }||kD  r|||z
  z	  S |S )Né   é   )Úintr   Úlen)ÚdataÚqlenÚxÚls       úR/home/www/utuvibe.miabetepe.com/venv/lib/python3.12/site-packages/ecdsa/rfc6979.pyr	   r	      s9   € ÜŒGD‹M˜2Ó€AÜˆD‹	A‰€Aàˆ4‚xØQ˜‘X‰ÐØ€Hó    c                 ó\   — t        | t        |«      «      }||z
  }|dk  r|}t        ||«      S )Nr   )r	   r   r   )r   ÚorderÚz1Úz2s       r   r
   r
       s5   € Ü	$œ
 5Ó)Ó	*€BØ	ˆe‰€Bà	ˆA‚vØˆä   UÓ+Ð+r   c                 ó"  — t        | «      } |«       j                  }|dz   dz  }t        t        || «      «      t        t	        || «      «      t        |«      f}	d|z  }
d|z  }t        j                  ||¬«      }|j                  |
dz   «       |	D ]  }|j                  |«       Œ |j                  «       }t        j                  ||
|«      j                  «       }
t        j                  ||¬«      }|j                  |
dz   «       |	D ]  }|j                  |«       Œ |j                  «       }t        j                  ||
|«      j                  «       }
	 d}t        |«      |k  r9t        j                  ||
|«      j                  «       }
||
z  }t        |«      |k  rŒ9t        ||«      }d|cxk  r| k  rn n|dk  r|S |dz  }t        j                  ||
dz   |«      j                  «       }t        j                  ||
|«      j                  «       }
Œ½)	aD  
    Generate the ``k`` value - the nonce for DSA.

    :param int order: order of the DSA generator used in the signature
    :param int secexp: secure exponent (private key) in numeric form
    :param hash_func: reference to the same hash function used for generating
        hash, like :py:class:`hashlib.sha1`
    :param bytes data: hash in binary form of the signing data
    :param int retry_gen: how many good 'k' values to skip before returning
    :param bytes extra_entropy: additional added data in binary form as per
        section-3.6 of rfc6979
    :rtype: int
    é   r   ó   ó    )Ú	digestmodr   r   r   )r   Údigest_sizer   r   r
   ÚhmacÚnewÚupdateÚdigestr   r	   )r   ÚsecexpÚ	hash_funcr   Ú	retry_genÚextra_entropyr   ÚholenÚrolenÚbxÚvÚkÚiÚtÚsecrets                  r   r   r   +   së  € ô eÓ€DÙ‹K×#Ñ#€EØA‰X˜!‰O€EäÔ$ V¨UÓ3Ó4Ü”K  eÓ,Ó-ÜMÓ"ð
€Bð 	%‰€Að 	%‰€Aô 	‰˜iÔ(€AØ‡HHˆQ‰[ÔØò ˆØ	‰ðà	‰‹
€Aô 	‰AyÓ!×(Ñ(Ó*€Aô 	‰˜iÔ(€AØ‡HHˆQ‰[ÔØò ˆØ	‰ðà	‰‹
€Aô 	‰AyÓ!×(Ñ(Ó*€Að àˆô !‹fuŠnÜ—‘˜˜A˜yÓ)×0Ñ0Ó2ˆAØ‰FˆAô !‹fu‹nô
 ˜!˜TÓ"ˆàÔ˜ÕØ˜AŠ~ØØ˜‰NˆIäH‰HQ˜˜G™ YÓ/×6Ñ6Ó8ˆÜH‰HQ˜˜9Ó%×,Ñ,Ó.ˆð% r   )r   r   )Ú__doc__r!   Úbinasciir   Úutilr   r   r   Ú_compatr   Ú__all__r	   r
   r   © r   r   ú<module>r7      s3   ðñ	ó Ý ß EÑ EÝ  ò
 B€òò,ôF/r   