%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/nacl/bindings/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/nacl/bindings/__pycache__/crypto_sign.cpython-312.pyc

�

�ff(��4�UddlmZddlmZddlmZmZddlm	Z	ej�Zee
d<ej�dzZee
d<ej �Zee
d<ej�Zee
d	<ej&�Zee
d
<ej*�Zee
d<deeeffd
�Zdedeeeffd�Zdededefd�Zdededefd�Zdedefd�Zdedefd�Zdedefd�Zdedefd�ZGd�d�Z de dedd fd!�Z!de dedefd"�Z"de d#edede#fd$�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�tjdt�}tjdt�}t	j
||�}t
|dk(dtj��tj|t�ddtj|t�ddfS)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�newrrr�crypto_sign_keypairr�exc�RuntimeError�buffer)�pk�sk�rcs   �;/usr/lib/python3/dist-packages/nacl/bindings/crypto_sign.pyrr s���

���"�$>�	?�B�	���"�$>�	?�B�	�	 �	 ��R�	(�B�
�2��7�.��8H�8H�I�	�
�
�2�1�2�1�5��
�
�2�1�2�1�5����seedc��t|�tk7rtjd��t	j
dt�}t	j
dt�}tj|||�}t|dk(dtj��t	j|t�ddt	j|t�ddfS)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 seedrrrrN)
�lenr
r�
ValueErrorrrrrr�crypto_sign_seed_keypairrrr)rrrrs    rr#r#2s����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�messagerc�2�tjdt|�tz�}tjd�}t	j
|||t|�|�}t
|dk(dtj��tj||d�ddS)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 *rrrN)
rrr!rr�crypto_signrrrr)r$r�signed�
signed_lenrs     rr'r'Hsy���W�W�&��G��7H�(H�
I�F����/�0�J�	�����W�c�'�l�B�	G�B�
�2��7�.��8H�8H�I��:�:�f�j��m�,�Q�/�/rr(rc��tjdt|��}tjd�}tj|||t|�|�dk7rtjd��tj||d�ddS)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
    rr&r�Signature was forged or corruptN)rrr!r�crypto_sign_openr�BadSignatureErrorr)r(rr$�message_lens    rr,r,Zsz���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|�tk7rtjd��t}tjd|�}tj||�}t|dk(dtj��tj||�ddS)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
    zInvalid curve public keyrrrrN)r!rrr"r
rrr�$crypto_sign_ed25519_pk_to_curve25519rrr)r/�curve_public_key_len�curve_public_keyrs    rr1r1o������ :�:��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|�tk7rtjd��t}tjd|�}tj||�}t|dk(dtj��tj||�ddS)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
    zInvalid curve secret keyrrrrN)r!rrr"r
rrr�$crypto_sign_ed25519_sk_to_curve25519rrr)r5�curve_secret_key_len�curve_secret_keyrs    rr7r7�r4rc�b�t|�tk7rtjd��|tdS)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rr"r
�r5s r�crypto_sign_ed25519_sk_to_pkr>�s2����� :�:��n�n�1�2�2��1�2�3�3rc�b�t|�tk7rtjd��|dtS)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�3rc��eZdZdZdgZdd�Zy)�crypto_sign_ed25519ph_statezO
    State object wrapping the sha-512 state used in ed25519ph computation
    �stateNc��tjdt�|_t	j
|j�}t
|dk(dtj��y)Nrrrr)	rrrrCr�crypto_sign_ed25519ph_initrrr)�selfrs  r�__init__z$crypto_sign_ed25519ph_state.__init__�sE���G�G��?�
��
��
+�
+�D�J�J�
7���r�Q�w�2�C�<L�<L�Mr)rN)�__name__�
__module__�__qualname__�__doc__�	__slots__rG�rrrBrB�s����	�I�NrrB�edph�pmsgNc�>�tt|t�dtj��tt|t
�dtj��t
j|j|t|��}t|dk(dtj��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 objectrz%pmsg parameter must be a bytes objectrrN)r�
isinstancerBr�	TypeError�bytesr�crypto_sign_ed25519ph_updaterCr!r)rNrOrs   rrUrU�st����4�4�5�9��
�
��
��4���/��
�
��


�	)�	)�$�*�*�d�C��I�	F�B�
�2��7�.��8H�8H�Irc�4�tt|t�dtj��tt|t
�dtj��tt
|�tk(djt�tj��tjdt�}tj|j|tj|�}t|dk(dtj ��tj"|t�ddS)	aR
    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 part of the signing key
    :type sk: bytes
    :return: ed25519ph signature
    :rtype: bytes
    rQrz+secret key parameter must be a bytes objectz secret key must be {} bytes longrrrN)rrRrBrrSrTr!r�formatrrrr�"crypto_sign_ed25519ph_final_createrC�NULLrr)rNr�	signaturers    rrXrX�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�6rrZc�r�tt|t�dtj��tt|t
�dtj��tt
|�tk(djt�tj��tt|t
�dtj��tt
|�tk(djt�tj��tj|j||�}|dk7rtjd��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
    rQrz*signature parameter must be a bytes objectzsignature must be {} bytes longz+public key parameter must be a bytes objectz public key must be {} bytes longrr+T)rrRrBrrSrTr!rrWrr�"crypto_sign_ed25519ph_final_verifyrCr-)rNrZrrs    rr\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�naclrr�nacl._sodiumrr�nacl.exceptionsr�crypto_sign_bytesr�int�__annotations__�crypto_sign_secretkeybytesr
�crypto_sign_publickeybytesrr�crypto_box_secretkeybytesr
� crypto_sign_ed25519ph_statebytesrrTrr#r'r,r1r7r>r@rBrUrX�boolr\rMrr�<module>ris����"�!�"�/��.�.�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�2A�5�A�U�A�24�5�4�U�4�"4�U�4�u�4�"N�N�"J�
%�J�-2�J�	�J�4&7�
%�&7�+0�&7�
�&7�R0�
%�0�27�0�=B�0�	�0r

Zerion Mini Shell 1.0