o
    pkj5                     @  s`  d dl mZ d dlZd dlmZmZ d dlmZ d dl	m
Z
 d dlmZ G dd dejd	Zeed
r:eejj G dd dejd	Zeed
rPeejj G dd dejd	Zeed
rfeejj G dd dejd	Zeed
r|eejj G dd dejd	Zeed
reejj G dd dejd	Zeed
reejj ejjZdS dS )    )annotationsN)UnsupportedAlgorithm_Reasons)openssl)_serialization)Bufferc                   @     e Zd Zed$ddZejd%d
dZejd&ddZej	d'd(ddZ	ejd)ddZ
ejd*ddZejd+ddZejd,d"d#ZdS )-MLDSA44PublicKeydatabytesreturnc                 C  ,   ddl m} | stdtjtj|S Nr   backendz+ML-DSA-44 is not supported by this backend.)	,cryptography.hazmat.backends.openssl.backendr   mldsa_supportedr   r    UNSUPPORTED_PUBLIC_KEY_ALGORITHMrust_opensslmldsafrom_mldsa44_public_bytesclsr
   r    r   m/home/djax/ivt_ai_plugin/venv/lib/python3.10/site-packages/cryptography/hazmat/primitives/asymmetric/mldsa.pyfrom_public_bytes      z"MLDSA44PublicKey.from_public_bytesencoding_serialization.Encodingformat_serialization.PublicFormatc                 C     dS z9
        The serialized bytes of the public key.
        Nr   selfr   r   r   r   r   public_bytes       zMLDSA44PublicKey.public_bytesc                 C  r!   )z
        The raw bytes of the public key.
        Equivalent to public_bytes(Raw, Raw).

        The public key is 1,312 bytes for MLDSA-44.
        Nr   r$   r   r   r   public_bytes_raw&   r&   z!MLDSA44PublicKey.public_bytes_rawN	signaturer   contextBuffer | NoneNonec                 C  r!   z'
        Verify the signature.
        Nr   r$   r)   r
   r*   r   r   r   verify/   r&   zMLDSA44PublicKey.verifymuc                 C  r!   zt
        Verify the signature over a precomputed mu (message representative).

        mu must be 64 bytes.
        Nr   r$   r)   r0   r   r   r   	verify_mu:   r&   zMLDSA44PublicKey.verify_muotherobjectboolc                 C  r!   z"
        Checks equality.
        Nr   r$   r4   r   r   r   __eq__F   r&   zMLDSA44PublicKey.__eq__c                 C  r!   z!
        Returns a copy.
        Nr   r'   r   r   r   __copy__L   r&   zMLDSA44PublicKey.__copy__memodictc                 C  r!   z&
        Returns a deep copy.
        Nr   r$   r<   r   r   r   __deepcopy__R   r&   zMLDSA44PublicKey.__deepcopy__)r
   r   r   r	   r   r   r   r    r   r   r   r   Nr)   r   r
   r   r*   r+   r   r,   r)   r   r0   r   r   r,   r4   r5   r   r6   r   r	   )r<   r=   r   r	   __name__
__module____qualname__classmethodr   abcabstractmethodr%   r(   r/   r3   r9   r;   r@   r   r   r   r   r	      $    	
r	   )	metaclassr   c                   @     e Zd Zed$ddZed%ddZejd&d	d
Zejd'ddZ	ejd(ddZ
ejd)d*ddZejd+ddZejd$ddZejd,d"d#ZdS )-MLDSA44PrivateKeyr   c                 C  *   ddl m} | stdtjtj S r   )	r   r   r   r   r   r   r   r   generate_mldsa44_keyr   r   r   r   r   generate^      
zMLDSA44PrivateKey.generater
   r   c                 C  r   r   )	r   r   r   r   r   r   r   r   from_mldsa44_seed_bytesr   r   r   r   from_seed_bytesj   r   z!MLDSA44PrivateKey.from_seed_bytesr	   c                 C  r!   )zD
        The MLDSA44PublicKey derived from the private key.
        Nr   r'   r   r   r   
public_keyv   r&   zMLDSA44PrivateKey.public_keyr   r   r   _serialization.PrivateFormatencryption_algorithm)_serialization.KeySerializationEncryptionr   c                 C  r!   z
        The serialized bytes of the private key.

        This method only returns the serialization of the seed form of the
        private key, never the expanded one.
        Nr   r$   r   r   r\   r   r   r   private_bytes|   r&   zMLDSA44PrivateKey.private_bytesc                 C  r!   z
        The raw bytes of the private key.
        Equivalent to private_bytes(Raw, Raw, NoEncryption()).

        This method only returns the seed form of the private key (32 bytes).
        Nr   r'   r   r   r   private_bytes_raw   r&   z#MLDSA44PrivateKey.private_bytes_rawNr*   r+   c                 C  r!   z!
        Signs the data.
        Nr   r$   r
   r*   r   r   r   sign   r&   zMLDSA44PrivateKey.signr0   c                 C  r!   z
        Signs a precomputed mu (message representative).

        mu must be 64 bytes and already incorporates the context, so no
        context is accepted here.
        Nr   r$   r0   r   r   r   sign_mu   r&   zMLDSA44PrivateKey.sign_muc                 C  r!   r:   r   r'   r   r   r   r;      r&   zMLDSA44PrivateKey.__copy__r<   r=   c                 C  r!   r>   r   r?   r   r   r   r@      r&   zMLDSA44PrivateKey.__deepcopy__)r   rR   )r
   r   r   rR   rG   r   r   r   r[   r\   r]   r   r   rB   rC   r
   r   r*   r+   r   r   r0   r   r   r   )r<   r=   r   rR   rI   rJ   rK   rL   rV   rY   rM   rN   rZ   r`   rb   re   rh   r;   r@   r   r   r   r   rR   ]   &    rR   c                   @  r   )-MLDSA65PublicKeyr
   r   r   c                 C  r   Nr   r   z+ML-DSA-65 is not supported by this backend.)	r   r   r   r   r   r   r   r   from_mldsa65_public_bytesr   r   r   r   r      r   z"MLDSA65PublicKey.from_public_bytesr   r   r   r    c                 C  r!   r"   r   r#   r   r   r   r%      r&   zMLDSA65PublicKey.public_bytesc                 C  r!   )z
        The raw bytes of the public key.
        Equivalent to public_bytes(Raw, Raw).

        The public key is 1,952 bytes for MLDSA-65.
        Nr   r'   r   r   r   r(      r&   z!MLDSA65PublicKey.public_bytes_rawNr)   r   r*   r+   r,   c                 C  r!   r-   r   r.   r   r   r   r/      r&   zMLDSA65PublicKey.verifyr0   c                 C  r!   r1   r   r2   r   r   r   r3      r&   zMLDSA65PublicKey.verify_mur4   r5   r6   c                 C  r!   r7   r   r8   r   r   r   r9      r&   zMLDSA65PublicKey.__eq__c                 C  r!   r:   r   r'   r   r   r   r;      r&   zMLDSA65PublicKey.__copy__r<   r=   c                 C  r!   r>   r   r?   r   r   r   r@      r&   zMLDSA65PublicKey.__deepcopy__)r
   r   r   rn   rA   rB   rC   rD   rE   rF   r   rn   )r<   r=   r   rn   rH   r   r   r   r   rn      rO   rn   c                   @  rQ   )-MLDSA65PrivateKeyr   c                 C  rS   ro   )	r   r   r   r   r   r   r   r   generate_mldsa65_keyrU   r   r   r   rV     rW   zMLDSA65PrivateKey.generater
   r   c                 C  r   ro   )	r   r   r   r   r   r   r   r   from_mldsa65_seed_bytesr   r   r   r   rY     r   z!MLDSA65PrivateKey.from_seed_bytesrn   c                 C  r!   )zD
        The MLDSA65PublicKey derived from the private key.
        Nr   r'   r   r   r   rZ     r&   zMLDSA65PrivateKey.public_keyr   r   r   r[   r\   r]   r   c                 C  r!   r^   r   r_   r   r   r   r`      r&   zMLDSA65PrivateKey.private_bytesc                 C  r!   ra   r   r'   r   r   r   rb   .  r&   z#MLDSA65PrivateKey.private_bytes_rawNr*   r+   c                 C  r!   rc   r   rd   r   r   r   re   7  r&   zMLDSA65PrivateKey.signr0   c                 C  r!   rf   r   rg   r   r   r   rh   =  r&   zMLDSA65PrivateKey.sign_muc                 C  r!   r:   r   r'   r   r   r   r;   F  r&   zMLDSA65PrivateKey.__copy__r<   r=   c                 C  r!   r>   r   r?   r   r   r   r@   L  r&   zMLDSA65PrivateKey.__deepcopy__)r   rr   )r
   r   r   rr   rq   ri   rB   rC   rj   rk   )r<   r=   r   rr   rl   r   r   r   r   rr     rm   rr   c                   @  r   )-MLDSA87PublicKeyr
   r   r   c                 C  r   Nr   r   z+ML-DSA-87 is not supported by this backend.)	r   r   r   r   r   r   r   r   from_mldsa87_public_bytesr   r   r   r   r   X  r   z"MLDSA87PublicKey.from_public_bytesr   r   r   r    c                 C  r!   r"   r   r#   r   r   r   r%   d  r&   zMLDSA87PublicKey.public_bytesc                 C  r!   )z
        The raw bytes of the public key.
        Equivalent to public_bytes(Raw, Raw).

        The public key is 2,592 bytes for MLDSA-87.
        Nr   r'   r   r   r   r(   n  r&   z!MLDSA87PublicKey.public_bytes_rawNr)   r   r*   r+   r,   c                 C  r!   r-   r   r.   r   r   r   r/   w  r&   zMLDSA87PublicKey.verifyr0   c                 C  r!   r1   r   r2   r   r   r   r3     r&   zMLDSA87PublicKey.verify_mur4   r5   r6   c                 C  r!   r7   r   r8   r   r   r   r9     r&   zMLDSA87PublicKey.__eq__c                 C  r!   r:   r   r'   r   r   r   r;     r&   zMLDSA87PublicKey.__copy__r<   r=   c                 C  r!   r>   r   r?   r   r   r   r@     r&   zMLDSA87PublicKey.__deepcopy__)r
   r   r   ru   rA   rB   rC   rD   rE   rF   r   ru   )r<   r=   r   ru   rH   r   r   r   r   ru   W  rO   ru   c                   @  rQ   )-MLDSA87PrivateKeyr   c                 C  rS   rv   )	r   r   r   r   r   r   r   r   generate_mldsa87_keyrU   r   r   r   rV     rW   zMLDSA87PrivateKey.generater
   r   c                 C  r   rv   )	r   r   r   r   r   r   r   r   from_mldsa87_seed_bytesr   r   r   r   rY     r   z!MLDSA87PrivateKey.from_seed_bytesru   c                 C  r!   )zD
        The MLDSA87PublicKey derived from the private key.
        Nr   r'   r   r   r   rZ     r&   zMLDSA87PrivateKey.public_keyr   r   r   r[   r\   r]   r   c                 C  r!   r^   r   r_   r   r   r   r`     r&   zMLDSA87PrivateKey.private_bytesc                 C  r!   ra   r   r'   r   r   r   rb     r&   z#MLDSA87PrivateKey.private_bytes_rawNr*   r+   c                 C  r!   rc   r   rd   r   r   r   re     r&   zMLDSA87PrivateKey.signr0   c                 C  r!   rf   r   rg   r   r   r   rh     r&   zMLDSA87PrivateKey.sign_muc                 C  r!   r:   r   r'   r   r   r   r;     r&   zMLDSA87PrivateKey.__copy__r<   r=   c                 C  r!   r>   r   r?   r   r   r   r@     r&   zMLDSA87PrivateKey.__deepcopy__)r   ry   )r
   r   r   ry   rx   ri   rB   rC   rj   rk   )r<   r=   r   ry   rl   r   r   r   r   ry     rm   ry   )
__future__r   rM   cryptography.exceptionsr   r   "cryptography.hazmat.bindings._rustr   r   cryptography.hazmat.primitivesr   cryptography.utilsr   ABCMetar	   hasattrregisterr   rR   rn   rr   ru   ry   MLDSAMuHasherr   r   r   r   <module>   s4   
J
R
J
R
J
R