https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/nacl/bindings/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/nacl/bindings/__pycache__/crypto_box.cpython-310.pyc
o

��a�'�
@s�UddlmZddlmZddlmZmZddlm	Z	ddgZ
e��Ze
ed<e��Ze
ed<e��Ze
ed	<e��Ze
ed
<e��Ze
ed<e��Ze
ed<e��Ze
ed
<e��Ze
ed<deeeffdd�Zdedeeeffdd�Zdededededef
dd�Z dededededef
dd�Z!dededefdd�Z"dedededefdd �Z#dedededefd!d"�Z$dededefd#d$�Z%dedededefd%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�returncCs`t�dt�}t�dt�}t�||�}t|dkdtjd�t�	|t�dd�t�	|t�dd�fS)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	rrr�exc�RuntimeError�buffer)�pk�sk�rc�r�:/usr/lib/python3/dist-packages/nacl/bindings/crypto_box.pyr"s��seedcCs�tt|t�dtd�t|�tkrt�d��t�	dt
�}t�	dt�}t�
|||�}t|dkdtjd�t�|t
�dd�t�|t�dd�fS)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))
    zseed must be bytesrzInvalid seedrrrN)r�
isinstance�bytes�	TypeError�lenrr�
ValueErrorrrr
r	r�crypto_box_seed_keypairrr)rrrrrrrr%4s
�r%�message�noncerrcC�t|�tkrt�d��t|�tkrt�d��t|�tkr!t�d��dt|}t�dt|��}t	�
||t|�|||�}t|dkdtjd�t�
|t|��td	�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�rrrrN)r#rrr$r
r	r
rrrrrrrr)r&r'rr�padded�
ciphertextrrrrrVs


r.cCr()
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,rr�/An error occurred trying to decrypt the messagerN)r#rrr$r
r	rrrr�crypto_box_openr�CryptoErrorrr
)r.r'rrr-�	plaintext�resrrrr0ss


�r0cCsnt|�tkrt�d��t|�tkrt�d��t�dt�}t�	|||�}t
|dkdtjd�t�|t�dd�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+rrrrN)
r#r
rr$r	rrrr�crypto_box_beforenmrrr)rr�krrrrr4�s


r4r5cC�t|�tkrt�d��t|�tkrt�d��dt|}t�dt|��}t�	||t|�||�}t
|dkdtjd�t�|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,rrrrN)r#rrr$rr
rrr�crypto_box_afternmrrrr)r&r'r5r-r.rrrrr9�s


r9cCr6)	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
    r7r8r,rrr/rN)r#rrr$rrrrr�crypto_box_open_afternmrr1rr
)r.r'r5r-r2r3rrrr:�s

�r:cCs�tt|t�dtd�tt|t�dtd�t|�tkrt�d��t|�}t|}t	�
d|�}t�||||�}t|dkdtj
d�t	�||�dd�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
    zinput message must be bytesr�public key must be bytesr*rrrN)rr r!r"r#r
rr$rrrr�crypto_box_sealrr)r&r�_mlen�_clenr.rrrrr<�s ��
r<cCs�tt|t�dtd�tt|t�dtd�tt|t�dtd�t|�tkr)t�d��t|�tkr4t�d��t|�}t|t	kd�
t	�tjd�|t	}t�dt
d	|��}t�|||||�}t|d
kdtjd�t�||�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
    zinput ciphertext must be bytesrr;zsecret key must be bytesr*r+z)Input cyphertext must be at least {} longr�rr/N)rr r!r"r#r
rr$r	r�formatrr�maxr�crypto_box_seal_openr1r)r.rrr>r=r2r3rrrrBs@���

���rBN)'�typingr�naclrr�nacl._sodiumrr�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_sealbytesrr!rr%rr0r4r9r:r<rBrrrr�<module>sP
"����
�#���
�&

https://t.me/RX1948 - 2025