Ë
    †f›'  ã            
       óz  — 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j2                  «       Zeed<    ej6                  «       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&y )!é    )Ú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                  ó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 )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      ú:/usr/lib/python3/dist-packages/nacl/bindings/crypto_box.pyr   r   "   s…   € ô 
�‰Ð"Ô$=Ó	>€BÜ	�‰Ð"Ô$=Ó	>€Bä	×	Ñ	  BÓ	'€BÜ
ˆ2�‰7Ð.¼×8HÑ8HÕIô 	�
‰
�2Ô0Ó1±!Ð4Ü�
‰
�2Ô0Ó1±!Ð4ðð ó    Úseedc                 óØ  — t        t        | t        «      dt        ¬«       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 )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ä
ˆ4ƒyÔ(Ò(Ü�n‰n˜^Ó,Ð,ä	�‰Ð"Ô$=Ó	>€BÜ	�‰Ð"Ô$=Ó	>€Bä	×	$Ñ	$ R¨¨TÓ	2€BÜ
ˆ2�‰7Ð.¼×8HÑ8HÕIô 	�
‰
�2Ô0Ó1±!Ð4Ü�
‰
�2Ô0Ó1±!Ð4ðð r    ÚmessageÚnoncer   r   c                 ó  — t        |«      t        k7  rt        j                  d«      ‚t        |«      t        k7  rt        j                  d«      ‚t        |«      t
        k7  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Ô*Ò*Ü�n‰nÐ1Ó2Ð2ä
ˆ2ƒwÔ+Ò+Ü�n‰nÐ1Ó2Ð2ä
ˆ2ƒwÔ+Ò+Ü�n‰nÐ1Ó2Ð2àÔ,Ñ,°Ñ7€FÜ—‘Ð*¬C°«KÓ8€Jä	�‰˜
 F¬C°«K¸ÀÀBÓ	G€BÜ
ˆ2�‰7Ð.¼×8HÑ8HÕIä�:‰:�j¤# f£+Ó.Ô/FÐ/GÐHÐHr    r1   c                 ó  — t        |«      t        k7  rt        j                  d«      ‚t        |«      t        k7  rt        j                  d«      ‚t        |«      t
        k7  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Ô*Ò*Ü�n‰nÐ1Ó2Ð2ä
ˆ2ƒwÔ+Ò+Ü�n‰nÐ1Ó2Ð2ä
ˆ2ƒwÔ+Ò+Ü�n‰nÐ1Ó2Ð2àÔ/Ñ/°:Ñ=€FÜ—‘Ð)¬3¨v«;Ó7€Iä
×
Ñ
˜i¨´°V³¸eÀRÈÓ
L€CÜ
Øˆq‰Ø9Ü—‘õô �:‰:�i¤ V£Ó-Ô.BÐ.CÐDÐDr    c                 óx  — t        | «      t        k7  rt        j                  d«      ‚t        |«      t        k7  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Ô+Ò+Ü�n‰nÐ1Ó2Ð2ä
ˆ2ƒwÔ+Ò+Ü�n‰nÐ1Ó2Ð2ä�‰Ð!Ô#;Ó<€Aä	×	 Ñ	   B¨Ó	+€BÜ
ˆ2�‰7Ð.¼×8HÑ8HÕIä�:‰:�aÔ1Ó2±1Ð5Ð5r    r:   c                 óÂ  — t        |«      t        k7  rt        j                  d«      ‚t        |«      t        k7  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Ô*Ò*Ü�n‰n˜_Ó-Ð-ä
ˆ1ƒvÔ)Ò)Ü�n‰nÐ1Ó2Ð2àÔ+Ñ+¨gÑ5€FÜ—‘Ð*¬C°«KÓ8€Jä	×	Ñ	 
¨F´C¸³KÀÈÓ	J€BÜ
ˆ2�‰7Ð.¼×8HÑ8HÕIä�:‰:�j¤# f£+Ó.Ô/FÐ/GÐHÐHr    c                 óÂ  — t        |«      t        k7  rt        j                  d«      ‚t        |«      t        k7  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Ô*Ò*Ü�n‰n˜_Ó-Ð-ä
ˆ1ƒvÔ)Ò)Ü�n‰nÐ1Ó2Ð2àÔ/Ñ/°:Ñ=€FÜ—‘Ð)¬3¨v«;Ó7€Iä
×
%Ñ
% i°¼¸V»ÀeÈQÓ
O€CÜ
Øˆq‰Ø9Ü—‘õô �:‰:�i¤ V£Ó-Ô.BÐ.CÐDÐDr    c                 óÄ  — t        t        | t        «      dt        ¬«       t        t        |t        «      dt        ¬«       t	        |«      t
        k7  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Ô+Ò+Ü�n‰nÐ1Ó2Ð2ä�‹L€EÜ  5Ñ(€Eä—‘Ð*¨EÓ2€Jä	×	Ñ	˜Z¨°%¸Ó	<€BÜ
ˆ2�‰7Ð.¼×8HÑ8HÕIä�:‰:�j %Ó(©Ð+Ð+r    c                 óÔ  — t        t        | t        «      dt        ¬«       t        t        |t        «      dt        ¬«       t        t        |t        «      dt        ¬«       t	        |«      t
        k7  rt        j                  d«      ‚t	        |«      t        k7  rt        j                  d«      ‚t	        | «      }t        |t        k\  dj                  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Ô+Ò+Ü�n‰nÐ1Ó2Ð2ä
ˆ2ƒwÔ+Ò+Ü�n‰nÐ1Ó2Ð2ä�
‹O€Eä
ØÔ%Ñ%Ø	4×<Ñ<Ü ó	
ô —‘õð Ô(Ñ(€Eô —‘Ð)¬3¨q°%«=Ó9€Iä
×
"Ñ
" 9¨j¸%ÀÀRÓ
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Ñ4Ó6Ð �cÓ 6Ø6˜S×6Ñ6Ó8Ð �sÓ 8Ø4˜C×4Ñ4Ó6Ð �cÓ 6Ø:˜s×:Ñ:Ó<Ð ˜Ó <Ø < × <Ñ <Ó >Ð ˜#Ó >Ø4˜C×4Ñ4Ó6Ð �cÓ 6ð˜E %¨ ,Ñ/ó ð$ %ð ¨E°%¸°,Ñ,?ó ðDI˜ð I eð I°ð I¸Eð IÀeó Ið: EØð EØ#ð EØ).ð EØ49ð Eà
ó EðF6˜Eð 6 uð 6°ó 6ð0I ð I¨eð I¸ð IÀ%ó Ið2EØðEØ#ðEØ(-ðEà
óEð>#,˜Uð #,¨ð #,°%ó #,ðL8+ Uð 8+°ð 8+¸5ð 8+ÀUô 8+r    