GOOD SHELL MAS BOY
Server: Apache/2.4.52 (Ubuntu)
System: Linux vmi1836763.contaboserver.net 5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:53 UTC 2024 x86_64
User: www-data (33)
PHP: 8.4.10
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/nacl/__pycache__/signing.cpython-310.pyc
o

��a� �@s�ddlmZddlZddlmZddlmZddlmZ	m
Zddlm
Z
mZGdd�de�ZGd	d
�d
eje
�ZGdd�deje
�ZdS)
�)�OptionalN)�encoding)�
exceptions)�
PrivateKey�	PublicKey)�StringFixer�randomc	@sdeZdZUdZeed<eed<ededededdfdd	��Zedefd
d��Z	edefdd
��Z
dS)�
SignedMessagezc
    A bytes subclass that holds a messaged that has been signed by a
    :class:`SigningKey`.
    �
_signature�_message�	signature�message�combined�returncCs||�}||_||_|S�N)r
r)�clsrr
r�obj�r�./usr/lib/python3/dist-packages/nacl/signing.py�_from_parts#szSignedMessage._from_partscC�|jS)zL
        The signature contained within the :class:`SignedMessage`.
        )r
��selfrrrr,�zSignedMessage.signaturecCr)zJ
        The message contained within the :class:`SignedMessage`.
        )rrrrrr
3rzSignedMessage.messageN)�__name__�
__module__�__qualname__�__doc__�bytes�__annotations__�classmethodr�propertyrr
rrrrr	s$
����r	c	@s�eZdZdZejfdedejfdd�Zdefdd�Z	de
fd	d
�Zdede
fdd
�Zdede
fdd�Zdejfdedeedejdefdd�Zdefdd�ZdS)�	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�encodercCsJ|�|�}t|t�st�d��t|�tjjkr t�	dtjj��||_
dS)Nz'VerifyKey must be created from 32 bytesz%The key must be exactly %s bytes long)�decode�
isinstancer�exc�	TypeError�len�nacl�bindingsZcrypto_sign_PUBLICKEYBYTES�
ValueError�_key)rr#r$rrr�__init__Ds


��
zVerifyKey.__init__rcCrr)r-rrrr�	__bytes__T�zVerifyKey.__bytes__cC�tt|��Sr��hashrrrrr�__hash__W�zVerifyKey.__hash__�othercC�&t||j�sdStj�t|�t|��S�NF�r&�	__class__r*r+Z
sodium_memcmpr�rr6rrr�__eq__Z�zVerifyKey.__eq__cC�
||kSrrr;rrr�__ne___�
zVerifyKey.__ne__N�smessagercCsp|dur+t|t�st�dtjj��t|�tjjkr#t�dtjj��||�	|�}n|�	|�}tj�
||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`
        Nz4Verification signature must be created from %d bytesz+The signature must be exactly %d bytes long)r&rr'r(r*r+�crypto_sign_BYTESr)r,r%Zcrypto_sign_openr-)rrArr$rrr�verifybs 
����
zVerifyKey.verifycCstj�|j�}t|�S)z�
        Converts a :class:`~nacl.signing.VerifyKey` to a
        :class:`~nacl.public.PublicKey`

        :rtype: :class:`~nacl.public.PublicKey`
        )r*r+Z$crypto_sign_ed25519_pk_to_curve25519r-�_Curve25519_PublicKey)rZraw_pkrrr�to_curve25519_public_key�sz"VerifyKey.to_curve25519_public_key)rrrrr�
RawEncoderr�Encoderr.r/�intr4�object�boolr<r?rrCrDrErrrrr";s0	��
�����
�)r"c@s�eZdZdZejfdedejfdd�Zdefdd�Z	de
fd	d
�Zdede
fdd
�Zdede
fdd�Zeddd��Zejfdedejdefdd�Zdefdd�ZdS)�
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$cCsj|�|�}t|t�st�d��t|�tjjkr t�	dtjj��tj�
|�\}}||_||_t
|�|_dS)Nz.SigningKey must be created from a 32 byte seedz&The seed must be exactly %d bytes long)r%r&rr'r(r)r*r+�crypto_sign_SEEDBYTESr,Zcrypto_sign_seed_keypair�_seed�_signing_keyr"Z
verify_key)rrLr$Z
public_keyZ
secret_keyrrrr.�s

���zSigningKey.__init__rcCrr)rNrrrrr/�r0zSigningKey.__bytes__cCr1rr2rrrrr4�r5zSigningKey.__hash__r6cCr7r8r9r;rrrr<�r=zSigningKey.__eq__cCr>rrr;rrrr?�r@zSigningKey.__ne__cCs|ttjj�tjd�S)z�
        Generates a random :class:`~nacl.signing.SigningKey` object.

        :rtype: :class:`~nacl.signing.SigningKey`
        )r$)rr*r+rMrrF)rrrr�generate�s
�zSigningKey.generater
cCsTtj�||j�}tjj}|�|d|��}|�||d��}|�|�}t�|||�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)r*r+Zcrypto_signrOrB�encoder	r)rr
r$Z
raw_signedrBrZsignedrrr�sign�s
zSigningKey.signcCs|j}tj�|�}t|�S)z�
        Converts a :class:`~nacl.signing.SigningKey` to a
        :class:`~nacl.public.PrivateKey`

        :rtype: :class:`~nacl.public.PrivateKey`
        )rOr*r+Z$crypto_sign_ed25519_sk_to_curve25519�_Curve25519_PrivateKey)r�skZraw_privaterrr�to_curve25519_private_key�sz$SigningKey.to_curve25519_private_keyN)rrK)rrrrrrFrrGr.r/rHr4rIrJr<r?r rPr	rRrSrUrrrrrK�s.��
����
�rK)�typingrZ
nacl.bindingsr*rrr'Znacl.publicrrSrrDZ
nacl.utilsrrrr	Z	Encodabler"rKrrrr�<module>s
![