
    E#i                       S SK Jr  S SKJrJr  S SKJr  S SKJ	r	J
r
  S SKJr  S SKJrJr  S SKJrJr  \(       a  S SKJr  S S	KJr  S
rSrSrSrSrSrSr\	R<                  " S5      S:w  a  \R>                  \R>                  4r S$S jrO: " S S\!5      r" " S S5      r#\"" \R>                  \R>                  45      r \#" 5       rS%S jr$S&S jr%S'S jr&S'S jr'S(S jr(S)S jr)S*S jr*S+S jr+S,S jr,S-S  jr-S.S! jr.\\4           S/S" jjr/g#)0    )annotations)	b64decode	b64encode)sha256)environurandom)TYPE_CHECKING)ffilib)GLOBAL_CONTEXTContext)	Generator)Hashers    H;^6AAl   AAl 3z~i9nW~         s   -----BEGIN PRIVATE KEY-----
s   -----END PRIVATE KEY-----
COINCURVE_BUILDING_DOCStruec                4    [        U 5      R                  5       $ N_sha256digestbytestrs    I/home/james-whalen/.local/lib/python3.13/site-packages/coincurve/utils.pyr   r      s    w&&((    c                      \ rS rSrSS jrSrg)__Nonce#   c                    g)Nz(ffi.NULL, ffi.NULL) selfs    r   __repr____Nonce.__repr__$   s    )r   r!   Nreturnstr)__name__
__module____qualname____firstlineno__r$   __static_attributes__r!   r   r   r   r   #   s    	*r   r   c                  (    \ rS rSrSS jrSS jrSrg)__HasherSHA256'   c                4    [        U5      R                  5       $ r   r   )r#   r   s     r   __call____HasherSHA256.__call__(   s    7#**,,r   c                    g)Nr   r!   r"   s    r   r$   __HasherSHA256.__repr__+   s    r   r!   Nr   bytesr'   r7   r&   )r)   r*   r+   r,   r2   r$   r-   r!   r   r   r/   r/   '   s    	-	r   r/   c                6    [        U 5      S-  (       d  U $ SU  3$ )N   0)lenhexeds    r   pad_hexr>   2   s    E
Q57awK7r   c                .    [         R                  U S5      $ )Nbig)int
from_bytesr   s    r   bytes_to_intrC   7   s    >>'5))r   c                `    U R                  U R                  5       S-   S-  =(       d    SS5      $ N      r9   r@   )to_bytes
bit_lengthnums    r   int_to_bytesrL   ;   s)    <<)A-!38q%@@r   c                r    [        U R                  U R                  5       S-   S-  =(       d    SS5      5      $ rE   )
pad_scalarrH   rI   rJ   s    r   int_to_bytes_paddedrO   ?   s.    cllCNN$4q$8Q#>#C!UKLLr   c                P    [        [        R                  [        U 5      5      5      $ r   )rN   r7   fromhexr>   r<   s    r   hex_to_bytesrR   C   s    emmGEN344r   c                H   ^ ^ U U4S j[        S[        T 5      T5       5       $ )Nc              3  2   >#    U  H  nTXT-    v   M     g 7fr   r!   ).0idatasizes     r   	<genexpr>chunk_data.<locals>.<genexpr>H   s     B(A1DX(As   r   )ranger;   )rW   rX   s   ``r   
chunk_datar\   G   s    BaTD(ABBr   c           
         SR                  [        SR                  [        [        U 5      S5      5      S[        /5      $ )Nr      
@   )join
PEM_HEADERr\   r   
PEM_FOOTER)ders    r   
der_to_pemrd   K   s/    88ZJy~r,J!KUT^_``r   c                t    [        SR                  U R                  5       R                  5       SS 5      5      $ )Nr   r9   )r   r`   strip
splitlines)pems    r   
pem_to_derrj   O   s,    SXXciik446q<=>>r   c                 X     [        [        5      n [        U s=:  a  [        :  a   U $   M*  r   )r   KEY_SIZEZEROGROUP_ORDER)secrets    r   get_valid_secretrp   S   s+    
"&&;&M ' r   c                :    [         [        [        U 5      -
  -  U -   $ r   )rm   rl   r;   )scalars    r   rN   rN   Z   s    Hs6{*+v55r   c                z    S[        U 5      s=:  a
  [        :  d  O  S[         S3n[        U5      e[        U 5      $ )Nr   z3Secret scalar must be greater than 0 and less than .)rC   GROUP_ORDER_INT
ValueErrorrN   )ro   msgs     r   validate_secretrx   ^   s9    |F#5o5COCTTUVofr   c                    [         R                  " S5      n[        R                  " UR                  XR[        U5      5      nU(       d  Sn[        U5      eUb  U" U5      OUn[        U5      [        :w  a  Sn[        U5      e[         R                  " S5      n	[        R                  " UR                  X[        U 5      5      n
U
(       d  Sn[        U5      e[        R                  " UR                  XU5      nU(       $ )a  
Verify an ECDSA signature.

Parameters:
    signature: The ECDSA signature.
    message: The message that was supposedly signed.
    public_key: The formatted public key.
    hasher (collections.abc.Callable[[bytes], bytes] | None): The hash function to use, which must return 32 bytes.
        By default, the `sha256` algorithm is used. If `None`, no hashing occurs.
    context: The secp256k1 context.

Returns:
    A boolean indicating whether or not the signature is correct.

Raises:
    ValueError: If the public key could not be parsed or was invalid, the
        message hash was not 32 bytes long, or the DER-encoded signature
        could not be parsed.
zsecp256k1_pubkey *z1The public key could not be parsed or is invalid.z#Message hash must be 32 bytes long.zsecp256k1_ecdsa_signature *z.The DER-encoded signature could not be parsed.)
r
   newr   secp256k1_ec_pubkey_parsectxr;   rv   MSG_HASH_SIZE#secp256k1_ecdsa_signature_parse_dersecp256k1_ecdsa_verify)	signaturemessage
public_keyhashercontextpubkeypubkey_parsedrw   msg_hashsig
sig_parsedverifieds               r   verify_signaturer   e   s    , WW)*F11'++vSVWaSbcMAo"("4vg'H
8}%3o
''/
0C88cVYZcVdeJ>o))'++sfMH |r   Nr6   )r=   r(   r'   r(   )r   r7   r'   rA   )rK   rA   r'   r7   )r=   r(   r'   r7   )rW   r7   rX   rA   r'   zGenerator[bytes, None, None])rc   r7   r'   r7   )ri   r7   r'   r7   )r'   r7   )rr   r7   r'   r7   )ro   r7   r'   r7   )r   r7   r   r7   r   r7   r   r   r   r   r'   bool)0
__future__r   base64r   r   hashlibr   r   osr   r   typingr	   coincurve._libsecp256k1r
   r   coincurve.contextr   r   collections.abcr   coincurve.typesr   rn   ru   rl   r}   rm   ra   rb   getNULLDEFAULT_NONCEtupler   r/   r>   rC   rL   rO   rR   r\   rd   rj   rp   rN   rx   r   r!   r   r   <module>r      s+   " ' %    , 5)& v  U-
+
 ;;()V3XXsxx(M)
*% *  SXXsxx01MF8
*AM5Ca?6 KQes..$.27.AG.[b.	.r   