Ë
    zñ�jk(  ã                   ó4  — U d dl mZ d dlmZ d dlmZmZ d dlm	Z	  ej                  «       Zeed<    ej                  «       dz  Zeed<    ej                   «       Zeed<    ej                  «       Zeed	<    ej&                  «       Zeed
<    ej*                  «       Zeed<   deeef   fd„Zdedeeef   fd„Zdededefd„Zdededefd„Zdedefd„Zdedefd„Zdedefd„Zdedefd„Z G d„ d«      Z de dedd fd!„Z!de dedefd"„Z"de d#edede#fd$„Z$y )%é    )ÚTuple)Ú
exceptions)ÚffiÚlib)ÚensureÚcrypto_sign_BYTESé   Úcrypto_sign_SEEDBYTESÚcrypto_sign_PUBLICKEYBYTESÚcrypto_sign_SECRETKEYBYTESÚcrypto_sign_curve25519_BYTESÚ crypto_sign_ed25519ph_STATEBYTESÚreturnc                  óH  — t        j                  dt        «      } t        j                  dt        «      }t	        j
                  | |«      }t        |dk(  dt        j                  ¬«       t        j                  | t        «      dd t        j                  |t        «      dd fS )zu
    Returns a randomly generated public key and secret key.

    :rtype: (bytes(public_key), bytes(secret_key))
    úunsigned char[]r   úUnexpected library error©ÚraisingN)
r   Únewr   r   r   Úcrypto_sign_keypairr   ÚexcÚRuntimeErrorÚbuffer)ÚpkÚskÚrcs      úZ/var/www/api.ozpay.ru/ozpay/venv/lib/python3.12/site-packages/nacl/bindings/crypto_sign.pyr   r       s…   € ô 
�‰Ð"Ô$>Ó	?€BÜ	�‰Ð"Ô$>Ó	?€Bä	×	 Ñ	   RÓ	(€BÜ
ˆ2�‰7Ð.¼×8HÑ8HÕIô 	�
‰
�2Ô1Ó2±1Ð5Ü�
‰
�2Ô1Ó2±1Ð5ðð ó    Úseedc                 ó˜  — t        | «      t        k7  rt        j                  d«      ‚t	        j
                  dt        «      }t	        j
                  dt        «      }t        j                  ||| «      }t        |dk(  dt        j                  ¬«       t	        j                  |t        «      dd t	        j                  |t        «      dd fS )z 
    Computes and returns the public key and secret key using the seed ``seed``.

    :param seed: bytes
    :rtype: (bytes(public_key), bytes(secret_key))
    zInvalid seedr   r   r   r   N)Úlenr
   r   Ú
ValueErrorr   r   r   r   r   Úcrypto_sign_seed_keypairr   r   r   )r   r   r   r   s       r   r#   r#   2   s£   € ô ˆ4ƒyÔ)Ò)Ü�n‰n˜^Ó,Ð,ä	�‰Ð"Ô$>Ó	?€BÜ	�‰Ð"Ô$>Ó	?€Bä	×	%Ñ	% b¨"¨dÓ	3€BÜ
ˆ2�‰7Ð.¼×8HÑ8HÕIô 	�
‰
�2Ô1Ó2±1Ð5Ü�
‰
�2Ô1Ó2±1Ð5ðð r   Úmessager   c                 ó2  — t        j                  dt        | «      t        z   «      }t        j                  d«      }t	        j
                  ||| t        | «      |«      }t        |dk(  dt        j                  ¬«       t        j                  ||d   «      dd S )z©
    Signs the message ``message`` using the secret key ``sk`` and returns the
    signed message.

    :param message: bytes
    :param sk: bytes
    :rtype: bytes
    r   úunsigned long long *r   r   r   N)
r   r   r!   r   r   Úcrypto_signr   r   r   r   )r$   r   ÚsignedÚ
signed_lenr   s        r   r'   r'   H   sy   € ô �W‰WÐ&¬¨G«Ô7HÑ(HÓI€FÜ—‘Ð/Ó0€Jä	�‰˜ ¨W´c¸'³lÀBÓ	G€BÜ
ˆ2�‰7Ð.¼×8HÑ8HÕIä�:‰:�f˜j¨™mÓ,©QÐ/Ð/r   r(   r   c                 ó  — t        j                  dt        | «      «      }t        j                  d«      }t        j                  ||| t        | «      |«      dk7  rt        j                  d«      ‚t        j                  ||d   «      dd S )zÄ
    Verifies the signature of the signed message ``signed`` using the public
    key ``pk`` and returns the unsigned message.

    :param signed: bytes
    :param pk: bytes
    :rtype: bytes
    r   r&   r   úSignature was forged or corruptN)r   r   r!   r   Úcrypto_sign_openr   ÚBadSignatureErrorr   )r(   r   r$   Úmessage_lens       r   r,   r,   Z   sz   € ô �g‰gÐ'¬¨V«Ó5€GÜ—'‘'Ð0Ó1€Kô 	×Ñ˜W k°6¼3¸v»;ÈÓKØò	ô ×#Ñ#Ð$EÓFÐFä�:‰:�g˜{¨1™~Ó.©qÐ1Ð1r   Úpublic_key_bytesc                 ó$  — t        | «      t        k7  rt        j                  d«      ‚t        }t        j                  d|«      }t        j                  || «      }t        |dk(  dt        j                  ¬«       t        j                  ||«      dd S )a  
    Converts a public Ed25519 key (encoded as bytes ``public_key_bytes``) to
    a public Curve25519 key as bytes.

    Raises a ValueError if ``public_key_bytes`` is not of length
    ``crypto_sign_PUBLICKEYBYTES``

    :param public_key_bytes: bytes
    :rtype: bytes
    zInvalid curve public keyr   r   r   r   N)r!   r   r   r"   r   r   r   r   Ú$crypto_sign_ed25519_pk_to_curve25519r   r   r   )r/   Úcurve_public_key_lenÚcurve_public_keyr   s       r   r1   r1   o   óƒ   € ô ÐÓÔ :Ò:Ü�n‰nÐ7Ó8Ð8ä7ÐÜ—w‘wÐ0Ð2FÓGÐä	×	1Ñ	1ØÐ*ó
€Bô ˆ2�‰7Ð.¼×8HÑ8HÕIä�:‰:Ð&Ð(<Ó=¹aÐ@Ð@r   Úsecret_key_bytesc                 ó$  — t        | «      t        k7  rt        j                  d«      ‚t        }t        j                  d|«      }t        j                  || «      }t        |dk(  dt        j                  ¬«       t        j                  ||«      dd S )a  
    Converts a secret Ed25519 key (encoded as bytes ``secret_key_bytes``) to
    a secret Curve25519 key as bytes.

    Raises a ValueError if ``secret_key_bytes``is not of length
    ``crypto_sign_SECRETKEYBYTES``

    :param secret_key_bytes: bytes
    :rtype: bytes
    zInvalid curve secret keyr   r   r   r   N)r!   r   r   r"   r   r   r   r   Ú$crypto_sign_ed25519_sk_to_curve25519r   r   r   )r5   Úcurve_secret_key_lenÚcurve_secret_keyr   s       r   r7   r7   ˆ   r4   r   c                 ób   — t        | «      t        k7  rt        j                  d«      ‚| t        d S )a	  
    Extract the public Ed25519 key from a secret Ed25519 key (encoded
    as bytes ``secret_key_bytes``).

    Raises a ValueError if ``secret_key_bytes``is not of length
    ``crypto_sign_SECRETKEYBYTES``

    :param secret_key_bytes: bytes
    :rtype: bytes
    úInvalid secret keyN©r!   r   r   r"   r
   ©r5   s    r   Úcrypto_sign_ed25519_sk_to_pkr>   ¡   s2   € ô ÐÓÔ :Ò:Ü�n‰nÐ1Ó2Ð2àÔ1Ð2Ð3Ð3r   c                 ób   — t        | «      t        k7  rt        j                  d«      ‚| dt         S )zû
    Extract the seed from a secret Ed25519 key (encoded
    as bytes ``secret_key_bytes``).

    Raises a ValueError if ``secret_key_bytes``is not of length
    ``crypto_sign_SECRETKEYBYTES``

    :param secret_key_bytes: bytes
    :rtype: bytes
    r;   Nr<   r=   s    r   Úcrypto_sign_ed25519_sk_to_seedr@   ²   s2   € ô ÐÓÔ :Ò:Ü�n‰nÐ1Ó2Ð2àÐ2Ô2Ð3Ð3r   c                   ó   — e Zd ZdZdgZdd„Zy)Úcrypto_sign_ed25519ph_statezO
    State object wrapping the sha-512 state used in ed25519ph computation
    ÚstateNc                 ó¾   — t        j                  dt        «      | _        t	        j
                  | j                  «      }t        |dk(  dt        j                  ¬«       y )Nr   r   r   r   )	r   r   r   rC   r   Úcrypto_sign_ed25519ph_initr   r   r   )Úselfr   s     r   Ú__init__z$crypto_sign_ed25519ph_state.__init__Ê   sE   € ÜŸG™GØÔ?ó
ˆŒ
ô ×+Ñ+¨D¯J©JÓ7ˆäˆr�Q‰wÐ2¼C×<LÑ<LÖMr   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__rG   © r   r   rB   rB   Ã   s   „ ñð �	€IôNr   rB   ÚedphÚpmsgNc                 ó>  — t        t        | t        «      dt        j                  ¬«       t        t        |t
        «      dt        j                  ¬«       t        j                  | j                  |t        |«      «      }t        |dk(  dt        j                  ¬«       y)zÛ
    Update the hash state wrapped in edph

    :param edph: the ed25519ph state being updated
    :type edph: crypto_sign_ed25519ph_state
    :param pmsg: the partial message
    :type pmsg: bytes
    :rtype: None
    ú/edph parameter must be a ed25519ph_state objectr   z%pmsg parameter must be a bytes objectr   r   N)r   Ú
isinstancerB   r   Ú	TypeErrorÚbytesr   Úcrypto_sign_ed25519ph_updaterC   r!   r   )rN   rO   r   s      r   rU   rU   Ô   st   € ô Ü�4Ô4Ó5Ø9Ü—‘õô
 Ü�4œÓØ/Ü—‘õô
 
×	)Ñ	)¨$¯*©*°d¼CÀ»IÓ	F€BÜ
ˆ2�‰7Ð.¼×8HÑ8HÖIr   c                 ó4  — t        t        | t        «      dt        j                  ¬«       t        t        |t
        «      dt        j                  ¬«       t        t        |«      t        k(  dj                  t        «      t        j                  ¬«       t        j                  dt        «      }t        j                  | j                  |t        j                  |«      }t        |dk(  dt        j                   ¬«       t        j"                  |t        «      dd S )	aW  
    Create a signature for the data hashed in edph
    using the secret key sk

    :param edph: the ed25519ph state for the data
                 being signed
    :type edph: crypto_sign_ed25519ph_state
    :param sk: the ed25519 secret key (secret and public part)
    :type sk: bytes
    :return: ed25519ph signature
    :rtype: bytes
    rQ   r   z+secret key parameter must be a bytes objectz secret key must be {} bytes longr   r   r   N)r   rR   rB   r   rS   rT   r!   r   Úformatr   r   r   r   Ú"crypto_sign_ed25519ph_final_createrC   ÚNULLr   r   )rN   r   Ú	signaturer   s       r   rX   rX   î   sÕ   € ô Ü�4Ô4Ó5Ø9Ü—‘õô
 Ü�2”uÓØ5Ü—‘õô
 ÜˆB‹Ô-Ñ-Ø	+×3Ñ3Ü&ó	
ô —‘õô —‘Ð)Ô+<Ó=€IÜ	×	/Ñ	/Ø�
‰
�IœsŸx™x¨ó
€Bô ˆ2�‰7Ð.¼×8HÑ8HÕIä�:‰:�iÔ!2Ó3±AÐ6Ð6r   rZ   c                 ór  — t        t        | t        «      dt        j                  ¬«       t        t        |t
        «      dt        j                  ¬«       t        t        |«      t        k(  dj                  t        «      t        j                  ¬«       t        t        |t
        «      dt        j                  ¬«       t        t        |«      t        k(  dj                  t        «      t        j                  ¬«       t        j                  | j                  ||«      }|dk7  rt        j                  d«      ‚y	)
aÚ  
    Verify a prehashed signature using the public key pk

    :param edph: the ed25519ph state for the data
                 being verified
    :type edph: crypto_sign_ed25519ph_state
    :param signature: the signature being verified
    :type signature: bytes
    :param pk: the ed25519 public part of the signing key
    :type pk: bytes
    :return: True if the signature is valid
    :rtype: boolean
    :raises exc.BadSignatureError: if the signature is not valid
    rQ   r   z*signature parameter must be a bytes objectzsignature must be {} bytes longz+public key parameter must be a bytes objectz public key must be {} bytes longr   r+   T)r   rR   rB   r   rS   rT   r!   r   rW   r   r   Ú"crypto_sign_ed25519ph_final_verifyrC   r-   )rN   rZ   r   r   s       r   r\   r\     sñ   € ô" Ü�4Ô4Ó5Ø9Ü—‘õô
 Ü�9œeÓ$Ø4Ü—‘õô
 ÜˆI‹Ô+Ñ+Ø	*×2Ñ2Ô3DÓEÜ—‘õô
 Ü�2”uÓØ5Ü—‘õô
 ÜˆB‹Ô-Ñ-Ø	+×3Ñ3Ü&ó	
ô —‘õô 
×	/Ñ	/°·
±
¸IÀrÓ	J€BØ	ˆQ‚wÜ×#Ñ#Ð$EÓFÐFàr   )%Útypingr   Únaclr   r   Únacl._sodiumr   r   Únacl.exceptionsr   Úcrypto_sign_bytesr   ÚintÚ__annotations__Úcrypto_sign_secretkeybytesr
   Úcrypto_sign_publickeybytesr   r   Úcrypto_box_secretkeybytesr   Ú crypto_sign_ed25519ph_statebytesr   rT   r   r#   r'   r,   r1   r7   r>   r@   rB   rU   rX   Úboolr\   rM   r   r   ú<module>ri      sÅ  ðö å "ß !Ý "ð /˜×.Ñ.Ó0Ð �3Ó 0à;˜S×;Ñ;Ó=ÀÑBÐ �sÓ BØ"@ #×"@Ñ"@Ó"BÐ ˜CÓ BØ"@ #×"@Ñ"@Ó"BÐ ˜CÓ Bà$A C×$AÑ$AÓ$CÐ ˜cÓ Cà(L¨×(LÑ(LÓ(NÐ   #Ó Nð˜U 5¨% <Ñ0ó ð$ 5ð ¨U°5¸%°<Ñ-@ó ð,0˜ð 0 Eð 0¨eó 0ð$2˜Uð 2¨ð 2°%ó 2ð*A¸5ð AÀUó Að2A¸5ð AÀUó Að24°5ð 4¸Uó 4ð"4°Uð 4¸uó 4÷"Nñ Nð"JØ
%ðJØ-2ðJà	óJð4&7Ø
%ð&7Ø+0ð&7à
ó&7ðR0Ø
%ð0Ø27ð0Ø=Bð0à	ô0r   