
    (i
                     L   d dl mZ d dlmZmZmZmZ d dlmZ d dl	m
Z
 deddfdZdeddfd	Zeded
eddfd       Zedededdfd       Z ee
dz
        ZdedededdfdZdeddfdZdeddfdZdeddfdZdeddfdZdeddfdZdeddfdZdeddfdZdeddfdZy)    )Any)ValidationError
encode_hexis_bytes
is_integer)curry)SECPK1_NvaluereturnNc                 h    t        |       rt        | t              rt        dt	        |              y )Nz"Value must be a an integer.  Got: )r   
isinstanceboolr   typer
   s    D/var/www/br/venv/lib/python3.12/site-packages/eth_keys/validation.pyvalidate_integerr      s/    e
5$ 7 B4;-PQQ !8    c                 H    t        |       st        dt        |              y )Nz#Value must be a byte string.  Got: )r   r   r   r   s    r   validate_bytesr      s%    E? CDK=QRR r   minimumc                 F    t        |        | |k  rt        d|  d|       y )NValue z! is not greater than or equal to r   r   )r
   r   s     r   validate_gter      s4    UwUG<WIF
 	
 r   maximumc                 F    t        |        | |kD  rt        d|  d|       y )Nr   z is not less than or equal to r   )r
   r   s     r   validate_lter   '   s/    Uwug-KG9UVV r      r   expected_lengthnamec           	      N    t        |       }||k7  rt        d| d| d| d      y )NzUnexpected z length: Expected z
, but got z bytes)lenr   )r
   r    r!   actual_lengths       r   validate_bytes_lengthr%   1   sB    JM'$1/1B*oV%
 	
 (r   c                 4    t        |        t        | dd       y )N    zmessage hashr   r%   r   s    r   validate_message_hashr)   :   s    5%^4r   c                 4    t        |        t        | dd       y )N@   zuncompressed public keyr(   r   s    r   &validate_uncompressed_public_key_bytesr,   ?   s    5%%>?r   c                 t    t        |        t        | dd       | dd }|dvrt        dt        |             y )N!   zcompressed public keyr   r   )      zWUnexpected compressed public key format: Must start with 0x02 or 0x03, but starts with )r   r%   r   r   )r
   
first_bytes     r   $validate_compressed_public_key_bytesr2   D   sR    5%%<=qJ++)*568
 	
 ,r   c                 4    t        |        t        | dd       y )Nr'   zprivate keyr(   r   s    r   validate_private_key_bytesr4   O   s    5%]3r   c                 4    t        |        t        | dd       y )NA   zrecoverable signaturer(   r   s    r   $validate_recoverable_signature_bytesr7   T   s    5%%<=r   c                 4    t        |        t        | dd       y )Nr+   znon recoverable signaturer(   r   s    r   (validate_non_recoverable_signature_bytesr9   Y   s    5%%@Ar   c                 N    t        |        t        | d       t        | d       y )Nr   )r   r   r   )r   r   r   r   s    r   validate_signature_vr;   ^   s    U""r   c                 H    t        |        t        | d       t        |        y )Nr   )r   r   validate_lt_secpk1nr   s    r   validate_signature_r_or_sr>   d   s    Ur   )typingr   	eth_utilsr   r   r   r   eth_utils.toolzr   eth_keys.constantsr	   r   r   intr   r   r=   bytesstrr%   r)   r,   r2   r4   r7   r9   r;   r>    r   r   <module>rG      sq   
RC RD R
S# S$ S
 
 
c 
d 
 
 W Wc Wd W W #8a<8 
 
 
C 
D 
5 5 5
@# @$ @

 
 
4c 4d 4
> > >
BC BD B
# # #S T r   