%PDF- %PDF-
Mini Shell

Mini Shell

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

�

�f� ���ddlmZddlZddlmZddlmZddlmZ	m
Zddlm
Z
mZGd�de�ZGd	�d
ej"e
�ZGd�dej"e
�Zy)
�)�OptionalN)�encoding)�
exceptions)�
PrivateKey�	PublicKey)�StringFixer�randomc	�t�eZdZUdZeed<eed<ededededdfd��Zedefd	��Z	edefd
��Z
y)�
SignedMessagezc
    A bytes subclass that holds a messaged that has been signed by a
    :class:`SigningKey`.
    �
_signature�_message�	signature�message�combined�returnc�2�||�}||_||_|S�N)rr
)�clsrrr�objs     �./usr/lib/python3/dist-packages/nacl/signing.py�_from_partszSignedMessage._from_parts#s ���(�m��"�������
�c��|jS)zL
        The signature contained within the :class:`SignedMessage`.
        )r��selfs rrzSignedMessage.signature,s��
���rc��|jS)zJ
        The message contained within the :class:`SignedMessage`.
        )r
rs rrzSignedMessage.message3s��
�}�}�rN)�__name__�
__module__�__qualname__�__doc__�bytes�__annotations__�classmethodr�propertyrr�rrrrs|���
���O�����(-��9>��	������5���������rrc	���eZdZdZej
fdedejfd�Zdefd�Z	de
fd�Zdede
fd	�Zdede
fd
�Zdej
fded
eedejdefd�Zdefd�Zy)�	VerifyKeyz�
    The public key counterpart to an Ed25519 SigningKey for producing digital
    signatures.

    :param key: [:class:`bytes`] Serialized Ed25519 public key
    :param encoder: A class that is able to decode the `key`
    �key�encoderc�*�|j|�}t|t�stjd��t|�tjjk7r0tjdtjjz��||_
y)Nz'VerifyKey must be created from 32 bytesz%The key must be exactly %s bytes long)�decode�
isinstancer!�exc�	TypeError�len�nacl�bindings�crypto_sign_PUBLICKEYBYTES�
ValueError�_key)rr(r)s   r�__init__zVerifyKey.__init__Dsq���n�n�S�!���#�u�%��-�-� I�J�J��s�8�t�}�}�?�?�?��.�.�7��-�-�:�:�;��
�
��	rrc��|jSr)r4rs r�	__bytes__zVerifyKey.__bytes__Ts���y�y�rc�*�tt|��Sr��hashr!rs r�__hash__zVerifyKey.__hash__W����E�$�K� � r�otherc��t||j�sytjj	t|�t|��S�NF�r,�	__class__r0r1�
sodium_memcmpr!�rr=s  r�__eq__zVerifyKey.__eq__Z�2���%����0���}�}�*�*�5��;��e��E�Erc��||k(Srr%rCs  r�__ne__zVerifyKey.__ne___����E�M�"�"rN�smessagerc���|��t|t�s0tjdtj
jz��t|�tj
jk7r0tjdtj
jz��||j|�z}n|j|�}tj
j||j�S)aS
        Verifies the signature of a signed message, returning the message
        if it has not been tampered with else raising
        :class:`~nacl.signing.BadSignatureError`.

        :param smessage: [:class:`bytes`] Either the original messaged or a
            signature and message concated together.
        :param signature: [:class:`bytes`] If an unsigned message is given for
            smessage then the detached signature must be provided.
        :param encoder: A class that is able to decode the secret message and
            signature.
        :rtype: :class:`bytes`
        z4Verification signature must be created from %d bytesz+The signature must be exactly %d bytes long)r,r!r-r.r0r1�crypto_sign_BYTESr/r3r+�crypto_sign_openr4)rrIrr)s    r�verifyzVerifyKey.verifybs���&� ��i��/��m�m�J��m�m�5�5�6���
�9�~����!@�!@�@��n�n�A��m�m�5�5�6���
!�7�>�>�(�#;�;�H��~�~�h�/�H��}�}�-�-�h��	�	�B�Brc�j�tjj|j�}t	|�S)z�
        Converts a :class:`~nacl.signing.VerifyKey` to a
        :class:`~nacl.public.PublicKey`

        :rtype: :class:`~nacl.public.PublicKey`
        )r0r1�$crypto_sign_ed25519_pk_to_curve25519r4�_Curve25519_PublicKey)r�raw_pks  r�to_curve25519_public_keyz"VerifyKey.to_curve25519_public_key�s'�����C�C�D�I�I�N��$�V�,�,r)rrrr r�
RawEncoderr!�Encoderr5r7�intr;�object�boolrDrGrrMrPrRr%rrr'r';s����7?�6I�6I����#+�#3�#3�� �5��!�#�!�F�F�F�t�F�
#�F�#�t�#�&*�$,�$7�$7�	'C��'C��E�?�'C��!�!�	'C�

�'C�R-�*?�-rr'c���eZdZdZej
fdedejfd�Zdefd�Z	de
fd�Zdede
fd	�Zdede
fd
�Zedd��Zej
fdedejdefd
�Zdefd�Zy)�
SigningKeya�
    Private key for producing digital signatures using the Ed25519 algorithm.

    Signing keys are produced from a 32-byte (256-bit) random seed value. This
    value can be passed into the :class:`~nacl.signing.SigningKey` as a
    :func:`bytes` whose length is 32.

    .. warning:: This **must** be protected and remain secret. Anyone who knows
        the value of your :class:`~nacl.signing.SigningKey` or it's seed can
        masquerade as you.

    :param seed: [:class:`bytes`] Random 32-byte value (i.e. private key)
    :param encoder: A class that is able to decode the seed

    :ivar: verify_key: [:class:`~nacl.signing.VerifyKey`] The verify
        (i.e. public) key that corresponds with this signing key.
    �seedr)c��|j|�}t|t�stjd��t|�tjjk7r0tjdtjjz��tjj|�\}}||_||_t|�|_y)Nz.SigningKey must be created from a 32 byte seedz&The seed must be exactly %d bytes long)r+r,r!r-r.r/r0r1�crypto_sign_SEEDBYTESr3�crypto_sign_seed_keypair�_seed�_signing_keyr'�
verify_key)rrZr)�
public_key�
secret_keys     rr5zSigningKey.__init__�s����~�~�d�#���$��&��-�-�@��
�
�t�9��
�
�;�;�;��.�.�8��-�-�5�5�6��
�
"&���!G�!G��!M��
�J���
�&���#�J�/��rrc��|jSr)r^rs rr7zSigningKey.__bytes__�s���z�z�rc�*�tt|��Srr9rs rr;zSigningKey.__hash__�r<rr=c��t||j�sytjj	t|�t|��Sr?r@rCs  rrDzSigningKey.__eq__�rErc��||k(Srr%rCs  rrGzSigningKey.__ne__�rHrc�t�|ttjj�tj
��S)z�
        Generates a random :class:`~nacl.signing.SigningKey` object.

        :rtype: :class:`~nacl.signing.SigningKey`
        )r))r	r0r1r\rrS)rs r�generatezSigningKey.generate�s,����4�=�=�6�6�7��'�'�
�	
rrc�*�tjj||j�}tjj}|j|d|�}|j||d�}|j|�}tj|||�S)z�
        Sign a message using this key.

        :param message: [:class:`bytes`] The data to be signed.
        :param encoder: A class that is used to encode the signed message.
        :rtype: :class:`~nacl.signing.SignedMessage`
        N)r0r1�crypto_signr_rK�encoderr)rrr)�
raw_signedrKr�signeds       r�signzSigningKey.sign�s����]�]�.�.�w��8I�8I�J�
� �M�M�;�;���N�N�:�.@�/@�#A�B�	��.�.��,=�,>�!?�@�����
�+���(�(��G�V�D�Drc�n�|j}tjj|�}t	|�S)z�
        Converts a :class:`~nacl.signing.SigningKey` to a
        :class:`~nacl.public.PrivateKey`

        :rtype: :class:`~nacl.public.PrivateKey`
        )r_r0r1�$crypto_sign_ed25519_sk_to_curve25519�_Curve25519_PrivateKey)r�sk�raw_privates   r�to_curve25519_private_keyz$SigningKey.to_curve25519_private_key�s.���
�
���m�m�H�H��L��%�k�2�2rN)rrY)rrrr rrSr!rTr5r7rUr;rVrWrDrGr#rhrrnrqrtr%rrrYrY�s����*%-�$7�$7�0��0��!�!�0�2�5��!�#�!�F�F�F�t�F�
#�F�#�t�#��	
��	
�%-�$7�$7�E��E��!�!�E�
�	E�*	3�+A�	3rrY)�typingr�
nacl.bindingsr0rrr-�nacl.publicrrqrrP�
nacl.utilsrr	r!r�	Encodabler'rYr%rr�<module>rzsW�����"��+��E��BX-��"�"�K�X-�vd3��#�#�[�d3r

Zerion Mini Shell 1.0