
    &i                     (    d dl mZmZ  G d d      Zy)   )
BackendAPIPreImageAPIc                   t    e Zd ZdeddfdZdeez  defdZdeez  defdZ	deez  defd	Z
deez  defd
Zy)	Keccak256backendreturnNc                 V    || _         | j                  | _        | j                  | _        y N)_backend_hasher_first_runhasher_preimage_first_runpreimage)selfr   s     >/var/www/br/venv/lib/python3.12/site-packages/eth_hash/main.py__init__zKeccak256.__init__   s#    ,,00    in_datac                     | j                   j                  |      }| j                   j                  } |d      dk(  sJ || _        |S )z
        Validate, on first-run, that the hasher backend is valid.

        After first run, replace this with the new hasher method.
        This is a bit of a hacky way to minimize overhead on hash calls after
        this first one.
        r   s    F#<~} Sʂ';{]p)r   	keccak256r   )r   r   result
new_hashers       r   r   zKeccak256._hasher_first_run   sP     ((1]],,
sOtu	
u !r   c                 r    | j                   j                  |      }| j                   j                  | _        |S r
   )r   r   )r   r   r   s      r   r   zKeccak256._preimage_first_run    s.     ''0..r   r   c                 ~    t        |t        t        f      st        dt	        |             | j                  |      S Nz@Can only compute the hash of `bytes` or `bytearray` values, not )
isinstance	bytearraybytes	TypeErrorreprr   r   r   s     r   __call__zKeccak256.__call__'   sC    (Y$67H~&( 
 {{8$$r   c                 ~    t        |t        t        f      st        dt	        |             | j                  |      S r   )r   r   r   r   r    r   r!   s     r   newzKeccak256.new0   sC    (Y$67H~&(  }}X&&r   )__name__
__module____qualname__r   r   r   r   r   r   r   r"   r$    r   r   r   r      su    1
 1t 1
U): u &9u+<  %U!2 %u %'I- '+ 'r   r   N)abcr   r   r   r(   r   r   <module>r*      s   /' /'r   