§
    ­eîi›'  ã            
       óh  — U d dl mZ d dlmZ d dlmZmZ d dlm	Z	 ddgZ
 ej        ¦   «         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<    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dedef
d„Z dededededef
d„Z!dededefd„Z"dedededefd„Z#dedededefd„Z$dededefd„Z%dedededefd„Z&d S )!é    )ÚTuple)Ú
exceptions)ÚffiÚlib)ÚensureÚcrypto_box_keypairÚ
crypto_boxÚcrypto_box_SECRETKEYBYTESÚcrypto_box_PUBLICKEYBYTESÚcrypto_box_SEEDBYTESÚcrypto_box_NONCEBYTESÚcrypto_box_ZEROBYTESÚcrypto_box_BOXZEROBYTESÚcrypto_box_BEFORENMBYTESÚcrypto_box_SEALBYTESÚreturnc                  ó\  — 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 )zq
    Returns a randomly generated public and secret key.

    :rtype: (bytes(public_key), bytes(secret_key))
    úunsigned char[]r   úUnexpected library error©ÚraisingN)
r   Únewr   r
   r   r   r   ÚexcÚRuntimeErrorÚbuffer)ÚpkÚskÚrcs      ú\/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/nacl/bindings/crypto_box.pyr   r   "   s—   € õ 
ŒÐ"Õ$=Ñ	>Ô	>€BÝ	ŒÐ"Õ$=Ñ	>Ô	>€Bå	Ô	  BÑ	'Ô	'€BÝ
ˆ2�Š7Ð.½Ô8HÐIÑIÔIÐIõ 	Œ
�2Õ0Ñ1Ô1°!°!°!Ô4ÝŒ
�2Õ0Ñ1Ô1°!°!°!Ô4ðð ó    Úseedc                 ó
  — t          t          | t          ¦  «        dt          ¬¦  «         t	          | ¦  «        t
          k    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 )a  
    Returns a (public, secret) keypair deterministically generated
    from an input ``seed``.

    .. warning:: The seed **must** be high-entropy; therefore,
        its generator **must** be a cryptographic quality
        random function like, for example, :func:`~nacl.utils.random`.

    .. warning:: The seed **must** be protected and remain secret.
        Anyone who knows the seed is really in possession of
        the corresponding PrivateKey.


    :param seed: bytes
    :rtype: (bytes(public_key), bytes(secret_key))
    zseed must be bytesr   zInvalid seedr   r   r   N)r   Ú
isinstanceÚbytesÚ	TypeErrorÚlenr   r   Ú
ValueErrorr   r   r   r
   r   Úcrypto_box_seed_keypairr   r   )r!   r   r   r   s       r   r(   r(   4   sÛ   € õ" �:�d�EÑ"Ô"Ð$8Å)ÐLÑLÔLÐLå
ˆ4�y„yÕ(Ò(Ð(ÝŒn˜^Ñ,Ô,Ð,å	ŒÐ"Õ$=Ñ	>Ô	>€BÝ	ŒÐ"Õ$=Ñ	>Ô	>€Bå	Ô	$ R¨¨TÑ	2Ô	2€BÝ
ˆ2�Š7Ð.½Ô8HÐIÑIÔIÐIõ 	Œ
�2Õ0Ñ1Ô1°!°!°!Ô4ÝŒ
�2Õ0Ñ1Ô1°!°!°!Ô4ðð r    ÚmessageÚnoncer   r   c                 óR  — t          |¦  «        t          k    rt          j        d¦  «        ‚t          |¦  «        t          k    rt          j        d¦  «        ‚t          |¦  «        t
          k    rt          j        d¦  «        ‚dt          z  | z   }t          j        dt          |¦  «        ¦  «        }t          j
        ||t          |¦  «        |||¦  «        }t          |dk    dt          j        ¬¦  «         t          j        |t          |¦  «        ¦  «        t          d	…         S )
zð
    Encrypts and returns a message ``message`` using the secret key ``sk``,
    public key ``pk``, and the nonce ``nonce``.

    :param message: bytes
    :param nonce: bytes
    :param pk: bytes
    :param sk: bytes
    :rtype: bytes
    úInvalid nonce sizeúInvalid public keyúInvalid secret keyó    r   r   r   r   N)r&   r   r   r'   r   r
   r   r   r   r   r	   r   r   r   r   )r)   r*   r   r   ÚpaddedÚ
ciphertextr   s          r   r	   r	   V   sõ   € õ ˆ5�z„zÕ*Ò*Ð*ÝŒnÐ1Ñ2Ô2Ð2å
ˆ2�w„wÕ+Ò+Ð+ÝŒnÐ1Ñ2Ô2Ð2å
ˆ2�w„wÕ+Ò+Ð+ÝŒnÐ1Ñ2Ô2Ð2àÕ,Ñ,°Ñ7€FÝ”Ð*­C°©K¬KÑ8Ô8€Jå	Œ˜
 F­C°©K¬K¸ÀÀBÑ	GÔ	G€BÝ
ˆ2�Š7Ð.½Ô8HÐIÑIÔIÐIåŒ:�j¥# f¡+¤+Ñ.Ô.Õ/FÐ/GÐ/GÔHÐHr    r1   c                 óR  — t          |¦  «        t          k    rt          j        d¦  «        ‚t          |¦  «        t          k    rt          j        d¦  «        ‚t          |¦  «        t
          k    rt          j        d¦  «        ‚dt          z  | z   }t          j        dt          |¦  «        ¦  «        }t          j
        ||t          |¦  «        |||¦  «        }t          |dk    dt          j        ¬¦  «         t          j        |t          |¦  «        ¦  «        t          d	…         S )
a  
    Decrypts and returns an encrypted message ``ciphertext``, using the secret
    key ``sk``, public key ``pk``, and the nonce ``nonce``.

    :param ciphertext: bytes
    :param nonce: bytes
    :param pk: bytes
    :param sk: bytes
    :rtype: bytes
    r,   r-   r.   r/   r   r   ú/An error occurred trying to decrypt the messager   N)r&   r   r   r'   r   r
   r   r   r   r   Úcrypto_box_openr   ÚCryptoErrorr   r   )r1   r*   r   r   r0   Ú	plaintextÚress          r   r4   r4   s   s  € õ ˆ5�z„zÕ*Ò*Ð*ÝŒnÐ1Ñ2Ô2Ð2å
ˆ2�w„wÕ+Ò+Ð+ÝŒnÐ1Ñ2Ô2Ð2å
ˆ2�w„wÕ+Ò+Ð+ÝŒnÐ1Ñ2Ô2Ð2àÕ/Ñ/°:Ñ=€FÝ”Ð)­3¨v©;¬;Ñ7Ô7€Iå
Ô
˜i¨µ°V±´¸eÀRÈÑ
LÔ
L€CÝ
ØˆqŠØ9Ý”ðñ ô ð õ Œ:�i¥ V¡¤Ñ-Ô-Õ.BÐ.CÐ.CÔDÐDr    c                 ó–  — t          | ¦  «        t          k    rt          j        d¦  «        ‚t          |¦  «        t          k    rt          j        d¦  «        ‚t          j        dt          ¦  «        }t          j	        || |¦  «        }t          |dk    dt          j        ¬¦  «         t          j        |t          ¦  «        dd…         S )a  
    Computes and returns the shared key for the public key ``pk`` and the
    secret key ``sk``. This can be used to speed up operations where the same
    set of keys is going to be used multiple times.

    :param pk: bytes
    :param sk: bytes
    :rtype: bytes
    r-   r.   r   r   r   r   N)r&   r   r   r'   r
   r   r   r   r   Úcrypto_box_beforenmr   r   r   )r   r   Úkr   s       r   r9   r9   –   sª   € õ ˆ2�w„wÕ+Ò+Ð+ÝŒnÐ1Ñ2Ô2Ð2å
ˆ2�w„wÕ+Ò+Ð+ÝŒnÐ1Ñ2Ô2Ð2åŒÐ!Õ#;Ñ<Ô<€Aå	Ô	   B¨Ñ	+Ô	+€BÝ
ˆ2�Š7Ð.½Ô8HÐIÑIÔIÐIåŒ:�aÕ1Ñ2Ô2°1°1°1Ô5Ð5r    r:   c                 óø  — t          |¦  «        t          k    rt          j        d¦  «        ‚t          |¦  «        t          k    rt          j        d¦  «        ‚dt
          z  | z   }t          j        dt          |¦  «        ¦  «        }t          j	        ||t          |¦  «        ||¦  «        }t          |dk    dt          j        ¬¦  «         t          j        |t          |¦  «        ¦  «        t          d…         S )	zÇ
    Encrypts and returns the message ``message`` using the shared key ``k`` and
    the nonce ``nonce``.

    :param message: bytes
    :param nonce: bytes
    :param k: bytes
    :rtype: bytes
    úInvalid nonceúInvalid shared keyr/   r   r   r   r   N)r&   r   r   r'   r   r   r   r   r   Úcrypto_box_afternmr   r   r   r   )r)   r*   r:   r0   r1   r   s         r   r>   r>   ®   sÐ   € õ ˆ5�z„zÕ*Ò*Ð*ÝŒn˜_Ñ-Ô-Ð-å
ˆ1�v„vÕ)Ò)Ð)ÝŒnÐ1Ñ2Ô2Ð2àÕ+Ñ+¨gÑ5€FÝ”Ð*­C°©K¬KÑ8Ô8€Jå	Ô	 
¨FµC¸±K´KÀÈÑ	JÔ	J€BÝ
ˆ2�Š7Ð.½Ô8HÐIÑIÔIÐIåŒ:�j¥# f¡+¤+Ñ.Ô.Õ/FÐ/GÐ/GÔHÐHr    c                 óø  — t          |¦  «        t          k    rt          j        d¦  «        ‚t          |¦  «        t          k    rt          j        d¦  «        ‚dt
          z  | z   }t          j        dt          |¦  «        ¦  «        }t          j	        ||t          |¦  «        ||¦  «        }t          |dk    dt          j        ¬¦  «         t          j        |t          |¦  «        ¦  «        t          d…         S )	zØ
    Decrypts and returns the encrypted message ``ciphertext``, using the shared
    key ``k`` and the nonce ``nonce``.

    :param ciphertext: bytes
    :param nonce: bytes
    :param k: bytes
    :rtype: bytes
    r<   r=   r/   r   r   r3   r   N)r&   r   r   r'   r   r   r   r   r   Úcrypto_box_open_afternmr   r5   r   r   )r1   r*   r:   r0   r6   r7   s         r   r@   r@   Ç   sÛ   € õ ˆ5�z„zÕ*Ò*Ð*ÝŒn˜_Ñ-Ô-Ð-å
ˆ1�v„vÕ)Ò)Ð)ÝŒnÐ1Ñ2Ô2Ð2àÕ/Ñ/°:Ñ=€FÝ”Ð)­3¨v©;¬;Ñ7Ô7€Iå
Ô
% i°½¸V¹¼ÀeÈQÑ
OÔ
O€CÝ
ØˆqŠØ9Ý”ðñ ô ð õ Œ:�i¥ V¡¤Ñ-Ô-Õ.BÐ.CÐ.CÔDÐDr    c                 ó  — t          t          | t          ¦  «        dt          ¬¦  «         t          t          |t          ¦  «        dt          ¬¦  «         t	          |¦  «        t
          k    rt          j        d¦  «        ‚t	          | ¦  «        }t          |z   }t          j
        d|¦  «        }t          j        || ||¦  «        }t          |dk    dt          j        ¬¦  «         t          j        ||¦  «        dd…         S )	a€  
    Encrypts and returns a message ``message`` using an ephemeral secret key
    and the public key ``pk``.
    The ephemeral public key, which is embedded in the sealed box, is also
    used, in combination with ``pk``, to derive the nonce needed for the
    underlying box construct.

    :param message: bytes
    :param pk: bytes
    :rtype: bytes

    .. versionadded:: 1.2
    zinput message must be bytesr   úpublic key must be bytesr-   r   r   r   N)r   r#   r$   r%   r&   r   r   r'   r   r   r   r   Úcrypto_box_sealr   r   )r)   r   Ú_mlenÚ_clenr1   r   s         r   rC   rC   æ   só   € õ Ý�7�EÑ"Ô"Ø%Ýðñ ô ð õ Ý�2•uÑÔÐ9Å9ðñ ô ð õ ˆ2�w„wÕ+Ò+Ð+ÝŒnÐ1Ñ2Ô2Ð2å�‰LŒL€EÝ  5Ñ(€Eå”Ð*¨EÑ2Ô2€Jå	Ô	˜Z¨°%¸Ñ	<Ô	<€BÝ
ˆ2�Š7Ð.½Ô8HÐIÑIÔIÐIåŒ:�j %Ñ(Ô(¨¨¨Ô+Ð+r    c                 óJ  — t          t          | t          ¦  «        dt          ¬¦  «         t          t          |t          ¦  «        dt          ¬¦  «         t          t          |t          ¦  «        dt          ¬¦  «         t	          |¦  «        t
          k    rt          j        d¦  «        ‚t	          |¦  «        t          k    rt          j        d¦  «        ‚t	          | ¦  «        }t          |t          k    d 
                    t          ¦  «        t          j        ¬¦  «         |t          z
  }t          j        dt          d	|¦  «        ¦  «        }t          j        || |||¦  «        }t          |d
k    dt          j        ¬¦  «         t          j        ||¦  «        dd…         S )a“  
    Decrypts and returns an encrypted message ``ciphertext``, using the
    recipent's secret key ``sk`` and the sender's ephemeral public key
    embedded in the sealed box. The box contruct nonce is derived from
    the recipient's public key ``pk`` and the sender's public key.

    :param ciphertext: bytes
    :param pk: bytes
    :param sk: bytes
    :rtype: bytes

    .. versionadded:: 1.2
    zinput ciphertext must be bytesr   rB   zsecret key must be bytesr-   r.   z)Input cyphertext must be at least {} longr   é   r   r3   N)r   r#   r$   r%   r&   r   r   r'   r
   r   Úformatr   r   Úmaxr   Úcrypto_box_seal_openr5   r   )r1   r   r   rE   rD   r6   r7   s          r   rJ   rJ     s˜  € õ Ý�:�uÑ%Ô%Ø(Ýðñ ô ð õ Ý�2•uÑÔÐ9Å9ðñ ô ð õ Ý�2•uÑÔÐ9Å9ðñ ô ð õ ˆ2�w„wÕ+Ò+Ð+ÝŒnÐ1Ñ2Ô2Ð2å
ˆ2�w„wÕ+Ò+Ð+ÝŒnÐ1Ñ2Ô2Ð2å�
‰OŒO€Eå
ØÕ%Ò%Ø	4×<Ò<Ý ñ	
ô 	
õ ”ðñ ô ð ð Õ(Ñ(€Eõ ”Ð)­3¨q°%©=¬=Ñ9Ô9€Iå
Ô
" 9¨j¸%ÀÀRÑ
HÔ
H€CÝ
ØˆqŠØ9Ý”ðñ ô ð õ Œ:�i Ñ'Ô'¨¨¨Ô*Ð*r    N)'Útypingr   Únaclr   r   Únacl._sodiumr   r   Únacl.exceptionsr   Ú__all__Úcrypto_box_secretkeybytesr
   ÚintÚ__annotations__Úcrypto_box_publickeybytesr   Úcrypto_box_seedbytesr   Úcrypto_box_noncebytesr   Úcrypto_box_zerobytesr   Úcrypto_box_boxzerobytesr   Úcrypto_box_beforenmbytesr   Úcrypto_box_sealbytesr   r$   r   r(   r	   r4   r9   r>   r@   rC   rJ   © r    r   ú<module>r[      s  ðð Ð Ð Ð Ð Ð Ð à "Ð "Ð "Ð "Ð "Ð "Ø !Ð !Ð !Ð !Ð !Ð !Ð !Ð !Ø "Ð "Ð "Ð "Ð "Ð "ð   Ð
.€ð "? Ô!>Ñ!@Ô!@Ð ˜3Ð @Ð @Ñ @Ø!> Ô!>Ñ!@Ô!@Ð ˜3Ð @Ð @Ñ @Ø4˜CÔ4Ñ6Ô6Ð �cÐ 6Ð 6Ñ 6Ø6˜SÔ6Ñ8Ô8Ð �sÐ 8Ð 8Ñ 8Ø4˜CÔ4Ñ6Ô6Ð �cÐ 6Ð 6Ñ 6Ø:˜sÔ:Ñ<Ô<Ð ˜Ð <Ð <Ñ <Ø < Ô <Ñ >Ô >Ð ˜#Ð >Ð >Ñ >Ø4˜CÔ4Ñ6Ô6Ð �cÐ 6Ð 6Ñ 6ð˜E %¨ ,Ô/ð ð ð ð ð$ %ð ¨E°%¸°,Ô,?ð ð ð ð ðDI˜ð I eð I°ð I¸Eð IÀeð Ið Ið Ið Ið: EØð EØ#ð EØ).ð EØ49ð Eà
ð Eð  Eð  Eð  EðF6˜Eð 6 uð 6°ð 6ð 6ð 6ð 6ð0I ð I¨eð I¸ð IÀ%ð Ið Ið Ið Ið2EØðEØ#ðEØ(-ðEà
ðEð Eð Eð Eð>#,˜Uð #,¨ð #,°%ð #,ð #,ð #,ð #,ðL8+ Uð 8+°ð 8+¸5ð 8+ÀUð 8+ð 8+ð 8+ð 8+ð 8+ð 8+r    