
    Ljb                     P   U 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                    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dededefdZdedededefdZdS )    )
exceptions)ffilib)ensurecrypto_secretbox_KEYBYTEScrypto_secretbox_NONCEBYTEScrypto_secretbox_ZEROBYTEScrypto_secretbox_BOXZEROBYTEScrypto_secretbox_MACBYTES!crypto_secretbox_MESSAGEBYTES_MAXmessagenoncekeyreturnc                    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`` with the secret ``key`` and
    the nonce ``nonce``.

    :param message: bytes
    :param nonce: bytes
    :param key: bytes
    :rtype: bytes
    Invalid keyInvalid nonce    unsigned char[]r   zEncryption failedraisingN)lenr   exc
ValueErrorr   r	   r   newr   crypto_secretboxr   CryptoErrorbufferr
   )r   r   r   padded
ciphertextress         b/home/ice/.hermes/hermes-agent/venv/lib/python3.11/site-packages/nacl/bindings/crypto_secretbox.pyr   r      s     3xx,,,n]+++
5zz000n_---11G;F*CKK88J

z63v;;s
K
KC
3!8(#/BBBBJF44J34455    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
    Decrypt and returns the encrypted message ``ciphertext`` with the secret
    ``key`` and the nonce ``nonce``.

    :param ciphertext: bytes
    :param nonce: bytes
    :param key: bytes
    :rtype: bytes
    r   r   r   r   r   z1Decryption failed. Ciphertext failed verificationr   N)r   r   r   r   r   r
   r   r   r   crypto_secretbox_openr   r   r   r	   )r    r   r   r   	plaintextr!   s         r"   r%   r%   9   s     3xx,,,n]+++
5zz000n_---44zAF)3v;;77I

#Ivs6{{E3
O
OC
q;    
9c&kk22I/0011r#   N)naclr   r   nacl._sodiumr   r   nacl.exceptionsr   crypto_secretbox_keybytesr   int__annotations__crypto_secretbox_noncebytesr   crypto_secretbox_zerobytesr	   crypto_secretbox_boxzerobytesr
   crypto_secretbox_macbytesr   !crypto_secretbox_messagebytes_maxr   bytesr   r%    r#   r"   <module>r4      sf    # " " " " " " ! ! ! ! ! ! ! ! " " " " " " "?!>!@!@ 3 @ @ @#B3#B#D#D S D D D"@#"@"B"B C B B B%FS%F%H%H s H H H!>!>!@!@ 3 @ @ @)C)++ "3   
6e 6E 6 6% 6 6 6 6422#2*/2
2 2 2 2 2 2r#   