
    Ii                          S SK Jr  S SKrS SKJr  S SKJr  S SKJr	J
r  S SKJrJr   " S S\5      r " S	 S
\R"                  \5      r " S S\R"                  \5      rg)    )OptionalN)encoding)
exceptions)
PrivateKey	PublicKey)StringFixerrandomc            	           \ rS rSr% Sr\\S'   \\S'   \S\S\S\SS 4S	 j5       r\	S\4S
 j5       r
\	S\4S j5       rSrg)SignedMessage   zW
A bytes subclass that holds a messaged that has been signed by a
:class:`SigningKey`.

_signature_message	signaturemessagecombinedreturnc                 .    U " U5      nXl         X$l        U$ N)r   r   )clsr   r   r   objs        2/venv/lib/python3.13/site-packages/nacl/signing.py_from_partsSignedMessage._from_parts#   s     (m"
    c                     U R                   $ )z<
The signature contained within the :class:`SignedMessage`.
)r   selfs    r   r   SignedMessage.signature,   s    
 r   c                     U R                   $ )z:
The message contained within the :class:`SignedMessage`.
)r   r   s    r   r   SignedMessage.message3   s    
 }}r    N)__name__
__module____qualname____firstlineno____doc__bytes__annotations__classmethodr   propertyr   r   __static_attributes__r!   r   r   r   r      s|    
 O(-9>	  5     r   r   c            	           \ rS rSrSr\R                  4S\S\R                  4S jjr	S\4S jr
S\4S jrS	\S\4S
 jrS	\S\4S jrS\R                  4S\S\\   S\R                  S\4S jjrS\4S jrSrg)	VerifyKey;   z
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                 8   UR                  U5      n[        U[        5      (       d  [        R                  " S5      e[        U5      [        R                  R                  :w  a1  [        R                  " S[        R                  R                  -  5      eXl
        g )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)r   r/   r0   s      r   __init__VerifyKey.__init__D   sr     nnS!#u%%-- IJJs8t}}???..7--::; 
 	r   r   c                     U R                   $ r   r;   r   s    r   	__bytes__VerifyKey.__bytes__T   s    yyr   c                 *    [        [        U 5      5      $ r   hashr'   r   s    r   __hash__VerifyKey.__hash__W       E$K  r   otherc                     [        XR                  5      (       d  g[        R                  R	                  [        U 5      [        U5      5      $ NFr3   	__class__r7   r8   sodium_memcmpr'   r   rH   s     r   __eq__VerifyKey.__eq__Z   3    %00}}**5;eEEr   c                     X:X  + $ r   r!   rN   s     r   __ne__VerifyKey.__ne___       ""r   Nsmessager   c                    Ub  [        U[        5      (       d1  [        R                  " S[        R
                  R                  -  5      e[        U5      [        R
                  R                  :w  a1  [        R                  " S[        R
                  R                  -  5      eX#R                  U5      -   nOUR                  U5      n[        R
                  R                  XR                  5      $ )a  
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)r3   r'   r4   r5   r7   r8   crypto_sign_BYTESr6   r:   r2   crypto_sign_openr;   )r   rV   r   r0   s       r   verifyVerifyKey.verifyb   s    &   i//mmJmm556 
 9~!@!@@nnAmm556 
 !>>(#;;H ~~h/H}}--h		BBr   c                 j    [         R                  R                  U R                  5      n[	        U5      $ )z{
Converts a :class:`~nacl.signing.VerifyKey` to a
:class:`~nacl.public.PublicKey`

:rtype: :class:`~nacl.public.PublicKey`
)r7   r8   $crypto_sign_ed25519_pk_to_curve25519r;   _Curve25519_PublicKey)r   raw_pks     r   to_curve25519_public_key"VerifyKey.to_curve25519_public_key   s'     CCDIIN$V,,r   r?   )r"   r#   r$   r%   r&   r   
RawEncoderr'   Encoderr<   r@   intrE   objectboolrO   rS   r   rZ   r^   r`   r+   r!   r   r   r-   r-   ;   s     7?6I6I#+#3#3 5 !# !FF Ft F
#F #t # &*$,$7$7	'C'C E?'C !!	'C
 
'CR-*? -r   r-   c                       \ rS rSrSr\R                  4S\S\R                  4S jjr	S\4S jr
S\4S jrS	\S\4S
 jrS	\S\4S jr\SS j5       r\R                  4S\S\R                  S\4S jjrS\4S jrSrg)
SigningKey   a  
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.
seedr0   c                    UR                  U5      n[        U[        5      (       d  [        R                  " S5      e[        U5      [        R                  R                  :w  a1  [        R                  " S[        R                  R                  -  5      e[        R                  R                  U5      u  p4Xl        X@l        [        U5      U l        g )Nz.SigningKey must be created from a 32 byte seedz&The seed must be exactly %d bytes long)r2   r3   r'   r4   r5   r6   r7   r8   crypto_sign_SEEDBYTESr:   crypto_sign_seed_keypair_seed_signing_keyr-   
verify_key)r   rj   r0   
public_key
secret_keys        r   r<   SigningKey.__init__   s     ~~d#$&&--@ 
 t9;;;..8--556 
 "&!G!G!M

&#J/r   r   c                     U R                   $ r   )rn   r   s    r   r@   SigningKey.__bytes__   s    zzr   c                 *    [        [        U 5      5      $ r   rC   r   s    r   rE   SigningKey.__hash__   rG   r   rH   c                     [        XR                  5      (       d  g[        R                  R	                  [        U 5      [        U5      5      $ rJ   rK   rN   s     r   rO   SigningKey.__eq__   rQ   r   c                     X:X  + $ r   r!   rN   s     r   rS   SigningKey.__ne__   rU   r   c                 n    U " [        [        R                  R                  5      [        R
                  S9$ )zi
Generates a random :class:`~nacl.signing.SigningKey` object.

:rtype: :class:`~nacl.signing.SigningKey`
)r0   )r	   r7   r8   rl   r   rb   )r   s    r   generateSigningKey.generate   s,     4==667''
 	
r   r   c                 $   [         R                  R                  XR                  5      n[         R                  R                  nUR                  USU 5      nUR                  X4S 5      nUR                  U5      n[        R                  XQU5      $ )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)r7   r8   crypto_signro   rX   encoder   r   )r   r   r0   
raw_signedrX   r   signeds          r   signSigningKey.sign   sz     ]]..w8I8IJ
 MM;;NN:.@/@#AB	..,>!?@
+((VDDr   c                 n    U R                   n[        R                  R                  U5      n[	        U5      $ )z~
Converts a :class:`~nacl.signing.SigningKey` to a
:class:`~nacl.public.PrivateKey`

:rtype: :class:`~nacl.public.PrivateKey`
)ro   r7   r8   $crypto_sign_ed25519_sk_to_curve25519_Curve25519_PrivateKey)r   skraw_privates      r   to_curve25519_private_key$SigningKey.to_curve25519_private_key   s.     mmHHL%k22r   )rn   ro   rp   N)r   rh   )r"   r#   r$   r%   r&   r   rb   r'   rc   r<   r@   rd   rE   re   rf   rO   rS   r)   r}   r   r   r   r   r+   r!   r   r   rh   rh      s    * %-$7$700 !!025 !# !FF Ft F
#F #t # 	
 	
 %-$7$7EE !!E 
	E*	3+A 	3r   rh   )typingr   nacl.bindingsr7   r   r   r4   nacl.publicr   r   r   r^   
nacl.utilsr   r	   r'   r   	Encodabler-   rh   r!   r   r   <module>r      sW       " +E BX-""K X-vd3##[ d3r   